A.1 the input pin (pin 8), Using the handshaking lines for general – Campbell Scientific SDM-SIO1 Serial Input/Output Module User Manual

Page 29

Advertising
background image

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 (pins 8 and 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 (Pin 8)

The state of the input line (pin 8) can be read by the SerialInChk() instruction
in CRBasic.

The SerialInChk() instruction has been modified compared to the standard.
SerialInChk() will return a 16-bit value representing the number of bytes
available within the SDM-SIO1s receive buffer, this value can be anywhere
from 0 to 2047.

The 16

th

bit (the furthest left or most significant) is reserved when using an

SIO1 for indicating the status of the spare input line (pin 8). If this bit is set
then the line is high and if it is not set then the line is low.

If the SerialInChk(comport) is used and the input line is high and no data is
available in the loggers buffer then 32768 would be returned (i.e., 0x8000 in
hex). This means that any number returned that’s greater than 32767 indicates
that the input line is set high.

If the CRBasic command SerialInChk(comport) is used and the input line is
low and no data is available in the loggers buffer then 0 would be returned (i.e.,
0x0000 in hex).

To get the amount of data in the SDM-SIO1s receive buffer without the 16th

bit affecting the result, mask the returned value as shown below.

CRBasic example of SerialInChk() masking and input line status checking

public ChkValReturned
public InputStatus
public AvailableData

scan(250,mSec,0,0)

ChkValReturned

=

SerialInChk (32)

‘Get the raw data


‘This statement will remove the input line status from the retuned

‘value leaving only the amount of data available in the SDM-SIO1s buffer

AvailableData = ChkValReturned AND 4095

‘Mask off lowest 12 bits (Ox0FFF in hex)

A-1

Advertising