A-1
Appendix A. Using the Handshaking
lines for general input/output
This Appendix describes how to use the CTS and RTS lines for input and output ports.
The I/O pins (CTS/pins 8 and RTS/9) can be read or set by the user as required
allowing unique protocols to be created, or they can simply be used as flags or
enable lines.
If the user enables automatic handshaking as discussed earlier then pins 8 and 9
can’t be accessed.
A.1 The input pin (CTS/pin 8)
The state of the input line (pin 8) can be read by using the special SDMGeneric
instruction in CRBasic.
Bit 16 of a value returned to the logger using the SDMGeneric command reports
whether the input is logic high or low. The example below shows how to call the
command with the required parameters.
'CR1000 Example program showing how to detect the state of the input line on an SDM-SIO1
'Using the SDMGeneric instruction
Public sio1response As Long, Inputstate As Boolean
Const addr = 0 'constant sdm address CHANGE with SDM-SIO1 address
Const cmd = 1 'constant, command 1 returns the input state in bit 16
Const bytes_out = 0 'constant number of bytes out - none sent
Const bytes_val = 2 'two bytes returned
Const big_endian = 1 '1=(big endian)
Const delay_usec = -0 'delay between outgoing bytes (negative means delay also for incoming bytes)
Const Values_in = 1
'Main Program
BeginProg
Scan (1,Sec,0,0) 'Or whatever scan rate is being used
' Use the SDMGeneric instruction to send command 0x01 which returns the input line state as bit 16
SDMGeneric(sio1response,addr,cmd,bytes_out,"",Values_in,bytes_val, big_endian,delay_usec)
'bit 16 set for input line high or low so check the value and set a boolean var TRUE or FALSE accordingly
Inputstate = sio1response AND &H8000
NextScan
EndProg