/* ptrnt - print labels on linux Copyright (C) 2023-2025 Moritz Martinius This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include #include #include #include "libusb.h" #include "libusbwrap/LibUsbTypes.hpp" namespace libusbwrap { namespace device { enum class Speed { UNKNOWN = LIBUSB_SPEED_UNKNOWN, LOW = LIBUSB_SPEED_LOW, FULL = LIBUSB_SPEED_FULL, HIGH = LIBUSB_SPEED_HIGH, SUPER = LIBUSB_SPEED_SUPER, SUPER_PLUS = LIBUSB_SPEED_SUPER_PLUS }; } // namespace device class IUsbDevice { public: virtual ~IUsbDevice() = default; virtual bool open() = 0; virtual void close() = 0; // libusb wrappers virtual bool detachKernelDriver(int interfaceNo) = 0; virtual bool claimInterface(int interfaceNo) = 0; virtual bool releaseInterface(int interfaceNo) = 0; virtual bool bulkTransfer(uint8_t endpoint, const std::vector& data, int* tx, unsigned int timeout) = 0; // getters virtual const usbId getUsbId() = 0; virtual const device::Speed getSpeed() = 0; virtual const uint8_t getBusNumber() = 0; virtual const uint8_t getPortNumber() = 0; // errors virtual const Error getLastError() = 0; virtual const std::string getLastErrorString() = 0; }; } // namespace libusbwrap