hi, I am trying to transfer bytes using the ftdi_sio driver for my usb-serial converter using ftdi chip with vendor id 0x067b and product id 0x230. I am using th below program to transfer bytes.
/*************************************************************************** * Copyright (C) 2003 by Michael Schuster * * [EMAIL PROTECTED] * * * * Last update 15.06.04 * * * * This programm comes without any warranty !!! * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * Parts of the code I found somewhere in newsgroups * * * * Other were inspired by an discussion at * * [EMAIL PROTECTED] with * * Ned Konz <[EMAIL PROTECTED]> and Ian Abbott <[EMAIL PROTECTED]> * * * ***************************************************************************/ /*************************************************************************** * This programm shows an simple way of comunication with the ftdi-chip * * connected to an usb port in the C Language. * * * * It is intended to show how a single byte transfer can be implemented * * You need to verify: * * + a kernel with the ftdi_sio (look as root with lsmod) running * * + a rs232-subsystem connected (asynchr.) to the ftdi FT232 BM chip * ***************************************************************************/ #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <termios.h> int data; int fd; char a=1; unsigned char rec; unsigned char r,s; struct termios tio,backup; // define the Baudrate #define BAUDRATE B9600 int main(int argc, char** arg) { //First we open the usbdevice (trying to find the chip if ( ( fd = open( "/dev/ttyUSB0", O_RDWR| O_NOCTTY| O_NDELAY )) < 0 ) { fprintf(stderr,"Can't open dev/ttyUSB0\n"); if ( ( fd = open( "/dev/ttyUSB0", O_RDWR| O_NOCTTY| O_NDELAY )) < 0 ) { fprintf(stderr,"Can't open dev/ttyUSB1 either\n"); return(-1); } } if ( tcgetattr( fd, &tio ) == -1 ) { fprintf(stderr,"Can't properly open dev/ttyUSB0\n"); }; backup=tio; // Setting baudrate if(cfsetispeed(&tio, BAUDRATE) == -1) { printf("serial_open(): unable to set input-baudrate\n"); return (-1); } if(cfsetospeed(&tio, BAUDRATE) == -1) { printf("serial_open(): unable to set output-baudrate\n"); return (-1); } // Setting the rawmode tio.c_lflag &=~(ECHO|ICANON|ISIG|IEXTEN); tio.c_lflag = tio.c_lflag | (FLUSHO); tio.c_iflag &=~ (ICRNL|BRKINT|IXON|IXOFF|ISTRIP|INPCK); tio.c_iflag = tio.c_iflag | (IGNBRK|IMAXBEL|IXANY); tio.c_cflag &= ~(CSIZE| PARENB); tio.c_cflag = tio.c_cflag | (CS8 |CREAD| CLOCAL); tio.c_oflag &= ~(OPOST); tio.c_cc[VMIN]=1; // Only 1 char to read! tio.c_cc[VTIME]=0; if (tio.c_lflag & (ECHO|ICANON|ISIG|IEXTEN)) printf("serial_open(): unable to set terminalmode -lflag "); if ( tio.c_iflag & (ICRNL|BRKINT|IXON|ISTRIP|INPCK)) printf("serial_open(): unable to set terminalmode -iflag \n"); // now clean the line ... if(tcflush(fd, TCIOFLUSH) == -1) { printf("serial_open(): unable to flush data\n"); return (-1); } // now clean the line ... if(tcflow(fd, TCIOFLUSH) == -1) { printf("serial_open(): unable to flush data\n"); return (-1); } // ... and activate the settings for the port if(tcsetattr(fd, TCSANOW, &tio) == -1) { printf("serial_open(): unable to set new attributes\n"); return (-1); } printf("Sucessfully opened device for read and write\n"); data=0; rec=0; // Now the simple transfer - pretty easy ;) // printf("\nPress 'Enter' for next bytetransfer, press 'q' for ending transfer\n"); a='a'; while (a!='q') { a=getc(stdin); write(fd,&s,1); while (read(fd,&rec,1)==-1); s=data%255; printf("\n recieved!"); data++; printf(" Sent %x \t Recieved %x \n",s,rec); } if(tcsetattr(fd, TCSANOW, &backup) == -1) { printf("serial_open(): unable to restore old attributes\n"); return (-1); } return 0; } when i execute I get error : /etc/usb-test # ./ftdi drivers/usb/serial/ftdi_sio.c: ftdi_set_termios FAILED to set databits/stopbits/parity drivers/usb/serial/ftdi_sio.c: ftdi_set_termios urb failed to set baurdrate drivers/usb/serial/ftdi_sio.c: urb failed to clear flow control drivers/usb/serial/ftdi_sio.c: ftdi_set_termios FAILED to set databits/stopbits/parity drivers/usb/serial/ftdi_sio.c: ftdi_set_termios urb failed to set baurdrate drivers/usb/serial/ftdi_sio.c: urb failed to clear flow control Sucessfully opened device for read and write Press 'Enter' for next bytetransfer, press 'q' for ending transfer q drivers/usb/serial/ftdi_sio.c: error from flowcontrol urb /etc/usb-test # Why is the driver throwing so many failures? what setting should be done so that it does the byte transfer properly ? I am using 2.6.11 kernel patched with 2.6.12-rc5 on s3c2410 contoller. Regards Ramya __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel