I am stumped as to what to do. I am trying to read in a message (only 10 bytes MAX) in hex, and then do something with it (the 3rd byte has the length of the data, the 4th-? bytes have the data, etc). I am using the ICC430 compiler. I've tried to use strcmp() to compare the packets, since I know what they will look like, with no success. I have created a buffer, but don't know how to start parsing it. I have also tried case statements, but don't think I did them correctly. What is the best way to do this? I'm familier with receiving just 1 byte and testing it, but not multiple. Thanks!
UART RX Question
Started by ●April 22, 2006
Reply by ●April 25, 20062006-04-25
Hi, i don't know how you are receiving your seril data, i often use rx interrupt to do that so if you are using a protocol like SOH Address STX Data0... Data n EOT you could use a switch instruction and a data received counter in order to recognize wich byte are arriving, something like this switch(Rx_counter) { case 0: if(Rxbuf0==SOH) Rx_counter=1; break; case 1: if(Rxbuf0=dress) Rx_counter=2; break; case 2: if(Rxbuf0==STX) { Rx_counter=3; Data_byte=0; } break; case 3: Buffer[Data_byte]=RXBUF0; if(++Data_byte==BUFFER_END) Rx_counter=4; break; case 4: if(Rxbuf0==EOT) Rx_counter=0; break; } or an equivalent assembler code, this is a simple way to recover serial info, of course you can count bytes and put them in a buffer first and then decode. probably you need a time out timer to reinitialize the counter when you lost the serial link hope this give you some idea Alexander --- In msp430@msp4..., "santabarbara350z" <santabarbara350z@...> wrote: > > I am stumped as to what to do. I am trying to read in a message (only > 10 bytes MAX) in hex, and then do something with it (the 3rd byte has > the length of the data, the 4th-? bytes have the data, etc). I am > using the ICC430 compiler. > > I've tried to use strcmp() to compare the packets, since I know what > they will look like, with no success. I have created a buffer, but > don't know how to start parsing it. I have also tried case > statements, but don't think I did them correctly. > > What is the best way to do this? I'm familier with receiving just 1 > byte and testing it, but not multiple. Thanks! >