serin help
Archiver
Posts: 46,084
In a message dated 6/20/02 16:10:58 Eastern Daylight Time,
manwithapipe@y... writes:
> SERIN ser_pin, ser_baud, 2000, MAIN, [noparse][[/noparse]DEC ser_input, DEC motor_steps]
>
>
>
You might try
serin 0, baud, 2000, [noparse][[/noparse]str serstring\2]
serstring(0) would be one byte of data, serstring(1) would be the other byte
of data.
Serstring has to be declared as
serstring var byte(2)
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
manwithapipe@y... writes:
> SERIN ser_pin, ser_baud, 2000, MAIN, [noparse][[/noparse]DEC ser_input, DEC motor_steps]
>
>
>
You might try
serin 0, baud, 2000, [noparse][[/noparse]str serstring\2]
serstring(0) would be one byte of data, serstring(1) would be the other byte
of data.
Serstring has to be declared as
serstring var byte(2)
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
identified. Serstr\6 would let you receive 6 bytes of data. .
if you
serout 0, n9600, [noparse][[/noparse]12,14]
the serin STR serstring\2 would receive both bytes, serstring(1) would =12,
serstring(0) would =14.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
manwithapipe@y... writes:
> I need the data in integer form within the program, wouldn't that
> leave me with strings? Would there be a way of just grabbing two
> integers separated and followed by a carriage return?
>
Not with a serin command. With serin you can
serin 0, N9600, [noparse][[/noparse]com] one byte
or
serin 0 , N9600, [noparse][[/noparse]dec com] a string of numbers. The serout sending the
numbers must end the string
with a non-
decimal digit.
serin 0, N9600, STR serstring\n] Will receive a string of n bytes. Each byte
can be determined by looking
at serstring(0),
serstring(1), and so on.
Are you serouting from an external sosurce or is everything within the
program. If everything is within the program, you don't need serin, and then
I don't understand your problem.
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
be your data rate. If your data is arriving at 4800 baud or faster,
your Stamp can fall behind when it has to apply formatters (such as
DEC) to the incoming data stream. If you can reduce the baud rate that
may help. Or, it may help to insert additional non-alphanumeric
characters (e.g., multiple CR's) between the ASCII numerics.
You asked for an example. Here's one from a working program that
shows the use of multiple variables and a variety of formatters. The
incoming data in this case plods along at 1200 baud.
...
serin ser_pin,baud,5000,thats_all,[noparse][[/noparse]msg_code,msg_len,SKIP 2,DEC4 date,DEC4
time,SKIP 1,name_len]
serin ser_pin,baud,5000,thats_all,[noparse][[/noparse]STR name\ (name_len MAX 9),SKIP (name_len -
(name_len max 9)),SKIP 1,num_len]
if num_len <> 10 then thats_all
serin ser_pin,baud,5000,thats_all,[noparse][[/noparse]DEC3 areacode,DEC3 prefix,DEC4 lastfour]
thats_all:
...
Regards,
Steve
manwithapipe wrote:
> ...Could someone please give some example as to how I can read in
> multiple variables using one SERIN command?...