summaryrefslogtreecommitdiffstats
path: root/src/common/port/usb_port.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/port/usb_port.cpp')
-rw-r--r--src/common/port/usb_port.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/common/port/usb_port.cpp b/src/common/port/usb_port.cpp
index 392b483..80e7de2 100644
--- a/src/common/port/usb_port.cpp
+++ b/src/common/port/usb_port.cpp
@@ -14,7 +14,7 @@
#ifdef HAVE_USB
# include <usb.h>
#endif
-#include <qdatetime.h>
+#include <tqdatetime.h>
#include "common/common/version_data.h"
#include "common/common/number.h"
@@ -38,7 +38,7 @@ void Port::USB::initialize()
#ifdef HAVE_USB
usb_init();
VersionData vd = VersionData::fromString(LIBUSB_VERSION);
- QString s = QString("libusb %1").arg(vd.pretty());
+ TQString s = TQString("libusb %1").tqarg(vd.pretty());
if ( vd<VersionData(0, 1, 8) ) qWarning("%s: may be too old (you need at least version 0.1.8)", s.latin1());
#endif
}
@@ -79,7 +79,7 @@ bool Port::USB::findBulk(const struct usb_device *dev)
for (int a=0; a < dev->config[c].interface[i].num_altsetting; a++) {
qDebug(" Looking at altsetting %d...This altsetting has %d endpoints.", a, dev->config[c].interface[i].altsetting[a].bNumEndpoints);
for (int e=0; e < dev->config[c].interface[i].altsetting[a].bNumEndpoints; e++) {
- QString s;
+ TQString s;
s.sprintf(" Endpoint %d: Address %02xh, attributes %02xh ", e, dev->config[c].interface[i].altsetting[a].endpoint[e].bEndpointAddress, dev->config[c].interface[i].altsetting[a].endpoint[e].bmAttributes);
uchar attribs = (dev->config[c].interface[i].altsetting[a].endpoint[e].bmAttributes & 3);
switch (attribs) {
@@ -122,17 +122,17 @@ bool Port::USB::findBulk(const struct usb_device *dev)
return true;
}
-QStringList Port::USB::probedDeviceList()
+TQStringList Port::USB::probedDeviceList()
{
initialize();
- QStringList list;
+ TQStringList list;
#ifdef HAVE_USB
usb_init(); // needed ?
for (usb_bus *bus=getBusses(); bus; bus=bus->next) {
for (struct usb_device *dev=bus->devices; dev; dev=dev->next) {
if ( dev->descriptor.idVendor==0 ) continue; // controller
- list.append(QString("Vendor Id: %1 - Product Id: %2")
- .arg(toLabel(NumberBase::Hex, dev->descriptor.idVendor, 4)).arg(toLabel(NumberBase::Hex, dev->descriptor.idProduct, 4)));
+ list.append(TQString("Vendor Id: %1 - Product Id: %2")
+ .tqarg(toLabel(NumberBase::Hex, dev->descriptor.idVendor, 4)).tqarg(toLabel(NumberBase::Hex, dev->descriptor.idProduct, 4)));
}
}
#endif
@@ -176,10 +176,10 @@ Port::USB::~USB()
delete _private;
}
-void Port::USB::setSystemError(const QString &message)
+void Port::USB::setSystemError(const TQString &message)
{
#ifdef HAVE_USB
- log(Log::LineType::Error, message + QString(" (err=%1).").arg(usb_strerror()));
+ log(Log::LineType::Error, message + TQString(" (err=%1).").tqarg(usb_strerror()));
#else
log(Log::LineType::Error, message);
#endif
@@ -192,7 +192,7 @@ void Port::USB::tryToDetachDriver()
log(Log::DebugLevel::Extra, "find if there is already an installed driver");
char dname[256] = "";
if ( usb_get_driver_np(_handle, _interface, dname, 255)<0 ) return;
- log(Log::DebugLevel::Normal, QString(" a driver \"%1\" is already installed...").arg(dname));
+ log(Log::DebugLevel::Normal, TQString(" a driver \"%1\" is already installed...").tqarg(dname));
# if defined(LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP) && LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
usb_detach_kernel_driver_np(_handle, _interface);
log(Log::DebugLevel::Normal, " try to detach it...");
@@ -208,10 +208,10 @@ bool Port::USB::internalOpen()
_device = findDevice(_vendorId, _productId);
if ( _device==0 ) {
log(Log::LineType::Error, i18n("Could not find USB device (vendor=%1 product=%2).")
- .arg(toLabel(NumberBase::Hex, _vendorId, 4)).arg(toLabel(NumberBase::Hex, _productId, 4)));
+ .tqarg(toLabel(NumberBase::Hex, _vendorId, 4)).tqarg(toLabel(NumberBase::Hex, _productId, 4)));
return false;
}
- log(Log::DebugLevel::Extra, QString("found USB device as \"%1\" on bus \"%2\"").arg(_device->filename).arg(_device->bus->dirname));
+ log(Log::DebugLevel::Extra, TQString("found USB device as \"%1\" on bus \"%2\"").tqarg(_device->filename).tqarg(_device->bus->dirname));
_handle = usb_open(_device);
if ( _handle==0 ) {
setSystemError(i18n("Error opening USB device."));
@@ -239,11 +239,11 @@ bool Port::USB::internalOpen()
uint old = _config;
i = 0;
_config = _device->config[i].bConfigurationValue;
- log(Log::LineType::Warning, i18n("Configuration %1 not present: using %2").arg(old).arg(_config));
+ log(Log::LineType::Warning, i18n("Configuration %1 not present: using %2").tqarg(old).tqarg(_config));
}
const usb_config_descriptor &configd = _device->config[i];
if ( usb_set_configuration(_handle, _config)<0 ) {
- setSystemError(i18n("Error setting USB configuration %1.").arg(_config));
+ setSystemError(i18n("Error setting USB configuration %1.").tqarg(_config));
return false;
}
for (i=0; i<configd.bNumInterfaces; i++)
@@ -252,15 +252,15 @@ bool Port::USB::internalOpen()
uint old = _interface;
i = 0;
_interface = configd.interface[i].altsetting[0].bInterfaceNumber;
- log(Log::LineType::Warning, i18n("Interface %1 not present: using %2").arg(old).arg(_interface));
+ log(Log::LineType::Warning, i18n("Interface %1 not present: using %2").tqarg(old).tqarg(_interface));
}
_private->_interface = &(configd.interface[i].altsetting[0]);
if ( usb_claim_interface(_handle, _interface)<0 ) {
- setSystemError(i18n("Could not claim USB interface %1").arg(_interface));
+ setSystemError(i18n("Could not claim USB interface %1").tqarg(_interface));
return false;
}
- log(Log::DebugLevel::Max, QString("alternate setting is %1").arg(_private->_interface->bAlternateSetting));
- log(Log::DebugLevel::Max, QString("USB bcdDevice: %1").arg(toHexLabel(_device->descriptor.bcdDevice, 4)));
+ log(Log::DebugLevel::Max, TQString("alternate setting is %1").tqarg(_private->_interface->bAlternateSetting));
+ log(Log::DebugLevel::Max, TQString("USB bcdDevice: %1").tqarg(toHexLabel(_device->descriptor.bcdDevice, 4)));
return true;
#else
log(Log::LineType::Error, i18n("USB support disabled"));
@@ -284,9 +284,9 @@ bool Port::USB::sendControlMessage(const ControlMessageData &data)
{
if ( hasError() ) return false;
#ifdef HAVE_USB
- QString s = data.bytes;
+ TQString s = data.bytes;
uint length = strlen(data.bytes) / 2;
- QByteArray ba(length);
+ TQByteArray ba(length);
for (uint i=0; i<length; i++)
ba[i] = fromString(NumberBase::Hex, s.mid(2*i, 2), 0);
int res = usb_control_msg(_handle, data.type, data.request, data.value, 0, ba.data(), length, 1000); // 1s
@@ -342,10 +342,10 @@ bool Port::USB::write(uint ep, const char *data, uint size)
#ifdef HAVE_USB
IODir dir = endpointDir(ep);
EndpointMode mode = endpointMode(ep);
- log(Log::DebugLevel::LowLevel, QString("write to endpoint %1 (%2 - %3) %4 chars: \"%5\"")
- .arg(toHexLabel(ep, 2)).arg(ENDPOINT_MODE_NAMES[mode]).arg(IO_DIR_NAMES[dir]).arg(size).arg(toPrintable(data, size, PrintEscapeAll)));
+ log(Log::DebugLevel::LowLevel, TQString("write to endpoint %1 (%2 - %3) %4 chars: \"%5\"")
+ .tqarg(toHexLabel(ep, 2)).tqarg(ENDPOINT_MODE_NAMES[mode]).tqarg(IO_DIR_NAMES[dir]).tqarg(size).tqarg(toPrintable(data, size, PrintEscapeAll)));
Q_ASSERT( dir==Out );
- QTime time;
+ TQTime time;
time.start();
int todo = size;
for (;;) {
@@ -356,8 +356,8 @@ bool Port::USB::write(uint ep, const char *data, uint size)
//qDebug("res: %i", res);
if ( res==todo ) break;
if ( uint(time.elapsed())>3000 ) { // 3 s
- if ( res<0 ) setSystemError(i18n("Error sending data (ep=%1 res=%2)").arg(toHexLabel(ep, 2)).arg(res));
- else log(Log::LineType::Error, i18n("Timeout: only some data sent (%1/%2 bytes).").arg(size-todo).arg(size));
+ if ( res<0 ) setSystemError(i18n("Error sending data (ep=%1 res=%2)").tqarg(toHexLabel(ep, 2)).tqarg(res));
+ else log(Log::LineType::Error, i18n("Timeout: only some data sent (%1/%2 bytes).").tqarg(size-todo).tqarg(size));
return false;
}
if ( res==0 ) log(Log::DebugLevel::Normal, i18n("Nothing sent: retrying..."));
@@ -376,10 +376,10 @@ bool Port::USB::read(uint ep, char *data, uint size, bool *poll)
#ifdef HAVE_USB
IODir dir = endpointDir(ep);
EndpointMode mode = endpointMode(ep);
- log(Log::DebugLevel::LowLevel, QString("read from endpoint %1 (%2 - %3) %4 chars")
- .arg(toHexLabel(ep, 2)).arg(ENDPOINT_MODE_NAMES[mode]).arg(IO_DIR_NAMES[dir]).arg(size));
+ log(Log::DebugLevel::LowLevel, TQString("read from endpoint %1 (%2 - %3) %4 chars")
+ .tqarg(toHexLabel(ep, 2)).tqarg(ENDPOINT_MODE_NAMES[mode]).tqarg(IO_DIR_NAMES[dir]).tqarg(size));
Q_ASSERT( dir==In );
- QTime time;
+ TQTime time;
time.start();
int todo = size;
for (;;) {
@@ -390,8 +390,8 @@ bool Port::USB::read(uint ep, char *data, uint size, bool *poll)
//qDebug("res: %i", res);
if ( res==todo ) break;
if ( uint(time.elapsed())>3000 ) { // 3 s: seems to help icd2 in some case (?)
- if ( res<0 ) setSystemError(i18n("Error receiving data (ep=%1 res=%2)").arg(toHexLabel(ep, 2)).arg(res));
- else log(Log::LineType::Error, i18n("Timeout: only some data received (%1/%2 bytes).").arg(size-todo).arg(size));
+ if ( res<0 ) setSystemError(i18n("Error receiving data (ep=%1 res=%2)").tqarg(toHexLabel(ep, 2)).tqarg(res));
+ else log(Log::LineType::Error, i18n("Timeout: only some data received (%1/%2 bytes).").tqarg(size-todo).tqarg(size));
return false;
}
if ( res==0 ) {