return 0;
}
+void usbtmc_claim(usb_dev_handle *sc)
+{
+ usb_claim_interface(sc, 0);
+}
+
+void usbtmc_release(usb_dev_handle *sc)
+{
+ usb_release_interface(sc, 0);
+}
+
//Initialize the scope.
usb_dev_handle* usbtmc_initscope(void) {
int r;
if (!dev) {
printf("No scope found.\n");
exit(1);
- } else {
- printf("Scope found.\n");
}
- usb_claim_interface(dev,0);
+ usbtmc_claim(dev);
//The following code isn't really necessary, the program works
//OK without it too.
r=usb_control_msg(dev, 0xC8, 9, 0, 0, (char*)buff, 4, 1000);
+ usbtmc_release(dev);
if (r < 0) {
fprintf (stderr, "Error %d sending init message: %s\n",
r, strerror (-r));
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_close(sc);
+}