[RFC] Driver for Arduino-as-I2C-adapter

Bernhard Kraft kraftb at think-open.at
Tue May 19 15:34:36 UTC 2015


Hi Alex,

On 2015-05-19 14:20, Alex Beregszaszi wrote:

> So I sat down and wrote an Arduino implementation of that specification
> just to see what the performance would be. You can find it at:
> https://github.com/axic/dtiic

I already took a look at the robot-electronics.co.uk link yesterday. I 
wasn't very fond of the serial protocol. It seems they implemented some 
kind of timeout which determines the start and end of a message.

Quote:
http://www.robot-electronics.co.uk/htm/usb_iss_i2c_tech.htm
"A gap will result in the USB-ISS re-starting its internal command 
synchronization loop and ignoring the message."


Hence my implementation uses <ESC> as ERROR character. Whenever one of 
the devices PC/Arduino looses sync or notices another problem it sends 
an <ESC> on to the serial line (0x1B). The <ESC> character is even valid 
through data transfers. This requires a literal <ESC> character to get 
escaped somehow. For this reason I introduced a quoting character 
(indeed it is an escape character - maybe I should use another character 
than <ESC> for signaling an error). The quoting character (currently 
'\') can quote itself and the <ESC> character. Every other combination 
of '\' and another character is invalid and causes the other end to send 
<ESC>
(error).

I don't know if this protocol is clever but it can get implemented using 
a layered approach and synchronization can get achieved without the need 
of other lines. Using the escaped mechanism also software flow control 
like XON/XOFF could get implemented:
http://en.wikipedia.org/wiki/Software_flow_control
(I didn't knew Xon was a Star Trek character :)

Here a link to my current Arduino sketch:
https://gist.github.com/kraftb/8c0bbcc35a9778608d74

I think to create a nice and useful sketch the communication would have 
to get a layer for supporting different client side (Arduino) features 
(I2C, SPI, GPIO).



Is it a problem that we discuss this issue here? I see mostly patches 
going around. If someone feels annoyed please post and we move to some 
other list.


greetings,
Bernhard
-- 
Wer nicht gelegentlich auch einmal kausalwidrige Dinge zu denken vermag,
wird seine Wissenschaft nie um eine neue Idee bereichern können.
Max Planck (1858-1947)


More information about the devel mailing list