PDA

View Full Version : Serin Question



eoasap
- 11th February 2006, 02:25
can i do this? no matter what i try i always get the error >> Expected ']'

SERIN2 GPS_TXA, GBAUD, [WAIT("$GPRMC"),skip 1, str HOUR\2, str MINUTE\2, str SEC\2, skip 1, STAT,skip 1, str LATDEG\2,str LATM\2,skip 1, str LATS\2, skip 1, LATHEAD, skip 1, str LONGD\3, str LONGM\2, skip 1, str LONGS\2, skip 1, LONGH, skip 1, str SP_Knots\5,skip 1, str Heading\5,skip 1, str DATED\2,skip 1, str DATEM\2, Month\2, skip 1, str DATEY\2]

the variables i'm reading to are all defined as bytes (or an ay of bytes depending)

eoasap
- 11th February 2006, 02:58
as a temporary fix i can do this, but is it possible to lose data during the command execution time? (baud rate is 4800, xtal is 15Mhz)

SERIN2 GPS_TXA, GBAUD, [WAIT("$GPRMC"),skip 1, str HOUR\2, str MINUTE\2, str SEC\2]
SERIN2 GPS_TXA, GBAUD, [skip 5, STAT,skip 1, str LATDEG\2,str LATM\2,skip 1, str LATS\4]
SERIN2 GPS_TXA, GBAUD, [skip 1, LATHEAD, skip 1,str LONGD\3, str LONGM\2, skip 1]
SERIN2 GPS_TXA, GBAUD, [str LONGS\4, skip 1, LONGH, skip 1, str SP_Knots\5, skip 1]
SERIN2 GPS_TXA, GBAUD, [str Heading\5,skip 1, str DATED\2,skip 1, str DATEM\2]
SERIN2 GPS_TXA, GBAUD, [skip 1, str DATEY\2]

keithdoxey
- 11th February 2006, 07:28
Quoting from the PBP manual....

4.14. Line-extension Character

The maximum number of characters that may appear on one PBP line is 256. Longer statements may be extended to the next line using the line-extension character (_) at the end of each line to be continued.

Branch B0,[label0,label1,label2,_
label3,label4]


Your example is 352 characters so it never sees the closing bracket.

I dont think there is any difference in execution speed between a statement with say 5 variable and 5 statements with a single variable.

eg.

lcdout "hello"

lcdout "h"
lcdout "e"
lcdout "l"
lcdout "l"
lcdout "o"

generates the following extract from the assembler

LCDOUT?C 068h h
LCDOUT?C 065h e
LCDOUT?C 06Ch l
LCDOUT?C 06Ch l
LCDOUT?C 06Fh o
LCDOUT?C 068h h
LCDOUT?C 065h e
LCDOUT?C 06Ch l
LCDOUT?C 06Ch l
LCDOUT?C 06Fh o

Obviously in the above example it is a lot easier to enter "hello" than 5 separate lines. Using either the single statement or the 5 statements the code compiled to 123 bytes. Using both it was 138 bytes.

Using your code, I personally find the second "temporary fix" verison to be far more readable and it would be even easier with just "one chunk of data" per statement line.

That way you would also be able to add comments to each line to say what you are receiving and skipping so that when you come back to your code in a few months time you can instantly tell what you were thinking when you wrote it :)

eoasap
- 11th February 2006, 13:16
Keith, thanks for such a quick answer on my question. i actually prefer the second (working) method, but i was just afraid of dropping bytes. great to know that's not the case though!