CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Parsing a never ending RS-232 input string.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
whmeade10



Joined: 27 Jan 2004
Posts: 12

View user's profile Send private message

Parsing a never ending RS-232 input string.
PostPosted: Fri Jan 20, 2006 1:24 pm     Reply with quote

I have a RS-232 string of data that I need to receive and then place it on a 4 x 20 LCD. The string of data is constantly being transmitted over and over.

Example:

Code:

0DPC07     
1TOTAL           3.15DC                       
2RATE             0.009C                       
3S-   0 T1-      3.159C                       
4    -3.25 MENU      BE         
0DPC07     
1TOTAL           3.15DC                       
2RATE            0.009C                       
3S-   0 T1-      3.159C                       
4  -3.25 MENU      BE         
0DPC07     
1TOTAL           3.15DC                       
2RATE            0.009C                       
3S-   0 T1-      3.159C                       
4    -3.25 MENU      BE         


What I need to take out of this and display is:

Code:

TOTAL             3.15
RATE             0.009
S-   0 T1-       3.159
    -3.25 MENU


I imagine that I would look for a constant that is always transmitted like TOTAL, RATE or MENU then start putting the string in a buffer and break it into 4 different strings to be sent to the LCD.

I have been searching the forum for about an hour or so and haven't found how to search for a word in a string.

If I use INT_rda, will it alwasy stay active since the string is constantly being sent? I will only need to update the LCD about every second or so. So I guess I would receive a string, turn off the interrupt, process the string, send it to the LCD, and then turn it back on again.

If any of this makes sense to you, please point me in the right direction.

I actually have this working in PBP (basic, very limited) but we have switched to PICC and I have to learn and convert.

Many thanks in advance.....
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 20, 2006 3:56 pm     Reply with quote

There are lots of ways to do this. This has been talk Ad nauseam.
http://en.wikipedia.org/wiki/Argumentum_ad_nauseam
I would look for 'MENU' over and over again.
Code:
xxxxxxMENUxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxMENUxxxxx
          ___________________________________________
         

pull out that data and sub_process on that string.
Normally the RX_BUF will have a IN and a OUT pointer.
IN is where the next RX byte is stored. OUT is moved when you have processed the data.
make a RX_BUF[256] and a int8 IN,OUT;
1. at the start look for menu. point OUT there. this is a starting point for the state machine.
2.now from that OUT position look for another MENU.
3.copy data from OUT position up to (and including) the MENU position
4.change OUT to that spot.
goto 2.

With the string you copied you then are looking for all other items.
btw CCS has all/most of the standard string functions. ie strcmp
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group