X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/blobdiff_plain/037166c11a9f4984d999639cf626e6f66de547fc..1c832d051d73e2e43e931136b575bd2d269ce599:/rigol.c diff --git a/rigol.c b/rigol.c index fff4846..7c42892 100644 --- a/rigol.c +++ b/rigol.c @@ -91,26 +91,28 @@ void printb (unsigned char *pkt, int len) //Send a scpi-command to the scope. The response goes into the buffer //called resp, with a size of resplen. If resp==NULL, no response //is requested. -int sendscpi(usb_dev_handle *dev, unsigned char* cmd, +int sendscpi(usb_dev_handle *dev, char* cmd, unsigned char *resp, int resplen) { - char *buff; + unsigned char *buff; int len,r,i; + int cmdlen = strlen(cmd); + buff=malloc(0x40); seq++; buff[0]=1; //func buff[1]=seq; buff[2]=~seq; //nseq buff[3]=0; - int2chars(buff+4,strlen(cmd)); + int2chars(buff+4, cmdlen); buff[8]=1; buff[9]=0x37; buff[10]=0x39; buff[11]=0x39; - // fprintf(stderr,"Writing header len=%d\n", strlen (cmd)); + // fprintf(stderr,"Writing header len=%d\n", cmdlen); // printb(buff,12); - r=usb_bulk_write(dev,1,buff,12,1000); + r=usb_bulk_write(dev, 1, (char*)buff, 12, 1000); // fprintf(stderr,"%i bytes written. Writing cmd\n",r); -// printb(cmd,strlen(cmd)); - r=usb_bulk_write(dev,1,cmd,strlen(cmd),1000); +// printb(cmd, cmdlen); + r=usb_bulk_write(dev, 1, cmd, cmdlen, 1000); // fprintf(stderr,"%i bytes written.\n",r); if (resp != NULL && resplen != 0) { //send read command @@ -124,9 +126,9 @@ int sendscpi(usb_dev_handle *dev, unsigned char* cmd, buff[11]=0; // fprintf(stderr,"Writing resp req header\n"); // printb(buff,12); - r=usb_bulk_write(dev,1,buff,12,1000); + r=usb_bulk_write(dev, 1, (char*)buff, 12, 1000); // fprintf(stderr,"%i bytes written. Reading response hdr\n",r); - r=usb_bulk_read(dev,2,buff,0x40,1000); + r=usb_bulk_read(dev, 2, (char*)buff, 0x40, 1000); // printb(buff,r); len=chars2int(buff+4); // fprintf(stderr,"%i bytes read. Resplen=%i\n",r,len); @@ -137,7 +139,7 @@ int sendscpi(usb_dev_handle *dev, unsigned char* cmd, if (len > 0x40-12) { // fprintf(stderr," Reading response:\n"); if (resplen 0) { - sscanf (buf, "%lf", &temp); + sscanf ((char*)buf, "%lf", &temp); return temp; } return ERROR; @@ -250,7 +252,8 @@ void do_get_buf (struct usb_dev_handle *sc) { FILE *fp; int i, j, l, bp; - unsigned char buf[1024], ch1[1024]; + char buf[1024]; + unsigned char ch1[1024]; unsigned char data[512*1024]; double sampfreq; @@ -295,7 +298,8 @@ void do_get_buf (struct usb_dev_handle *sc) int main(int argc, char **argv) { struct usb_dev_handle *sc; - char *scpi, *buff; + char *scpi; + unsigned char *buff; int l; //Init libusb usb_init();