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

RS232 Rx Frame Question

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



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

RS232 Rx Frame Question
PostPosted: Mon Aug 09, 2010 12:27 pm     Reply with quote

Hi,

I need to get a variable length frame from RS232, I use int_rda and I need to know which is the best way for detect that the end of frame.

The frame have this format |ETX|CMD|LEN|DATA|CRC|ETX|

I wait for your comments,

Thanks & Regards
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 12:45 pm     Reply with quote

Where does this protocol come from ? What device ?

Are you certain that it begins with "ETX" ? It would be a lot easier if it
began with "STX" (Start of Text). It would be more logical, too.
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 12:50 pm     Reply with quote

PCM programmer wrote:
Where does this protocol come from ? What device ?

Are you certain that it begins with "ETX" ? It would be a lot easier if it
began with "STX" (Start of Text). It would be more logical, too.


This frame come in from PC, I have a error, sorry, the frame start with STX.

Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 4:41 pm     Reply with quote

If you want to find examples, use Google. Use this search string to search for your protocol with a CCS int_rda routine:
Quote:

STX ETX #int_rda

Example of result:
http://www.goase.com/quickset/PTCR%20Comm%20Code%20Snippets.doc
In other words, I don't want to write the code for you. Search the net.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 6:40 pm     Reply with quote

Quote:

I need to know which is the best way for detect that the end of frame

By the way, ETX is used specifically to detect an end of frame in strings of variable length.

regards.
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PostPosted: Mon Aug 09, 2010 7:56 pm     Reply with quote

Humberto wrote:
Quote:

I need to know which is the best way for detect that the end of frame

By the way, ETX is used specifically to detect an end of frame in strings of variable length.

regards.


PCM Programmer

Thank for your time!, I dont want that you write the code for me, my question is for know how to implement this other people.

Humberto, you are wrong, in the binary frame the char 0x03 can exist into the frame, is not possible detect the end of frame seeking the char 0x03.

thanks,
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Aug 10, 2010 10:38 am     Reply with quote

You defined you protocol in this way
Quote:

The frame have this format |ETX|CMD|LEN|DATA|CRC|ETX|

FYI, LEN=Packet length
Hence, you know in advance in what position you are going to expect ETX.
If it's a continous stream you might have to get more tricky based upon known commands sequences and lengths etc.
There is not any conflict handling data streams in this way, I have made hundreds of systems and they are still
running since years.

Humberto
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Tue Aug 10, 2010 3:06 pm     Reply with quote

How about this? Both you and Humberto are correct Smile

Quote:
Humberto, you are wrong, in the binary frame the char 0x03 can exist into the frame, is not possible detect the end of frame seeking the char 0x03.

If you are referring to binary numbers, then you are correct; 0x03 could be one of the sequence of numbers on the frame.

Quote:
ETX is used specifically to detect an end of frame in strings of variable length

For strings (which is what Humberto is referring to) this is true. A normal character will not be 0x03, lookup the ascii chart and noticed 0x03 is defined as ETX.

The frame structure you are looking at really only makes sense for strings (or characters), not for straight binary numbers. Not saying you could not use it for such, but to use it for binary numbers then STX and ETX would not have much meaning. It really all depends on how you define the frames.

In either case, you would probably use buffering (as previously suggested).
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