Prop not processing serial data correctly
Gunstar1
Posts: 18
I am trying to move some things from·a BS2 to the prop and have run into a problem regarding receiving serial.
On the BS2 I have a simple bit of code that grabs the text that is sent and displays it in debug.· Pretty much borrowed from the manual itself.
On the debug screen for the BS2 I get the text string I am expecting... "ELM322 v2.0"
Now I go into the prop·to·try to get get a similar string and I am having zero luck.· First since it is not inverted, it seems the only serial·object I can use is simple serial (the chip·uses·9600Baud· 8 N 1).· So I get that up and running with a simple code that init's the serial and calls rx.· I the tell debug to dec whatever is in Rx.
I am expecting to see the numbers that correspond to the·ASCII string that the chip sends, but instead I get "691733820114615313033262"
The 69 is E,·and the 62 appears to be the > character that·signals the end of the serial transmission (sent from the chip), but what in the world is all that stuff in the middle?· What is it I am doing wrong?
I can't continue programing until I know I can get the text that the chip sends when it first starts up... which should be:
·If I uncomment out that carriage return I get this in the debug screen.
69
213
38
50
178
147
152
41
72
223
I would have thought the 2 would have been identical except one would be easier to read, but·other than the first·number 69, which is the E, the rest does not match.
I am totally lost now so I would welcome any ideas.
Thanks.
On the BS2 I have a simple bit of code that grabs the text that is sent and displays it in debug.· Pretty much borrowed from the manual itself.
Baud CON T9600 serStr VAR Byte(13) Main: serStr(12) = 0 SERIN 1, BAUD, [noparse][[/noparse]STR serStr\12] DEBUG STR serStr
On the debug screen for the BS2 I get the text string I am expecting... "ELM322 v2.0"
Now I go into the prop·to·try to get get a similar string and I am having zero luck.· First since it is not inverted, it seems the only serial·object I can use is simple serial (the chip·uses·9600Baud· 8 N 1).· So I get that up and running with a simple code that init's the serial and calls rx.· I the tell debug to dec whatever is in Rx.
Debug.start(31, 30, 0, 57600) ELM322.init(ELM_RX_PIN, ELM_TX_PIN, 9600) waitcnt(clkfreq + cnt) repeat Rx := ELM322.Rx Debug.dec(Rx) ' Debug.str(string(13))
I am expecting to see the numbers that correspond to the·ASCII string that the chip sends, but instead I get "691733820114615313033262"
The 69 is E,·and the 62 appears to be the > character that·signals the end of the serial transmission (sent from the chip), but what in the world is all that stuff in the middle?· What is it I am doing wrong?
I can't continue programing until I know I can get the text that the chip sends when it first starts up... which should be:
ELM322 v2.0 >
·If I uncomment out that carriage return I get this in the debug screen.
69
213
38
50
178
147
152
41
72
223
I would have thought the 2 would have been identical except one would be easier to read, but·other than the first·number 69, which is the E, the rest does not match.
I am totally lost now so I would welcome any ideas.
Thanks.
Comments
or
debug.str expects an address of a zero-terminated string in memory somewhere just as it does in the BS2.
P.S. scrub that reply....I see you are expecting the characters back from the "ELM" but bear in mind that the simple serial code can miss bits. Use the FullDuplexSerial and set the mode bits accordingly. I don't understand why you say you can only use SimpleSerial though. Another tip, replace debug.dec with debug.hex and pad it with a space for readbility.
Also, since SimpleSerial is used for both receiving from the ELM and transmitting to debug it will miss any receive data from the ELM while it is busy sending data to debug as you are using the same (main) cog. The cogs are used as programmable peripherals so one cog can be dedicated as a UART, or even 4 UARTS (check the OBEX).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Post Edited (Peter Jakacki) : 1/19/2010 8:25:59 AM GMT
As for why I don't think full duplex will work for the elm... I don't know what to set it to for non inverted receive.
None of those mode options seem to apply.· I tried 3 but it did not show anything on the debug screen so I figured it was not what I wanted.
I have found for debug to be completely transparent and have no effect on your intended code, it's got to be run in a separate cog.
Rereading the post, Peter pretty much mentions what I just wrote....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Bad spellers of the world untie!
Post Edited (mojorizing) : 1/20/2010 6:22:01 PM GMT
This means: if you set bit 0 then rx signal is inverted, if you clear bit 0 then rx is not inverted. Same for the other bits.
So for normal Full Duplex, non inverted, the mode is 0 (none bit set).
If you set the Terminal to 9600 Baud, you can use the same FullDuplexSerial for receiving the ELM and to output the bytes to the Terminal.
Andy
A little bit more progress. Now instead of seeing the message I am supposed to get, I am seeing the full message that it sends if it did not understand the command·it was·sent... only I didn't send any command at all.
This is a pain to get a·serial device working.
I was not paying attention to·full duplex mode·saying "bit".
Just in case someone else has the same problem I did...
the "mode" wants a number that corresponds to the binary equivilent.·
if you want to "invert rx" and "ignore tx echo on rx" you want a binary number of 1001
1001 = 9
so you put 9 in the start call for mode
if you want to just invert tx then you want a binary number of 0010
0010 = 2