This commit is contained in:
2024-01-17 18:32:06 +03:00
parent d299a1f386
commit 6b87536d8d
2 changed files with 50 additions and 55 deletions

View File

@@ -40,7 +40,7 @@ PIUSB::PIUSB(ushort vid, ushort pid): PIIODevice("", ReadWrite) {
hdev = 0;
timeout_r = timeout_w = 0;
interface_claimed = -1;
setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, "0") + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, "0"));
setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, '0') + ":" + PIString::fromNumber(pid_, 16).expandLeftTo(4, '0'));
setDeviceNumber(1);
setTimeoutRead(1000);
setTimeoutWrite(1000);
@@ -53,10 +53,8 @@ PIUSB::~PIUSB() {
}
void PIUSB::Endpoint::parse() {
synchronisation_type = NoSynchonisation;
usage_type = DataEndpoint;
direction = (Direction)((address >> 7) & 1);
transfer_type = (TransferType)(attributes & 3);
direction = (Direction)((address >> 7) & 1);
transfer_type = (TransferType)(attributes & 3);
if (transfer_type == Isochronous) {
synchronisation_type = (SynchronisationType)((attributes >> 2) & 3);
usage_type = (UsageType)((attributes >> 4) & 3);
@@ -71,6 +69,18 @@ PIUSB::Endpoint PIUSB::getEndpointByAddress(uchar address) {
}
void PIUSB::setVendorID(ushort vid) {
vid_ = vid;
setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, '0') + ':' + PIString::fromNumber(pid_, 16).expandLeftTo(4, '0'));
}
void PIUSB::setProductID(ushort pid) {
pid_ = pid;
setPath(PIString::fromNumber(vid_, 16).expandLeftTo(4, '0') + ':' + PIString::fromNumber(pid_, 16).expandLeftTo(4, '0'));
}
PIVector<PIUSB::Endpoint> PIUSB::endpointsRead() {
PIVector<Endpoint> ret;
piForeachC(Endpoint & i, eps)