Greg KH wrote:
On Mon, Mar 21, 2005 at 11:45:38PM -0500, Brian Perkins wrote:

So it doesn't matter that the "type one" variety works fine with this script, and the "type two" variety doesn't?


Who knows?  :)

As these devices are undocumented, in the end, we really can never be
sure :(


And it doesn't matter that the problem observed _precisely_ mirrors the problem seen in the C problem (gpsbabel)?


And that program uses the proper tty setup calls?

Yes, as far as I can tell. And it works fine with the type one controller.



If I look at an strace of gpsbabel, I can clearly see the first characters of certain transfers getting dropped with the type two adapter. The type one version works fine.


If you enable debugging in the driver:
        modprobe pl2303 debug=1
what does the kernel log show?  Is the data being received by the
kernel and dropped in the driver?  Or does the device itself drop the
data?


Well, I decided to write a small program that reads and writes and does the ioctls the way gpsbabel does from my GPS. I've tacked it on the end of this email. It does appear as though the data never gets to the driver.

To cause the bug to happen, I had to run the program twice. It always messes up the second time.

Here are the logs.  They are kind of long.

http://throb.netspace.org/~bperk/pl2303-type1b.log
http://throb.netspace.org/~bperk/pl2303-type2b.log

The problem show up on line 152 or so of pl2303-type2b.log
Where it says
Mar 22 12:35:17 thump kernel: PL-2303 ttyUSB0: pl2303_read_bulk_callback - length = 1, data = 50


Which should  have been preceded by a '$' (0x24)

There is a pattern. After inserting the device and running the program the first time, it works fine. The second time it drops the first character. The third time, it's OK. The fourth time it drops the first character. Etc. Etc.


#include<stdio.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h>

void main(void){
  int fd,fd2; struct termios orig_tio; struct termios new_tio;

  char buf[4096];
  fd2=  open("/dev/ttyUSB0", O_RDONLY|O_CREAT|O_TRUNC, 0666);
  fd=  open("/dev/ttyUSB0", O_RDWR|O_CREAT|O_TRUNC, 0666);
 tcgetattr(fd, &orig_tio);
   new_tio = orig_tio;
   new_tio.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|
      IGNCR|ICRNL|IXON);
   new_tio.c_oflag &= ~OPOST;
   new_tio.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
   new_tio.c_cflag &= ~(CSIZE|PARENB);



   new_tio.c_cflag |= CS8;
   new_tio.c_cc[VTIME] = 10;
   new_tio.c_cc[VMIN] = 0;

   cfsetospeed(&new_tio, B57600);
   cfsetispeed(&new_tio, B57600);
   tcsetattr(fd, TCSAFLUSH, &new_tio);








write(fd, "$PMGNCMD,HANDON*70\r\n", 20); write(fd, "$PMGNCMD,VERSION*28\r\n", 21); sleep(1); read(fd2,buf,4096);

  if (buf[0]== '$') { printf("That transfer was good:%s\n");}
  else {printf("That transfer was bad:%s\n");}

}


------------------------------------------------------- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click _______________________________________________ Linux-usb-users@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to