#include "usbtmc.h"
-#define USB_TIMEOUT 10000
+#define USB_TIMEOUT 50000
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define LE32(x) x
+#elif BYTE_ORDER == BIG_ENDIAN
+#define LE32(x) ((uint32_t)((((uint32_t)x)>>24) | ((((uint32_t)x)>>8) & 0xff00) | ((((uint32_t)x)<<8) & 0xff0000) | (((uint32_t)x)<<24)))
+#else
+#error BYTE_ORDER not defined/known!
+#endif
//Helper-routine: Convert a little-endian 4-byte word to an int
static void int2chars(unsigned char *buff,unsigned int a) {
buff[3]=0;
int2chars(buff+4, cmdlen);
buff[8]=1;
- buff[9]=0x37;
- buff[10]=0x39;
- buff[11]=0x39;
+ buff[9]=0x00;
+ buff[10]=0x00;
+ buff[11]=0x00;
//fprintf(stderr,"Writing header len=%d\n", cmdlen);
//printb(buff,12);
r=usb_bulk_write(dev, 1, (char*)buff, 12, USB_TIMEOUT);
seq++;
buff[1]=seq; buff[2]=~seq; //nseq
int2chars(buff+4,0x40);
- buff[8]=1;
+ buff[8]=0;
buff[9]=0xA;
buff[10]=0;
buff[11]=0;
//Locate and open the scope
dev = usbtmc_find_scope();
if (!dev) {
- printf("No scope found.\n");
- exit(1);
+ return NULL;
}
usbtmc_claim(dev);
//The following code isn't really necessary, the program works