X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=examples%2Fbaud_test.c;h=d8d4886154c05907962d3a1375abac8796c92465;hp=32b9beb3492eb0ca14de694efd3df24dd75c17b3;hb=05c2e40a3c720c63a75d36a33d0d5de0677f8f57;hpb=579b006f4873fa72c73d372660d158061497bcc9 diff --git a/examples/baud_test.c b/examples/baud_test.c index 32b9beb..d8d4886 100644 --- a/examples/baud_test.c +++ b/examples/baud_test.c @@ -12,7 +12,7 @@ * s::: first device with given vendor id, product id and serial string * -d * -b (divides by 16 if bitbang as taken from the ftdi datasheets) - * -m r: serial a: async bitbang s:sync bitbang + * -m r: serial a: async bitbang s:sync bitbang * -c * * (C) 2009 by Gerd v. Egidy @@ -39,7 +39,7 @@ double get_prec_time() { struct timeval tv; double res; - + gettimeofday(&tv,NULL); res=tv.tv_sec; @@ -52,8 +52,8 @@ int main(int argc, char **argv) { struct ftdi_context ftdic; int i, t; - char *txbuf; - char *rxbuf; + unsigned char *txbuf; + unsigned char *rxbuf; double start, duration, plan; // default values @@ -65,7 +65,7 @@ int main(int argc, char **argv) char *devicedesc=default_devicedesc; int txchunksize=256; enum ftdi_mpsse_mode test_mode=BITMODE_BITBANG; - + while ((t = getopt (argc, argv, "b:d:p:m:c:")) != -1) { switch (t) @@ -74,7 +74,7 @@ int main(int argc, char **argv) datasize = atoi (optarg); break; case 'm': - switch(*optarg) + switch (*optarg) { case 'r': // serial @@ -162,16 +162,16 @@ int main(int argc, char **argv) } if (ftdi_write_data_set_chunksize(&ftdic, txchunksize) < 0 || - ftdi_read_data_set_chunksize(&ftdic, txchunksize) < 0) + ftdi_read_data_set_chunksize(&ftdic, txchunksize) < 0) { fprintf(stderr,"Can't set chunksize: %s\n",ftdi_get_error_string(&ftdic)); return EXIT_FAILURE; } - if(test_mode==BITMODE_SYNCBB) + if (test_mode==BITMODE_SYNCBB) { // completely clear the receive buffer before beginning - while(ftdi_read_data(&ftdic, rxbuf, txchunksize)>0); + while (ftdi_read_data(&ftdic, rxbuf, txchunksize)>0); } start=get_prec_time(); @@ -181,7 +181,7 @@ int main(int argc, char **argv) ftdic.usb_read_timeout=1; i=0; - while(i < datasize) + while (i < datasize) { int sendsize=txchunksize; if (i+sendsize > datasize) @@ -196,7 +196,7 @@ int main(int argc, char **argv) i+=sendsize; - if(test_mode==BITMODE_SYNCBB) + if (test_mode==BITMODE_SYNCBB) { // read the same amount of data as sent ftdi_read_data(&ftdic, rxbuf, sendsize);