-
-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to clear TX buffer #60
Comments
This error happens when you don´t have a Connection to the Network. If you have It terminated right it won´t hang. I know it its a bad habit to have this kind of scenario in the code, but i haven´t had any issues with this behavior. I found some page on the web that had a janky workarround for this. |
EDIT: int ESP32SJA1000Class::endPacket() // wait for TX buffer to free int dataReg; if (_txExtended) {
} else {
} for (int i = 0; i < _txLength; i++) { if ( _loopback) { // wait for TX complete return 1; //------------------------------------------------------------- IN PROGRAM: CAN.beginPacket(id); //------------------------------------------------------------- Console: Message to send: 00 01 09 03 04 05 06 07 8 Byte 1 Buf sent! |
@Petros144 thank you, you are most helpful !!!! But, if I leave the CAN bus disconnected for at least an hour, it seems the TX buffer gets backed up. When I then reconnect a device to the CAN bus I get the " Get tx buff time out!" error. I need a way to flush the CAN bus when this happens, not even ESP.restart() can do the trick, only a power reset (or pressing reset button) can resolve the problem. |
@NeliusNDL i just had a look at the Datasheet, and I found this: /* address and bit definitions for the Command Register / //-------------------------- also see here: Example for the PeliCAN mode: Im not a professional in CAN or c++ mabe you can see some helpfull stuff here. |
@Petros144 I have added a the following line: ie note that I have also made |
Thanks to @Petros144 I was able to fix the hanging problem, however, from that point forward, I only got Send msg timeout. So I put a
and the problem was solved. |
I encountered a similar situation. |
Hi all, |
I'm surprised no fix for the MCP2515 module as this issue exists in that version also. |
Hello, it seems that these lines
// wait for TX buffer to free
while ((readRegister(REG_SR) & 0x04) != 0x04) {
yield();
}
and
// wait for TX complete
while ((readRegister(REG_SR) & 0x08) != 0x08) {
if (readRegister(REG_ECC) == 0xd9) {
modifyRegister(REG_CMR, 0x1f, 0x02); // error, abort
return 0;
}
yield();
}
can make the device hang, I think that the TX buffer is full when there is nothing connected to the bus to RX and ack the data. Then the buffer gets full and the device hangs.
How can the TX buffer be cleared ? or there should be a timeout for these while loops and then return an error code
The text was updated successfully, but these errors were encountered: