Improve on storing hw/sw version of device controller

This commit is contained in:
Gerhard Hoffmann 2024-02-02 13:41:13 +01:00
parent fb5cf3cc6a
commit 100ada06f8

View File

@ -64,66 +64,36 @@ bool indat_isMdbOn()
void gpi_storeHWver(QString text)
{
// change Qstring to array of chars, because shared mem allowes no QString!
int nn, LL = text.length();
if (LL >= versionBufferLen)
LL=versionBufferLen-1; // leave place for termination
for (nn=0; nn<LL; nn++)
{
SharedMem::write()->indat_HWversion[nn] = text.at(nn).toLatin1();
if (qstrlen(SharedMem::read()->indat_HWversion) == 0) {
char const *p = text.toUtf8().constData();
if (qstrlen(p) > 0) {
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
memcpy(SharedMem::write()->indat_HWversion, p,
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
}
}
for (nn=LL; nn<versionBufferLen; nn++)
SharedMem::write()->indat_HWversion[nn] =0;
}
QString epi_loadHWver(void)
{
// load array of chars from SM and change to QString
int nn, LL = versionBufferLen;
char cc;
QString myStr;
myStr.clear();
for (nn=0; nn<LL; nn++)
{
cc = SharedMem::read()->indat_HWversion[nn];
myStr.append(cc);
}
return myStr;
return QString((char const*)SharedMem::read()->indat_HWversion);
}
void gpi_storeSWver(QString text)
{
int nn, LL = text.length();
if (LL >= versionBufferLen)
LL=versionBufferLen-1; // leave place for termination
for (nn=0; nn<LL; nn++)
{
SharedMem::write()->indat_SWversion[nn] = text.at(nn).toLatin1();
if (qstrlen(SharedMem::read()->indat_SWversion) == 0) {
char const *p = text.toUtf8().constData();
if (qstrlen(p) > 0) {
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
memcpy(SharedMem::write()->indat_SWversion, p,
qMin((uint)versionBufferLen, qstrlen(p)) - 1);
}
}
for (nn=LL; nn<versionBufferLen; nn++)
SharedMem::write()->indat_SWversion[nn] =0;
}
QString epi_loadSWver(void)
{
int nn, LL = versionBufferLen;
char cc;
QString myStr;
myStr.clear();
for (nn=0; nn<LL; nn++)
{
cc = SharedMem::read()->indat_SWversion[nn];
myStr.append(cc);
}
return myStr;
return QString((char const*)SharedMem::read()->indat_SWversion);
}
void gpi_storeDCstate(QString text)