Re: [Ftdi-usb-sio-devel] Cant do simple serial-mode writes on FT2232H
Brought to you by:
bryder
From: Bill R. <bil...@gm...> - 2009-11-25 18:27:20
|
Hi there, This list is for the kernel driver which you access through the normal open,close termios stuff. The driver doesn't have a userspace ftdi.h. It looks like you're using a userspace ftdi library and so will probably want a different forum. On Thu, Nov 26, 2009 at 4:50 AM, T. Horsnell <ts...@mr...> wrote: > Hi, > I'm struggling with what ought to be the most straightforward thing. > I'm trying to write to channel A of an FT2232H mini-module in serial > mode, but after writing a total of 4096 bytes, the writes hang > and I get an error -110 returned. > Presumably the buffer on the mini-module has filled up. But why > is this not being emptied as the device send things to its serial pin? > I've set flow-control to SIO_DISABLE_FLOW_CTRL (does this function > actually work? It seems to return success even if I try idiot values > like -1 or 12345 for the flow-control parameter). > > Thanks, > Terry > > My code: > > #include <stdio.h> > #include <time.h> > #include <unistd.h> > #include <usb.h> > #include <ftdi.h> > > const int vendor_id=0x0403; > const int product_id=0x6010; //FT2232H > > int main(int argc, char **argv) > { > struct ftdi_context ftdicA,ftdicB; > int f,i,j,k; > > printf("setting up channel A\n"); > ftdi_init(&ftdicA); > f = ftdi_usb_open(&ftdicA, vendor_id, product_id); > if(f < 0 && f != -5) > { > fprintf(stderr, "unable to open ftdi device: %d - > %s\n",f,ftdicA.error_str); > exit(-1); > } > printf("ftdi open A succeeded: %d\n",f); > > printf("setting flowcontrol\n"); > //i=ftdi_setflowctrl(&ftdicA, SIO_DISABLE_FLOW_CTRL); > i=ftdi_setflowctrl(&ftdicA, 7); > if (i != 0) > { > printf("setting channel A flow-control failed. stat=%i\n",i); > exit(0); > } > > #define BUFLEN 100000 > unsigned char buf0[BUFLEN]; > for (i=0; i<BUFLEN; i++) buf0[i]=0xff; > > for (j=0; j<5; j++) > { > printf("loop=%i\n",j); > //write a buffer > f = ftdi_write_data(&ftdicA, buf0, 1000); > if(f < 0) > { > fprintf(stderr,"write failed for %x, error %d - > %s\n",buf0[0],f,ftdicA.error_str); > break; > } > } > > ftdi_usb_close(&ftdicA); > ftdi_deinit(&ftdicA); > return 0; > } > > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Ftdi-usb-sio-devel mailing list > Ftd...@li... > https://lists.sourceforge.net/lists/listinfo/ftdi-usb-sio-devel > |