usbdev = usbtmc_initscope();
- if (!usbdev)
- return NULL;
+ if (!usbdev) {
+ printf("No scope found.\n");
+ exit(EXIT_FAILURE);
+ }
sc = calloc(1, sizeof(struct scope));
if (sc == NULL) {
//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
+struct usbtmc_header {
+ unsigned char MsgID;
+ unsigned char bTag;
+ unsigned char bTagInverse;
+ unsigned char Reserved3;
+ uint32_t TransferSize;
+ unsigned char bmTransferAttributes;
+ unsigned char TermChar; /* Only in REQUEST_DEV_DEP_MSG_IN */
+ unsigned char Reverved10;
+ unsigned char Reverved11;
+} __attribute__ ((__packed__));
+
+#define USBTMC_DEV_DEP_MSG_OUT 0x1
+#define USBTMC_REQUEST_DEV_DEP_MSG_IN 0x2
+#define USBTMC_DEV_DEP_MSG_IN 0x2
+
+#define USBTMC_TRANSFERATTRIB_EOM (1<<0)
+#define USBTMC_TRANSFERATTRIB_TERMCHAR (1<<1)
+
int usbtmc_sendscpi(struct usb_dev_handle *dev, char* cmd, unsigned char *resp, int resplen);
struct usb_dev_handle* usbtmc_initscope(void);
void usbtmc_close(struct usb_dev_handle *sc);