xnihilo
- 25th November 2009, 10:25
Hello,
Could someone help me out with serin2?
serin2 portA.0,188,3000,toto,[WAIT("$GPRMC")]
works
serin2 portA.0,188,3000,toto,[WAIT("$GPRMC"), STR mystring\10]
does not work (stays stuck in SERIN3
Why is that? I though that it would wait for a string then collect next 10 bytes and store them in the mystring byte array but it doesn't... Why?
xnihilo
- 25th November 2009, 11:28
THIS does NOT work:
gps:
LCDOUT $fe,1,"in GPS"
LCDOUT $fe,$c0,"Serin start"
PAUSE 2000
'SerIn2 PORTA.0,188,3000,toto,[Wait("$GPRMC,"),DEC2 b1,DEC2 b2] 'works
SerIn2 PORTA.0,188,3000,toto,[wait("$GPRMC"),wait(","),DEC2 hh,DEC2 mm,wait(","),fix,wait(","),DEC2 latdeg,DEC2 latmin,wait(","),NS,wait(","),DEC3 londeg,DEC2 lonmin,wait(","),EO,wait(","),knots,wait("."),DEC2 knotsten,wait(","),DEC3 course,wait(","),DEC2 j,DEC2 m,DEC2 a] 'works
LCDOUT $fe,1,"found"
LCDOUT $fe,$c0,"="
PAUSE 2000
IF fix="V" Then display
goto gps
toto:
LCDOUT $fe,1,"timeout"
PAUSE 2000
GOTO gps
display:
LCDOUT $fe,1,"Data is:"
PAUSE 2000
goto gps
While THIS works:
gps:
LCDOUT $fe,1,"in GPS"
LCDOUT $fe,$c0,"Serin start"
PAUSE 2000
'SerIn2 PORTA.0,188,3000,toto,[Wait("$GPRMC,"),DEC2 b1,DEC2 b2] 'works
SerIn2 PORTA.0,188,3000,toto,[wait("$GPRMC"),wait(","),DEC2 hh,DEC2 mm,wait(","),fix,wait(","),DEC2 latdeg,DEC2 latmin,wait(","),NS,wait(","),DEC3 londeg,DEC2 lonmin,wait(","),EO,wait(","),knots,wait("."),DEC2 knotsten,wait(","),DEC3 course,wait(","),DEC2 j,DEC2 m,DEC2 a] 'works
LCDOUT $fe,1,"found"
LCDOUT $fe,$c0,"="
PAUSE 2000
goto gps
toto:
LCDOUT $fe,1,"timeout"
PAUSE 2000
GOTO gps
WHY?
KaanInal
- 17th December 2009, 16:55
Hi xnihilo,
I think the problem is about STR, i mean PBP doesn't work well (not a bit) with strings.
But, i have the same problem, SERIN2 freezes when i add a timeout and label of delay. This code doesn't work:
'**
'
'Purpose: How many delays do i have?
'
'**
myRX VAR PORTB.0
myVar VAR BYTE
data VAR BYTE
CALL OnScreen
loop:
SERIN2 myRX,396,100,delay,[wait ("N"),data]
GOTO loop
delay:
myVar=myVar+1
CALL OnScreen
RETURN
OnScreen:
lcdout $fe,1
lcdout #MyVar
RETURN
the code doesn't go to delay label.
mackrackit
- 17th December 2009, 21:38
I think the problem is about STR, i mean PBP doesn't work well (not a bit) with strings.
But, i have the same problem, SERIN2 freezes when i add a timeout and label of delay. This code doesn't work:
Hmmm. Put the blame on the compiler when your code does not work?
Maybe you need to look at the CALL section in the manual.
And that RETURN right after that might not be helping either.
KaanInal
- 18th December 2009, 11:17
Sorry for the misunderstanding :) it was not a blame, i love this compiler. I didn't find any string functions on my sources, if you knew some please tell me so i can change my sources with correct ones. It was an opinion.
It was a part of my code but i don't understand what is wrong with the call? Should i use gosub? What do you suggest ?
Also,
there is an answer on this page: http://www.picbasic.co.uk/forum/showthread.php?t=1944&highlight=idle
xnihilo, is that solves your problem too?
mackrackit
- 18th December 2009, 14:13
No problems :D
The PIC it's self is not really a string type setup, but PBP gives it a good shot by treating strings as an array. The STR modifier is for that. Yes, more string handling might be nice, or a different way of handling them... But we are so limited on memory the way it is with most PICs that it may be a shot in the foot.
CALL -- that is for "CALLING" an ASM function.
The TIME OUT/GOTO label is just that. a GOTO.
So wherever you send things after a serial time out do not use a RETURN.
SERIN2 myRX,396,100,delay,[wait ("N"),data]
GOTO loop
delay:
myVar=myVar+1
CALL OnScreen
RETURN
In the above case replace the RETURN with GOTO LOOP.
Looks like that is what you want....
KaanInal
- 18th December 2009, 23:42
I got it;) .
Thank you by the way, that explains the "CALL and RETURN overflow" problems on my simulations :rolleyes:.
mackrackit
- 18th December 2009, 23:50
Glad to bof soivice ;)
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.