move usb_close to usbtmc, fix memory leak
authorMichael Gernoth <michael@gernoth.net>
Sun, 6 Jun 2010 13:21:17 +0000 (15:21 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 6 Jun 2010 13:21:17 +0000 (15:21 +0200)
commands.c
commands.h
rigol.c
usbtmc.c
usbtmc.h

index 498690240602c3a3c86c92482531c486a9eeba28..75e76d03d65f2a4a2b4095de2ca49233f42811da 100644 (file)
@@ -224,4 +224,3 @@ void do_display_screen(struct usb_dev_handle *sc)
                        break;
        }
 }
-
index 67afc0037033c303eca6b3b0ebc41e86a1bdb4be..9d20fe8320bce96de8a0d1eb7f0dad0e71114338 100644 (file)
@@ -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 93b85665c0c3c2fe7f70038d95cc313534c38d0d..6ae9d73dac9a3eb3f0d73b74f965e5ef7923a9dc 100644 (file)
--- 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;
 }
index 483014f58e51fa7de953e717323204bd791772cb..d652494ffe39ffa60d71f75a29e4142daa11b3e6 100644 (file)
--- 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);
+}
index 358cad364b277b56210de215eea5793def2b2e75..175511e8926fa69247ca13540c42bcc614a8dc98 100644 (file)
--- 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);
Impressum, Datenschutz