I've struggled with Linux for about a year now and have used a Linux router to remotely connect to a I2C sensor from another Linux computer. Here's how I did it.
The USB-I2C module seem to be a good little thing, that does what it says.
First find and loaded the Serial driver usbserial.o
Second find and load the serial driver for your USB cable E.g. ftdi_sio.o and pl2303.o
Use lsmod to check the modules are loaded and running
Module Size Used by
ftdi_sio 23440 0 (unused)
pl2303 17720 0
usbserial 26156 0 [pl2303 ftdi_sio]
Notice that the usbserial is used by the cable modules.
dmesg should give you the device for the serial port, in my case 'usb/tts/0'
usb.c: registered new driver serial
usbserial.c: USB Serial support registered for Generic
usbserial.c: USB Serial Driver core v1.4
usbserial.c: USB Serial support registered for PL-2303
usbserial.c: PL-2303 converter detected
usbserial.c: PL-2303 converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
pl2303.c: Prolific PL2303 USB to serial adaptor driver
For a LM75 temperature sensor with hard wired address of ‘05’ I set the I2C address to 0x9A. the A being the ‘05’ shifted left one. The response is 2 bits, the MS and LS bytes of the returned temperature.
So Hex‘54 9B 02’ is sent to the serial port these being:
#echo -e "\x54\x9B\x02" > /dev/usb/tts/0
0x54 - I2C_MUL Read multiple bytes without setting new address
0x9B - Device Address + R/W bit
0x02 - Number of Data bytes returned
and a two byte temperature is returned.
19 80 that’s 25.5 degC a hot day.
To capture the returned values from the serial port is a bit more difficult as a command like
cat /dev/usb/tts/0 > /mnt/play.txt &
would capture the returned value, but only if it has a CR at the end of the string. As my sensor only returns 2 bits no CR is present. This is a problem for a bash script.
As I was wanting to read the sensor in a remote location, I connected the USB-I2C serial port to an IP port using ser2net.
now from another machine across a network I can send a command and receive the temperatures
#echo -e "\x54\x9B\x02" | nc 192.168.1.201 2007 -o temp -w1
will send the hex 54, 9B, 02 to the port 2007 on IP address 192.168.1.201 storing the returned message to a file 'temp'
The contents of the file are:
# cat temp
> 00000000 54 9b 02 0a # T...
< 00000000 19 00 # ..
A drop of .5 degC from earlier.
Hope this helps.
If you are looking for details of read from the local serial port with out the CR see the following http://www.linuxquestions.org/questions ... ut-607010/