Skip to content

Commit 48c134c

Browse files
committed
IsoTp: allow custom padding byte
1 parent c903a04 commit 48c134c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

firmware/controllers/can/isotp/isotp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ int IsoTpBase::sendFrame(const IsoTpFrameHeader &header, const uint8_t *data, in
3838

3939
int dlc = 8;
4040
CanTxMessage txmsg(CanCategory::SERIAL, txFrameId, dlc, busIndex, IS_EXT_RANGE_ID(txFrameId));
41-
41+
// fill message with padding byte
42+
for (int i = isoHeaderByteIndex; i < 8; i++) {
43+
txmsg[i] = paddingByte;
44+
}
4245
// fill the frame data according to the CAN-TP protocol (ISO 15765-2)
4346
txmsg[isoHeaderByteIndex] = (uint8_t)((header.frameType & 0xf) << 4);
4447
switch (header.frameType) {

firmware/controllers/can/isotp/isotp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ class IsoTpBase {
113113
// but some vendors add some specific data in first CAN byte
114114
size_t isoHeaderByteIndex = 0;
115115

116+
// default padding byte
117+
// Normally a "0xA" is used as padding since it will produce no stuffing bits on the CAN.
118+
uint8_t paddingByte = 0x0A;
119+
116120
ICanTransmitter *txTransport;
117121

118122
size_t busIndex;

0 commit comments

Comments
 (0)