From: Michael Gernoth Date: Mon, 7 Jun 2010 07:59:21 +0000 (+0200) Subject: add struct for usbtmc header X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/commitdiff_plain/2999345d8f501d54dc19bc3f60f01c573910d565 add struct for usbtmc header --- diff --git a/scope.c b/scope.c index 3152243..806ba34 100644 --- a/scope.c +++ b/scope.c @@ -36,8 +36,10 @@ struct scope* initscope(void) 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) { diff --git a/usbtmc.c b/usbtmc.c index 622ea80..32f83a8 100644 --- a/usbtmc.c +++ b/usbtmc.c @@ -126,8 +126,7 @@ usb_dev_handle* usbtmc_initscope(void) { //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 diff --git a/usbtmc.h b/usbtmc.h index 1ac3005..bae36da 100644 --- a/usbtmc.h +++ b/usbtmc.h @@ -1,3 +1,22 @@ +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);