logging of live data structs was: data points #3614

This commit is contained in:
rusefi 2022-04-14 02:01:34 -04:00
parent b6483c2d8b
commit 7ff80dfbbc
3 changed files with 15 additions and 8 deletions

View File

@ -47,8 +47,9 @@ void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, u
tsState.outputChannelsCommandCounter++;
updateTunerStudioState();
tsChannel->assertPacketSize(count, false);
// this method is invoked too often to print any debug information
tsChannel->writeCrcPacket(TS_RESPONSE_OK, reinterpret_cast<const uint8_t*>(&engine->outputChannels) + offset, count);
tsChannel->writeCrcPacketSmall(TS_RESPONSE_OK, reinterpret_cast<const uint8_t*>(&engine->outputChannels) + offset, count);
}
#endif // EFI_TUNER_STUDIO

View File

@ -79,6 +79,14 @@ TsChannelBase::TsChannelBase(const char *name) {
this->name = name;
}
#define isBigPacket(size) ((size) > BLOCKING_FACTOR + 7)
void TsChannelBase::assertPacketSize(size_t size, bool allowLongPackets) {
if (isBigPacket(size) && !allowLongPackets) {
firmwareError(OBD_PCM_Processor_Fault, "tried to send disallowed long packet of size %d", size);
}
}
/**
* Adds size to the beginning of a packet and a crc32 at the end. Then send the packet.
*/
@ -88,13 +96,9 @@ void TsChannelBase::writeCrcPacket(uint8_t responseCode, const uint8_t* buf, siz
size = 0;
}
bool isBigPacket = size > BLOCKING_FACTOR + 7;
assertPacketSize(size, allowLongPackets);
if (isBigPacket && !allowLongPackets) {
firmwareError(OBD_PCM_Processor_Fault, "tried to send disallowed long packet of size %d", size);
}
if (isBigPacket) {
if (isBigPacket(size)) {
// for larger packets we do not use a buffer for CRC calculation meaning data is now allowed to modify while pending
writeCrcPacketLarge(responseCode, buf, size);
} else {

View File

@ -58,8 +58,10 @@ public:
char scratchBuffer[BLOCKING_FACTOR + 30];
const char *name;
private:
void assertPacketSize(size_t size, bool allowLongPackets);
void writeCrcPacketSmall(uint8_t responseCode, const uint8_t* buf, size_t size);
private:
void writeCrcPacketLarge(uint8_t responseCode, const uint8_t* buf, size_t size);
};