+ if ((res->bTag != sc->usb.bTag) ||
+ (res->bTagInverse != (unsigned char)(~sc->usb.bTag))) {
+ fprintf(stderr, "Wrong TAG received! We: 0x%02x, Scope: 0x%02x\n", sc->usb.bTag, res->bTag);
+ if (sc->usb.brokenRigol == 1) {
+ fprintf(stderr, "Tying to restart transfer...\n");
+ bytes_read = 0;
+ continue;
+ }
+ return 0;
+ }
+
+ if (buff == NULL) {
+ len = LE32(res->TransferSize);
+ buff=malloc(len);
+ if (buff == NULL) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+
+ if ((sc->usb.brokenRigol == 0) || (transfer_size == USBTMC_IN_TRANSFERSIZE) ||
+ ((r - sizeof(struct usbtmc_header) >= len))) {
+ memcpy(buff + bytes_read, rxbuff + headerlen, r - headerlen);
+ bytes_read += r - headerlen;
+ }
+
+ transfer_size = USBTMC_IN_TRANSFERSIZE;
+ } while(bytes_read < len);
+
+ free(req);