Skip to content

Commit

Permalink
Addition of BenchTest Wizard, which starts/stops bench tests
Browse files Browse the repository at this point in the history
  • Loading branch information
malcom2073 committed Nov 24, 2013
1 parent 65d7ae9 commit 8ae2e32
Show file tree
Hide file tree
Showing 8 changed files with 602 additions and 6 deletions.
507 changes: 507 additions & 0 deletions core/Wizards/BenchTest.qml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion core/core.pro
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ unix {
target.path = /usr/bin
dashboard.path = /usr/share/EMStudio/dashboards
dashboard.files += src/gauges.qml
dashboard.files += Wizards/BenchTest.qml
config.path = /usr/share/EMStudio/definitions
config.files += freeems.config.json
INSTALLS += target config dashboard
Expand Down Expand Up @@ -176,4 +177,4 @@ FORMS += src/mainwindow.ui \
SUBDIRS += plugins
OTHER_FILES += \
README.md \
wizard.qml
Wizards/BenchTest.qml
17 changes: 16 additions & 1 deletion core/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ void MainWindow::emsCommsConnected()
}
view->setFile(emsComms,wizards.absoluteFilePath(file));
view->passConfig(m_memoryMetaData->configMetaData());
view->setGeometry(0,0,400,300);
view->setGeometry(0,0,800,600);
QAction *action = new QAction(this);
action->setText(file.mid(0,file.lastIndexOf(".")));
action->setCheckable(true);
Expand Down Expand Up @@ -1635,6 +1635,21 @@ void MainWindow::interrogationComplete()
{
emsMdiWindow->show();
}
QList<unsigned char> list;
QList<unsigned short> list2;
list.append(0);
list.append(2);
list.append(4);
list.append(6);
list.append(8);
list.append(10);
list2.append(50000);
list2.append(50000);
list2.append(50000);
list2.append(50000);
list2.append(50000);
list2.append(50000);
//emsComms->startBenchTest(12,4000,10000,list,list2);
}
void MainWindow::interrogateTaskStart(QString task, int sequence)
{
Expand Down
3 changes: 3 additions & 0 deletions lib/core/emscomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class EmsComms : public QThread
virtual int getLocationIdList(unsigned char listtype, unsigned short listmask)=0;
virtual int softReset()=0;
virtual int hardReset()=0;
virtual int Q_INVOKABLE startBenchTest(unsigned char eventspercycle,unsigned short numcycles,unsigned short ticksperevent,QVariantList pineventmask,QVariantList pinmode)=0;
virtual int Q_INVOKABLE stopBenchTest()=0;
virtual int Q_INVOKABLE bumpBenchTest(unsigned char cyclenum)=0;
virtual bool sendSimplePacket(unsigned short payload)=0;
virtual void connectSerial(QString port,int baud)=0;
virtual void disconnectSerial()=0;
Expand Down
70 changes: 68 additions & 2 deletions plugins/freeems/freeemscomms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,54 @@ int FreeEmsComms::echoPacket(QByteArray packet)
m_reqListMutex.unlock();
return m_sequenceNumber-1;
}
int FreeEmsComms::startBenchTest(unsigned char eventspercycle,unsigned short numcycles,unsigned short ticksperevent,QVariantList pineventmask,QVariantList pinmode)
{
m_reqListMutex.lock();
RequestClass req;
req.type = BENCHTEST;
req.addArg(0x01,sizeof(char));
req.addArg(eventspercycle,sizeof(eventspercycle));
req.addArg(numcycles,sizeof(numcycles));
req.addArg(ticksperevent,sizeof(ticksperevent));
for (int i=0;i<pineventmask.size();i++)
{
req.addArg((unsigned char)pineventmask[i].toInt(),1);
}
for (int i=0;i<pinmode.size();i++)
{
req.addArg((unsigned short)pinmode[i].toInt(),2);
}
req.sequencenumber = m_sequenceNumber;
m_sequenceNumber++;
m_reqList.append(req);
m_reqListMutex.unlock();
return m_sequenceNumber-1;
}
int FreeEmsComms::stopBenchTest()
{
m_reqListMutex.lock();
RequestClass req;
req.type = BENCHTEST;
req.addArg(0x00,sizeof(char));
req.sequencenumber = m_sequenceNumber;
m_sequenceNumber++;
m_reqList.append(req);
m_reqListMutex.unlock();
return m_sequenceNumber-1;
}
int FreeEmsComms::bumpBenchTest(unsigned char cyclenum)
{
m_reqListMutex.lock();
RequestClass req;
req.type = BENCHTEST;
req.addArg(0x02,sizeof(char));
req.addArg(cyclenum,sizeof(cyclenum));
req.sequencenumber = m_sequenceNumber;
m_sequenceNumber++;
m_reqList.append(req);
m_reqListMutex.unlock();
}

int FreeEmsComms::getLocationIdInfo(unsigned short locationid)
{
m_reqListMutex.lock();
Expand Down Expand Up @@ -755,11 +803,11 @@ bool FreeEmsComms::sendPacket(unsigned short payloadid,QList<QVariant> arglist,Q
header.append((char)((payloadid) & 0xFF));
}
QLOG_TRACE() << "About to send packet";
if (serialPort->writeBytes(generatePacket(header,payload)) < 0)
if (serialPort->writeBytes(generatePacket(header,payload)) < 0)
{
return false;
}
QLOG_TRACE() << "Sent packet" << "0x" + QString::number(payloadid,16).toUpper();
QLOG_TRACE() << "Sent packet" << "0x" + QString::number(payloadid,16).toUpper() << header.size() << payload.size();
emit packetSent(payloadid,header,payload);
return true;
}
Expand Down Expand Up @@ -1325,6 +1373,24 @@ void FreeEmsComms::run()
}
m_waitingInfoMutex.unlock();
}
else if (m_threadReqList[i].type == BENCHTEST)
{
m_waitingInfoMutex.lock();
if (!m_waitingForResponse)
{
m_waitingForResponse = true;
m_timeoutMsecs = QDateTime::currentDateTime().currentMSecsSinceEpoch();
m_currentWaitingRequest = m_threadReqList[i];
m_payloadWaitingForResponse = BENCHTEST;
if (!sendPacket(m_threadReqList[i],true))
{
QLOG_FATAL() << "Error writing packet. Quitting thread";
return;
}
m_threadReqList.removeAt(i);
}
m_waitingInfoMutex.unlock();
}
else if (m_threadReqList[i].type == SOFT_RESET)
{
m_waitingInfoMutex.lock();
Expand Down
3 changes: 3 additions & 0 deletions plugins/freeems/freeemscomms.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class FreeEmsComms : public EmsComms
int getCompilerVersion();
int getOperatingSystem();
int echoPacket(QByteArray packet);
Q_INVOKABLE int startBenchTest(unsigned char eventspercycle,unsigned short numcycles,unsigned short ticksperevent,QVariantList pineventmask,QVariantList pinmode);
Q_INVOKABLE int stopBenchTest();
Q_INVOKABLE int bumpBenchTest(unsigned char cyclenum);
int getLocationIdList(unsigned char listtype, unsigned short listmask);
int softReset();
int hardReset();
Expand Down
1 change: 1 addition & 0 deletions plugins/freeems/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum RequestType
RETRIEVE_BLOCK_IN_RAM=0x0104,
RETRIEVE_BLOCK_IN_FLASH=0x0106,
BURN_BLOCK_FROM_RAM_TO_FLASH=0x0108,
BENCHTEST=0x8888,
GET_LOCATION_ID_LIST=0xDA5E,
GET_DECODER_NAME=0xEEEE,
GET_FIRMWARE_BUILD_DATE=0xEEF0,
Expand Down
4 changes: 2 additions & 2 deletions plugins/freeems/packetdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ void PacketDecoder::parsePacket(Packet parsedPacket)
{
if (parsedPacket.isNAK)
{
unsigned short errornum = parsedPacket.payload[0] << 8;
errornum += parsedPacket.payload[1];
unsigned short errornum = ((unsigned char)parsedPacket.payload[0]) << 8;
errornum += ((unsigned char)parsedPacket.payload[1]);
emit packetNaked(payloadid,parsedPacket.header,parsedPacket.payload,errornum);
return;
}
Expand Down

0 comments on commit 8ae2e32

Please sign in to comment.