
	Remote serial port driver and test program documentation.

What is remote serial port driver ?

 Remote serial port driver is a virtual serial port driver to make a host 
 without serial port or without enough serial ports to use the physical 
 serail port located on other host. The communication is made via TCP/IP.
 Any datum sent to the virtual serial port will arrive to the physical 
 serial port on the remote host. You can also change the settings of the 
 virtual serial port including Baud rate, data bits, and parity check just
 the way you've always done to physical ones.



Install the remote serial port driver

 Let's define something to make this documentation easier to read.

  1. The host wants to have virtual serial port is called a 'Client'.

  2. The host with physical serial port is called a 'Remote'.

 A Client needs to insert a kernel module and run a client program to
 make it able to connect to Remote. A Remote needs to run a remote program 
 to be able to connected with client. In the following we will state the 
 install processes for Client and Remote respectively. In the very first,
 you can simplily run 'make' to build two executables, remote and client,
 and one module, rserial.o, and a testing program, rstest.

 	Executable:

		remote
		client

	Kernel module:

		rserial.o

	Testing program:

		rstest

 Install process at Client site:
	
	1. Build virtual serial port devices.

           #./Makedev

           This step will generate /dev/ttyrs0 to /dev/ttyrs15 and 
           /dev/ptyrs0 to /dev/ptyrs15. The /dev/ttyrsx is the virtual 
           serial port deivce for you to use as the way you've always
	   done to physical serial port before. The /dev/ptyrsx is used
           by the program, 'client'. 

        2. Insert virtual serial port module into kernel.

	   #insmod rserial.o

           You can also build it in kernel statically.

        3. Connect to Remote by assigning IP address.

	   #./client 192.168.1.100
  
           The example above is to connect the a Remote host with IP address
           192.168.1.100. If you don't assign an IP address as the first
	   argument, 'client' will use 127.0.0.1, ie localhost, as the IP
	   address. This is a convenient feature for testing.

	4. The connection is made so far. You can read the messages to
	   monitor the connection state.

 Install process at Remote site:

	Assume you have a 8 port multi-serial port card on your Remote site 
	and the devices is /dev/ttyS44 to /dev/ttyS51. 

	1. Run the 'remote' program.

	   #./remote 44

	   The first argument of remote program will tell it the start port
	   number of serial port devices. The remote program will find how
	   many ports there are on this host. If you don't fill the first
	   argument the remote will take 44 for the start port number.

	2. Waiting for connection of client.


Monitor the remote serial port.

 Sometines you may want to know if your datum have been sent to the remote
 site correctly and what's coming from the remote site. You can use the 
 'telnet' program to minitor them. By 'telnet' to port 18000 of Remote you 
 can see everything come from Client to first physical serial port. Port
 18001 of Remote is for the second physical serial port and so on. 
 By 'telnet' to port 18100 of Remote you can see everything come from physic
 serial port to Client. Port 18101 of Remote is for the second serial port
 and so on. 

 All datum come from Client to physical serial port will be recorded in
 '/tmp/e2s.x' at Remote site.

 All datum come from physical serial port to Client will be recorded in
 '/tmp/s2e.x' at Remote site.

 The 'x' of the above two filenames are the port index.



Test the remote serial port.

 There is a test program for remote serial port, 'rstest'. You will have
 a loop back connector first connecting on your serial port. It simplily
 route the TX to RX of your serial port. If you wants to use hardware
 flow control, routing other signal pin is needed. Then you can run the 
 testing program to test it. There are several arguments for 'rstest'.

 #./rstest dev num [baud] [bytes]

 	dev : The starting device to do the loop back test.
 	num : The number of ports following the starting device.
 	[baud]: This is omissible. The default baud is 9600.
		0 -> 9600
		1 -> 19200
		2 -> 38400
		3 -> 57600
		4 -> 115200
	
	 [bytes]: This is omissible. This is the total bytes to send.

		  If not specifing, the default value is 128 KB.

 The datum used for testing is the ascii number from 0 to 255. All the datum
 will be recorded on '/tmp/rswrite.x'.
 
 The 'x' of the above filename is the port index.

 <example>
 
 #./retest /dev/ttyrs0 8 4 1024000

 This means I want to send 1024000 bytes using /dev/ttyrs0 to /dev/ttyrs7
 with baud rate 115200.

