Skip to content
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

esp32 hangs on CAN.endPacket(); #10

Open
creativtransfer opened this issue Nov 18, 2018 · 9 comments
Open

esp32 hangs on CAN.endPacket(); #10

creativtransfer opened this issue Nov 18, 2018 · 9 comments

Comments

@creativtransfer
Copy link

I have no transceiver attached and when sending a packet, the ESP32 hangs upon executing CAN.endPacket();

Also when configured for loopback mode.

Which ESP32 Version do you use?

@creativtransfer creativtransfer changed the title esp32 crashes on CAN.endPacket() esp32 hangs on CAN.endPacket(); Nov 19, 2018
@stiebel
Copy link

stiebel commented Nov 28, 2018

I have the same problem.
with no receiver CAN.endPacket() should return an error but hangs instead.
Same problem when sending RTR - hangs instead of returning error.
If not to fix I at least need a workaround.
I work with a couple of WROOM32

@noiasca
Copy link

noiasca commented Dec 21, 2018

Same here. Without transceiver ESP32 hangs in the
while ((readRegister(REG_SR) & 0x08) != 0x08) {
and doesn't get beyond row 226

@noiasca
Copy link

noiasca commented Jan 8, 2019

to get an error and avoid hanging of the lib i found a workaround and added an errorhandling based on my returncodes.

extend the while loop in file ESP32JA1000.cpp row 219:

// wait for TX complete
while ((readRegister(REG_SR) & 0x08) != 0x08) { // 0000‭1000‬ Transmission complete status. 0 = incomplete
//Serial.print(F("D220 REG_SR:")); Serial.print(readRegister(REG_SR)); Serial.print(F(" REG_ECC:")); Serial.println(readRegister(REG_ECC));
if (readRegister(REG_ECC) == 0xd9) { // 217=‭11011001‬
modifyRegister(REG_CMR, 0x1f, 0x02); // error, abort
return 0;
}
if (readRegister(REG_SR) == 0x30) { // e.g. if no transceiver is connected REG_SR=48 (‭0b00110000‬) ECC=0
modifyRegister(REG_CMR, 0x1f, 0x02); // error, abort
Serial.print(F("D227 abort ")); Serial.println(readRegister(REG_SR));
return 0;
}
yield();
}

@NeliusNDL
Copy link

to get an error and avoid hanging of the lib i found a workaround and added an errorhandling based on my returncodes.

extend the while loop in file ESP32JA1000.cpp row 219:

// wait for TX complete
while ((readRegister(REG_SR) & 0x08) != 0x08) { // 0000‭1000‬ Transmission complete status. 0 = incomplete
//Serial.print(F("D220 REG_SR:")); Serial.print(readRegister(REG_SR)); Serial.print(F(" REG_ECC:")); Serial.println(readRegister(REG_ECC));
if (readRegister(REG_ECC) == 0xd9) { // 217=‭11011001‬
modifyRegister(REG_CMR, 0x1f, 0x02); // error, abort
return 0;
}
if (readRegister(REG_SR) == 0x30) { // e.g. if no transceiver is connected REG_SR=48 (‭0b00110000‬) ECC=0
modifyRegister(REG_CMR, 0x1f, 0x02); // error, abort
Serial.print(F("D227 abort ")); Serial.println(readRegister(REG_SR));
return 0;
}
yield();
}

Thanks for this. I'll give it a try as I have the same problem. Is this still the best way to do it? Any updates to the libraries? Any better CAN bus library?

@noiasca
Copy link

noiasca commented Nov 1, 2020

I don't see a change in the lib, so i guess this workaround still works.

@DNThomas
Copy link

I have a transceiver attached (SN65HVD230). When plugged into a vehicle CAN bus, the lib performs as expected. When unplugged from the vehicle , it still hangs at the CAN.endPacket(); even with the above workaround.

I ended up just putting a timeout in place instead and that seems to work.

@ghost
Copy link

ghost commented Mar 16, 2021

I have the same error but Im not sure if the transceiver is connected. it should but I can't verify it.

@NeliusNDL
Copy link

look at this for a solution
#60 (comment)

@zengfanfan
Copy link

os this lib is out of maintenance ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants