enfieldcat / ESP32_miniThrottle

ESP32 based JMRI WiThrottle with support for locomotives (rosters), turnouts and routes. Configurable ove serial connection. Uses Arduino IDE.
5 stars 2 forks source link

Crash after turnout operation #4

Closed ajs65 closed 1 year ago

ajs65 commented 1 year ago

Using DCC EX, system crashes after turnout has thrown/closed.

Guru Meditation Error Core 1. Panic’ed (loadprohibited) exception was unhandled

enfieldcat commented 1 year ago

Ok, thank you for you feedback. I appreciate your persistence - I'd don't get to test all permutations of the software and a simple fix/typo somewhere may have unintended consequences elsewhere.

Can you tell me a bit more? Version 0.5? Connecting over wifi to DCC-Ex, and using protocol of WiThrottle/JMRI or DCC-Ex? Running a protocol command will show this.

As usual it may take a few days for me to replicate and resolve the issue.

On Mon, 6 Feb 2023, 10:04 PM ajs65, @.***> wrote:

Using DCC EX, system crashes after turnout has thrown/closed.

Guru Meditation Error Core 1. Panic’ed (loadprohibited) exception was unhandled

— Reply to this email directly, view it on GitHub https://github.com/enfieldcat/ESP32_miniThrottle/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXKLEGBS7KHMKEU664NVNDWWC5BHANCNFSM6AAAAAAUSNAYNA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ajs65 commented 1 year ago

Latest from 2 days ago, Wi-Fi Direct connection to DCC EX. Protocol DCC Ex. If you point me to the area of source code, that you think may be the culprit, happy to try and debug on my test setup.

enfieldcat commented 1 year ago

I'd suspect the issue to be in file dispatch command.ino in the setTurnout routine. This should take parameters of index number to the internal turnout table, and a desired state. Then since you are running DCC-Ex protocol, look fo the CMD protocol == DCCEX line.

But perhaps before doing that set "debug 3" - this should give bit of a track and trace as to what subroutines you go through. Not all will be reported, but certainly to the level of set turnout they will. It may we'll be somewhere else unexpected. You'll not have to recompile to get the additional debug output.

I suspect it is likely to be something like a buffer overflow or using %s when a %c is required in forming a command string.

On Tue, 7 Feb 2023, 6:47 AM ajs65, @.***> wrote:

Latest from 2 days ago, Wi-Fi Direct connection to DCC EX. Protocol DCC Ex. If you point me to the area of source code, that you think may be the culprit, happy to try and debug on my test setup.

— Reply to this email directly, view it on GitHub https://github.com/enfieldcat/ESP32_miniThrottle/issues/4#issuecomment-1419497662, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXKLEFBU46SMBSDOHKSUO3WWE2LZANCNFSM6AAAAAAUSNAYNA . You are receiving this because you commented.Message ID: @.***>

enfieldcat commented 1 year ago

Also "dump turnout" will dump out your turnout structures, defined in static_defs.h

On Tue, 7 Feb 2023, 6:47 AM ajs65, @.***> wrote:

Latest from 2 days ago, Wi-Fi Direct connection to DCC EX. Protocol DCC Ex. If you point me to the area of source code, that you think may be the culprit, happy to try and debug on my test setup.

— Reply to this email directly, view it on GitHub https://github.com/enfieldcat/ESP32_miniThrottle/issues/4#issuecomment-1419497662, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXKLEFBU46SMBSDOHKSUO3WWE2LZANCNFSM6AAAAAAUSNAYNA . You are receiving this because you commented.Message ID: @.***>

ajs65 commented 1 year ago

dispatchCommands.ino if (routeList[n].state == '8' || routeList[n].state == '2') Fails with no routes setup, added a route it then stopped crashing at the above line.

Need to exit turnout menu, back to menu; Locomotives Routes Track Power for turnouts to operate correctly changing from THROW to CLOSE, or CLOSE to THROW doesn't work without doing this. If you stay in the turnouts list menu they will only move once to either THROW or CLOSE

enfieldcat commented 1 year ago

Ok thanks for that. It would have taken me some time to track that down given it is caused by not having any routes defined. It might only be the weekend before I get to implement a fix for it though.

On Wed, 8 Feb 2023, 5:21 AM ajs65, @.***> wrote:

dispatchCommands.ino if (routeList[n].state == '8' || routeList[n].state == '2') Fails with no routes setup, added a route it then stopped crashing at the above line.

Need to exit turnout menu, back to menu; Locomotives Routes Track Power for turnouts to operate correctly changing from THROW to CLOSE, or CLOSE to THROW doesn't work without doing this. If you stay in the turnouts list menu they will only move once to either THROW or CLOSE

— Reply to this email directly, view it on GitHub https://github.com/enfieldcat/ESP32_miniThrottle/issues/4#issuecomment-1421048858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXKLEB3JIABNZMLKN6X36LWWJZABANCNFSM6AAAAAAUSNAYNA . You are receiving this because you commented.Message ID: @.***>

enfieldcat commented 1 year ago

I think that is actually easily resolved, the loop was running against the wrong count, sould be route count not turnoutCount. Updated git repo with the following

void invalidateRoutes (int8_t turnoutNr, char state) { bool active;

for (uint8_t n=0; n<routeCount; n++) { if (xSemaphoreTake(routeSem, pdMS_TO_TICKS(TIMEOUT)) == pdTRUE) { if (routeList[n].state == '8' || routeList[n].state == '2') active = true; else active = false;

On Wed, 8 Feb 2023, 5:41 AM Trevor Alborough, @.***> wrote:

Ok thanks for that. It would have taken me some time to track that down given it is caused by not having any routes defined. It might only be the weekend before I get to implement a fix for it though.

On Wed, 8 Feb 2023, 5:21 AM ajs65, @.***> wrote:

dispatchCommands.ino if (routeList[n].state == '8' || routeList[n].state == '2') Fails with no routes setup, added a route it then stopped crashing at the above line.

Need to exit turnout menu, back to menu; Locomotives Routes Track Power for turnouts to operate correctly changing from THROW to CLOSE, or CLOSE to THROW doesn't work without doing this. If you stay in the turnouts list menu they will only move once to either THROW or CLOSE

— Reply to this email directly, view it on GitHub https://github.com/enfieldcat/ESP32_miniThrottle/issues/4#issuecomment-1421048858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIXKLEB3JIABNZMLKN6X36LWWJZABANCNFSM6AAAAAAUSNAYNA . You are receiving this because you commented.Message ID: @.***>

ajs65 commented 1 year ago

I’ll check it out over the weekend. Always happy to help debug.