From: Johannes E. <joh...@er...> - 2003-05-04 18:54:34
|
On Sun, May 04, 2003, dw0811 <dw...@cn...> wrote: > I have met a strange problem in my program. > I have two hosts which run redhat7.3(2.4.18-3),and their usb hub was connected by a usbtousb bridge device(or PL2301),here is parts of my code: > > > char recvbuf[4096]; > char sendbuf[4096]; > > > int j,sendlen; > > strcpy(sendbuf,"STARTING"); > > sendlen=4096; > > if (!strcmp(argv[1],"send")) > { > j=usb_bulk_write(udev,outendpoint,(char *)sendbuf,sendlen,5000); > if (j>0) > printf("send %d\n",sendlen); > else > perror("Error"); > } > > if (!strcmp(argv[1],"recv")) > { > for(;;) > { > j=usb_bulk_read(udev,inendpoint,(char *)recvbuf, sendlen,5000); > if (j>0) > { > printf("recv %d\n",j); > printf("%s\n",recvbuf); > break; > } > else > perror("Error"); > } > } > > i want run my test program on host A to send data,and another on host B to recv data, > BUT,the data was recved by host B was unexpected, > the data is not "STARTING",'\0' <repeats 4088 times> > but '\0' <repeats 192 times>, "STARTING", '\0' <repeats 3896 times> > > Sorry,my english is poor,i hope people here can understand me what i want to say, Thanks for your help. I'm not too familiar with pl2301 (only the netchip 1080), but it could be a FIFO which is causing this shifting of data. 192 bytes is a multiple of the USB packet size, so I suspect it's just something the pl2301 does that you may have to take into consideration. JE |