Sample Linux code




Instructions to install new driver: You may require the sources matching the
current kernel to be installed on your system (and built).

To install the ftdi_sio driver use the following steps:
1. Create a temporary folder in your linux machine.
2. Extract the files from ftdi_sio.tar.gz file to your temporary folder
"gunzip ftdi_sio.tar.gz"
"tar -xvf ftdi_sio.tar"
3. Build the driver
4. Plug in your ftdi device
5. Check to see if default driver was loaded
"lsmod" - you will see ftdi_sio if a driver is loaded
6. Remove the default installed driver
"rmmod ftdi_sio"
7. Install the newly built driver
"insmod ftdi_sio.o"
1.This driver was adapted from the 2.4.32 kernel to support both the 2232C
and 232R chip
2.There is no need to follow this procedure if you want 232R chip supprt. The
232BM driver will be sufficient.Changes made to the driver for the 232R chip
are purly cosmetic (plug/unplug will appear as a 232R chip in the kernel log).



In this case the driver is correctly installed and with the bash's command

The old kernel's "echo" commands:
stty -F /dev/ttyUSB0 9600
echo $ '\xff\x01\x01' > ttyUSB0
// the relay 1 go ON
echo $ '\xff\x01\x00' > ttyUSB0 // the relay 1 go OFF

The new kernel's "echo" commands:
stty -F /dev/ttyUSB0 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

echo -e '\xff\x01\x01' > /dev/ttyUSB0
// the relay 1 go ON
echo -e '\xff\x01\x00' > /dev/ttyUSB0 // the relay 1 go OFF

echo -e "\xff\x01\x03" > /dev/ttyUSB0 | od -A n -N 3 -t x1 < /dev/ttyUSB0 // read status



Read 16129 times