1 /* sane - Scanner Access Now Easy. 2 3 Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt> 4 5 This file is part of the SANE package. 6 7 This program is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the 10 License, or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, but 13 WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef BACKEND_GENESYS_TEST_USB_DEVICE_H 22 #define BACKEND_GENESYS_TEST_USB_DEVICE_H 23 24 #include "usb_device.h" 25 26 namespace genesys { 27 28 class TestUsbDevice : public IUsbDevice { 29 public: 30 TestUsbDevice(std::uint16_t vendor, std::uint16_t product, std::uint16_t bcd_device); 31 ~TestUsbDevice() override; 32 33 bool is_open() const override { return is_open_; } 34 35 const std::string& name() const override { return name_; } 36 37 void open(const char* dev_name) override; 38 39 void clear_halt() override; 40 void reset() override; 41 void close() override; 42 43 std::uint16_t get_vendor_id() override; 44 std::uint16_t get_product_id() override; 45 std::uint16_t get_bcd_device() override; 46 47 void control_msg(int rtype, int reg, int value, int index, int length, 48 std::uint8_t* data) override; 49 void bulk_read(std::uint8_t* buffer, std::size_t* size) override; 50 void bulk_write(const std::uint8_t* buffer, std::size_t* size) override; 51 private: 52 void assert_is_open() const; 53 54 std::string name_; 55 bool is_open_ = false; 56 std::uint16_t vendor_ = 0; 57 std::uint16_t product_ = 0; 58 std::uint16_t bcd_device_ = 0; 59 }; 60 61 } // namespace genesys 62 63 #endif // BACKEND_GENESYS_TEST_USB_DEVICE_H 64