Download smartBASIC user`s manual

Transcript
smart BASIC Core Functionality
User Manual
UartReadN
FUNCTION
This function is used to read the content of the receive buffer and append it to the string
variable supplied but it ensures that the string is not longer than nMaxLen.
UARTREADN(strMsg, nMaxLen)
INTEGER 0 to N : The total length of the string variable – not just what got
appended. This means the caller does not need to call strlen() function to
determine how many bytes in the string that need to be processed.
Returns
Exceptions



Local Stack Frame Underflow
Local Stack Frame Overflow
Uart has not been opened using UARTOPENxxx
Arguments
strMsg
byRef
strMsg AS STRING
The content of the receive buffer will get appended to this string.
nMaxLen
byval
nMaxLen AS INTEGER
The output string strMsg will never be longer than this value. If a value less than 1
is specified, it will be clipped to 1 and if > that 0xFFFF it will be clipped to 0xFFFF.
Interactive
Command
NO
Related
Commands
UARTOPEN,UARTINFO, UARTCLOSE, UARTWRITE, UARTREADMATCH, UARTGETDSR,
UARTGETCTS, UARTGETDCD, UARTGETRI, UARTSETDTR, UARTSETRTS, UARTSETDCD,
UARTSETRI, UARTBREAK, UARTFLUSH
Note:
strMsg cannot be a string constant, e.g. “the cat”, but must be a string variable and so
if you must use a const string then first save it to a temp string variable and then pass it
to the function
//Example
DIM rc,strLength,str$
str$="Your name is "
FUNCTION HndlrUartRx()
TimerStart(0,100,0)
ENDFUNC 1
//Allow enough time for data to reach rx buffer
FUNCTION HndlrTmr0()
strLength=UartReadn(str$,11)
PRINT "\n";str$
ENDFUNC 0
ONEVENT EVTMR0
ONEVENT EVUARTRX
CALL HndlrTmr0
CALL HndlrUartRx
PRINT "\nWhat is your name?\n"
WAITEVENT
Embedded Wireless Solutions Support Center:
http://ews-support.lairdtech.com
www.lairdtech.com/bluetooth
144
Laird Technologies
Americas: +1-800-492-2320
Europe: +44-1628-858-940
Hong Kong: +852-2268-6567 x026