Re: [Ftdi-usb-sio-devel] howto: setting up driver to ftdi usb
Brought to you by:
bryder
From: Mike R. <er...@es...> - 2002-11-15 06:53:42
|
On Thu, 14 Nov 2002, Bill Ryder wrote: > Does it write into /var/log/messages saying a FTDI device was detected? > /proc doesn't tell the whole story - it will take you a usb device was > detected. Yeah, baby, this looks really good: Nov 14 21:23:07 localhost kernel: hub.c: USB new device connect on bus1/1, assigned device number 2 Nov 14 21:23:07 localhost kernel: usb.c: USB new device connect, assigned device number 2 Nov 14 21:23:07 localhost kernel: Manufacturer: FTDI Nov 14 21:23:07 localhost kernel: Product: USB <-> Serial Nov 14 21:23:07 localhost kernel: usbserial.c: FTDI 8U232AM converter detected Nov 14 21:23:07 localhost kernel: usbserial.c: FTDI 8U232AM converter now attached to ttyUSB0 (or usb/tts/0 for devfs) and dmesg returns: hub.c: port 1 connection change hub.c: port 1, portstatus 101, change 1, 12 Mb/s hub.c: port 1, portstatus 103, change 10, 12 Mb/s hub.c: USB new device connect on bus1/1, assigned device number 2 usb.c: USB new device connect, assigned device number 2 usb.c: kmalloc IF d18c5900, numif 1 usb.c: new device strings: Mfr=1, Product=2, SerialNumber=0 usb.c: USB device number 2 default language ID 0x409 Manufacturer: FTDI Product: USB <-> Serial usbserial.c: Looking at FTDI 8U232AM Vendor id=0403 Product id=6001 usbserial.c: descriptor matches usbserial.c: found bulk in usbserial.c: found bulk out usbserial.c: FTDI 8U232AM converter detected usbserial.c: get_free_serial 1 usbserial.c: get_free_serial - minor base = 0 usbserial.c: usb_serial_probe - setting up 1 port structures for this device usbserial.c: FTDI 8U232AM converter now attached to ttyUSB0 (or usb/tts/0 for devfs) usb.c: serial driver claimed interface d18c5900 So I'm doing something stupid in my calls to the driver. Here's what I do: serial = open( portname, O_RDWR | O_NOCTTY | O_NONBLOCK); [..error check on serial ok..] tcgetattr( serial, &tio); printf("tio.c_cc[vmin] = %d, [vtime] = %d\n", tio.c_cc[VMIN], tio.c_cc[VTIME]); tio.c_iflag = 0; tio.c_oflag = 0; tio.c_cflag = CREAD | CRTSCTS | CS8 | B38400 | CLOCAL; tio.c_lflag = 0; /* use time instead of data. If no response, something wrong. If there is a response, deal with as much as possible. */ tio.c_cc[VMIN] = 0; tio.c_cc[VTIME] = 1; tcflush( serial, TCIOFLUSH); tcsetattr( serial, TCSANOW, &tio); [...other stuff for me ...] i = ioctl( serial, TIOCMGET, &arg); printf("error = %d iniitial bits are %x\n", i, arg); outmsg[0] = 'A'; outmsg[1] = 'B'; outmsg[2] = 'C'; num = write( serial, outmsg, 3); if(num<0) perror("write didn't work"); j = 0; while( j<10) { num = read( serial, inmsg, 63); if (num < 0) perror("first read didn't work"); : : and here's what I get: tio.c_cc[vmin] = 0, [vtime] = 1 error = 0 iniitial bits are 120 Initializing com link to jtag interface first read didn't work: Resource temporarily unavailable number of bytes from 0x81 command -1 number of bytes from 0x81 command 3 received A@A init_stream returns 4 > I am making an *assumption* (possibly unwarranted) that it won't work > because I am not aware of anyone backporting the current drivers - and > the early versions had plenty of bugs and they only supported the > original SIO. Yeah, it seems like I should be able to fake my way past it tho. I just gotta make the driver think it's doing something useful, even tho there are no serial lines out there. > ftdi_sio_write > > The trick with the devices is the original device (the SIO) required a > byte count on the front of the output packet, the newer devices (ie the > 232AM and 232BM, 245 don't. > > So your choices are to backport the current driver, or compare the > current driver to the driver in 2.2 and fix it manually. Certainly not > impossible. Oh I see, that extra byte is being sent to the device, and it's not really needed. Maybe I can fake that out too, but I guess talking to the usb device directly rather than to the serial device might be simpler. Thanks, I think it's getting closer. Yesterday I didn't even get the "A" back, just pure garbage. If all I have to do is change the open() line and it makes the driver happy, I may be in the clear. Patience, persistence, truth, Dr. mike |