@@ -20,38 +20,37 @@ int IsoTpBase::sendFrame(const IsoTpFrameHeader &header, const uint8_t *data, in
2020
2121 // fill the frame data according to the CAN-TP protocol (ISO 15765-2)
2222 txmsg[isoHeaderByteIndex] = (uint8_t )((header.frameType & 0xf ) << 4 );
23- int offset, maxNumBytes ;
23+ int offset, numBytes ;
2424 switch (header.frameType ) {
2525 case ISO_TP_FRAME_SINGLE :
2626 offset = isoHeaderByteIndex + 1 ;
27- maxNumBytes = minI (header. numBytes , dlc - offset);
28- txmsg[isoHeaderByteIndex] |= maxNumBytes ;
27+ numBytes = minI (num , dlc - offset);
28+ txmsg[isoHeaderByteIndex] |= numBytes ;
2929 break ;
3030 case ISO_TP_FRAME_FIRST :
3131 txmsg[isoHeaderByteIndex] |= (header.numBytes >> 8 ) & 0xf ;
3232 txmsg[isoHeaderByteIndex + 1 ] = (uint8_t )(header.numBytes & 0xff );
3333 offset = isoHeaderByteIndex + 2 ;
34- maxNumBytes = minI (header. numBytes , dlc - offset);
34+ numBytes = minI (num , dlc - offset);
3535 break ;
3636 case ISO_TP_FRAME_CONSECUTIVE :
3737 txmsg[isoHeaderByteIndex] |= header.index & 0xf ;
3838 offset = isoHeaderByteIndex + 1 ;
3939 // todo: is it correct?
40- maxNumBytes = dlc - offset;
40+ numBytes = minI (num, dlc - offset) ;
4141 break ;
4242 case ISO_TP_FRAME_FLOW_CONTROL :
4343 txmsg[isoHeaderByteIndex] |= header.fcFlag & 0xf ;
4444 txmsg[isoHeaderByteIndex + 1 ] = (uint8_t )(header.blockSize );
4545 txmsg[isoHeaderByteIndex + 2 ] = (uint8_t )(header.separationTime );
46- offset = isoHeaderByteIndex + 3 ;
47- maxNumBytes = 0 ; // no data is sent with 'flow control' frame
46+ offset = isoHeaderByteIndex + 3 ; // actually don't care
47+ numBytes = 0 ; // no data is sent with 'flow control' frame
4848 break ;
4949 default :
5050 // bad frame type
5151 return 0 ;
5252 }
5353
54- int numBytes = minI (maxNumBytes, num);
5554 // copy the contents
5655 if (data != nullptr ) {
5756 for (int i = 0 ; i < numBytes; i++) {
@@ -200,7 +199,6 @@ int CanStreamerState::sendDataTimeout(const uint8_t *txbuf, int numBytes, can_sy
200199 int numSent = IsoTpBase::sendFrame (header, txbuf + offset, numBytes, timeout);
201200 offset += numSent;
202201 numBytes -= numSent;
203- int totalNumSent = numSent;
204202
205203 // get a flow control (FC) frame
206204#if !EFI_UNIT_TEST // todo: add FC to unit-tests?
@@ -252,11 +250,10 @@ int CanStreamerState::sendDataTimeout(const uint8_t *txbuf, int numBytes, can_sy
252250 numSent = IsoTpBase::sendFrame (header, txbuf + offset, len, timeout);
253251 if (numSent < 1 )
254252 break ;
255- totalNumSent += numSent;
256253 offset += numSent;
257254 numBytes -= numSent;
258255 }
259- return totalNumSent ;
256+ return offset ;
260257}
261258
262259int CanStreamerState::getDataFromFifo (uint8_t *rxbuf, size_t &numBytes) {
0 commit comments