PDA

View Full Version : serial formatting



barkerben
- 6th January 2005, 14:03
Hi...


As I understand it, I can use the serial formatting tags as follows:

For instance, If I send the text string 123, consisting of 3 bytes coding for the characters 1,2,and 3, but specify

HSERIN[DEC3 my_variable]

Then I will receive those 3 bytes and they will be interpreted, then stored in the variable my_variable


I have 2 questions about this:

How much overhead is involved - it would seem to require an ASCII lookup on the pic to convert from character codes to actual values, and more jiggery pokery to combine them all into one number ...


Also, what hapens if one of the characters sent is not a number - if, for instance, instead of sending 123 i send the string "abc", how will the code react ...?


Cheers,


Ben

barkerben
- 6th January 2005, 14:16
...My other question is whether I can backfill with zeroes. For instance, if I specify DEC3, but in fact only want to sent 56, could I send the string 056 ...

barkerben
- 6th January 2005, 19:29
Ok - tests have shown that padding zeroes are ignored as hoped for

For the moment I'm passing data as a string, but really want to pass raw bytes. If I have a word sized variable, then to fill it I need to receive 2 bytes. There seems to be no standard formatting command to achieve this. Is there some useful word.highbyte type syntax, or do I need to use the shift operators ....

barkerben
- 6th January 2005, 20:16
Ah - I've found the section in the manual:

the answer is to use myvariable.byte1 and myvariable.byte2

(or highbyte / lowbyte)

mister_e
- 7th January 2005, 17:54
As many says here, the best way to get answer to assumption is the real-life testing. then if you don't have the expected result after many different approach, looking in the FAQ, searching the forum thread, post question here with your whole code + PIC and everything we need to reproduce the problem. BUT i'm glad to see everything looks to work !!! Good luck!

we still be there :)