# Direct Access to RS232 Controllers

Usually serial ports are accessed by SICS through David Maden's SerPortServer program which then communicates with a terminal server box through the TCP/IP network. This limits the amount of control over the controller. If more control is required, the RS232 controllers can be accessed directly from SICS through the terminal server, thereby bypassing the SerPortServer program. Please note, that these two modes of operation are mutually exclusive: a given port can either be accessed through the mechanism described here OR through SerPortServer.

Before being able to use this system, the RS232 controller has to be configured into SICS as described in the hardware initialization section through the following command in the initialization file:

    MakeRS232Controller name terminalserver port

For example:

    MakeRS232Controller hugo psts213 3004

name is the SICS name for the controller, terminalserver is the name of the terminal server the device is connected to and port is the port number at which the terminal server publishes the RS232 channel to which the device is connected. This is usally the port number plus 3000.

Now various commands are available for interfacing with the RS232 controller. In the following description the SICS name of the controller is replaced by the symbol rs232name.

rs232name sendterminator
  prints the current terminator used when sending data to the device as hexadecimal numbers.
rs232name sendterminator h1h2..hn
  sets the current terminator used when sending data to the device to the characters described by the hexadecimal numbers h1 to hn. The numbers are in the format 0xval, where val is the hex number.
rs232name replyterminator
  prints the current terminator expected to terminate a response from the device as a hexadecimal number.
rs232name replyterminator h1h2..hn
  sets the current terminator expected to terminate a response from the device to the characters described by the hexadecimal numbers h1 to hn. The numbers are in the format 0xval, where val is the hex number.
rs232name timeout
  prints the current timeout when waiting for a reponse from the device.
rs232name timeout val
  sets the timeout for waiting for responses from the device. The value is in microseconds.
rs232name send data data data
  sends the remainder of the line to the RS232 device and waits for a response terminated with the proper reply terminator specified. This commands waits at maximum timeout microseconds for a response. If a valid response is obtained it is printed, otherwise an error message occurs.
rs232name write data data data
  writes the remainder of the line after write to the device without waiting for a response.
rs232 available
  checks if data is pending to be read from the device.
rs232 read
  reads data from the device.