From 1c832d051d73e2e43e931136b575bd2d269ce599 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 30 May 2010 22:44:47 +0200 Subject: [PATCH 1/1] get rid of signed/unsigned warnings --- rigol.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) 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(); -- 2.39.5