SERIN - BASIC Stamp Command Reference
Page 286
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
SerString VAR BYTE(4) ' Make a 4-byte array.
DEBUG "Enter a 4 character password", CR
SERIN 1, 16468, [STR SerString\4] ' Get the string
DEBUG "Waiting for: ", STR SerString\4, CR
SERIN 1, 16468, [WAITSTR SerString\4] 'Wait for a match
DEBUG "Password accepted!", CR
SERIN’s InputData can be structured as a sophisticated list of actions to
perform on the incoming data. This allows you to process incoming data
in powerful ways. For example, suppose you have a serial stream that
contains “pos: xxxx yyyy” (where xxxx and yyyy are 4-digit numbers) and
you want to capture just the decimal y value. The following code would
do the trick:
YOffset VAR WORD
SERIN 1, 16468, [WAIT ("pos: "), SKIP 4, DEC yOffset]
DEBUG ? yOffset
The items of the InputData list work together to locate the label “pos: ”,
skip over the four-byte x data, then convert and capture the decimal y
data. This sequence assumes that the x data is always four digits long; if its
length varies, the following code would be more appropriate:
YOffset VAR WORD
SERIN 1, 16468, [WAIT ("pos: "), DEC yOffset, DEC yOffset]
DEBUG ? yOffset
The unwanted x data is stored in yOffset then replaced by the desired y
data. This is a sneaky way to filter out a number of any size without using
an extra variable. With a little creativity, you can combine the InputData
modifiers to filter and extract almost any data.
Parity is a simple error-checking feature. When a serial sender is set for
even parity (the mode the BASIC Stamps support) it counts the number of
1s in an outgoing byte and uses the parity bit to make that number even.
For instance, if it is sending the 7-bit value: %0011010, it sets the parity bit
to 1 in order to make an even number of 1s (four).
The receiver also counts the data bits to calculate what the parity bit
should be. If it matches the parity bit received, the serial receiver assumes
that the data was received correctly. Of course, this is not necessarily true,
since two incorrectly received bits could make parity seem correct when
B
UILDING COMPOUND
I
NPUT
D
ATA
STATEMENTS
.
U
SING PARITY AND HANDLING PARITY
ERRORS
.
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
Содержание BASIC Stamp 1
Страница 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...