Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/hal/user_comps/xhc-whb04b-6/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ static int printUsage(const char* programName, const char* deviceName, bool isEr
<< " Force being silent and not printing any output except of errors. This will also inhibit messages "
"prefixed with \"init\"." << endl
<< endl
<< " -P " << endl
<< " Device ProductId in hex (defaults to 0xeb93 if omitted)." << endl
<< endl
<< "EXAMPLES" << endl
<< programName << " -ue" << endl
<< " Prints incoming USB data transfer and generated key pressed/released events." << endl
<< endl
<< programName << " -ue -P 0xeb91" << endl
<< " Same as above but for a device with a product id 'eb91'." << endl
<< endl
<< programName << " -p" << endl
<< " Prints hal pin names and events distributed to HAL memory." << endl
<< endl
Expand Down Expand Up @@ -168,7 +174,7 @@ int main(int argc, char** argv)
{
WhbComponent = new XhcWhb04b6::XhcWhb04b6Component();

const char* optargs = "phaeHuctsfBnU:v:";
const char* optargs = "phaeHuctsfBnUP:v:";
for (int opt = getopt(argc, argv, optargs); opt != -1; opt = getopt(argc, argv, optargs))
{
switch (opt)
Expand Down Expand Up @@ -221,6 +227,9 @@ int main(int argc, char** argv)
case 'h':
return printUsage(basename(argv[0]), WhbComponent->getName());
break;
case 'P':
WhbComponent->setUsbProductId(std::stoi(optarg, 0, 16));
break;
default:
return printUsage(basename(argv[0]), WhbComponent->getName(), true);
break;
Expand Down
5 changes: 5 additions & 0 deletions src/hal/user_comps/xhc-whb04b-6/usb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ void Usb::setDoReconnect(bool doReconnect)
this->mDoReconnect = doReconnect;
}
// ----------------------------------------------------------------------
void Usb::setUsbProductId(uint16_t usbProductId)
{
this->usbProductId = usbProductId;
}
// ----------------------------------------------------------------------
Usb::Usb(const char* name, OnUsbInputPackageListener& onDataReceivedCallback, Hal& hal) :
sleepState(),
inputPackageBuffer(),
Expand Down
3 changes: 2 additions & 1 deletion src/hal/user_comps/xhc-whb04b-6/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class Usb : public UsbRawInputListener
~Usb();
uint16_t getUsbVendorId() const;
uint16_t getUsbProductId() const;
void setUsbProductId(uint16_t usbProductId);
bool isDeviceOpen() const;
libusb_context** getContextReference();
libusb_context* getContext();
Expand Down Expand Up @@ -308,7 +309,7 @@ class Usb : public UsbRawInputListener

private:
const uint16_t usbVendorId{0x10ce};
const uint16_t usbProductId{0xeb93};
uint16_t usbProductId{0xeb93};
libusb_context * context{nullptr};
libusb_device_handle* deviceHandle{nullptr};
bool mDoReconnect{false};
Expand Down
5 changes: 5 additions & 0 deletions src/hal/user_comps/xhc-whb04b-6/xhc-whb04b6.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ void XhcWhb04b6Component::setWaitWithTimeout(uint8_t waitSecs)
mUsb.setWaitWithTimeout(waitSecs);
}
// ----------------------------------------------------------------------
void XhcWhb04b6Component::setUsbProductId(uint16_t usbProductId)
{
mUsb.setUsbProductId(usbProductId);
}
// ----------------------------------------------------------------------
bool XhcWhb04b6Component::isSimulationModeEnabled() const
{
return mIsSimulationMode;
Expand Down
1 change: 1 addition & 0 deletions src/hal/user_comps/xhc-whb04b-6/xhc-whb04b6.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class XhcWhb04b6Component :
void setLeadModeSpindle(bool enable);
void setLeadModeFeed(bool enable);
void setStepMode_5_10(bool enable);
void setUsbProductId(uint16_t usbProductId);

private:
const char* mName;
Expand Down
Loading