Mar 7, 2003

          onlpara, Red Hat Linux 8.0 のシステムでのJavaRMIの実行
                 ---  リモートマシンからの camac読み書き  #2
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  (http://www-online.kek.jp/~inoue/para-CAMAC/
                                   Work/CAMAC-JavaRMI2.html)



                        高エネルギー加速器研究機構
                            素粒子原子核研究所
                         物理、オンライングループ
                                井上 栄二



	目的

	    JavaRMIとJNIを使って、リモートマシン onlpara から ターゲットマシン
	  onlsbc1を通してCAMACを読み出すことができた(CAMAC-JavaRMI1.htmlを
	  参照)。  ここでは、このCAMAC読み出しの例題プログラムをより汎用性を
	  持ったものに仕上げる。


	(1). 構成
	(2). リモートマシンonlpara からの任意のCAMACコマンドを実行可能にする
	(3). コマンド入力を繰り返し実行できるように変更

  --------------------------------------------------------------------


 (1). 構成

	テストに使用するマシンは onlpara と onlsbc1 である。 マシン onlpara は
	DELL社製のPC, Dimension 4500 で、RedHat Linux 7.3 が動作している。 Java
	のバージョンは1.4.1 である。 一方 onlsbc1 は、アドバンテク社のSBC、
	PCM-9370である。 このSBCは、CAMACコントローラ上に装着されている。
	SBC上で動作している OSは Red Hat Linux 8.0 で、コンパクトフラッシュ上に
	構成してある。 Javaのバージョンは1.4.1_01 である。


 (2). リモートマシンonlpara からの任意のCAMACコマンドを実行可能にする

   (2-1).  サーバ側、onlsbc1.kek.jp

     (2-1-1).  Javaのチェック

[inoue@onlsbc1 keyin-21]$ java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
[inoue@onlsbc1 keyin-21]$


     (2-1-2).  実行環境

[inoue@onlsbc1 keyin-21]$ env
MANPATH=:/usr/java/man
HOSTNAME=onlsbc1.kek.jp
TERM=vt100
SHELL=/bin/bash
JLESSCHARSET=japanese
HISTSIZE=1000
SSH_CLIENT=130.87.153.9 33704 22
SSH_TTY=/dev/pts/0
USER=inoue
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;0
1:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.b
tm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:
*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*
.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;3
5:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
MAIL=/var/spool/mail/inoue
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/java/bin:/home/inoue/bin
INPUTRC=/etc/inputrc
PWD=/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
LANG=ja_JP.eucJP
SHLVL=1
HOME=/home/inoue
LOGNAME=inoue
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env
OLDPWD=/home/inoue/JavaRMI/CAMAC/Key-in
[inoue@onlsbc1 keyin-21]$


     (2-1-3).  コンパイル

[inoue@onlsbc1 keyin-21]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
[inoue@onlsbc1 keyin-21]$ ls -l
合計 36
-rw-rw-r--    1 inoue    inoue         213  3月  6 16:00 Client.java
-rw-r--r--    1 inoue    inoue       11478  3月  6 16:25 ClientImpl.java
-rw-rw-r--    1 inoue    inoue         853  3月  6 16:00 Makefile
-rw-r--r--    1 inoue    inoue         288  3月  6 16:00 Server.java
-rw-r--r--    1 inoue    inoue        2417  3月  6 16:00 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        3846  3月  6 16:25 camac.c
-rw-rw-r--    1 inoue    inoue         828  3月  6 16:00 camac.java
[inoue@onlsbc1 keyin-21]$

       (2-1-3a).  Client.java

[inoue@onlsbc1 keyin-21]$ cat Client.java
// File Name: Client.java
// Date: Feb 19, 2003
// Edited by: Eiji Inoue

public interface Client extends java.rmi.Remote {
        public void camac_reply( int[] ia, int[] ib, int ic) throws java.rmi.Rem
oteException;
}
[inoue@onlsbc1 keyin-21]$


       (2-1-3b).  ClientImpl.java

[inoue@onlsbc1 keyin-21]$ more ClientImpl.java
// File Name: ClientImpl.java
// Date: Mar 6, 2003
// Edited by: Eiji Inoue

import java.io.*;
import java.rmi.*;
import java.rmi.server.*;

class ClientImpl implements Client {
        public static final int  CMD_F16_A0_N3 = 0xE0030010;
        public static final int  CMD_F0_A0_N3  = 0xE0030000;
        public static final char COM = ',';
        public static final char QUIT = 'q';
        public static final char STAR = 's';

        public static int scmd[] = new int[100];
        public static int sdat[] = new int[100];

        static Server server;

        public ClientImpl(String host) {
                try{
                   UnicastRemoteObject.exportObject(this);
                   Server server = (Server)Naming.lookup("//"+host+"/Server");
                   server.register(this);
                   ClientImpl.server = server;
                } catch ( Exception e ) {
                   System.err.println ("Failed to setup for RMI");
                }
        }

        public void camac_exec( int l_count ) {
                int[]  s_cmd, s_dat;
                int[] array_sizes = {4096*16};
                int    s_length;
                int    j;

                try{
                System.out.println(" RMI: Client side: ");
                // to send int array

                        System.out.println("   RMI: Sent CAMAC command: array le
ngth =" + l_count );
                        for (int i = 0; i < l_count + 1; i++)
                            System.out.println("      ClientImpl.scmd[" + i + "]
 = 0x" + Integer.toHexString( ClientImpl.scmd[i]) + ", ClientImpl.sdat[" + i + "
] = 0x" + Integer.toHexString( ClientImpl.sdat[i]));

                        ClientImpl.server.camac_cmd(ClientImpl.scmd, ClientImpl.
sdat, l_count );
                } catch ( Exception e ) {
                   System.err.println ("Failed to setup for RMI step2");
                }
        }

        public void camac_reply( int[] c_reply, int[] d_reply, int l_reply) thro
ws RemoteException {
                System.out.println();
                System.out.println("   RMI: Received CAMAC reply: " + "array len
gth = " + l_reply);
                for (int i = 0; i < l_reply + 1; i++)
                    System.out.println("      c_reply[" + i + "] = 0x" + Integer
.toHexString(c_reply[i]) + ", d_reply[" + i + "] = 0x" + Integer.toHexString(d_r
eply[i]));

        }

// TX
// +---------+-------+-------+-------+-------+---------------------------+
// |   cmd   |   N   |   A   |   F   |       |       24-bit DATA         |
// +---------+-------+-------+-------+-------+---------------------------+
//
// cmd Header pattern
// +-------------+---------+---------+---------+---------------+
// |             | Packet  | Packet  | Packet  | Single        |
// |             | Start   | Period  | End     | Frame Packet  |
// +-------------+---------+---------+---------+---------------+
// | CAMAC       |         |         |         |               |
// | Operation   |  0xC0   |  0x8C   |  0xA0   |      0xE0     |
// +-------------+---------+---------+---------+---------------+
// | CAMAC       |         |         |         |               |
// | LAM         |   --    |   --    |   --    |      0xE8     |
// +-------------+---------+---------+---------+---------------+
// | DAQ Trigger |         |         |         |               |
// | out         |  0xD0   |  0x90   |  0xB0   |      0xF0     |
// +-------------+---------+---------+---------+---------------+
// | DAQ         |         |         |         |               |
// | Interrupt   |   --    |   --    |   --    |      0xF8     |
// +-------------+---------+---------+---------+---------------+
//
// CAMAC N.
//    55   54   53   52   51  50  49  48  47                              32
// +--------------------+----------------+-------------------+---------------+
// |   -    -    -  N16 | N8  N4  N2  N1 |         |         |       |       |
// +--------------------+----------------+-------------------+---------------+
//
// CAMAC A.
//                        47   46   45  44    43  42  41  40              32
// +--------------------+-------------------+----------------+---------------+
//                      |  -    -    -   -  | A8  A4  A2  A1 |       |       |
// +--------------------+-------------------+----------------+---------------+
//
// CAMAC F.
//                                        39   38   37   36   35  34  33  32
// +--------------------+----------------+------------------+----------------+
//                                       | -    -    -  F16 | F8  F4  F2  F1 |
// +--------------------+----------------+------------------+----------------+
//


   public void cmdbld( int n, int a, int f, int l_count ){
      // CAMAC Single action.
      System.out.println ( "   Make up CAMAC Command of Single action." );
      System.out.println ( "   Accepted data:   n = " + n + ", a = " + a + ", f
= " + f + ", l_count = " + l_count );
      a = a << 8;
      n = n << 16;
      ClientImpl.scmd [ l_count -1 ] = 0xE0000000 | ( 0x0000001F & f ) | ( 0x000
00F00 & a ) | ( 0x001F0000 & n );
      System.out.println ( "   ClientImpl.scmd [ " + ( l_count -1 ) + " ] = " +
ClientImpl.scmd [ l_count -1 ] + "(dec), " + "0x" + Integer.toHexString( ClientI
mpl.scmd [ l_count -1 ] ) + "(hex)" );
      System.out.println ( "   ClientImpl.sdat [ " + ( l_count -1 ) + " ] = " +
ClientImpl.sdat [ l_count -1 ] + "(dec), " + "0x" + Integer.toHexString( ClientI
mpl.sdat [ l_count -1 ] ) + "(hex)" );

      // CAMAC LAM handling.
      // CAMAC DMA action.
   }

   public void keyincmd() {
      char cstr[] = new char[20];
      char n[] = new char[4];
      char a[] = new char[4];
      char f[] = new char[4];
      int  c[] = new int[3];
      int  i, i2, count, loop, k_error;
      int  spoin, epoin;
      String cn = "0", ca = "0", cf = "0";
      String tmp;

      String nchk[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "
b", "c", "d", "e", "f" };

      InputStream inStream = System.in;
      InputStreamReader InData = new InputStreamReader ( inStream );

      int s_flg = 0;
      try{
         spoin = 0;
         epoin = 0;
         loop = 1;
         k_error = 0;
         System.out.println ( "" );
         System.out.println ( " (1). Enter 'q' to quit." );
         System.out.println ( " (2). Enter numerical value to sep up CAMAC comma
nd");
         System.out.println ( " (3). Enter 's' to start up command execution." )
;
         System.out.println ( "" );
         do {
            if ( k_error == 1 ) {
                System.out.println ( "" );
                k_error = 0;
            }
            System.out.print ( "Command (N, A, F)(dec) = " );
            count = InData.read ( cstr, 0, 19 );
            String str = new String ( cstr );

            if ( QUIT == str.charAt ( 0 ) ) {
               s_flg = 2;
               break;
            } else if ( STAR == str.charAt ( 0 )) {
               if ( epoin == 0 ) {
                  System.out.print ( "   Command bufer is empty !!");
                  System.out.println ( "" );
                  continue;
               } else {
                  // camacstart();
                  s_flg = 1;
                  System.out.println( "   Ok. Start up CAMAC execution. " );
                  break;
               }
            }
            tmp = str.substring ( 0, count -1 );
            System.out.println ( "   入力されたCommand: " + tmp );
            i2 = 0;
            for ( i = 0; i < str.length(); i++ ) {
               if ( COM == str.charAt ( i ) ) {
                   c[ i2++ ] = i;
               }
            }
            cn = str.substring ( 0, c[ 0 ] );
            ca = str.substring ( c[ 0 ] +1, c[ 1 ]  );
            cf = str.substring ( c[ 1 ] +1, count-1 );

            try{
               int in = Integer.parseInt(cn, 10);
               if ( ( in < 0 ) || ( in > 25 ) ) {
                   System.out.println ( "   Command Error: Illegal value of N: O
ut of range !! " );
                   k_error = 1;
                   continue;
               }
               int ia = Integer.parseInt(ca, 10);
               if ( ( ia < 0 ) || ( ia > 15 ) ) {
                   System.out.println ( "   Command Error: Illegal value of A: O
ut of range !! " );
                   k_error = 1;
                   continue;
               }
               int inf = Integer.parseInt(cf, 10);
               if ( ( inf < 0 ) || ( inf > 31 ) ) {
                   System.out.println ( "   Command Error: Illegal value of F: O
ut of range !! " );
                   k_error = 1;
                   continue;
               }

               if ( ( inf >= 16 ) && ( inf <= 23 ) ) {
                  // データ入力要求
                  int datf = 0;
                  do {
                  System.out.print ( "   Write Data(hex) = " );
                  count = InData.read ( cstr, 0, 19 );
                  str = new String ( cstr );
                  String cdat = str.substring ( 0, count -1 );
                  for ( i = 0; i < count -1; i++) {
                     String cdat1 = cdat.substring ( i, i + 1 );
                     // numerical check
                     for ( i2 = 0; i2 < 16; i2++ ) {
                        if ( cdat1.equals( nchk [ i2 ] ) ) {
                           datf = 0;
                           break;
                        }
                           datf = 1;
                     }
                     if ( datf == 1 ) {
                        System.out.println ( "   Data error: Illegal character -
-- " + cdat1 + " !" );
                        System.out.println ( "" );
                        break;
                     }
                  }
                  if ( datf == 1) {
                     continue;
                  }
                  ClientImpl.sdat [ loop -1 ] = Integer.parseInt( cdat, 16);
                  System.out.println ( "   入力されたData:  " + ClientImpl.sdat
[ loop -1 ] + "(dec), 0x" + Integer.toHexString( ClientImpl.sdat [ loop -1 ] ) +
 "(hex)");
                  if ( ( ClientImpl.sdat [ loop -1 ] < 0 ) || ( ClientImpl.sdat
[ loop -1 ] > 0xffffff ) ) {
                     System.out.println ( "   Data error: Out of range ---  " +
ClientImpl.sdat [ loop -1 ] + " !" );
                     System.out.println ( "" );
                     datf = 1;
                     continue;
                  }
                  } while ( datf == 1 );
               }

               // CAMAC command set up.
               cmdbld ( in, ia, inf, loop );
               epoin++;
               loop++;
               System.out.println ( "" );

            } catch (NumberFormatException e) {
               System.out.println("   NumberFormatException occurred !!");
               System.out.println ( "" );
            }
         } while ( loop > 1 );
            if ( s_flg == 1 ) {
//               System.out.println ( "   CAMAC execution. " );
               camac_exec( loop -1 );
         } else if ( s_flg == 2 ) {
            System.out.println ( "    Quited Program.  Enter Ctl-C. " );
         }

         } catch ( IOException e ) {
            System.out.println ( "   IOException Error:" + e  + " !");
         }
      }


        public static void main(String argv[]) throws Exception{

                String  host = (argv.length == 1) ? argv[0] : "localhost";
                ClientImpl obj = new ClientImpl(host);
                obj.keyincmd();
        }
}
[inoue@onlsbc1 keyin-21]$


       (2-1-3c).  Server.java

[inoue@onlsbc1 keyin-21]$ cat Server.java
// File Name: Server.java
// Date: Feb 19, 2003
// Edited by: Eiji Inoue

import java.rmi.*;

public interface Server extends java.rmi.Remote {
        void register(Client aclient) throws java.rmi.RemoteException;
        void camac_cmd(int[] ia, int[] ib, int ic) throws RemoteException;
}
[inoue@onlsbc1 keyin-21]$


       (2-1-3d).  ServerImpl.java

[inoue@onlsbc1 keyin-21]$ more ServerImpl.java
// File Name: ServerImpl.java
// Date: Feb 19, 2003
// Edited by: Eiji Inoue

import java.rmi.*;
import java.rmi.server.*;

public class ServerImpl extends UnicastRemoteObject implements Server {
        Client client;
        static String serverName;
        static int[] r_cmd, r_dat;
        static camac p;


        static {
                try {
                        serverName = java.net.InetAddress.getLocalHost().getHost
Name();
                }catch(Exception e){
                        serverName = "localhost";
                }
        }

        public ServerImpl() throws Exception {
                super();
                r_cmd = new int[4096*16];
                r_dat = new int[4096*16];
                p = new camac();

        }

        public void register (Client aclient) {
                client = aclient;
        }

        public void camac_cmd(int[] cmd, int[] dat, int length) throws RemoteExc
eption{

           System.out.println(" RMI: Server side: ");
           System.out.println("   RMI: Received CAMAC command: " + "array length
 = " + length);
           for (int i = 0; i < length + 1; i++)
               System.out.println("      cmd[" + i + "] = 0x" + Integer.toHexStr
ing(cmd[i]) + ", dat[" + i + "] = 0x" + Integer.toHexString(dat[i]));

        ServerImpl.r_cmd = cmd;
        ServerImpl.r_dat = dat;

//JNI
    try{
    System.out.println();
    System.out.println("   JNI, Java side: before Native Call");
    for (int i = 0; i < length + 1; i++)
         System.out.println("      ServerImpl.r_cmd[" + i + "] = 0x" + Integer.t
oHexString(ServerImpl.r_cmd[i]) + ", ServerImpl.r_dat[" + i + "] = 0x" + Integer
.toHexString(ServerImpl.r_dat[i]));


    int sum = ServerImpl.p.cmdArray(ServerImpl.r_cmd, ServerImpl.r_dat, length);


    System.out.println();
    System.out.println("   JNI, Java side: after Native Call" + " array length =
 " + length);
    for (int i = 0; i < length + 1; i++)
         System.out.println("      ServerImpl.r_cmd[" + i + "] = 0x" + Integer.t
oHexString(ServerImpl.r_cmd[i]) + ", ServerImpl.r_dat[" + i + "] = 0x" + Integer
.toHexString(ServerImpl.r_dat[i]));

        client.camac_reply (ServerImpl.r_cmd, ServerImpl.r_dat, length);

   } catch ( Exception e ) {
       System.err.println ("Failed to exec for camac");
   }

//JNI end
        }

        public static void main(String argv[]) throws Exception {
                //System.setSecurityManager(new RMISecurityManager());
                ServerImpl obj = new ServerImpl();
                Naming.bind("//"+serverName+"/Server", obj);
                System.out.println("bind done");
        }
}
[inoue@onlsbc1 keyin-21]$


       (2-1-3e).  camac.java

[inoue@onlsbc1 keyin-21]$ cat camac.java
// File name:  camac.java
// Date: Feb 19, 2003
// Edited by: Eiji Inoue
//
//
// Parallel camac
// packet format of basic camac opeation
// TX
// +---------+-------+-------+-------+-------+---------------------------+
// |   cmd   |   N   |   A   |   F   |       |       24-bit DATA         |
// +---------+-------+-------+-------+-------+---------------------------+
//
// RX
// +---------+-------+-------+-------+-------+---------------------------+
// |  rply   |   N   |   A   |   F   |  ST   |       24-bit DATA         |
// +---------+-------+-------+-------+-------+---------------------------+

public class camac {

  public native int cmdArray(int j_cmd[], int j_dat[], int j_length);

  public static void main(String args[]) {
    camac p = new camac();
  }
  static {
    System.loadLibrary("MyImpOfcamac");
  }
}
[inoue@onlsbc1 keyin-21]$


       (2-1-3f).  camac.c

[inoue@onlsbc1 keyin-21]$ more camac.c
// file name:  camac.c
// Date: Mar 6, 2003
// Edited by:  E.Inoue
//
// Parallel camac
// packet format of basic camac opeation
// TX
// +---------+-------+-------+-------+-------+---------------------------+
// |   cmd   |   N   |   A   |   F   |       |       24-bit DATA         |
// +---------+-------+-------+-------+-------+---------------------------+
//
// RX
// +---------+-------+-------+-------+-------+---------------------------+
// |  rply   |   N   |   A   |   F   |  ST   |       24-bit DATA         |
// +---------+-------+-------+-------+-------+---------------------------+

#include    
#include    
#include    
#include    "camac.h"

#define BASE 0xE800
#define TX_DATA1REG BASE
#define TX_DATA2REG (BASE+4)
/* #define TX_STATUSREG (BASE+0x10) */
#define TX_STATUSREG (BASE+0x1c)
#define TXSTATUS_BUSY 0x10000
#define TXSTATUS_TIMEOUT 0x20000
#define RX_DATA1REG (BASE+0x20)
#define RX_DATA2REG (BASE+0x24)
/* #define RX_FIFOREG  (BASE+0x30) */
#define RX_FIFOREG  (BASE+0x3c)
#define CMD_F16_A0_N3 0xE0030010
#define CMD_F0_A0_N3 0xE0030000

unsigned long long int value;
unsigned int camac;


JNIEXPORT jint JNICALL
Java_camac_cmdArray(JNIEnv *env, jobject obj, jintArray r_cmd, jintArray r_dat,
jint length)
{
        int     i, sum = 0;
        jsize   len = (*env)->GetArrayLength(env, r_cmd);
        jint    *c_cmd = (*env)->GetIntArrayElements(env, r_cmd, 0);

        jsize   len2 = (*env)->GetArrayLength(env, r_dat);
        jint    *c_dat = (*env)->GetIntArrayElements(env, r_dat, 0);

        int     loop = length;
        int     ii, j, data, cmd, value;

        printf ("\n   JNI, C side: Received CAMAC command: ");
        printf ("array length = %d\n", length);
        for (i=0; i < length +1; i++) {
           printf("      c_cmd[%d] = 0x%x, c_dat[%d] = 0x%x\n", i, c_cmd[i], i,
c_dat[i]);
        }

        if( iopl(3) ){
           printf("can not change the privilege level\n");
           exit(0);
        }

        printf("\n   JNI, C side: CAMAC access\n");
        for( i = 0; i < loop; i++) {
           switch (c_cmd[i] & 0x00000018) {

//  CAMAC Write
                case 0x00000010 :

//  送信可能状態になるまで待つ
                        value = inl(TX_STATUSREG);
                        while (value & TXSTATUS_BUSY) {
                           if (value & TXSTATUS_TIMEOUT) break;
                           value = inl(TX_STATUSREG);
                        }

//  camac writeコマンド&データをセットして、PCIレジスタに書き込む
                        data = c_dat[i] & 0x00ffffff;
                        outl(data, TX_DATA1REG);
                        outl(CMD_F16_A0_N3, TX_DATA2REG);
                        printf("      camac write data:  data = 0x%x\n", data);

//  camac応答が読み出し可能状態になるまで待つ
                        value = 0;
                        do {
                           value = inl(RX_FIFOREG);
                           // for PCI ROM of new version
                           //  value = value >> 24;
                        } while( value < 2 );

//  camacからの受信用レジスタを読んで camacからの応答を得る
                        data = inl(RX_DATA1REG);
                        cmd = inl(RX_DATA2REG);
                        printf("      camac write command reply:  cmd = 0x%x : d
ata = %x\n", cmd, data);
                        c_cmd[i] = cmd;
                        c_dat[i] = data;
                        break;


//  CAMAC Read
                case 0x00000000 :

//  送信可能状態になるまで待つ
                        value = inl(TX_STATUSREG);
                        while (value & TXSTATUS_BUSY) {
                        if (value & TXSTATUS_TIMEOUT) break;
                           value = inl(TX_STATUSREG);
                        }

//  camac readコマンド&データをセットして、PCIレジスタに書き込む
                        outl(CMD_F0_A0_N3, TX_DATA2REG);

//  camac応答が読み出し可能状態になるまで待つ
                        value = 0;
                        do {
                           value = inl(RX_FIFOREG);
                           // for PCI ROM of new version
                           //  value = value >> 24;
                        } while( value < 2);

//  camacからの受信用レジスタを読んで camacからの応答を得る
                        data = inl(RX_DATA1REG);
                        cmd = inl(RX_DATA2REG);
                        data = 0xffffff & data;
                        ii = 0xffffff & c_dat[i];
                        printf("      camac read command reply:  cmd = 0x%x : da
ta = 0x%x\n", cmd, data);
                        c_cmd[i] = cmd;
                        c_dat[i] = data;
                        break;

//  Default
                default :
                        break;
           }
        }

        (*env)->ReleaseIntArrayElements(env, r_cmd, c_cmd, 0);
        (*env)->ReleaseIntArrayElements(env, r_dat, c_dat, 0);
        return sum;
}
[inoue@onlsbc1 keyin-21]$


       (2-1-3g).  Makefile

[inoue@onlsbc1 keyin-21]$ more Makefile
# File Name: Makefile
# Date: Mar 4, 2003
# Edited by: Eiji Inoue

all :  camac.class camac.h libMyImpOfcamac.so Client.class ClientImpl.class Serv
er.class ServerImpl.class ClientImpl_Skel.class ClientImpl_Stub.class ServerImpl
_Skel.class ServerImpl_Stub.class


camac.class:    camac.java
        javac camac.java

Client.class:   Client.java
        javac Client.java

ClientImpl.class:       ClientImpl.java
        javac ClientImpl.java

Server.class:   Server.java
        javac Server.java

ServerImpl.class:       ServerImpl.java
        javac ServerImpl.java

ClientImpl_Skel.class:  ClientImpl.class
        rmic ClientImpl

ServerImpl_Skel.class:  ServerImpl.class
        rmic ServerImpl


camac.h:        camac.class
        javah -jni camac

libMyImpOfcamac.so:     camac.c
        gcc -O -shared -I/usr/java/include -I/usr/java/include/linux camac.c -o
libMyImpOfcamac.so

clean:
        rm -f *.class camac.h libMyImpOfcamac.so *.o core *~
[inoue@onlsbc1 keyin-21]$


       (2-1-3h).  上記のソースプログラムをコンパイルする

[inoue@onlsbc1 keyin-21]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
[inoue@onlsbc1 keyin-21]$ ls -l
合計 36
-rw-rw-r--    1 inoue    inoue         213  3月  6 16:00 Client.java
-rw-r--r--    1 inoue    inoue       11478  3月  6 16:25 ClientImpl.java
-rw-rw-r--    1 inoue    inoue         853  3月  6 16:00 Makefile
-rw-r--r--    1 inoue    inoue         288  3月  6 16:00 Server.java
-rw-r--r--    1 inoue    inoue        2417  3月  6 16:00 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        3846  3月  6 16:25 camac.c
-rw-rw-r--    1 inoue    inoue         828  3月  6 16:00 camac.java
[inoue@onlsbc1 keyin-21]$
[inoue@onlsbc1 keyin-21]$ make clean
rm -f *.class camac.h libMyImpOfcamac.so *.o core *~
[inoue@onlsbc1 keyin-21]$ make
javac camac.java
javah -jni camac
gcc -O -shared -I/usr/java/include -I/usr/java/include/linux camac.c -o libMyImp
Ofcamac.so
javac Client.java
javac ClientImpl.java
javac ServerImpl.java
rmic ClientImpl
rmic ServerImpl
[inoue@onlsbc1 keyin-21]$ ls -l
合計 88
-rw-rw-r--    1 inoue    inoue         202  3月  7 15:35 Client.class
-rw-rw-r--    1 inoue    inoue         213  3月  6 16:00 Client.java
-rw-rw-r--    1 inoue    inoue        5783  3月  7 15:35 ClientImpl.class
-rw-r--r--    1 inoue    inoue       11478  3月  6 16:25 ClientImpl.java
-rw-rw-r--    1 inoue    inoue        1689  3月  7 15:36 ClientImpl_Skel.class
-rw-rw-r--    1 inoue    inoue        3046  3月  7 15:36 ClientImpl_Stub.class
-rw-rw-r--    1 inoue    inoue         853  3月  6 16:00 Makefile
-rw-rw-r--    1 inoue    inoue         243  3月  7 15:35 Server.class
-rw-r--r--    1 inoue    inoue         288  3月  6 16:00 Server.java
-rw-rw-r--    1 inoue    inoue        2429  3月  7 15:35 ServerImpl.class
-rw-r--r--    1 inoue    inoue        2417  3月  6 16:00 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        1939  3月  7 15:36 ServerImpl_Skel.class
-rw-rw-r--    1 inoue    inoue        3477  3月  7 15:36 ServerImpl_Stub.class
-rw-rw-r--    1 inoue    inoue        3846  3月  6 16:25 camac.c
-rw-rw-r--    1 inoue    inoue         449  3月  7 15:35 camac.class
-rw-rw-r--    1 inoue    inoue         391  3月  7 15:35 camac.h
-rw-rw-r--    1 inoue    inoue         828  3月  6 16:00 camac.java
-rwxrwxr-x    1 inoue    inoue        6984  3月  7 15:35 libMyImpOfcamac.so
[inoue@onlsbc1 keyin-21]$


   (2-2).  クライアント側、onlpara.kek.jp のソース

     (2-2-1).  コンパイル

[inoue@onlpara keyin-21]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
[inoue@onlpara keyin-21]$ ls -l
合計 36
-rw-rw-r--    1 inoue    inoue         213  3月  6 16:00 Client.java
-rw-r--r--    1 inoue    inoue       11478  3月  6 16:08 ClientImpl.java
-rw-rw-r--    1 inoue    inoue         853  3月  6 16:00 Makefile
-rw-r--r--    1 inoue    inoue         288  3月  6 16:00 Server.java
-rw-r--r--    1 inoue    inoue        2417  3月  6 16:00 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        3846  3月  6 16:09 camac.c
-rw-rw-r--    1 inoue    inoue         828  3月  6 16:00 camac.java
[inoue@onlpara keyin-21]$


       (2-2-1a).  Client.java

	上記の項目(2-1-3a)を参照。


       (2-2-1b).  ClientImpl.java

        上記の項目(2-1-3b)を参照。


       (2-2-1c).  Server.java

        上記の項目(2-1-3c)を参照。


       (2-2-1d).  ServerImpl.java

        上記の項目(2-1-3d)を参照。


       (2-2-1e).  camac.java

        上記の項目(2-1-3e)を参照。


       (2-2-1f).  camac.c

        上記の項目(2-1-3f)を参照。


       (2-2-1g).  Makefile

        上記の項目(2-1-3g)を参照。


       (2-2-1h).  コンパイル

[inoue@onlpara keyin-21]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
[inoue@onlpara keyin-21]$ ls -l
合計 36
-rw-rw-r--    1 inoue    inoue         213  3月  6 16:00 Client.java
-rw-r--r--    1 inoue    inoue       11478  3月  6 16:08 ClientImpl.java
-rw-rw-r--    1 inoue    inoue         853  3月  6 16:00 Makefile
-rw-r--r--    1 inoue    inoue         288  3月  6 16:00 Server.java
-rw-r--r--    1 inoue    inoue        2417  3月  6 16:00 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        3846  3月  6 16:09 camac.c
-rw-rw-r--    1 inoue    inoue         828  3月  6 16:00 camac.java
[inoue@onlpara keyin-21]$
[inoue@onlpara keyin-21]$ make clean
rm -f *.class camac.h libMyImpOfcamac.so *.o core *~
[inoue@onlpara keyin-21]$ make
javac camac.java
javah -jni camac
gcc -O -shared -I/usr/java/include -I/usr/java/include/linux camac.c -o libMyImp
Ofcamac.so
javac Client.java
javac ClientImpl.java
javac ServerImpl.java
rmic ClientImpl
rmic ServerImpl
[inoue@onlpara keyin-21]$ ls -l
合計 88
-rw-rw-r--    1 inoue    inoue         202  3月  7 15:26 Client.class
-rw-rw-r--    1 inoue    inoue         213  3月  6 16:00 Client.java
-rw-rw-r--    1 inoue    inoue        5783  3月  7 15:26 ClientImpl.class
-rw-r--r--    1 inoue    inoue       11478  3月  6 16:08 ClientImpl.java
-rw-rw-r--    1 inoue    inoue        1689  3月  7 15:26 ClientImpl_Skel.class
-rw-rw-r--    1 inoue    inoue        3046  3月  7 15:26 ClientImpl_Stub.class
-rw-rw-r--    1 inoue    inoue         853  3月  6 16:00 Makefile
-rw-rw-r--    1 inoue    inoue         243  3月  7 15:26 Server.class
-rw-r--r--    1 inoue    inoue         288  3月  6 16:00 Server.java
-rw-rw-r--    1 inoue    inoue        2429  3月  7 15:26 ServerImpl.class
-rw-r--r--    1 inoue    inoue        2417  3月  6 16:00 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        1939  3月  7 15:26 ServerImpl_Skel.class
-rw-rw-r--    1 inoue    inoue        3477  3月  7 15:26 ServerImpl_Stub.class
-rw-rw-r--    1 inoue    inoue        3846  3月  6 16:09 camac.c
-rw-rw-r--    1 inoue    inoue         449  3月  7 15:26 camac.class
-rw-rw-r--    1 inoue    inoue         391  3月  7 15:26 camac.h
-rw-rw-r--    1 inoue    inoue         828  3月  6 16:00 camac.java
-rwxrwxr-x    1 inoue    inoue        6659  3月  7 15:26 libMyImpOfcamac.so
[inoue@onlpara keyin-21]$


   (2-3).  サーバ側のプログラムの起動

	onlsbc1 のSBCからPCIへアクセスする前に、PCIのシステムレジスタに 1を書き
	込んで CAMAC 用の FPGA をイニシャライズしないと CAMACにアクセスできない
	ようになっている。 今回のテストに使用しているネイティブコードには、この
	ための操作は含んでいない。 したがって、サーバ側のプログラムを起動する前
	に手動でこの操作をする必要がある。 これは、以下の一行のコマンドで行う。

	# ./w e840 1

[root@onlsbc1 keyin-21]# pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
[root@onlsbc1 keyin-21]# export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
[root@onlsbc1 keyin-21]# rmiregistry &
[1] 1280
[root@onlsbc1 keyin-21]# java ServerImpl
bind done
 RMI: Server side:
   RMI: Received CAMAC command: array length = 6
      cmd[0] = 0xe0030010, dat[0] = 0x0
      cmd[1] = 0xe0030000, dat[1] = 0x0
      cmd[2] = 0xe0030010, dat[2] = 0xabcdef
      cmd[3] = 0xe0030000, dat[3] = 0x0
      cmd[4] = 0xe0030010, dat[4] = 0x567483
      cmd[5] = 0xe0030000, dat[5] = 0x0
      cmd[6] = 0x0, dat[6] = 0x0

   JNI, Java side: before Native Call
      ServerImpl.r_cmd[0] = 0xe0030010, ServerImpl.r_dat[0] = 0x0
      ServerImpl.r_cmd[1] = 0xe0030000, ServerImpl.r_dat[1] = 0x0
      ServerImpl.r_cmd[2] = 0xe0030010, ServerImpl.r_dat[2] = 0xabcdef
      ServerImpl.r_cmd[3] = 0xe0030000, ServerImpl.r_dat[3] = 0x0
      ServerImpl.r_cmd[4] = 0xe0030010, ServerImpl.r_dat[4] = 0x567483
      ServerImpl.r_cmd[5] = 0xe0030000, ServerImpl.r_dat[5] = 0x0
      ServerImpl.r_cmd[6] = 0x0, ServerImpl.r_dat[6] = 0x0

   JNI, C side: Received CAMAC command: array length = 6
      c_cmd[0] = 0xe0030010, c_dat[0] = 0x0
      c_cmd[1] = 0xe0030000, c_dat[1] = 0x0
      c_cmd[2] = 0xe0030010, c_dat[2] = 0xabcdef
      c_cmd[3] = 0xe0030000, c_dat[3] = 0x0
      c_cmd[4] = 0xe0030010, c_dat[4] = 0x567483
      c_cmd[5] = 0xe0030000, c_dat[5] = 0x0
      c_cmd[6] = 0x0, c_dat[6] = 0x0

   JNI, C side: CAMAC access
      camac write data:  data = 0x0
      camac write command reply:  cmd = 0xe0030010 : data = 23000000
      camac read command reply:  cmd = 0xe0030000 : data = 0x0
      camac write data:  data = 0xabcdef
      camac write command reply:  cmd = 0xe0030010 : data = 23000000
      camac read command reply:  cmd = 0xe0030000 : data = 0xabcdef
      camac write data:  data = 0x567483
      camac write command reply:  cmd = 0xe0030010 : data = 23000000
      camac read command reply:  cmd = 0xe0030000 : data = 0x567483

   JNI, Java side: after Native Call array length = 6
      ServerImpl.r_cmd[0] = 0xe0030010, ServerImpl.r_dat[0] = 0x23000000
      ServerImpl.r_cmd[1] = 0xe0030000, ServerImpl.r_dat[1] = 0x0
      ServerImpl.r_cmd[2] = 0xe0030010, ServerImpl.r_dat[2] = 0x23000000
      ServerImpl.r_cmd[3] = 0xe0030000, ServerImpl.r_dat[3] = 0xabcdef
      ServerImpl.r_cmd[4] = 0xe0030010, ServerImpl.r_dat[4] = 0x23000000
      ServerImpl.r_cmd[5] = 0xe0030000, ServerImpl.r_dat[5] = 0x567483
      ServerImpl.r_cmd[6] = 0x0, ServerImpl.r_dat[6] = 0x0
[root@onlsbc1 keyin-21]# kill -KILL 1280
[root@onlsbc1 keyin-21]#
[1]+  強制終了                rmiregistry
[root@onlsbc1 keyin-21]#


   (2-4).  クライアント側のプログラムの起動

[inoue@onlpara keyin-21]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-21
[inoue@onlpara keyin-21]$ rmiregistry &
[1] 30910
[inoue@onlpara keyin-21]$ java ClientImpl onlsbc1

 (1). Enter 'q' to quit.
 (2). Enter numerical value to sep up CAMAC command
 (3). Enter 's' to start up command execution.

Command (N, A, F)(dec) = 3,0,16
   入力されたCommand: 3,0,16
   Write Data(hex) = 0
   入力されたData:  0(dec), 0x0(hex)
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 16, l_count = 1
   ClientImpl.scmd [ 0 ] = -536674288(dec), 0xe0030010(hex)
   ClientImpl.sdat [ 0 ] = 0(dec), 0x0(hex)

Command (N, A, F)(dec) = 3,0,0
   入力されたCommand: 3,0,0
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 0, l_count = 2
   ClientImpl.scmd [ 1 ] = -536674304(dec), 0xe0030000(hex)
   ClientImpl.sdat [ 1 ] = 0(dec), 0x0(hex)

Command (N, A, F)(dec) = 3,0,16
   入力されたCommand: 3,0,16
   Write Data(hex) = abcdef
   入力されたData:  11259375(dec), 0xabcdef(hex)
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 16, l_count = 3
   ClientImpl.scmd [ 2 ] = -536674288(dec), 0xe0030010(hex)
   ClientImpl.sdat [ 2 ] = 11259375(dec), 0xabcdef(hex)

Command (N, A, F)(dec) = 3,0,0
   入力されたCommand: 3,0,0
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 0, l_count = 4
   ClientImpl.scmd [ 3 ] = -536674304(dec), 0xe0030000(hex)
   ClientImpl.sdat [ 3 ] = 0(dec), 0x0(hex)

Command (N, A, F)(dec) = 3,0,16
   入力されたCommand: 3,0,16
   Write Data(hex) = 567483
   入力されたData:  5665923(dec), 0x567483(hex)
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 16, l_count = 5
   ClientImpl.scmd [ 4 ] = -536674288(dec), 0xe0030010(hex)
   ClientImpl.sdat [ 4 ] = 5665923(dec), 0x567483(hex)

Command (N, A, F)(dec) = 3,0,0
   入力されたCommand: 3,0,0
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 0, l_count = 6
   ClientImpl.scmd [ 5 ] = -536674304(dec), 0xe0030000(hex)
   ClientImpl.sdat [ 5 ] = 0(dec), 0x0(hex)

Command (N, A, F)(dec) = s
   Ok. Start up CAMAC execution.
 RMI: Client side:
   RMI: Sent CAMAC command: array length =6
      ClientImpl.scmd[0] = 0xe0030010, ClientImpl.sdat[0] = 0x0
      ClientImpl.scmd[1] = 0xe0030000, ClientImpl.sdat[1] = 0x0
      ClientImpl.scmd[2] = 0xe0030010, ClientImpl.sdat[2] = 0xabcdef
      ClientImpl.scmd[3] = 0xe0030000, ClientImpl.sdat[3] = 0x0
      ClientImpl.scmd[4] = 0xe0030010, ClientImpl.sdat[4] = 0x567483
      ClientImpl.scmd[5] = 0xe0030000, ClientImpl.sdat[5] = 0x0
      ClientImpl.scmd[6] = 0x0, ClientImpl.sdat[6] = 0x0

   RMI: Received CAMAC reply: array length = 6
      c_reply[0] = 0xe0030010, d_reply[0] = 0x23000000
      c_reply[1] = 0xe0030000, d_reply[1] = 0x0
      c_reply[2] = 0xe0030010, d_reply[2] = 0x23000000
      c_reply[3] = 0xe0030000, d_reply[3] = 0xabcdef
      c_reply[4] = 0xe0030010, d_reply[4] = 0x23000000
      c_reply[5] = 0xe0030000, d_reply[5] = 0x567483
      c_reply[6] = 0x0, d_reply[6] = 0x0
[inoue@onlpara keyin-21]$ kill -KILL 30910
[inoue@onlpara keyin-21]$
[1]+  Killed                  rmiregistry
[inoue@onlpara keyin-21]$

	ok.    キーボードから入力した任意のCAMACコマンドをリモートマシンから
	CAMACコントローラ上のターゲットマシンに送信して、CAMACアクセスを実行し
	実行結果のリプライをリモートマシン側へ送り返した。 正常に実行できた。


 (3). コマンド入力を繰り返し実行できるように変更

	現在のプログラムは、CAMACコマンド群を入力して一度実行するとそこで
	終わってしまう。 再度、コマンド入力のところから繰り返し実行できるように
	したほうが実用的と思う。 そのように変更する。


   (3-1).  ClientImpl.javaプログラムの修正

[inoue@onlpara keyin-22]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-22
[inoue@onlpara keyin-22]$ ls -l
合計 36
-rw-rw-r--    1 inoue    inoue         213  3月  7 15:51 Client.java
-rw-r--r--    1 inoue    inoue       11491  3月  7 15:59 ClientImpl.java
-rw-rw-r--    1 inoue    inoue         853  3月  7 15:51 Makefile
-rw-r--r--    1 inoue    inoue         288  3月  7 15:51 Server.java
-rw-r--r--    1 inoue    inoue        2417  3月  7 15:51 ServerImpl.java
-rw-rw-r--    1 inoue    inoue        3846  3月  7 15:51 camac.c
-rw-rw-r--    1 inoue    inoue         828  3月  7 15:51 camac.java
[inoue@onlpara keyin-22]$
[inoue@onlpara keyin-22]$ vi ClientImpl.java
				:
        public void camac_reply( int[] c_reply, int[] d_reply, int l_reply) thro
ws RemoteException {
                System.out.println();
                System.out.println("   RMI: Received CAMAC reply: " + "array len
gth = " + l_reply);
                for (int i = 0; i < l_reply + 1; i++)
                    System.out.println("      c_reply[" + i + "] = 0x" + Integer
.toHexString(c_reply[i]) + ", d_reply[" + i + "] = 0x" + Integer.toHexString(d_r
eply[i]));
                keyincmd();
        }
				:
[inoue@onlpara keyin-22]$


   (3-2).  コンパイル

[inoue@onlpara keyin-22]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-22
[inoue@onlpara keyin-22]$ make clean
rm -f *.class camac.h libMyImpOfcamac.so *.o core *~
[inoue@onlpara keyin-22]$ make
javac camac.java
javah -jni camac
gcc -O -shared -I/usr/java/include -I/usr/java/include/linux camac.c -o libMyImp
Ofcamac.so
javac Client.java
javac ClientImpl.java
javac ServerImpl.java
rmic ClientImpl
rmic ServerImpl
[inoue@onlpara keyin-22]$


   (3-3).  実行

     (3-3-1).  サーバ側のプログラムの起動

ot@onlsbc1 keyin-22]# pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-22
[root@onlsbc1 keyin-22]# export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
[root@onlsbc1 keyin-22]# rmiregistry &
[1] 1540
[root@onlsbc1 keyin-22]# java ServerImpl
bind done
 RMI: Server side:
   RMI: Received CAMAC command: array length = 1
      cmd[0] = 0xe0030010, dat[0] = 0x0
      cmd[1] = 0x0, dat[1] = 0x0

   JNI, Java side: before Native Call
      ServerImpl.r_cmd[0] = 0xe0030010, ServerImpl.r_dat[0] = 0x0
      ServerImpl.r_cmd[1] = 0x0, ServerImpl.r_dat[1] = 0x0

   JNI, C side: Received CAMAC command: array length = 1
      c_cmd[0] = 0xe0030010, c_dat[0] = 0x0
      c_cmd[1] = 0x0, c_dat[1] = 0x0

   JNI, C side: CAMAC access
      camac write data:  data = 0x0
      camac write command reply:  cmd = 0xe0030010 : data = 23000000

   JNI, Java side: after Native Call array length = 1
      ServerImpl.r_cmd[0] = 0xe0030010, ServerImpl.r_dat[0] = 0x23000000
      ServerImpl.r_cmd[1] = 0x0, ServerImpl.r_dat[1] = 0x0





 RMI: Server side:
   RMI: Received CAMAC command: array length = 1
      cmd[0] = 0xe0030010, dat[0] = 0x555555
      cmd[1] = 0x0, dat[1] = 0x0

   JNI, Java side: before Native Call
      ServerImpl.r_cmd[0] = 0xe0030010, ServerImpl.r_dat[0] = 0x555555
      ServerImpl.r_cmd[1] = 0x0, ServerImpl.r_dat[1] = 0x0

   JNI, C side: Received CAMAC command: array length = 1
      c_cmd[0] = 0xe0030010, c_dat[0] = 0x555555
      c_cmd[1] = 0x0, c_dat[1] = 0x0

   JNI, C side: CAMAC access
      camac write data:  data = 0x555555
      camac write command reply:  cmd = 0xe0030010 : data = 23000000

   JNI, Java side: after Native Call array length = 1
      ServerImpl.r_cmd[0] = 0xe0030010, ServerImpl.r_dat[0] = 0x23000000
      ServerImpl.r_cmd[1] = 0x0, ServerImpl.r_dat[1] = 0x0




 RMI: Server side:
   RMI: Received CAMAC command: array length = 1
      cmd[0] = 0xe0030000, dat[0] = 0x555555
      cmd[1] = 0x0, dat[1] = 0x0

   JNI, Java side: before Native Call
      ServerImpl.r_cmd[0] = 0xe0030000, ServerImpl.r_dat[0] = 0x555555
      ServerImpl.r_cmd[1] = 0x0, ServerImpl.r_dat[1] = 0x0

   JNI, C side: Received CAMAC command: array length = 1
      c_cmd[0] = 0xe0030000, c_dat[0] = 0x555555
      c_cmd[1] = 0x0, c_dat[1] = 0x0

   JNI, C side: CAMAC access
      camac read command reply:  cmd = 0xe0030000 : data = 0x555555

   JNI, Java side: after Native Call array length = 1
      ServerImpl.r_cmd[0] = 0xe0030000, ServerImpl.r_dat[0] = 0x555555
      ServerImpl.r_cmd[1] = 0x0, ServerImpl.r_dat[1] = 0x0
[root@onlsbc1 keyin-22]# kill -KILL 1540
[root@onlsbc1 keyin-22]#
[1]+  強制終了                rmiregistry
[root@onlsbc1 keyin-22]#


     (3-3-2).  クライアント側のプログラムの起動

[inoue@onlpara keyin-22]$ pwd
/home/inoue/JavaRMI/CAMAC/Key-in/keyin-22
[inoue@onlpara keyin-22]$ rmiregistry &
[1] 31210
[inoue@onlpara keyin-22]$ java ClientImpl onlsbc1

 (1). Enter 'q' to quit.
 (2). Enter numerical value to sep up CAMAC command
 (3). Enter 's' to start up command execution.

Command (N, A, F)(dec) = 3,0,16
   入力されたCommand: 3,0,16
   Write Data(hex) = 0
   入力されたData:  0(dec), 0x0(hex)
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 16, l_count = 1
   ClientImpl.scmd [ 0 ] = -536674288(dec), 0xe0030010(hex)
   ClientImpl.sdat [ 0 ] = 0(dec), 0x0(hex)

Command (N, A, F)(dec) = s
   Ok. Start up CAMAC execution.
 RMI: Client side:
   RMI: Sent CAMAC command: array length =1
      ClientImpl.scmd[0] = 0xe0030010, ClientImpl.sdat[0] = 0x0
      ClientImpl.scmd[1] = 0x0, ClientImpl.sdat[1] = 0x0

   RMI: Received CAMAC reply: array length = 1
      c_reply[0] = 0xe0030010, d_reply[0] = 0x23000000
      c_reply[1] = 0x0, d_reply[1] = 0x0

 (1). Enter 'q' to quit.
 (2). Enter numerical value to sep up CAMAC command
 (3). Enter 's' to start up command execution.

Command (N, A, F)(dec) = 3,0,16
   入力されたCommand: 3,0,16
   Write Data(hex) = 555555
   入力されたData:  5592405(dec), 0x555555(hex)
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 16, l_count = 1
   ClientImpl.scmd [ 0 ] = -536674288(dec), 0xe0030010(hex)
   ClientImpl.sdat [ 0 ] = 5592405(dec), 0x555555(hex)

Command (N, A, F)(dec) = s
   Ok. Start up CAMAC execution.
 RMI: Client side:
   RMI: Sent CAMAC command: array length =1
      ClientImpl.scmd[0] = 0xe0030010, ClientImpl.sdat[0] = 0x555555
      ClientImpl.scmd[1] = 0x0, ClientImpl.sdat[1] = 0x0

   RMI: Received CAMAC reply: array length = 1
      c_reply[0] = 0xe0030010, d_reply[0] = 0x23000000
      c_reply[1] = 0x0, d_reply[1] = 0x0

 (1). Enter 'q' to quit.
 (2). Enter numerical value to sep up CAMAC command
 (3). Enter 's' to start up command execution.

Command (N, A, F)(dec) = 3,0,0
   入力されたCommand: 3,0,0
   Make up CAMAC Command of Single action.
   Accepted data:   n = 3, a = 0, f = 0, l_count = 1
   ClientImpl.scmd [ 0 ] = -536674304(dec), 0xe0030000(hex)
   ClientImpl.sdat [ 0 ] = 5592405(dec), 0x555555(hex)

Command (N, A, F)(dec) = s
   Ok. Start up CAMAC execution.
 RMI: Client side:
   RMI: Sent CAMAC command: array length =1
      ClientImpl.scmd[0] = 0xe0030000, ClientImpl.sdat[0] = 0x555555
      ClientImpl.scmd[1] = 0x0, ClientImpl.sdat[1] = 0x0

   RMI: Received CAMAC reply: array length = 1
      c_reply[0] = 0xe0030000, d_reply[0] = 0x555555
      c_reply[1] = 0x0, d_reply[1] = 0x0

 (1). Enter 'q' to quit.
 (2). Enter numerical value to sep up CAMAC command
 (3). Enter 's' to start up command execution.

Command (N, A, F)(dec) = q
    Quited Program.  Enter Ctl-C.
[inoue@onlpara keyin-22]$ kill -KILL 31210
[inoue@onlpara keyin-22]$
[1]+  Killed                  rmiregistry
[inoue@onlpara keyin-22]$

	ok.  一旦CAMACコマンドを実行した後、再度コマンド入力のところから繰り返す
	ようにできた。 正常に実行できている。


---xxxx