Skip to content

Commit

Permalink
detect ack
Browse files Browse the repository at this point in the history
  • Loading branch information
geohot committed Jun 15, 2018
1 parent f5fab4b commit 8efa389
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions board/drivers/canbitbang.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,20 @@ void TIM4_IRQHandler(void) {
gmlan_silent_count++;
}
} else if (gmlan_silent_count == REQUIRED_SILENT_TIME) {
int retry = 0;
// in send loop
if (gmlan_sending > 0 && // not first bit
(read == 0 && pkt_stuffed[gmlan_sending-1] == 1) && // bus wrongly dominant
gmlan_sending != (gmlan_sendmax-11)) { //not ack bit
puts("GMLAN ERR: bus driven at ");
puth(gmlan_sending);
puts("\n");
retry = 1;
} else if (read == 1 && gmlan_sending == (gmlan_sendmax-11)) { // recessive during ACK
puts("GMLAN ERR: didn't recv ACK\n");
retry = 1;
}
if (retry) {
// reset sender (retry after 7 silent)
set_bitbanged_gmlan(1); // recessive
gmlan_silent_count = 0;
Expand Down

0 comments on commit 8efa389

Please sign in to comment.