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

CRC and Parity error indication

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



Joined: 05 Jun 2013
Posts: 14

View user's profile Send private message

CRC and Parity error indication
PostPosted: Sat Aug 17, 2013 6:49 am     Reply with quote

Hi,
I am working on modbus 485 (RTU mode). I want to monitor the CRC and Parity Errors, how many times these error comes.
Is there any function in modbus driver file though which i come to know and then display these error counts?

thanks
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

Re: CRC and Parity error indication
PostPosted: Mon Aug 19, 2013 5:15 am     Reply with quote

micro_man wrote:

I am working on modbus 485 (RTU mode). I want to monitor the CRC and Parity Errors, how many times these error comes.
Is there any function in modbus driver file though which i come to know and then display these error counts?


modbus.c works without parity and does no parity checks. Technically it doesn't meet the requirements of the Modbus spec, http://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf . The spec requires 11 bit character frames, one start bit, eight data bits and two stop bits if parity is not used, or one parity and one stop bit if it is. modbus.c uses the more common 10 bit frame of one start, eight data, no parity bit and one stop bit, this though appears to be common practice. Its compatible with "no parity, two stop bits" provided the inter-character gap is at least one bit period. However, modbus.c will NOT work, without modifications, with modbus implementations that used parity. Parity is rare and essentially pointless with a message based CRC such as modbus uses. The "8-N-1" format is now so common and near-universal that its almost perverse not to support it. Modbus RTU should be "8-N-2" or "8-E-1" or even "8-O-1" as either parity is acceptable.

As for the CRC, my inspection of the modbus.c code shows it doesn't seem to explicitly check the CRC in the message decoding state machine as we might expect. In RTU mode, the end of a message frame is determined not by the structure of the message as would be the case with more recent protocols, but rather by the inter-message timeout of at least 3.5 character periods. So the place it detects CRC error is in modbus_timeout_now() which declares a received message as valid, or not, and set up for the next message. As it stands if there's a CRC error in a received message, then the message is simply ignored and no record of the error is made.

By the way, this is a classic situation when being able to see the pre-processed code, with all macros and conditionals resolved, would be an advantage. Instead I had to make use of the collapsing of conditionals feature of the CCS IDE's editor to hide modbus-ascii related code.
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