]> cvs.zerfleddert.de Git - rigol/blobdiff - usbtmc.c
export data through webinterface
[rigol] / usbtmc.c
index b29f4e77919a4a69ddef7430e1d4d84f9b36fd6d..d87d9ac7955c643ba261b6d6c5d51190daf50b60 100644 (file)
--- a/usbtmc.c
+++ b/usbtmc.c
@@ -236,7 +236,7 @@ int usbtmc_sendscpi(struct scope *sc, char* cmd,
                unsigned char rxbuff[USBTMC_IN_TRANSFERSIZE];
                struct usbtmc_header *res;
                int bytes_read;
-               unsigned int transfer_size = USBTMC_IN_TRANSFERSIZE;
+               unsigned int read_size = USBTMC_IN_TRANSFERSIZE;
                unsigned int headerlen;
 
                req = calloc(1, sizeof(struct usbtmc_header));
@@ -246,7 +246,7 @@ int usbtmc_sendscpi(struct scope *sc, char* cmd,
                }
 
                if (sc->usb.brokenRigol == 1) {
-                       transfer_size = sc->usb.wMaxPacketSize_in;
+                       read_size = sc->usb.wMaxPacketSize_in;
                }
 
                bytes_read = 0;
@@ -259,7 +259,7 @@ int usbtmc_sendscpi(struct scope *sc, char* cmd,
                                req->MsgID = USBTMC_REQUEST_DEV_DEP_MSG_IN;
                                req->bTag = sc->usb.bTag;
                                req->bTagInverse = ~sc->usb.bTag;
-                               req->TransferSize = LE32(transfer_size);
+                               req->TransferSize = LE32(USBTMC_IN_TRANSFERSIZE);
                                req->bmTransferAttributes = 0;
                                req->TermChar = 0;
 
@@ -272,7 +272,7 @@ int usbtmc_sendscpi(struct scope *sc, char* cmd,
                        }
 
                        r=usb_bulk_read(sc->usb.dev, sc->usb.ep_bulk_in,
-                                       (char*)rxbuff, transfer_size, USB_TIMEOUT);
+                                       (char*)rxbuff, read_size, USB_TIMEOUT);
                        USB_ERROR("USBTMC_DEV_DEP_MSG_IN", r);
 
                        if (r < headerlen) {
@@ -280,7 +280,6 @@ int usbtmc_sendscpi(struct scope *sc, char* cmd,
                                return 0;
                        }
 
-
                        if (headerlen > 0) {
                                res = (struct usbtmc_header*)rxbuff;
 
@@ -305,13 +304,12 @@ int usbtmc_sendscpi(struct scope *sc, char* cmd,
                                }
                        }
 
-                       if ((sc->usb.brokenRigol == 0) || (transfer_size == USBTMC_IN_TRANSFERSIZE) ||
-                           ((r - sizeof(struct usbtmc_header) >= len))) {
+                       if ((r - headerlen) > 0) {
                                memcpy(buff + bytes_read, rxbuff + headerlen, r - headerlen);
                                bytes_read += r - headerlen;
                        }
 
-                       transfer_size = USBTMC_IN_TRANSFERSIZE;
+                       read_size = USBTMC_IN_TRANSFERSIZE;
                } while(bytes_read < len);
 
                free(req);
Impressum, Datenschutz