From: Michael Gernoth Date: Sun, 6 Jun 2010 13:21:17 +0000 (+0200) Subject: move usb_close to usbtmc, fix memory leak X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rigol/commitdiff_plain/b74fea90bd5429ab527016eb89d98b4c6a246e68?hp=c1ec14bbf5b7269df2ab382250556f9146b0e042 move usb_close to usbtmc, fix memory leak --- diff --git a/commands.c b/commands.c index 4986902..75e76d0 100644 --- a/commands.c +++ b/commands.c @@ -224,4 +224,3 @@ void do_display_screen(struct usb_dev_handle *sc) break; } } - diff --git a/commands.h b/commands.h index 67afc00..9d20fe8 100644 --- a/commands.h +++ b/commands.h @@ -1,3 +1,4 @@ void do_plot (struct usb_dev_handle *sc); void do_get_buf (struct usb_dev_handle *sc); void do_get_screen(struct usb_dev_handle *sc); +void do_display_screen(struct usb_dev_handle *sc); diff --git a/rigol.c b/rigol.c index 93b8566..6ae9d73 100644 --- a/rigol.c +++ b/rigol.c @@ -165,8 +165,6 @@ int main(int argc, char **argv) //Disable keylock, so the user doesn't have to press the 'force'-button l=usbtmc_sendscpi(sc, ":KEY:LOCK DISABLE",NULL,0); - //Free up and exit - usb_release_interface(sc,0); - usb_close(sc); + usbtmc_close(sc); return 0; } diff --git a/usbtmc.c b/usbtmc.c index 483014f..d652494 100644 --- a/usbtmc.c +++ b/usbtmc.c @@ -129,8 +129,15 @@ usb_dev_handle* usbtmc_initscope(void) { fprintf (stderr, "Do you have permission on the USB device?\n"); exit (1); } - if (chars2int(buff)!=0x40004dc) { + if (chars2int(buff)!=0x40005dc) { fprintf(stderr,"Init: buff[%i]=%x\n",r,chars2int(buff)); } return dev; } + +void usbtmc_close(usb_dev_handle *sc) +{ + //Free up and exit + usb_release_interface(sc,0); + usb_close(sc); +} diff --git a/usbtmc.h b/usbtmc.h index 358cad3..175511e 100644 --- a/usbtmc.h +++ b/usbtmc.h @@ -1,2 +1,3 @@ int usbtmc_sendscpi(usb_dev_handle *dev, char* cmd, unsigned char *resp, int resplen); usb_dev_handle* usbtmc_initscope(void); +void usbtmc_close(usb_dev_handle *sc);