Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I purchased a Sainsmart 4 channel USB relay board which seems to be based on a FTDI FT245RL chip. I should be easy enough to use. when you plug it in it appears as a serial port (VCP). You send it three bytes which tell it what to turn on and off. E.g. \xFF\x00\x01 turns on just relay 1 and \xff\x00\x03 turns on relay 1 and 2.

I wrote a very simple python program to test this on a Debian squeeze machine:

import serial
ser = serial.Serial('/dev/ttyUSB0') # Defaults to 9600 8N1
ser.open()
ser.write(chr(255) + chr(0) + chr(3))
ser.close

...and nothing happened. Sometimes I get nothing, and sometimes it blocks. I installed the drivers on a win7x64 machine, and changed one line to point to COM3, it works great. I then tried it on a CentOS 5 machine and it doesn't work here either. I don't think it is permissions, I've added the users to the dialout and uucp groups respectively. I've also tried it as root. I was able to set up a udev rule on Debian which seems to work. If I do lsusb, this is the relevant result:

Bus 005 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

If I do stty -F /dev/ttyUSB0 -a I get

speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^A; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z;
rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 0; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
share|improve this question
    
Can you short RX and TX and check if anything gets transmitted at all? Be careful not to fry anything! You should be able to see what you're typing on some kind of tool then, like on GNU screen. –  TNW Apr 18 '13 at 18:05
    
@TNW If it was a DB9 I would know how to do this, but an FTDI chip? I think that I'm not able to short pins on a SMD. –  RyanN Apr 19 '13 at 18:20
    
I think it might be possible at receiver's pins, not exactly on FTDI IC's leads. Is it so? –  TNW Apr 19 '13 at 18:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.