summaryrefslogtreecommitdiffstats
path: root/src/common/port
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-30 00:15:53 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-30 00:15:53 +0000
commit0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 (patch)
treeb95c0ca86c4876dd139af376b9f4afd8917cf0cd /src/common/port
parentb79a2c28534cf09987eeeba3077fff9236df182a (diff)
downloadpiklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.tar.gz
piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.zip
TQt4 port piklab
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1238822 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/common/port')
-rw-r--r--src/common/port/parallel.cpp58
-rw-r--r--src/common/port/parallel.h20
-rw-r--r--src/common/port/port.cpp12
-rw-r--r--src/common/port/port.h14
-rw-r--r--src/common/port/port_base.cpp26
-rw-r--r--src/common/port/port_base.h16
-rw-r--r--src/common/port/serial.cpp78
-rw-r--r--src/common/port/serial.h30
-rw-r--r--src/common/port/usb_port.cpp60
-rw-r--r--src/common/port/usb_port.h6
10 files changed, 160 insertions, 160 deletions
diff --git a/src/common/port/parallel.cpp b/src/common/port/parallel.cpp
index 22b6a4c..d92bc82 100644
--- a/src/common/port/parallel.cpp
+++ b/src/common/port/parallel.cpp
@@ -30,9 +30,9 @@
#include "common/common/misc.h"
//-----------------------------------------------------------------------------
-QStringList *Port::Parallel::_list = 0;
+TQStringList *Port::Parallel::_list = 0;
-Port::IODirs Port::Parallel::probe(const QString &device)
+Port::IODirs Port::Parallel::probe(const TQString &device)
{
#if defined(HAVE_PPDEV)
int fd = ::open(device.latin1(), O_RDWR);
@@ -54,26 +54,26 @@ Port::IODirs Port::Parallel::probe(const QString &device)
#endif
}
-QStringList Port::Parallel::deviceList()
+TQStringList Port::Parallel::deviceList()
{
- QStringList list;
+ TQStringList list;
#if defined(HAVE_PPDEV)
// standard parport in user space
- for(int i = 0; i<8; ++i) list.append(QString("/dev/parport%1").arg(i));
+ for(int i = 0; i<8; ++i) list.append(TQString("/dev/parport%1").tqarg(i));
// new devfs parport flavour
- for(int i = 0; i<8; ++i) list.append(QString("/dev/parports/%1").arg(i));
+ for(int i = 0; i<8; ++i) list.append(TQString("/dev/parports/%1").tqarg(i));
#elif defined(HAVE_PPBUS)
// FreeBSD
- for(int i = 0; i<8; ++i) list.append(QString("/dev/ppi%1").arg(i));
+ for(int i = 0; i<8; ++i) list.append(TQString("/dev/ppi%1").tqarg(i));
#endif
return list;
}
-const QStringList &Port::Parallel::probedDeviceList()
+const TQStringList &Port::Parallel::probedDeviceList()
{
if ( _list==0 ) {
- QStringList all = deviceList();
- _list = new QStringList;
+ TQStringList all = deviceList();
+ _list = new TQStringList;
for (uint i=0; i<uint(all.count()); i++)
if( probe(all[i]) & (In | Out) ) _list->append(all[i]);
}
@@ -100,12 +100,12 @@ const Port::Parallel::PPinData Port::Parallel::PIN_DATA[Nb_Pins] = {
{ Data, 0x20, Out, "D5" }, // data 5
{ Data, 0x40, Out, "D6" }, // data 6
{ Data, 0x80, Out, "D7" }, // data 7
- { Status, 0x40, In, "/ACK" }, // !ack
- { Status, 0x80, In, "BUSY" }, // busy
- { Status, 0x20, In, "PAPER" }, // pout
- { Status, 0x10, In, "SELin" }, // select
+ { tqStatus, 0x40, In, "/ACK" }, // !ack
+ { tqStatus, 0x80, In, "BUSY" }, // busy
+ { tqStatus, 0x20, In, "PAPER" }, // pout
+ { tqStatus, 0x10, In, "SELin" }, // select
{ Control, 0x02, Out, "LF" }, // !feed
- { Status, 0x08, In, "/ERROR" }, // !error
+ { tqStatus, 0x08, In, "/ERROR" }, // !error
{ Control, 0x04, Out, "PRIME" }, // !init
{ Control, 0x08, Out, "SELout" }, // !si
{ Nb_RequestTypes, 0x00, NoIO, "GND" }, // GND
@@ -118,9 +118,9 @@ const Port::Parallel::PPinData Port::Parallel::PIN_DATA[Nb_Pins] = {
{ Nb_RequestTypes, 0x00, NoIO, "GND" } // GND
};
-QValueVector<Port::PinData> Port::Parallel::pinData(IODir dir) const
+TQValueVector<Port::PinData> Port::Parallel::pinData(IODir dir) const
{
- QValueVector<PinData> v;
+ TQValueVector<PinData> v;
for (uint i=0; i<Nb_Pins; i++) {
if ( PIN_DATA[i].dir!=dir ) continue;
PinData pd = { i, PIN_DATA[i].label };
@@ -131,7 +131,7 @@ QValueVector<Port::PinData> Port::Parallel::pinData(IODir dir) const
bool Port::Parallel::isGroundPin(uint pin) const
{
- return ( PIN_DATA[pin].label==QString("GND") );
+ return ( PIN_DATA[pin].label==TQString("GND") );
}
Port::IODir Port::Parallel::ioDir(uint pin) const
@@ -155,7 +155,7 @@ const Port::Parallel::RequestData Port::Parallel::REQUEST_DATA[Nb_RequestTypes]
#endif
};
-Port::Parallel::Parallel(const QString &device, Log::Base &base)
+Port::Parallel::Parallel(const TQString &device, Log::Base &base)
: Base(base), _fd(-1), _device(device)
{
for (uint i=0; i<Nb_RequestTypes; i++) _images[i] = 0;
@@ -166,17 +166,17 @@ bool Port::Parallel::internalOpen()
#if defined(HAVE_PPDEV)
_fd = ::open(_device.latin1(), O_RDWR);
if ( _fd<0 ) {
- setSystemError(i18n("Could not open device \"%1\"").arg(_device));
+ setSystemError(i18n("Could not open device \"%1\"").tqarg(_device));
return false;
}
if ( ioctl(_fd, PPCLAIM)<0 ) {
- setSystemError(i18n("Could not claim device \"%1\": check it is read/write enabled").arg(_device));
+ setSystemError(i18n("Could not claim device \"%1\": check it is read/write enabled").tqarg(_device));
return false;
}
#elif defined(HAVE_PPBUS)
_fd = ::open(_device.latin1(), O_RDWR);
if ( _fd<0 ) {
- setSystemError(i18n("Could not open device \"%1\"").arg(_device));
+ setSystemError(i18n("Could not open device \"%1\"").tqarg(_device));
return false;
}
#endif
@@ -203,12 +203,12 @@ bool Port::Parallel::setPinOn(uint pin, bool on, LogicType type)
Q_ASSERT( PIN_DATA[pin].dir==Out );
RequestType rtype = PIN_DATA[pin].rType;
Q_ASSERT( rtype!=Nb_RequestTypes );
- uchar mask = PIN_DATA[pin].mask;
- uchar c = (XOR(type==NegativeLogic, on) ? _images[rtype] | mask : _images[rtype] & ~mask);
+ uchar tqmask = PIN_DATA[pin].tqmask;
+ uchar c = (XOR(type==NegativeLogic, on) ? _images[rtype] | tqmask : _images[rtype] & ~tqmask);
int request = REQUEST_DATA[rtype].write;
Q_ASSERT( request!=0 );
if ( ioctl(_fd, request, &c)<0 ) {
- setSystemError(i18n("Error setting pin %1 to %2").arg(PIN_DATA[pin].label).arg(on));
+ setSystemError(i18n("Error setting pin %1 to %2").tqarg(PIN_DATA[pin].label).tqarg(on));
return false;
}
_images[rtype] = c;
@@ -228,19 +228,19 @@ bool Port::Parallel::readPin(uint pin, LogicType type, bool &value)
Q_ASSERT( request!=0 );
uchar c = 0;
if ( ioctl(_fd, request, &c)<0 ) {
- setSystemError(i18n("Error reading bit on pin %1").arg(PIN_DATA[pin].label));
+ setSystemError(i18n("Error reading bit on pin %1").tqarg(PIN_DATA[pin].label));
return false;
}
_images[rtype] = c;
- value = (type==NegativeLogic ? ~c : c ) & PIN_DATA[pin].mask;
+ value = (type==NegativeLogic ? ~c : c ) & PIN_DATA[pin].tqmask;
#endif
return true;
}
-void Port::Parallel::setSystemError(const QString &message)
+void Port::Parallel::setSystemError(const TQString &message)
{
#if defined(HAVE_PPDEV) || defined(HAVE_PPBUS)
- log(Log::LineType::Error, message + QString(" (errno=%1).").arg(strerror(errno)));
+ log(Log::LineType::Error, message + TQString(" (errno=%1).").tqarg(strerror(errno)));
#else
Q_UNUSED(message);
#endif
diff --git a/src/common/port/parallel.h b/src/common/port/parallel.h
index 1473db0..2dbfc71 100644
--- a/src/common/port/parallel.h
+++ b/src/common/port/parallel.h
@@ -22,47 +22,47 @@ namespace Port
class Parallel : public Base
{
public:
- Parallel(const QString &device, Log::Base &base);
+ Parallel(const TQString &device, Log::Base &base);
virtual ~Parallel() { close(); }
virtual Description description() const { return Description(PortType::Parallel, _device); }
- static IODirs probe(const QString &device);
- static const QStringList &probedDeviceList();
+ static IODirs probe(const TQString &device);
+ static const TQStringList &probedDeviceList();
static bool isAvailable();
enum Pin { DS = 0, D0, D1, D2, D3, D4, D5, D6, D7, ACK, BUSY, PAPER, SELin,
LF, ERROR, PRIME, SELout, P18, P19, P20, P21, P22, P23, P24, P25,
Nb_Pins };
- enum RequestType { Control = 0, Status, Data, Nb_RequestTypes };
+ enum RequestType { Control = 0, tqStatus, Data, Nb_RequestTypes };
struct PPinData {
RequestType rType;
- uchar mask;
+ uchar tqmask;
IODir dir;
const char *label;
};
static const PPinData PIN_DATA[Nb_Pins];
virtual bool setPinOn(uint pin, bool on, LogicType type);
virtual bool readPin(uint pin, LogicType type, bool &value);
- virtual QValueVector<PinData> pinData(IODir dir) const;
+ virtual TQValueVector<PinData> pinData(IODir dir) const;
virtual bool isGroundPin(uint pin) const;
virtual uint groundPin() const { return P25; }
virtual IODir ioDir(uint pin) const;
private:
int _fd;
- QString _device;
+ TQString _device;
struct RequestData {
int read, write;
};
static const RequestData REQUEST_DATA[Nb_RequestTypes];
uchar _images[Nb_RequestTypes];
- static QStringList *_list;
- static QStringList deviceList();
+ static TQStringList *_list;
+ static TQStringList deviceList();
virtual bool internalOpen();
virtual void internalClose();
- virtual void setSystemError(const QString &message);
+ virtual void setSystemError(const TQString &message);
};
} // namespace
diff --git a/src/common/port/port.cpp b/src/common/port/port.cpp
index c56c120..3df2d48 100644
--- a/src/common/port/port.cpp
+++ b/src/common/port/port.cpp
@@ -8,7 +8,7 @@
***************************************************************************/
#include "port.h"
-#if defined(Q_WS_WIN)
+#if defined(TQ_WS_WIN)
# include <sys/timeb.h>
#else
# include <sys/time.h>
@@ -65,16 +65,16 @@ const PortType::Data PortType::DATA[Nb_Types] = {
const char * const Port::IO_DIR_NAMES[3] = { "no_io", "in", "out" };
-QStringList Port::probedDeviceList(PortType type)
+TQStringList Port::probedDeviceList(PortType type)
{
- if ( !isAvailable(type) ) return QStringList();
+ if ( !isAvailable(type) ) return TQStringList();
switch (type.type()) {
case PortType::Serial: return Serial::probedDeviceList();
case PortType::Parallel: return Parallel::probedDeviceList();
case PortType::USB: return USB::probedDeviceList();
case PortType::Nb_Types: break;
}
- return QStringList();
+ return TQStringList();
}
bool Port::isAvailable(PortType type)
@@ -88,11 +88,11 @@ bool Port::isAvailable(PortType type)
return false;
}
-PortType Port::findType(const QString &portDevice)
+PortType Port::findType(const TQString &portDevice)
{
FOR_EACH(PortType, type) {
if ( !type.data().withDevice ) continue;
- if ( probedDeviceList(type).contains(portDevice) ) return type;
+ if ( probedDeviceList(type).tqcontains(portDevice) ) return type;
}
return PortType::Nb_Types;
}
diff --git a/src/common/port/port.h b/src/common/port/port.h
index f385deb..7c644cd 100644
--- a/src/common/port/port.h
+++ b/src/common/port/port.h
@@ -9,7 +9,7 @@
#ifndef PORT_H
#define PORT_H
-#include <qstringlist.h>
+#include <tqstringlist.h>
#include "common/global/global.h"
#include "common/common/key_enum.h"
@@ -34,17 +34,17 @@ extern void usleep(uint us); // in microseconds
class Description {
public:
Description() : type(PortType::Nb_Types) {}
- Description(PortType ptype, const QString &pdevice) : type(ptype), device(pdevice) {}
+ Description(PortType ptype, const TQString &pdevice) : type(ptype), device(pdevice) {}
PortType type;
- QString device;
+ TQString device;
};
enum IODir { NoIO = 0, In = 1, Out = 2 };
extern const char * const IO_DIR_NAMES[3];
- Q_DECLARE_FLAGS(IODirs, IODir)
- Q_DECLARE_OPERATORS_FOR_FLAGS(IODirs)
- extern QStringList probedDeviceList(PortType type);
- extern PortType findType(const QString &device);
+ TQ_DECLARE_FLAGS(IODirs, IODir)
+ TQ_DECLARE_OPERATORS_FOR_FLAGS(IODirs)
+ extern TQStringList probedDeviceList(PortType type);
+ extern PortType findType(const TQString &device);
extern bool isAvailable(PortType type);
struct PinData {
uint pin;
diff --git a/src/common/port/port_base.cpp b/src/common/port/port_base.cpp
index 7528eeb..0112a1b 100644
--- a/src/common/port/port_base.cpp
+++ b/src/common/port/port_base.cpp
@@ -28,31 +28,31 @@ void Port::Base::close()
bool Port::Base::send(const char *data, uint size, uint timeout)
{
- log(Log::DebugLevel::LowLevel, QString("Sending: \"%1\"").arg(toPrintable(data, size, PrintAlphaNum)));
+ log(Log::DebugLevel::LowLevel, TQString("Sending: \"%1\"").tqarg(toPrintable(data, size, PrintAlphaNum)));
return internalSend(data, size, timeout);
}
-bool Port::Base::receive(uint size, QString &s, uint timeout)
+bool Port::Base::receive(uint size, TQString &s, uint timeout)
{
- QMemArray<uchar> a;
+ TQMemArray<uchar> a;
if ( !receive(size, a, timeout) ) return false;
s.fill(0, size);
for (uint i=0; i<size; i++) s[i] = a[i];
return true;
}
-bool Port::Base::receive(uint size, QMemArray<uchar> &a, uint timeout)
+bool Port::Base::receive(uint size, TQMemArray<uchar> &a, uint timeout)
{
a.resize(size);
bool ok = internalReceive(size, (char *)a.data(), timeout);
- if (ok) log(Log::DebugLevel::LowLevel, QString("Received: \"%1\"").arg(toPrintable(a, PrintAlphaNum)));
+ if (ok) log(Log::DebugLevel::LowLevel, TQString("Received: \"%1\"").tqarg(toPrintable(a, PrintAlphaNum)));
return ok;
}
bool Port::Base::receiveChar(char &c, uint timeout)
{
if ( !internalReceive(1, &c, timeout) ) return false;
- log(Log::DebugLevel::LowLevel, QString("Received: \"%1\"").arg(toPrintable(c, PrintAlphaNum)));
+ log(Log::DebugLevel::LowLevel, TQString("Received: \"%1\"").tqarg(toPrintable(c, PrintAlphaNum)));
return true;
}
@@ -66,10 +66,10 @@ bool Port::Base::readPin(uint, LogicType, bool &)
qFatal("readPin not implemented");
return 0;
}
-QValueVector<Port::PinData> Port::Base::pinData(IODir) const
+TQValueVector<Port::PinData> Port::Base::pinData(IODir) const
{
qFatal("pinData not implemented");
- return QValueVector<PinData>();
+ return TQValueVector<PinData>();
}
bool Port::Base::isGroundPin(uint) const
{
@@ -87,22 +87,22 @@ Port::IODir Port::Base::ioDir(uint) const
return NoIO;
}
-void Port::Base::log(Log::LineType lineType, const QString &message)
+void Port::Base::log(Log::LineType lineType, const TQString &message)
{
if ( lineType==Log::LineType::Error && _closing ) return;
Log::Base::log(lineType, description().type.label() + ": " + message);
if ( lineType==Log::LineType::Error ) close();
}
-void Port::Base::log(Log::DebugLevel level, const QString &message)
+void Port::Base::log(Log::DebugLevel level, const TQString &message)
{
Log::Base::log(level, description().type.label() + ": " + message);
}
-void Port::Base::logData(const QString &)
+void Port::Base::logData(const TQString &)
{
/*
- QString vs;
+ TQString vs;
for (uint i=0; i<s.length(); i++) {
char c = s[i];
switch (c) {
@@ -113,7 +113,7 @@ void Port::Base::logData(const QString &)
default: {
if ( c>=32 && c<=126 ) vs += c;
else {
- QString tmp;
+ TQString tmp;
tmp.sprintf("\\x%02x", c);
vs += tmp;
}
diff --git a/src/common/port/port_base.h b/src/common/port/port_base.h
index 3ae4787..c48fed6 100644
--- a/src/common/port/port_base.h
+++ b/src/common/port/port_base.h
@@ -24,21 +24,21 @@ public:
bool open();
void close();
- virtual void log(Log::LineType kind, const QString &message);
- virtual void log(Log::DebugLevel level, const QString &message);
- void logData(const QString &s);
+ virtual void log(Log::LineType kind, const TQString &message);
+ virtual void log(Log::DebugLevel level, const TQString &message);
+ void logData(const TQString &s);
enum { DEFAULT_TIMEOUT = 3000 }; // 3s
bool sendChar(char c, uint timeout = DEFAULT_TIMEOUT) { return send(&c, 1, timeout); }
bool send(const char *data, uint size, uint timeout = DEFAULT_TIMEOUT);
- bool send(const QMemArray<uchar> &a, uint timeout = DEFAULT_TIMEOUT) { return send((const char *)a.data(), a.count(), timeout); }
+ bool send(const TQMemArray<uchar> &a, uint timeout = DEFAULT_TIMEOUT) { return send((const char *)a.data(), a.count(), timeout); }
bool receiveChar(char &c, uint timeout = DEFAULT_TIMEOUT);
- bool receive(uint size, QString &s, uint timeout = DEFAULT_TIMEOUT);
- bool receive(uint size, QMemArray<uchar> &a, uint timeout = DEFAULT_TIMEOUT);
+ bool receive(uint size, TQString &s, uint timeout = DEFAULT_TIMEOUT);
+ bool receive(uint size, TQMemArray<uchar> &a, uint timeout = DEFAULT_TIMEOUT);
virtual bool setPinOn(uint pin, bool on, LogicType type);
virtual bool readPin(uint pin, LogicType type, bool &value);
- virtual QValueVector<PinData> pinData(IODir dir) const;
+ virtual TQValueVector<PinData> pinData(IODir dir) const;
virtual bool isGroundPin(uint pin) const;
virtual uint groundPin() const;
virtual IODir ioDir(uint pin) const;
@@ -48,7 +48,7 @@ protected:
virtual void internalClose() = 0;
virtual bool internalSend(const char *, uint, uint) { qFatal("Not implemented"); return false; }
virtual bool internalReceive(uint, char *, uint) { qFatal("Not implemented"); return false; }
- virtual void setSystemError(const QString &message) = 0;
+ virtual void setSystemError(const TQString &message) = 0;
private:
bool _closing;
diff --git a/src/common/port/serial.cpp b/src/common/port/serial.cpp
index b370d22..5942561 100644
--- a/src/common/port/serial.cpp
+++ b/src/common/port/serial.cpp
@@ -20,17 +20,17 @@
# include <errno.h>
# include <unistd.h> // needed on some system
#endif
-#include <qdatetime.h>
+#include <tqdatetime.h>
//-----------------------------------------------------------------------------
-QStringList *Port::Serial::_list = 0;
+TQStringList *Port::Serial::_list = 0;
#if defined(Q_OS_UNIX)
const Port::Serial::Handle Port::Serial::INVALID_HANDLE = -1;
#elif defined(Q_OS_WIN)
const Port::Serial::Handle Port::Serial::INVALID_HANDLE = INVALID_HANDLE_VALUE;
#endif
-Port::Serial::Handle Port::Serial::openHandle(const QString &device, IODirs dirs)
+Port::Serial::Handle Port::Serial::openHandle(const TQString &device, IODirs dirs)
{
#if defined(Q_OS_UNIX)
// open non blocking: avoid missing DCD (comment from xwisp2)
@@ -57,7 +57,7 @@ void Port::Serial::closeHandle(Handle handle)
#endif
}
-Port::IODirs Port::Serial::probe(const QString &device)
+Port::IODirs Port::Serial::probe(const TQString &device)
{
Handle handle = openHandle(device, In);
if ( handle==INVALID_HANDLE ) return NoIO;
@@ -68,35 +68,35 @@ Port::IODirs Port::Serial::probe(const QString &device)
return (In | Out);
}
-QStringList Port::Serial::deviceList()
+TQStringList Port::Serial::deviceList()
{
- QStringList list;
+ TQStringList list;
#if defined(Q_OS_UNIX)
// standard serport in user space
- for (uint i=0; i<8; i++) list.append(QString("/dev/ttyS%1").arg(i));
+ for (uint i=0; i<8; i++) list.append(TQString("/dev/ttyS%1").tqarg(i));
// new devfs serport flavour
- for (uint i=0; i<8; i++) list.append(QString("/dev/tts/%1").arg(i));
+ for (uint i=0; i<8; i++) list.append(TQString("/dev/tts/%1").tqarg(i));
// standard USB serport in user space
- for (uint i=0; i<8; i++) list.append(QString("/dev/ttyUSB%1").arg(i));
+ for (uint i=0; i<8; i++) list.append(TQString("/dev/ttyUSB%1").tqarg(i));
// new devfs USB serport flavour
- for (uint i=0; i<8; i++) list.append(QString("/dev/usb/tts/%1").arg(i));
+ for (uint i=0; i<8; i++) list.append(TQString("/dev/usb/tts/%1").tqarg(i));
// FreeBSD
- for (uint i=0; i<8; i++) list.append(QString("/dev/ttyd%1").arg(i));
+ for (uint i=0; i<8; i++) list.append(TQString("/dev/ttyd%1").tqarg(i));
// Slackware 11 devfs USB Serial port support.
- for (uint i=0; i<8; i++) list.append(QString("/dev/tts/USB%1").arg(i));
+ for (uint i=0; i<8; i++) list.append(TQString("/dev/tts/USB%1").tqarg(i));
// MacOSX devfs USB Serial port support.
list.append("/dev/tty.usbserial");
#elif defined(Q_OS_WIN)
- for (uint i=1; i<10; i++) list.append(QString("COM%1").arg(i));
+ for (uint i=1; i<10; i++) list.append(TQString("COM%1").tqarg(i));
#endif
return list;
}
-const QStringList &Port::Serial::probedDeviceList()
+const TQStringList &Port::Serial::probedDeviceList()
{
if ( _list==0 ) {
- QStringList all = deviceList();
- _list = new QStringList;
+ TQStringList all = deviceList();
+ _list = new TQStringList;
for (uint i=0; i<uint(all.count()); i++)
if( probe(all[i]) & (In | Out) ) _list->append(all[i]);
}
@@ -130,9 +130,9 @@ const Port::Serial::SPinData Port::Serial::PIN_DATA[Nb_Pins] = {
{ Out, "RI" }
};
-QValueVector<Port::PinData> Port::Serial::pinData(IODir dir) const
+TQValueVector<Port::PinData> Port::Serial::pinData(IODir dir) const
{
- QValueVector<PinData> v;
+ TQValueVector<PinData> v;
for (uint i=0; i<Nb_Pins; i++) {
if ( PIN_DATA[i].dir!=dir ) continue;
PinData pd = { i, PIN_DATA[i].label };
@@ -142,7 +142,7 @@ QValueVector<Port::PinData> Port::Serial::pinData(IODir dir) const
}
bool Port::Serial::isGroundPin(uint pin) const
{
- return ( PIN_DATA[pin].label==QString("GND") );
+ return ( PIN_DATA[pin].label==TQString("GND") );
}
Port::IODir Port::Serial::ioDir(uint pin) const
@@ -150,7 +150,7 @@ Port::IODir Port::Serial::ioDir(uint pin) const
return PIN_DATA[pin].dir;
}
-Port::Serial::Serial(const QString &device, Properties properties, Log::Base &base)
+Port::Serial::Serial(const TQString &device, Properties properties, Log::Base &base)
: Base(base), _device(device), _properties(properties), _fd(INVALID_HANDLE)
{}
@@ -187,7 +187,7 @@ bool Port::Serial::internalOpen()
{
_fd = openHandle(_device, In | Out);
if ( _fd==INVALID_HANDLE ) {
- setSystemError(i18n("Could not open device \"%1\" read-write").arg(_device));
+ setSystemError(i18n("Could not open device \"%1\" read-write").tqarg(_device));
return false;
}
if ( !getParameters(_oldParameters) ) return false; // save configuration
@@ -216,7 +216,7 @@ void Port::Serial::internalClose()
bool Port::Serial::internalSend(const char *data, uint size, uint timeout)
{
if ( _fd==INVALID_HANDLE ) return false;
- QTime time;
+ TQTime time;
time.start();
for (uint todo=size; todo!=0; ) {
#if defined(Q_OS_UNIX)
@@ -232,7 +232,7 @@ bool Port::Serial::internalSend(const char *data, uint size, uint timeout)
if ( res>0 ) todo -= res;
else {
if ( uint(time.elapsed())>timeout ) {
- log(Log::LineType::Error, i18n("Timeout sending data (%1/%2 bytes sent).").arg(size-todo).arg(size));
+ log(Log::LineType::Error, i18n("Timeout sending data (%1/%2 bytes sent).").tqarg(size-todo).tqarg(size));
return false;
}
msleep(1);
@@ -245,7 +245,7 @@ bool Port::Serial::internalSend(const char *data, uint size, uint timeout)
bool Port::Serial::internalReceive(uint size, char *data, uint timeout)
{
if ( _fd==INVALID_HANDLE ) return false;
- QTime time;
+ TQTime time;
time.start();
for(uint todo=size; todo!=0; ) {
#if defined(Q_OS_UNIX)
@@ -277,7 +277,7 @@ bool Port::Serial::internalReceive(uint size, char *data, uint timeout)
if ( res>0 ) todo -= res;
else {
if ( uint(time.elapsed())>timeout ) {
- log(Log::LineType::Error, i18n("Timeout receiving data (%1/%2 bytes received).").arg(size-todo).arg(size));
+ log(Log::LineType::Error, i18n("Timeout receiving data (%1/%2 bytes received).").tqarg(size-todo).tqarg(size));
return false;
}
msleep(1);
@@ -292,7 +292,7 @@ bool Port::Serial::drain(uint timeout)
#if defined(Q_OS_UNIX)
// tcdrain will block if the serial cable is disconnected
// so we first check for data in output buffer...
- QTime time;
+ TQTime time;
time.start();
for (;;) {
int nb;
@@ -303,7 +303,7 @@ bool Port::Serial::drain(uint timeout)
if ( nb==0 ) break;
if ( uint(time.elapsed())>timeout ) {
_fd = INVALID_HANDLE; // otherwise close blocks...
- log(Log::LineType::Error, i18n("Timeout sending data (%1 bytes left).").arg(nb));
+ log(Log::LineType::Error, i18n("Timeout sending data (%1 bytes left).").tqarg(nb));
return false;
}
}
@@ -364,7 +364,7 @@ bool Port::Serial::setPinOn(uint pin, bool on, LogicType type)
Q_ASSERT( pin<Nb_Pins );
Q_ASSERT( PIN_DATA[pin].dir==Out );
if ( !internalSetPinOn(Pin(pin), on) ) {
- setSystemError(i18n("Error setting bit %1 of serial port to %2").arg(PIN_DATA[pin].label).arg(on));
+ setSystemError(i18n("Error setting bit %1 of serial port to %2").tqarg(PIN_DATA[pin].label).tqarg(on));
return false;
}
return true;
@@ -375,19 +375,19 @@ bool Port::Serial::internalReadPin(Pin pin, LogicType type, bool &value)
#if defined(Q_OS_UNIX)
int bits;
if ( ioctl(_fd, TIOCMGET, &bits)<0 ) return false;
- int mask = 0;
+ int tqmask = 0;
switch (pin) {
- case DCD: mask = TIOCM_CD; break;
- case RX : mask = TIOCM_SR; break;
- case DSR: mask = TIOCM_DSR; break;
- case CTS: mask = TIOCM_CTS; break;
+ case DCD: tqmask = TIOCM_CD; break;
+ case RX : tqmask = TIOCM_SR; break;
+ case DSR: tqmask = TIOCM_DSR; break;
+ case CTS: tqmask = TIOCM_CTS; break;
default: Q_ASSERT(false); return false;
}
- value = ((type==NegativeLogic ? ~bits : bits) & mask);
+ value = ((type==NegativeLogic ? ~bits : bits) & tqmask);
return true;
#elif defined(Q_OS_WIN)
DWORD status;
- if ( GetCommModemStatus(_fd, &status)==0 ) return false;
+ if ( GetCommModemtqStatus(_fd, &status)==0 ) return false;
switch (pin) {
case DCD: value = (status & MS_RLSD_ON); break;
case DSR: value = (status & MS_DSR_ON); break;
@@ -406,7 +406,7 @@ bool Port::Serial::internalReadPin(Pin pin, LogicType type, bool &value)
Q_ASSERT( pin<Nb_Pins );
Q_ASSERT( PIN_DATA[pin].dir==In );
if ( !internalReadPin(Pin(pin), type, value) ) {
- setSystemError(i18n("Error reading serial pin %1").arg(PIN_DATA[pin].label));
+ setSystemError(i18n("Error reading serial pin %1").tqarg(PIN_DATA[pin].label));
return false;
}
return true;
@@ -510,14 +510,14 @@ bool Port::Serial::setHardwareFlowControl(bool on)
return setParameters(parameters);
}
-void Port::Serial::setSystemError(const QString &message)
+void Port::Serial::setSystemError(const TQString &message)
{
#if defined(Q_OS_UNIX)
- log(Log::LineType::Error, message + QString(" (errno=%1)").arg(strerror(errno)));
+ log(Log::LineType::Error, message + TQString(" (errno=%1)").tqarg(strerror(errno)));
#elif defined(Q_OS_WIN)
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL);
- log(Log::LineType::Error, message + QString(" (last error=%1 %2)").arg(GetLastError()).arg((const char *)(LPCTSTR)lpMsgBuf));
+ log(Log::LineType::Error, message + TQString(" (last error=%1 %2)").tqarg(GetLastError()).tqarg((const char *)(LPCTSTR)lpMsgBuf));
LocalFree(lpMsgBuf);
#endif
}
diff --git a/src/common/port/serial.h b/src/common/port/serial.h
index b2911e6..9296068 100644
--- a/src/common/port/serial.h
+++ b/src/common/port/serial.h
@@ -37,21 +37,21 @@ public:
enum Property { NoProperty = 0, NeedDrain = 1, NeedFlush = 2, NeedBreak = 4,
Blocking = 8 };
- Q_DECLARE_FLAGS(Properties, Property)
+ TQ_DECLARE_FLAGS(Properties, Property)
- Serial(const QString &device, Properties properties, Log::Base &base);
+ Serial(const TQString &device, Properties properties, Log::Base &base);
virtual ~Serial() { close(); }
virtual Description description() const { return Description(PortType::Serial, _device); }
- static const QStringList &probedDeviceList();
- static IODirs probe(const QString &device);
+ static const TQStringList &probedDeviceList();
+ static IODirs probe(const TQString &device);
static bool isAvailable() { return true; }
enum InputFlag { NoInputFlag = 0, IgnoreBreak = 1, IgnoreParity = 2 };
- Q_DECLARE_FLAGS(InputFlags, InputFlag)
+ TQ_DECLARE_FLAGS(InputFlags, InputFlag)
enum ControlFlag { NoControlFlag = 0, ByteSize8 = 1, HardwareFlowControl = 2,
EnableReceiver = 4, IgnoreControlLines = 8 };
- Q_DECLARE_FLAGS(ControlFlags, ControlFlag)
+ TQ_DECLARE_FLAGS(ControlFlags, ControlFlag)
bool setMode(InputFlags inputFlags, ControlFlags controlFlags, Speed speed, uint readTimeout); // in ms
bool drain(uint timeout);
bool flush(uint timeout);
@@ -66,13 +66,13 @@ public:
static const SPinData PIN_DATA[Nb_Pins];
virtual bool setPinOn(uint pin, bool on, LogicType type);
virtual bool readPin(uint pin, LogicType type, bool &value);
- virtual QValueVector<PinData> pinData(IODir dir) const;
+ virtual TQValueVector<PinData> pinData(IODir dir) const;
virtual bool isGroundPin(uint pin) const;
virtual uint groundPin() const { return SG; }
virtual IODir ioDir(uint pin) const;
private:
- QString _device;
+ TQString _device;
Properties _properties;
#if defined(Q_OS_UNIX)
typedef int Handle;
@@ -93,20 +93,20 @@ private:
virtual void internalClose();
virtual bool internalSend(const char *data, uint size, uint timeout);
virtual bool internalReceive(uint size, char *data, uint timeout);
- virtual void setSystemError(const QString &message);
+ virtual void setSystemError(const TQString &message);
bool internalSetPinOn(Pin pin, bool on);
bool internalReadPin(Pin pin, LogicType type, bool &value);
static const Handle INVALID_HANDLE;
- static Handle openHandle(const QString &device, IODirs dirs);
+ static Handle openHandle(const TQString &device, IODirs dirs);
static void closeHandle(Handle handle);
- static QStringList *_list;
- static QStringList deviceList();
+ static TQStringList *_list;
+ static TQStringList deviceList();
static void setHardwareFlowControl(Parameters &parameters, bool on);
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(Serial::Properties)
-Q_DECLARE_OPERATORS_FOR_FLAGS(Serial::InputFlags)
-Q_DECLARE_OPERATORS_FOR_FLAGS(Serial::ControlFlags)
+TQ_DECLARE_OPERATORS_FOR_FLAGS(Serial::Properties)
+TQ_DECLARE_OPERATORS_FOR_FLAGS(Serial::InputFlags)
+TQ_DECLARE_OPERATORS_FOR_FLAGS(Serial::ControlFlags)
} // namespace
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 ) {
diff --git a/src/common/port/usb_port.h b/src/common/port/usb_port.h
index 73961cc..0da7aa1 100644
--- a/src/common/port/usb_port.h
+++ b/src/common/port/usb_port.h
@@ -27,11 +27,11 @@ class USB : public Base
public:
USB(Log::Base &base, uint vendorId, uint productId, uint config, uint interface);
virtual ~USB();
- virtual Description description() const { return Description(PortType::USB, QString::null); }
+ virtual Description description() const { return Description(PortType::USB, TQString()); }
static struct usb_device *findDevice(uint vendorId, uint productId);
static bool isAvailable();
- static QStringList probedDeviceList();
+ static TQStringList probedDeviceList();
struct ControlMessageData {
int type, request, value;
@@ -56,7 +56,7 @@ private:
virtual bool internalOpen();
virtual void internalClose();
- virtual void setSystemError(const QString &message);
+ virtual void setSystemError(const TQString &message);
void tryToDetachDriver();
static bool _initialized;