64
User Manual
Copyright ©2003 A7 Engineering, Inc.
BASIC Stamp Application eb500 Command Error Handling
The BASIC Stamp has a software based UART; meaning it does not buffer incoming serial
data. Therefore, the checking of errors from the issuing of an eb500 command must be
performed immediately after the issuing of the command; otherwise, the data may be lost.
Below is a sample of BASIC Stamp code that issues an eb500 Connect command, waits for
the ACK<CR> response from the eb500, then waits for the error string or the prompt (>) to
be returned from the eb500. It then checks the first bye of the data returned to determine if
an error has occurred. If an error has occurred, the code jumps to the error handler code,
where an error string along with the error number is shown in the debug window of the Basic
Stamp Editor.
'Connect to remote Bluetooth device
SEROUT
1,84,["con
00:0C:84:00:07:D8",CR]
SERIN
0,84,[WAIT(“ACK”,CR)]
‘Either an Err #<CR> or a ">" will be received
SERIN 0,84,[STR bBuffer\6\”>”]
IF bBuffer(0) = “E” THEN ErrorCode
… Progam Logic …
ErrorCode:
bErrorCode
=
bBuffer(4)
DEBUG “Error: “,STR bErrorCode,CR
END