]> git.zerfleddert.de Git - rigol/commitdiff
increase USB timeout
authorMichael Gernoth <michael@gernoth.net>
Sun, 6 Jun 2010 19:03:42 +0000 (21:03 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 6 Jun 2010 19:03:42 +0000 (21:03 +0200)
usbtmc.c

index 8a35dd30c96e5a954bc231e57b250fbc2765691a..0249e25712b766dd44c3679b25996c1f0c0084c9 100644 (file)
--- a/usbtmc.c
+++ b/usbtmc.c
@@ -6,6 +6,8 @@
 
 #include "usbtmc.h"
 
 
 #include "usbtmc.h"
 
+#define USB_TIMEOUT 10000
+
 //Helper-routine: Convert a little-endian 4-byte word to an int
 static void int2chars(unsigned char *buff,unsigned int a) {
        buff[3]=(a>>24)&0xff;
 //Helper-routine: Convert a little-endian 4-byte word to an int
 static void int2chars(unsigned char *buff,unsigned int a) {
        buff[3]=(a>>24)&0xff;
@@ -64,10 +66,10 @@ int usbtmc_sendscpi(usb_dev_handle *dev, char* cmd,
        buff[11]=0x39;
        //fprintf(stderr,"Writing header len=%d\n", cmdlen);
        //printb(buff,12);
        buff[11]=0x39;
        //fprintf(stderr,"Writing header len=%d\n", cmdlen);
        //printb(buff,12);
-       r=usb_bulk_write(dev, 1, (char*)buff, 12, 1000);
+       r=usb_bulk_write(dev, 1, (char*)buff, 12, USB_TIMEOUT);
        //fprintf(stderr,"%i bytes written. Writing cmd\n",r);
        //printb(cmd, cmdlen);
        //fprintf(stderr,"%i bytes written. Writing cmd\n",r);
        //printb(cmd, cmdlen);
-       r=usb_bulk_write(dev, 1, cmd, cmdlen, 1000);
+       r=usb_bulk_write(dev, 1, cmd, cmdlen, USB_TIMEOUT);
        //fprintf(stderr,"%i bytes written.\n",r);
        if (resp != NULL && resplen != 0) {
                //send read command
        //fprintf(stderr,"%i bytes written.\n",r);
        if (resp != NULL && resplen != 0) {
                //send read command
@@ -81,9 +83,9 @@ int usbtmc_sendscpi(usb_dev_handle *dev, char* cmd,
                buff[11]=0;
                //fprintf(stderr,"Writing resp req header\n");
                //printb(buff,12);
                buff[11]=0;
                //fprintf(stderr,"Writing resp req header\n");
                //printb(buff,12);
-               r=usb_bulk_write(dev, 1, (char*)buff, 12, 1000);
+               r=usb_bulk_write(dev, 1, (char*)buff, 12, USB_TIMEOUT);
                //fprintf(stderr,"%i bytes written. Reading response hdr\n",r);
                //fprintf(stderr,"%i bytes written. Reading response hdr\n",r);
-               r=usb_bulk_read(dev, 2, (char*)buff, 0x40, 1000);
+               r=usb_bulk_read(dev, 2, (char*)buff, 0x40, USB_TIMEOUT);
                //printb(buff,r);
                len=chars2int(buff+4);
                //fprintf(stderr,"%i bytes read. Resplen=%i\n",r,len);
                //printb(buff,r);
                len=chars2int(buff+4);
                //fprintf(stderr,"%i bytes read. Resplen=%i\n",r,len);
@@ -94,7 +96,7 @@ int usbtmc_sendscpi(usb_dev_handle *dev, char* cmd,
                if (len > 0x40-12) {
                        //fprintf(stderr," Reading response:\n");
                        if (resplen<len) len=resplen;
                if (len > 0x40-12) {
                        //fprintf(stderr," Reading response:\n");
                        if (resplen<len) len=resplen;
-                       r=usb_bulk_read(dev, 2, (char*)resp+(0x40-12), len-(0x40-12),1000);
+                       r=usb_bulk_read(dev, 2, (char*)resp+(0x40-12), len-(0x40-12), USB_TIMEOUT);
                        //fprintf(stderr,"%i bytes read, wanted %i.\n", r, len-(0x40-12));
                        return r+(0x40-12);
                }
                        //fprintf(stderr,"%i bytes read, wanted %i.\n", r, len-(0x40-12));
                        return r+(0x40-12);
                }
@@ -130,7 +132,7 @@ usb_dev_handle* usbtmc_initscope(void) {
        usbtmc_claim(dev);
        //The following code isn't really necessary, the program works
        //OK without it too.
        usbtmc_claim(dev);
        //The following code isn't really necessary, the program works
        //OK without it too.
-       r=usb_control_msg(dev, 0xC8, 9, 0, 0, (char*)buff, 4, 1000);
+       r=usb_control_msg(dev, 0xC8, 9, 0, 0, (char*)buff, 4, USB_TIMEOUT);
        usbtmc_release(dev);
        if (r < 0) {
                fprintf (stderr, "Error %d sending init message: %s\n", 
        usbtmc_release(dev);
        if (r < 0) {
                fprintf (stderr, "Error %d sending init message: %s\n", 
Impressum, Datenschutz