The original blog is in Turkish and in www.dincay.blogspot.com. This is the English translation of it.

30 Ekim 2010 Cumartesi

Serial commnication with Ftdi VCP Driver

I had performed serial communication with libftdi. I did it again with ftdi vcp drivers instead of libftdi.

The reason that I wanted to use vcp drivers is I want to use other programming languages than C. I thought that libftdi would give me greater flexibility. But I forgot that nearly all programming languages can communicate with serial port. Instead of a specific library like libftdi, working with native serial port libraties is better I think.

I downloaded the vcp drivers from ftdi's web site. When I gave make command, driver gave me this error

cc1: fatal error: /lib/modules/2.6.35-22-generic/build/include/linux/modversions.h: No such file or directory

After a little googling, I understood that modversion.h is found in older linux versions (I am using ubuntu 10.04 now). In http://ftdi-usb-sio.sourceforge.net/#sec6 it says you can test your vcp drivers if they installed correctly by these ways. When I did the tests, I understood that driver was installed succesfully : Probably ubuntu has the drivers in it already.

I wrote a small program in python to check the vcp drivers. Python is already integrated to ubuntu. But I needed to install pySerial: python serial communication module. I downloaded the module from http://pypi.python.org/pypi/pyserial. In downloded folder I give

sudo python setup.py install

command and setup was completed. Very easy.

Here is the program I used:

#python serial read-write

#Dincay Akcoren
import serial

#baud rate = 19200, timeout = 10 sec
ser = serial.Serial('/dev/ttyUSB0', 19200, timeout=10)
ser.write("5")
x = ser.read()
print(x)
ser.close()


Now I can communicate with my DE0 from pc. I can send commands and receive responses. Next I will write a command decoder/encoder that eases giving/receiving commands.

Hiç yorum yok:

Yorum Gönder