dont be so verbose
This commit is contained in:
parent
bc35f95a06
commit
205e5eaae3
1 changed files with 6 additions and 7 deletions
|
@ -59,15 +59,16 @@ PosPrinter::PosPrinter()
|
|||
}
|
||||
|
||||
if (libusb_kernel_driver_active(devicePtr_, 0) == 1) { // find out if kernel driver is attached
|
||||
std::cout << "Kernel driver active" << std::endl;
|
||||
if (libusb_detach_kernel_driver(devicePtr_, 0) == 0) // detach it
|
||||
std::cout << "Kernel driver detached!" << std::endl;
|
||||
if (libusb_detach_kernel_driver(devicePtr_, 0) != 0) { // detach it
|
||||
libusb_free_device_list(devList, 1);
|
||||
libusb_exit(contextPtr_);
|
||||
throw std::runtime_error("Could not detach kernel printer driver");
|
||||
}
|
||||
}
|
||||
|
||||
retValue = libusb_claim_interface(
|
||||
devicePtr_, 0); // claim interface 0 (the first) of device (mine had jsut 1)
|
||||
if (retValue < 0) {
|
||||
std::cout << "Cannot claim printer interface" << std::endl;
|
||||
throw std::runtime_error("Cannot claim printer interface");
|
||||
}
|
||||
|
||||
|
@ -80,9 +81,7 @@ PosPrinter::~PosPrinter()
|
|||
int retValue;
|
||||
retValue = libusb_release_interface(devicePtr_, 0); // release the claimed interface
|
||||
if (retValue != 0) {
|
||||
std::cout << "Cannot release printer interface" << std::endl;
|
||||
} else {
|
||||
std::cout << "Printer interface released" << std::endl;
|
||||
std::cerr << "Cannot release printer interface" << std::endl;
|
||||
}
|
||||
|
||||
libusb_close(devicePtr_); // close the device we opened
|
||||
|
|
Loading…
Reference in a new issue