When receiving dynamic machine data, check if not too much data has been

received: copy only as much data as possible.
This commit is contained in:
Gerhard Hoffmann 2024-06-27 12:40:50 +02:00
parent 0dc38d8908
commit c8d7f2f904

View File

@ -1042,9 +1042,19 @@ char T_datif::loadRecDataFromFrame()
epi_setDcDataValid(); // DC-Data are valid as DC responded.
// Could be set to every response but this (31)
// is a very common and very important request
gpi_storeDynMachineConditions(RdDleng, receivedData);
gpi_storeDI_CoinAttach(receivedData[6]); // new, 14.2.24 needed for direct coin insertion
if (RdDleng > sizeof(struct T_dynamicCondition)) {
qCritical() << "!!!WARNING!!! RdDlen too high" << RdDleng;
// only use as many bytes as maximally possible
char buf[sizeof(struct T_dynamicCondition)];
memset(buf, 0, sizeof(buf));
memcpy(buf, receivedData, sizeof(struct T_dynamicCondition));
gpi_storeDynMachineConditions(buf);
} else {
gpi_storeDynMachineConditions(receivedData);
}
gpi_storeDI_CoinAttach(((struct T_dynamicCondition *)receivedData)->coinAttached); // new, 14.2.24 needed for direct coin insertion
}
/* funktioniert, ist aber nicht nötig. Signal wird nach dem shared memory erzeugt