PDA

View Full Version : SerIn & wait



Lotondo
- 24th May 2006, 11:32
Hi guys,
i was wondering if it's possible to use 'and' and 'or' into SerIn instruction.
For example:
Serin2 Porta.1,188,3000,[wait("ABC") and ("123"), ................
I tried some possible ways but without success.
Thanks
Bye

mat janssen
- 24th May 2006, 12:00
Serin2 normaly takes 1 byte as an input. If you want to take more than one byte you will have to say how much binairy or decimal or hexadecimal bytes you want to recieve at once. Look into you PBP book 5.72 (my page 132)

mister_e
- 24th May 2006, 13:42
could be a situation to use STR ArraVar\XCharacter\EndedByXYZ

using STR ArrayVar\7\13

if you send ABC\13 it will consider only the ABC

If you Send ABC123\13 it will consider all character.

Now read ArrayVar[3] to know wich string combination you received.

Now if there's a way hidden way to know how much character you received by one of the internal ressource of PBP (macro or PBP variable)it can add some flexibility. Maybe Darrel or somebody else may dig in it.

Lotondo
- 24th May 2006, 14:14
Thanks for your replies.
I believe i was not clear enough with my explanation.
I receive a serial string : wers-ABC,897-00587
now this string does not contain ABC and 123 so in this
case serin2 command has nothing to do, it loops waiting for another
string.
If I receive a serial string: qwts-ABC,123-98756 now serin2 has
to do something.
Serin2 has to wait not only the characters ABC but ABC and 123.
This is a classic serin line: SerIn2 pinin,396 [wait ("ABC"),testbyte]
but in my code line serin2 should wait not only for ABC but ABC and 123.
Hope to be enough clear.
Thanks and bye

mister_e
- 24th May 2006, 14:56
this on work with HSERIN, should also work with SERIN2


DEFINE LOADER_USED 1
DEFINE OSC 20
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 129 ' 9600 Bauds
DEFINE HSER_CLROERR 1

discard var byte
ArrayVar var byte[10]

start:
hserin 5000,NotReceivedYet,[wait("abc"),discard,wait("123"),str arrayvar\10\13]
hserout ["Discard:",discard,13,10,_
"Received:",str arrayvar,13,10]
goto start

NotReceivedYet:
hserout [13,10,"no!",13,10]
goto start