summaryrefslogtreecommitdiffstats
path: root/src/progs/icd2/base/icd2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/progs/icd2/base/icd2.cpp')
-rw-r--r--src/progs/icd2/base/icd2.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/progs/icd2/base/icd2.cpp b/src/progs/icd2/base/icd2.cpp
index 375fc60..6765340 100644
--- a/src/progs/icd2/base/icd2.cpp
+++ b/src/progs/icd2/base/icd2.cpp
@@ -57,7 +57,7 @@ Icd2::TestData::TestData()
for (uint k=0; k<Nb_VoltageTypes; k++) _voltages[k] = -1;
}
-Icd2::TestData::TestData(const QString &rx)
+Icd2::TestData::TestData(const TQString &rx)
{
for (uint k=0; k<Nb_VoltageTypes; k++)
_voltages[k] = fromHex(rx.mid(5 + 2*k, 2), 0);
@@ -70,14 +70,14 @@ bool Icd2::TestData::pass() const
return true;
}
-QString Icd2::TestData::result(VoltageType type) const
+TQString Icd2::TestData::result(VoltageType type) const
{
for (uint i=0; i<=(::Programmer::Nb_ResultTypes); i++)
if ( _voltages[type]==RESULT_TYPE_VALUES[i] ) return i18n(::Programmer::RESULT_TYPE_LABELS[i]);
return toHex(_voltages[type], 2);
}
-QString Icd2::TestData::pretty(VoltageType type) const
+TQString Icd2::TestData::pretty(VoltageType type) const
{
return i18n(VOLTAGE_LABELS[type]) + "=" + result(type);
}
@@ -136,7 +136,7 @@ bool Icd2::Hardware::uploadFirmware(const Pic::Memory &memory)
if ( !internalConnect("V") ) return false;
log(Log::LineType::Information, " Uploading firmware to ICD2...");
uint start = 0x0004, size = 0x1BFB;
- QString cmd = "10" + toHex(start, 4) + toHex(size, 4);
+ TQString cmd = "10" + toHex(start, 4) + toHex(size, 4);
if ( !command(cmd, 0) ) return false;
uint nbBytesWord = memory.device().nbBytesWord(Pic::MemoryRangeType::Code); // should be 2 for 16F876
Device::Array data = memory.arrayForWriting(Pic::MemoryRangeType::Code);
@@ -151,7 +151,7 @@ bool Icd2::Hardware::setTarget()
log(Log::DebugLevel::Normal, " Set target");
// set target family
const Icd2::Data &d = data(device().name());
- if ( !command(QString("2A") + toHex(d.famid, 2), 0) ) return false;
+ if ( !command(TQString("2A") + toHex(d.famid, 2), 0) ) return false;
// set code range end
Address end = device().range(Pic::MemoryRangeType::Code).end;
if ( device().range(Pic::MemoryRangeType::Cal).start==end ) end += 1;
@@ -167,47 +167,47 @@ bool Icd2::Hardware::setup()
// ??
_port->send("$7F00\x0D", 6);
- QString s;
+ TQString s;
if ( !_port->receive(2, s) ) return false;
if ( s!="02" ) {
- log(Log::LineType::Error, i18n("Unexpected answer ($7F00) from ICD2 (%1).").arg(s));
+ log(Log::LineType::Error, i18n("Unexpected answer ($7F00) from ICD2 (%1).").tqarg(s));
return false;
}
// ??
if ( !command("08", 2) ) return false;
if ( _rx.mid(5, 2)!="00" ) {
- log(Log::LineType::Error, i18n("Unexpected answer (08) from ICD2 (%1).").arg(_rx));
+ log(Log::LineType::Error, i18n("Unexpected answer (08) from ICD2 (%1).").tqarg(_rx));
return false;
}
return !hasError();
}
-bool Icd2::Hardware::sendCommand(const QString &s)
+bool Icd2::Hardware::sendCommand(const TQString &s)
{
//format: <LLXX....CC>
- QString cs = s.upper();
- QString tx = "<";
+ TQString cs = s.upper();
+ TQString tx = "<";
tx += toHex(cs.length() + 6, 2);
tx += cs;
uchar chk = tx[1].latin1() + tx[2].latin1();
for (uint i=0; i<uint(s.length()); i++) chk += cs[i].latin1();
tx += toHex(chk, 2);
tx += '>';
- log(Log::DebugLevel::Extra, QString("send command: '%1'").arg(tx));
- QByteArray a = toAscii(tx);
+ log(Log::DebugLevel::Extra, TQString("send command: '%1'").tqarg(tx));
+ TQByteArray a = toAscii(tx);
return _port->send(a.data(), a.count());
}
-bool Icd2::Hardware::receiveResponse(const QString &command, uint responseSize, bool poll)
+bool Icd2::Hardware::receiveResponse(const TQString &command, uint responseSize, bool poll)
{
// format: [LLXX...CC]
uint size = responseSize + 8;
if ( poll && _port->type()==PortType::USB ) {
if ( !static_cast<USBPort *>(_port)->poll(size, _rx) ) return false;
} else if ( !_port->receive(size, _rx, 180000) ) return false; // is 3 minutes enough ?? (we should really have an abort button here...)
- log(Log::DebugLevel::Extra, QString("received answer: '%1'").arg(_rx));
+ log(Log::DebugLevel::Extra, TQString("received answer: '%1'").tqarg(_rx));
if ( size!=fromHex(_rx.mid(1, 2), 0) ) {
log(Log::LineType::Error, i18n("Received length too short."));
return false;
@@ -217,12 +217,12 @@ bool Icd2::Hardware::receiveResponse(const QString &command, uint responseSize,
return false;
}
if ( _rx[0]!='[' || _rx[size-1]!=']' ) {
- log(Log::LineType::Error, i18n("Malformed string received \"%1\"").arg(_rx));
+ log(Log::LineType::Error, i18n("Malformed string received \"%1\"").tqarg(_rx));
return false;
}
if ( command.mid(0, 2)!=_rx.mid(3, 2) ) {
log(Log::LineType::Error, i18n("Wrong return value (\"%1\"; was expecting \"%2\")")
- .arg(_rx.mid(3, 2)).arg(command.mid(0, 2)));
+ .tqarg(_rx.mid(3, 2)).tqarg(command.mid(0, 2)));
return false;
}
// verify the checksum
@@ -235,7 +235,7 @@ bool Icd2::Hardware::receiveResponse(const QString &command, uint responseSize,
return true;
}
-bool Icd2::Hardware::command(const QString &command, uint responseSize)
+bool Icd2::Hardware::command(const TQString &command, uint responseSize)
{
if ( hasError() ) return false;
if ( !sendCommand(command) ) return false;
@@ -265,7 +265,7 @@ bool Icd2::Hardware::getDebugExecVersion(VersionData &version)
bool Icd2::Hardware::setTargetPowerOn(bool on)
{
- return command(QString("05") + (on ? "FF" : "00"), 0);
+ return command(TQString("05") + (on ? "FF" : "00"), 0);
}
bool Icd2::Hardware::readVoltage(Pic::VoltageType type, double &value)
@@ -299,7 +299,7 @@ bool Icd2::Hardware::getTargetMode(Pic::TargetMode &tmode)
bool Icd2::Hardware::setTargetReset(Pic::ResetMode mode)
{
- return command(QString("33") + RESET_MODE_VALUES[mode], 0);
+ return command(TQString("33") + RESET_MODE_VALUES[mode], 0);
}
bool Icd2::Hardware::selfTest(TestData &test)
@@ -314,12 +314,12 @@ bool Icd2::Hardware::readBlock(uint nbBytesWord, uint nbWords, Device::Array &da
//qDebug("readBlock %i %s", nbBytesWord, toHex(nbWords, 8).data());
// receive data
uint length = 2*nbBytesWord*nbWords+4;
- QString s;
+ TQString s;
uint i = 0;
while ( i<length ) {
uint maxSize = (_port->type()==PortType::Serial ? 2*nbBytesWord : 0x100);
- uint size = QMIN(maxSize, length-i);
- QString tmp;
+ uint size = TQMIN(maxSize, length-i);
+ TQString tmp;
if ( _port->type()==PortType::USB ) {
if ( !static_cast<USBPort *>(_port)->dataReceive(size, tmp) ) return false;
} else if ( !_port->receive(size, tmp) ) return false;
@@ -334,9 +334,9 @@ bool Icd2::Hardware::readBlock(uint nbBytesWord, uint nbWords, Device::Array &da
}
log(Log::DebugLevel::Max, "received: " + s);
data.resize(nbWords);
- Q_UINT8 chk = 0;
+ TQ_UINT8 chk = 0;
for (uint i=0; i<nbWords; i++) {
- QString ts = s.mid(1+2*nbBytesWord*i, 2*nbBytesWord);
+ TQString ts = s.mid(1+2*nbBytesWord*i, 2*nbBytesWord);
//if ( i<10 ) qDebug("%i: %s", i, ts.data());
data[i] = 0;
for (int k=nbBytesWord-1; k>=0; k--) {
@@ -346,9 +346,9 @@ bool Icd2::Hardware::readBlock(uint nbBytesWord, uint nbWords, Device::Array &da
}
}
- QString cs = s.mid(s.length()-3, 2);
+ TQString cs = s.mid(s.length()-3, 2);
if ( chk!=fromHex(cs, 0) ) {
- log(Log::LineType::Error, i18n("Bad checksum for read block: %1 (%2 expected).").arg(cs).arg(toHex(chk, 2)));
+ log(Log::LineType::Error, i18n("Bad checksum for read block: %1 (%2 expected).").tqarg(cs).tqarg(toHex(chk, 2)));
return false;
}
return true;
@@ -369,10 +369,10 @@ bool Icd2::Hardware::readMemory(Pic::MemoryRangeType type, uint wordOffset,
//qDebug("read size=%s div=%i nbBytes=%i", toHex(size, 8).data(), div, nbBytesWord);
data.resize(0);
do {
- uint size = QMIN(todo, uint(0x1000)); // addresses
+ uint size = TQMIN(todo, uint(0x1000)); // addresses
uint nb = size / inc; // word
//qDebug("read %s start=%s size=%s", Pic::MEMORY_RANGE_TYPE_DATA[type].label, toHex(start+offset, 8).data(), toHex(nb, 8).data());
- QString cmd = r + toHex(start+offset, 8) + toHex(nb/div, 8);
+ TQString cmd = r + toHex(start+offset, 8) + toHex(nb/div, 8);
if ( !command(cmd, 0) ) return false;
Device::Array pdata;
if ( !readBlock(nbBytesWord, nb, pdata) ) return false;
@@ -392,13 +392,13 @@ bool Icd2::Hardware::readMemory(Pic::MemoryRangeType type, uint wordOffset,
bool Icd2::Hardware::writeBlock(uint nbBytesWord, const Device::Array &data, uint wordIndex, uint nbWords)
{
- log(Log::DebugLevel::Extra, QString("writeBlock offset:%1 nbWords:%2 (size: %3)").arg(toHex(wordIndex, 8)).arg(toHex(nbWords, 8)).arg(toHex(data.size(), 8)));
+ log(Log::DebugLevel::Extra, TQString("writeBlock offset:%1 nbWords:%2 (size: %3)").tqarg(toHex(wordIndex, 8)).tqarg(toHex(nbWords, 8)).tqarg(toHex(data.size(), 8)));
Q_ASSERT( wordIndex+nbWords<=data.size() );
// prepare data
- QString s = "{";
+ TQString s = "{";
uchar chk = 0;
for (uint i=0; i<nbWords; i++) {
- QString ts = toHex(data[wordIndex+i], 2*nbBytesWord);
+ TQString ts = toHex(data[wordIndex+i], 2*nbBytesWord);
for (int k=nbBytesWord-1; k>=0; k--) {
//if ( i<10 || i>=nbWords-10 ) qDebug("send: %i-%i %s", i, k, ts.mid(2*k, 2).data());
s += ts.mid(2*k, 2);
@@ -414,8 +414,8 @@ bool Icd2::Hardware::writeBlock(uint nbBytesWord, const Device::Array &data, uin
while ( i<uint(s.length()) ) {
uint maxSize = (_port->description().type==PortType::Serial ? 2*nbBytesWord : 0x100);
if ( _port->description().type==PortType::Serial && i==0 ) maxSize = 1;
- uint size = QMIN(maxSize, s.length()-i);
- QByteArray a = toAscii(s);
+ uint size = TQMIN(maxSize, s.length()-i);
+ TQByteArray a = toAscii(s);
if ( _port->type()==PortType::USB ) {
if ( !static_cast<USBPort *>(_port)->dataSend(a.data()+i, size) ) return false;
} else if ( !_port->send(a.data()+i, size) ) return false;
@@ -441,10 +441,10 @@ bool Icd2::Hardware::writeMemory(Pic::MemoryRangeType type, uint wordOffset, con
uint index = 0;
//qDebug("write todo=%s div=%i nbBytes=%i dataSize=%i", toHex(todo, 8).data(), div, nbBytesWord, data.size());
do {
- uint size = QMIN(todo, uint(0x1000)); // address
+ uint size = TQMIN(todo, uint(0x1000)); // address
uint nb = size / inc; // word
//qDebug("write %s start=%s nbWords=%s", Pic::MEMORY_RANGE_TYPE_DATA[type].label, toHex(start+offset, 8).data(), toHex(nb, 8).data());
- QString cmd = w + toHex(start+offset+index, 8) + toHex(nb/div, 8);
+ TQString cmd = w + toHex(start+offset+index, 8) + toHex(nb/div, 8);
if ( !command(cmd, 0) ) return false;
if ( !writeBlock(nbBytesWord, data, index/inc, nb) ) return false;
if ( !receiveResponse(cmd, 0, false) ) return false;
@@ -482,12 +482,12 @@ bool Icd2::Hardware::resumeRun()
bool Icd2::Hardware::setWriteMode(Pic::WriteMode mode)
{
- return command(QString("4B") + WRITE_MODE_VALUES[mode], 0);
+ return command(TQString("4B") + WRITE_MODE_VALUES[mode], 0);
}
bool Icd2::Hardware::writeRegister(Address address, BitValue value, uint nbBytes)
{
- QString cmd = "1B" + toHex(address, 8) + toHex(nbBytes, 8);
+ TQString cmd = "1B" + toHex(address, 8) + toHex(nbBytes, 8);
if ( !command(cmd, 0) ) return false;
Device::Array data(nbBytes);
for (uint i=0; i<nbBytes; i++) data[nbBytes-i-1] = value.byte(i);
@@ -497,7 +497,7 @@ bool Icd2::Hardware::writeRegister(Address address, BitValue value, uint nbBytes
bool Icd2::Hardware::readRegister(Address address, BitValue &value, uint nbBytes)
{
- QString cmd = "1E" + toHex(address, 8) + toHex(nbBytes, 8);
+ TQString cmd = "1E" + toHex(address, 8) + toHex(nbBytes, 8);
if ( !command(cmd, 0) ) return false;
Device::Array data;
if ( !readBlock(1, nbBytes, data) ) return false;