Skip to content

Commit

Permalink
Fixed log messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmatuschek committed May 8, 2021
1 parent f5fcc65 commit bf1d568
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/dfu_libusb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ DFUDevice::DFUDevice(unsigned vid, unsigned pid, QObject *parent)
: QObject(parent), RadioInterface(), _ctx(nullptr), _dev(nullptr), _ident(nullptr)
{
//logDebug() << "Try to detect USB DFU interface " << Qt::hex << vid << ":" << pid << ".";
logDebug() << "Try to detect USB DFU interface " << vid << ":" << pid << ".";
logDebug() << "Try to detect USB DFU interface " << QString::number(vid,16)
<< ":" << QString::number(pid,16) << ".";
int error = libusb_init(&_ctx);
if (error < 0) {
_errorMessage = tr("%1 Libusb init failed: %2 %3").arg(__func__).arg(error)
Expand All @@ -46,7 +47,7 @@ DFUDevice::DFUDevice(unsigned vid, unsigned pid, QObject *parent)
}

if (! (_dev = libusb_open_device_with_vid_pid(_ctx, vid, pid))) {
_errorMessage = tr("%1 Cannot open device %2, %3: %4 %5").arg(__func__).arg(vid).arg(pid)
_errorMessage = tr("%1 Cannot open device %2, %3: %4 %5").arg(__func__).arg(vid,0,16).arg(pid,0,16)
.arg(error).arg(libusb_strerror((enum libusb_error) error));
libusb_exit(_ctx);
_ctx = 0;
Expand Down
8 changes: 5 additions & 3 deletions lib/usbserial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ USBSerial::USBSerial(unsigned vid, unsigned pid, QObject *parent)
: QSerialPort(parent), RadioInterface(), _errorMessage()
{
//logDebug() << "Try to detect USB serial interface " << Qt::hex << vid << ":" << pid << ".";
logDebug() << "Try to detect USB serial interface " << vid << ":" << pid << ".";
logDebug() << "Try to detect USB serial interface " << QString::number(vid,16) << ":"
<< QString::number(pid,16) << ".";

// Find matching serial port by VID/PID.
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
foreach (QSerialPortInfo port, ports) {
if (port.hasProductIdentifier() && (pid == port.productIdentifier()) &&
port.hasVendorIdentifier() && (vid == port.vendorIdentifier()))
{
logDebug() << "Found serial port " << vid << ":" << pid << ": "
<< port.portName() << " '" << port.description() << "'.";
logDebug() << "Found serial port " << QString::number(vid,16) << ":"
<< QString::number(pid,16) << ": " << port.portName()
<< " '" << port.description() << "'.";
this->setPort(port);
this->setBaudRate(115200);
if (! this->open(QIODevice::ReadWrite)) {
Expand Down

0 comments on commit bf1d568

Please sign in to comment.