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

ring buffer
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 9:41 am     Reply with quote

Ttelmah wrote:
Questions:

How does the code 'know' where the data block ends?.
What has to happen for the different commands?.

There is a big problem with the CRC calculation. As written, it can generate an ETX character. This could be disastrous.


1.How does the code 'know' where the data block ends?.
if(rxBuff[index-1]==etxPC)

2.What has to happen for the different commands?.
This is not complete program!

3.There is a big problem with the CRC calculation. As written, it can generate an ETX character.
With This example crc calc is not perform yet. But what is the problem ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19242

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 10:56 am     Reply with quote

Imagine you have 208 in the sum so far, and then a '1' is sent (49). This will add to 257. This then adds another 1 to the sum (258), for the carry, and takes the low eight bits, and gets 2. ETX. So your CRC sends as ETX. Result everything starts to go wrong....
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Tue Aug 04, 2015 1:47 pm     Reply with quote

Ttelmah wrote:
Imagine you have 208 in the sum so far, and then a '1' is sent (49). This will add to 257. This then adds another 1 to the sum (258), for the carry, and takes the low eight bits, and gets 2. ETX. So your CRC sends as ETX. Result everything starts to go wrong....


ETX=0xE3;

Code:

    if (temp<224)
       checksum=temp;
    else
       checksum=temp-224;
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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