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

testing stream of characters @rs23 with minimal ram usage ?

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








testing stream of characters @rs23 with minimal ram usage ?
PostPosted: Wed Jun 02, 2004 4:36 am     Reply with quote

how do you test a series of headers(around 60 bytes) received at rx pin without using no more than 20 bytes of RAM?
jack11
Guest







PostPosted: Wed Jun 02, 2004 4:42 am     Reply with quote

if the baud rate is slow enough. and the code to test is fast enough. you could do it on a byte by byte basis and set some kind of flag to indicate a positive or negative test. If you want to retain the whole header at the completion of a successful test. You might be able to write it into ROM but that is a slow process. Try declating some variables as type 'const' this will free up RAM. only problem with that is 'const' variables can't be changed at runtime.

good luck. there is always a way
Ttelmah
Guest







Re: testing stream of characters @rs23 with minimal ram usag
PostPosted: Wed Jun 02, 2004 6:55 am     Reply with quote

Anonymous wrote:
how do you test a series of headers(around 60 bytes) received at rx pin without using no more than 20 bytes of RAM?

Depends what you want to test. You are going to have to give a lot more information, before a real answer can be given, but (for instance), you can walk a 'state machine', where as each character arrives, the code switches to a state depending on a value, and then checks in this state, the current character, against that allowed at this point in the string. If the right charcter is found, the state is incremented, otherwise it is reset, and the search begins again.
This type of approach, requires a few variables (one saying how far you have got in matching the string, and one saying which of the possible strings has so far matched). Use possible strings stored in a constant text array, with 'markers' for the end of strings, and only about 2 variables are needed. The size of search table, and the variables, will depend on the number of possible strings.

Best Wishes
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Header parsing
PostPosted: Wed Jun 02, 2004 7:03 am     Reply with quote

One question that would need to be answered is:
"How far into the headers do you need to go to be unique?".

I have one application where I do some of the same things you are needing to do on long strings (37 chars or so) but I only have to test 6 chars to determine the unique characteristics.

Are we to assume you have not stored the incoming string in RAM at this point so all these test have to be performed on the fly?
Guest








Re: Header parsing
PostPosted: Wed Jun 02, 2004 8:10 pm     Reply with quote

dyeatman wrote:
One question that would need to be answered is:
"How far into the headers do you need to go to be unique?".


ok six coule be fine


dyeatman wrote:

Are we to assume you have not stored the incoming string in RAM at this point so all these test have to be performed on the fly?


its ok if u have any suggestions, as long as the RAM usage is minimized or lets say optimized
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

String Parsing
PostPosted: Wed Jun 02, 2004 8:26 pm     Reply with quote

Ss TTelmah said earlier, we need to know more info. Give us an example of several of the strings (or at least the part of the string up to where it becomes unique and we can come up with some suggestions.

Psuedocode of one approach:

1. you set a pointer counter to keep track of the postion to be compared
2. set a match flag when the match with the first char occurs and increment the pointer ctr.

3. When you get the next char check the match flag to see if it is set, if so compare for the next char in the string, if nopt reset the match flag and pointer counter to 0.

4. If the counter reaches six you decide on what to do with the string since it has been identified at this point.

5. If you store your match strings in constants as suggested you shouldn't need more than maybe 4-5 RAM variables to accomplish the task.
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