refactoring

This commit is contained in:
rusefillc 2022-04-15 09:47:12 -04:00
parent c9b18e3db4
commit 11cea53c36
1 changed files with 4 additions and 4 deletions

View File

@ -19,11 +19,13 @@ size_t TsChannelBase::read(uint8_t* buffer, size_t size) {
}
#endif
#define isBigPacket(size) ((size) > BLOCKING_FACTOR + 7)
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, "copyAndWriteSmallCrcPacket tried to transmit too large a packet")
efiAssertVoid(OBD_PCM_Processor_Fault, !isBigPacket(size), "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
@ -37,7 +39,7 @@ void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8
}
void TsChannelBase::crcAndWriteBuffer(uint8_t responseCode, size_t size) {
efiAssertVoid(OBD_PCM_Processor_Fault, size <= BLOCKING_FACTOR + 7, "crcAndWriteBuffer tried to transmit too large a packet")
efiAssertVoid(OBD_PCM_Processor_Fault, !isBigPacket(size), "crcAndWriteBuffer tried to transmit too large a packet")
auto scratchBuffer = this->scratchBuffer;
// Index 0/1 = packet size (big endian)
@ -86,8 +88,6 @@ 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);