5: BASIC Stamp Command Reference – SERIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 281
available for the SERIN command. If not using a BS1, see the “Additional
Conversion Formatters” section below for more information.
The SERIN command can also be configured to wait for specified data
before it retrieves any additional input. For example, suppose a device
that is attached to the BASIC Stamp is known to send many different
sequences of data, but the only data you desire happens to appear right
after the unique characters, “XYZ”. The BS1 has optional Qualifier
arguments for this purpose. On the BS2, BS2e, BS2sx and BS2p a special
formatter called WAIT can be used for this.
Symbol SerData = B0
SERIN 1, N2400, ("XYZ"), #SerData
--or--
SerData VAR BYTE
SERIN 1, 16780, [WAIT("XYZ"), DEC SerData]
The above code waits for the characters “X”, “Y” and “Z” to be received,
in that order, and then it looks for a decimal number to follow. If the
device in this example were to send the characters “XYZ100” followed by
a carriage return or some other non-decimal numeric character, the
SerData variable would end up with the number 100 after the SERIN line
finishes. If the device sent some data other than “XYZ” followed by a
number, the BASIC Stamp would continue to wait at the SERIN
command.
The BS1 will accept an unlimited number of Qualifiers. The BS2, BS2e,
BS2sx and BS2p will only accept up to six bytes (characters) in the WAIT
formatter.
Keep in mind that when we type “XYZ” into the SERIN command, the
BASIC Stamp actually uses the ASCII codes for each of those characters for
its tasks. We could also have typed: 88, 89, 90 in place of “XYZ” and the
code would run the same way since 88 is the ASCII code for the “X”
character, 89 is the ASCII code for the “Y” character, and so on. Also note,
serial communication with the BASIC Stamp is case sensitive. If the device
mentioned above sent, “xYZ” or “xyZ”, or some other combination of
lower and upper-case characters, the BASIC Stamp would have ignored it
because we told it to look for “XYZ” (all capital letters).
U
SING
SERIN
TO WAIT FOR SPECIFIC
DATA BEFORE PROCESSING
.
U
SING
ASCII
CODES AND CASE
SENSITIVITY
.
1
2
e
2
sx
2
p
2
T
HIS IS WRITTEN WITH THE
BS2'
S
B
AUD
M
ODE VALUE
. B
E SURE TO
ADJUST THE VALUE FOR YOUR
BASIC
S
TAMP
.
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...