Skip to content

Commit 2c3eb40

Browse files
authored
Merge pull request #34 from jxltom/jxltom-patch-1
More appropriate return code for sendMessage method
2 parents 4ab9454 + 7dbf333 commit 2c3eb40

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mcp2515.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@ MCP2515::ERROR MCP2515::sendMessage(const TXBn txbn, const struct can_frame *fra
599599

600600
modifyRegister(txbuf->CTRL, TXB_TXREQ, TXB_TXREQ);
601601

602+
uint8_t ctrl = readRegister(txbuf->CTRL);
603+
if ((ctrl & (TXB_ABTF | TXB_MLOA | TXB_TXERR)) != 0) {
604+
return ERROR_FAILTX;
605+
}
602606
return ERROR_OK;
603607
}
604608

@@ -618,7 +622,7 @@ MCP2515::ERROR MCP2515::sendMessage(const struct can_frame *frame)
618622
}
619623
}
620624

621-
return ERROR_FAILTX;
625+
return ERROR_ALLTXBUSY;
622626
}
623627

624628
MCP2515::ERROR MCP2515::readMessage(const RXBn rxbn, struct can_frame *frame)

0 commit comments

Comments
 (0)