User Tools

Site Tools

한국어

cubloc:put:index

Put

Put channel, data, byteLength

channel RS-232 channel (1 to 3)
data Data to send (up to Long type value)
byteLength Length of data in bytes (1 to 4)

This command sends data on the specified RS-232 channel. For data, variables and constants can be used. To send a String, please use the PutStr command instead.

The OpenCom command must be used beforehand.

OpenCom 1,19200,0,50,10
Dim A As Byte
A = &HA0
Put 1,A,1    ' Send &HA0 (0xA0) to RS232 Channel 1.

The data is first stored in the send buffer set by OpenCom. The Cubloc BASIC Interpreter will automatically keep transmitting the data until the send buffer is empty.

If the send buffer is full when the Put command is executed, Put will overwrite the data currently in the buffer. The BFree command can be used to check the send buffer beforehand to prevent overwriting existing data in the send buffer.

If BFree(1,1) > 2 Then    ' If send buffer has at least 2 bytes free
  Put 1,A,2
End If

Bfree is used to check how much free space the send buffer has before writing any data to it.

TIP

After using Put or PutStr, the function Sys(0) can be used to verify that the data has been stored in the send buffer.

OpenCom 1,19200,0,50,10
PutStr 1,"COMFILE"
Debug Dec Sys(0)   ' If output is 7, all data has been stored in the send buffer

Please refer to the On Recv interrupt service routine for receiving data using the hardware serial buffer.

Go CUBLOC home

cubloc/put/index.txt · Last modified: 2016/04/14 11:07 (external edit)