OpenServo.com Forum Index OpenServo.com
Discussion of the OpenServo project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TWI checksum

 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
MosaicDave



Joined: 20 Jul 2010
Posts: 18
Location: Pennsylvania, USA

PostPosted: Wed Sep 01, 2010 3:50 pm    Post subject: TWI checksum Reply with quote

So I've come upon the #DEFINE for TWI_CHECKED_ENABLED in config.h (enabled by default in the current OSV3 release code) but can't find any clear commentary or discussion about this parameter. I can see where it's being used in twi.h / twi.c, so it's clear enough basically what it's doing. But I find I'm having a few questions; if someone can clear this up for me a bit, that would be great:

-- Is this I2C checksum protocol, an implementation of something that is part of any standard? Or is this really just an OpenServo specific thing?

-- With TWI_CHECKED_ENABLED enabled, as it is in the default released code, are there times when you must send requests with a checksum? In other words, are there conditions under which ordinary, common I2C read/write/command requests will be rejected by the servo, because I didn't create a checksum?

-- Additionally, if anyone can provide (or point me to) a brief, high-level explanation as to how this checking is supposed to work in practice, that would be great. I can follow through the code and see what's going on, but the exact flow of things under different conditions and cases is a little hard to follow.

Thanks much--

--Dave
_________________
http://www.mosaicengineering.com/
Back to top
View user's profile Send private message Visit poster's website
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Sat Sep 11, 2010 12:06 pm    Post subject: Reply with quote

Hi Dave,

[quote]- Is this I2C checksum protocol, an implementation of something that is part of any standard? Or is this really just an OpenServo specific thing?[quote]

I2C makes no provision for checksums, in fact I2C makes no real provisions about anything! To this end it is OpenServo specific

Quote:
-- With TWI_CHECKED_ENABLED enabled, as it is in the default released code, are there times when you must send requests with a checksum? In other words, are there conditions under which ordinary, common I2C read/write/command requests will be rejected by the servo, because I didn't create a checksum?


No, if you don't send the checksum byte, the OpenServo will never reject the request.

Quote:
-- Additionally, if anyone can provide (or point me to) a brief, high-level explanation as to how this checking is supposed to work in practice, that would be great. I can follow through the code and see what's going on, but the exact flow of things under different conditions and cases is a little hard to follow.


#if TWI_CHECKED_ENABLED
// For checked writing send in the format of [i2c addr][0x81][data length][data address][data]...[data] [checksum value]
// For a checked read use [i2c_addr][0x81][data length][data address] SLA+R [data][data]...[checksum value]
// Checksum is defined as data length + data_address + data[n]
// To verify a write was successful, write the header above, and see if it nacks. nack is failure of checksum.

In short, if you tell OpenServo you are wrting 2 bytes, but write 3, then it knows the last byte is the checksum. Only if you write more bytes than it expects do you get the nack on bad CRC.


Cheers
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
MosaicDave



Joined: 20 Jul 2010
Posts: 18
Location: Pennsylvania, USA

PostPosted: Sat Sep 11, 2010 1:57 pm    Post subject: Reply with quote

Great, Barry - thanks much.
_________________
http://www.mosaicengineering.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software All times are GMT
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