Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell USB bus and address when ftdi open fails. #353

Merged
merged 1 commit into from
Jul 29, 2023
Merged
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
14 changes: 12 additions & 2 deletions src/ftdipp_mpsse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,18 @@ void FTDIpp_MPSSE::open_device(const std::string &serial, unsigned int baudrate)
ret = ftdi_usb_open_bus_addr(_ftdi, _bus, _addr);
#endif
if (ret < 0) {
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
ret, ftdi_get_error_string(_ftdi));
char description[256];
if (_bus == 0 || _addr == 0)
snprintf(description, sizeof(description), "");
else
#if (FTDI_VERSION < 104)
snprintf(description, sizeof(description), "");
#else
snprintf(description, sizeof(description), " (USB bus %d addr %d)",
_bus, _addr);
#endif
fprintf(stderr, "unable to open ftdi device: %d (%s)%s\n",
ret, ftdi_get_error_string(_ftdi), description);
ftdi_free(_ftdi);
throw std::runtime_error("unable to open ftdi device");
}
Expand Down
Loading