I2C Serial Port in Squeak
ned at squeakland.org
Fri Oct 29 20:53:01 UTC 2004
On Wednesday 27 October 2004 8:45 am, Jon Hylands wrote:
> I have a question for the VM guys -- I'm planning on using an I2C bus on my
> next autonomous robot, and the Squeak machine I'm going to use
> (www.gumstix.com) has a hardware I2C interface, with a driver for it in
> Linux. As far as I can tell, the I2C port looks just like another device in
> Linux, so I'm hoping I can just use the serial port with a different com
> port #.
> Any thoughts?
Yes. It won't work. You'll have to use FFI or write a plugin.
I'd probably try using FFI first and only write a plugin if you absolutely
For one thing, the i2c doesn't look like serial, because of the address/data
separation (each i2c message has an address and a direction), the
master/slave separation, and the concept of messages.
I wrote a Linux kernel driver for an i2c interface, and also a Perl module for
i2c on Linux at one point. Using the 'net as my backup device since I can't
find it on my system any more, I find:
It appears to concentrate on SMBus, which is a protocol on top of I2C that
smart batteries, etc. use. But it might be enlightening if you can stand the
Perl. Just substitute the non-smbus functions for the smbus ones I used.
It's easiest to look at the files in linux-whatever/Documentation/i2c/ if you
want to do this stuff. Just download the corresponding kernel source file.
The most useful is Documentation/i2c/dev-interface because it outlines what
the i2c-dev module provides as the interface for the /dev/i2c* devices. It
even gives a complete userspace example in C.
That's what I worked from to do the Perl driver.
Note that it helps to have a digital storage scope, or at least a
microcontroller set up to dump i2c bus information to a serial port.
More information about the Squeak-dev