User Tools

Site Tools

한국어

cubloc:get:index

Get( )

variable = Get(channel, length)

variable Variable to store results (Cannot use String or Single)
channel RS-232 Channel (1 to 3)
length Length of data to receive in bytes (1 to 4)

Read data from the RS-232 port. The Get command actually reads from the receive buffer. If there is no data in the receive buffer, it will quit without waiting for data and return 0. The Blen command can be used to check if there is any data in the receive buffer before trying to read data.

The length of data to be read must be between 1 and 4. If receiving a single Byte, it would be 1. If receiving a Long, it would be 4. For larger amounts of data, use GetStr or GetA.

Use Sys(1) after Get or GetStr to verify how much data was actually read. If 5 bytes are received but only 4 bytes are verified, 1 byte is lost.

Const Device = CB280
Dim A as Byte
OpenCom 1,115200,3,50,10
On Recv1 GoSub GOTDATA
Do
  Do While In(0) = 0
  Loop ' Wait for a button press (Connect P0)
  Put 1,Asc("H"),1
  Put 1,Asc("E"),1
  Put 1,Asc("L"),1
  Put 1,Asc("L"),1
  Put 1,Asc("O"),1
  Put 1,13,1 ' HELLO + Chr (13) + Chr (10)
  Put 1,10,1
  Do While In(0) = 1
  Loop
Loop
 
GOTDATA:
  A=Get(1,1)
  Debug A
  Return

Go CUBLOC home

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