Perle Systems SCS8C DC Server User Manual


 
Utilities 421
API I/O Access Over TruePort
API I/O Access Over TruePort
You can access IOLAN I/O data through TruePort using the Perle API. The API uses the
command/response format. See the
ioapiotp.c sample program, found on the product CD-ROM,
for an example implementation.
API Request Format
All data in the Request must be sent as a single write to the COM port. The API command takes the
following format:
API Response Format
The API command takes the following response format:
Number of Bytes Value
1 Function Code (in hexadecimal):
z 01—Get read/write boolean register
z 03—Get read/write register
z 04—Get read only register
z 15—Set read/write boolean register (0x0F)
z 16—Set read/write register (0x10)
2 Starting register number (see A4/T4 Registers , A4D2/A4R2 Registers ,
or D4/D2R2 Registers for this value).
2 Number of registers to act on starting from the register defined in byte
2 above.
n Data for write. Some values must be read/written as a unit consisting of
2 consecutive registers. If the request is to write, the data to write
follows the number of registers. If accessing registers consisting of 2
bytes or 4 bytes, the data is in big endian (network order) format.
Number of Bytes Value
1 Function code of request if no error. Most significant bit will be set if
an error occurred.
1 Length of data in response if no error occurred. If an error occurred, the
byte will contain the error code (see the
Error Codes table below).
n Data response for request (the number of bytes is dependent on the
number and type of registers requested). If the request returns 2 or 4
byte values, it will be in big endian (network order) format. If the
request returns boolean values, the least significant bit (bit 0) represents
the first value requested and bits 1 to 7 represents subsequent boolean
values. If more than 8 boolean registers are requested, they are returned
in successive bytes.