List usb device

This commit is contained in:
2022-11-08 19:51:11 +01:00
parent 0081d219f9
commit 4809f60d2c
6 changed files with 90 additions and 8 deletions

2
.vscode/launch.json vendored
View File

@@ -8,7 +8,7 @@
"name": "(gdb) Starten", "name": "(gdb) Starten",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/build/ptprnt", "program": "${workspaceFolder}/builddir/ptprnt",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${fileDirname}", "cwd": "${fileDirname}",

77
.vscode/settings.json vendored
View File

@@ -4,5 +4,80 @@
"--background-index", "--background-index",
"--compile-commands-dir=${workspaceFolder}/builddir", "--compile-commands-dir=${workspaceFolder}/builddir",
"-std=c++17" "-std=c++17"
] ],
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
} }

View File

@@ -2,8 +2,6 @@
#include <cstdint> #include <cstdint>
#include <libusb-1.0/libusb.h>
#pragma once #pragma once
namespace ptprnt::driver { namespace ptprnt::driver {

View File

@@ -11,7 +11,8 @@ incdir = include_directories('inc')
srcs = [ srcs = [
'src/main.cpp', 'src/main.cpp',
'src/P700Driver.cpp', 'src/P700Driver.cpp',
'src/P700Printer.cpp' 'src/P700Printer.cpp',
'src/Usb.cpp'
] ]
executable( executable(

View File

@@ -8,7 +8,7 @@ namespace ptprnt::driver {
P700Driver::P700Driver(uint16_t UsbDevVendor, uint16_t UsbDevId) {} P700Driver::P700Driver(uint16_t UsbDevVendor, uint16_t UsbDevId) {}
P700Driver::~P700Driver() { P700Driver::~P700Driver() {
libusb_init(NULL);
} }
driver::info P700Driver::getInfo() { driver::info P700Driver::getInfo() {

View File

@@ -3,6 +3,7 @@
#include "IPrinter.hpp" #include "IPrinter.hpp"
#include "P700Printer.hpp" #include "P700Printer.hpp"
#include "Usb.hpp"
#include <libusb-1.0/libusb.h> #include <libusb-1.0/libusb.h>
using namespace ptprnt; using namespace ptprnt;
@@ -11,9 +12,16 @@ int main(int argc, char** argv) {
std::cout << "Hello ptprnt!" << std::endl; std::cout << "Hello ptprnt!" << std::endl;
auto driver = std::make_unique<driver::P700Driver>(); auto usb = std::make_unique<driver::Usb>();
auto devs = usb->listDevices();
for (auto dev : devs) {
}
/*auto driver = std::make_unique<driver::P700Driver>();
auto printer = std::make_unique<printer::P700Printer>(std::move(driver)); auto printer = std::make_unique<printer::P700Printer>(std::move(driver));
printer::info info = printer->getInfo(); printer::info info = printer->getInfo();*/
return 0; return 0;
} }