#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;
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);
- 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
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);
- 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);
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);
}
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",