diff --git a/firmware/console/binary/tunerstudio_commands.cpp b/firmware/console/binary/tunerstudio_commands.cpp index 358c453305..f720eb93e1 100644 --- a/firmware/console/binary/tunerstudio_commands.cpp +++ b/firmware/console/binary/tunerstudio_commands.cpp @@ -49,7 +49,15 @@ void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, u updateTunerStudioState(); tsChannel->assertPacketSize(count, false); // this method is invoked too often to print any debug information - tsChannel->writeCrcPacketSmall(TS_RESPONSE_OK, reinterpret_cast(&engine->outputChannels) + offset, count); + uint8_t * scratchBuffer = (uint8_t *)tsChannel->scratchBuffer; + /** + * collect data from all models + */ + copyRange(scratchBuffer + 3, + getFragments(), getFragmentsCount(), + offset, count); + + tsChannel->crcAndWriteBuffer(TS_RESPONSE_OK, count); } #endif // EFI_TUNER_STUDIO diff --git a/firmware/console/binary/tunerstudio_io.cpp b/firmware/console/binary/tunerstudio_io.cpp index 3975a4f7a5..df4129d579 100644 --- a/firmware/console/binary/tunerstudio_io.cpp +++ b/firmware/console/binary/tunerstudio_io.cpp @@ -19,11 +19,11 @@ size_t TsChannelBase::read(uint8_t* buffer, size_t size) { } #endif -void TsChannelBase::writeCrcPacketSmall(uint8_t responseCode, const uint8_t* buf, size_t size) { +void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size) { auto scratchBuffer = this->scratchBuffer; // don't transmit too large a buffer - efiAssertVoid(OBD_PCM_Processor_Fault, size <= BLOCKING_FACTOR + 7, "writeCrcPacketSmall tried to transmit too large a packet") + efiAssertVoid(OBD_PCM_Processor_Fault, size <= BLOCKING_FACTOR + 7, "copyAndWriteSmallCrcPacket tried to transmit too large a packet") // If transmitting data, copy it in to place in the scratch buffer // We want to prevent the data changing itself (higher priority threads could write @@ -33,6 +33,11 @@ void TsChannelBase::writeCrcPacketSmall(uint8_t responseCode, const uint8_t* buf memcpy(scratchBuffer + 3, buf, size); } + crcAndWriteBuffer(responseCode, size); +} + +void TsChannelBase::crcAndWriteBuffer(uint8_t responseCode, size_t size) { + auto scratchBuffer = this->scratchBuffer; // Index 0/1 = packet size (big endian) *(uint16_t*)scratchBuffer = SWAP_UINT16(size + 1); // Index 2 = response code @@ -103,7 +108,7 @@ void TsChannelBase::writeCrcPacket(uint8_t responseCode, const uint8_t* buf, siz writeCrcPacketLarge(responseCode, buf, size); } else { // for small packets we use a buffer for CRC calculation - writeCrcPacketSmall(responseCode, buf, size); + copyAndWriteSmallCrcPacket(responseCode, buf, size); } } diff --git a/firmware/console/binary/tunerstudio_io.h b/firmware/console/binary/tunerstudio_io.h index 01a5e64aa1..8debb66b2b 100644 --- a/firmware/console/binary/tunerstudio_io.h +++ b/firmware/console/binary/tunerstudio_io.h @@ -59,7 +59,8 @@ public: const char *name; void assertPacketSize(size_t size, bool allowLongPackets); - void writeCrcPacketSmall(uint8_t responseCode, const uint8_t* buf, size_t size); + void crcAndWriteBuffer(uint8_t responseCode, size_t size); + void copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size); private: void writeCrcPacketLarge(uint8_t responseCode, const uint8_t* buf, size_t size);