gpi_storeHW/SWver(): store passed parameter ('QString text') in shared memory.
This commit is contained in:
parent
a63e7018a4
commit
35f7d56c2a
@ -6,6 +6,8 @@
|
|||||||
#include "shared_mem_buffer.h"
|
#include "shared_mem_buffer.h"
|
||||||
#include "datei.h"
|
#include "datei.h"
|
||||||
|
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||||
|
|
||||||
@ -64,40 +66,64 @@ bool indat_isMdbOn()
|
|||||||
|
|
||||||
void gpi_storeHWver(QString text)
|
void gpi_storeHWver(QString text)
|
||||||
{
|
{
|
||||||
QString hwVersion((char const *)SharedMem::read()->indat_HWversion);
|
QString prev(QByteArray(SharedMem::read()->indat_HWversion, versionBufferLen-1));
|
||||||
if (hwVersion != text) {
|
prev = prev.trimmed();
|
||||||
char const *p = text.toUtf8().constData();
|
|
||||||
if (qstrlen(p) > 0) {
|
QString const textTruncated = text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||||
|
|
||||||
|
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||||
|
&& textTruncated != prev) {
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||||
|
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||||
|
if (!string.isEmpty()) {
|
||||||
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
|
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
|
||||||
memcpy(SharedMem::write()->indat_HWversion, p,
|
char *p = (char *)SharedMem::write()->indat_HWversion;
|
||||||
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
|
char *q = (char *)string.constData();
|
||||||
|
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||||
|
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||||
|
if (q[j]) {
|
||||||
|
*p++ = q[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qCritical() << "Changed" << hwVersion << "to" << epi_loadHWver();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString epi_loadHWver(void)
|
QString epi_loadHWver(void)
|
||||||
{
|
{
|
||||||
return QString((char const*)SharedMem::read()->indat_HWversion);
|
QString text(SharedMem::read()->indat_HWversion);
|
||||||
|
return text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_storeSWver(QString text)
|
void gpi_storeSWver(QString text)
|
||||||
{
|
{
|
||||||
QString swVersion((char const *)SharedMem::read()->indat_SWversion);
|
QString prev(QByteArray(SharedMem::read()->indat_SWversion, 12));
|
||||||
if (swVersion != text) {
|
prev = prev.trimmed();
|
||||||
char const *p = text.toUtf8().constData();
|
|
||||||
if (qstrlen(p) > 0) {
|
QString const textTruncated = text.mid(0, qMin(12, text.size())).trimmed();
|
||||||
|
|
||||||
|
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||||
|
&& textTruncated != prev) {
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||||
|
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||||
|
if (!string.isEmpty()) {
|
||||||
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
|
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
|
||||||
memcpy(SharedMem::write()->indat_SWversion, p,
|
char *p = (char *)SharedMem::write()->indat_SWversion;
|
||||||
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
|
char *q = (char *)string.constData();
|
||||||
|
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||||
|
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||||
|
if (q[j]) {
|
||||||
|
*p++ = q[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qCritical() << "Changed" << swVersion << "to" << epi_loadSWver();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString epi_loadSWver(void)
|
QString epi_loadSWver(void)
|
||||||
{
|
{
|
||||||
return QString((char const*)SharedMem::read()->indat_SWversion);
|
QString text(SharedMem::read()->indat_SWversion);
|
||||||
|
return text.mid(0, qMin(12, text.size())).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_storeDCstate(QString text)
|
void gpi_storeDCstate(QString text)
|
||||||
@ -2177,8 +2203,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
|
|||||||
SharedMem::write()->Sdata_LengthRawData=lrd;
|
SharedMem::write()->Sdata_LengthRawData=lrd;
|
||||||
for (nn=0; nn<lrd; nn++)
|
for (nn=0; nn<lrd; nn++)
|
||||||
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
|
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
|
||||||
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
|
||||||
|
|
||||||
|
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
||||||
|
Loading…
Reference in New Issue
Block a user