Adding Wireless Connectivity to DCC++ Mega Base Station

LMSFan72 Jan 20, 2019

  1. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    4.14+Rd060e0b
     
  2. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
    I've looked at the code and it looks ok, so I'll need to fire up the debugger and trace into it. It looks like there is something parsing the response incorrectly or possibly the DCC++ side is sending a packet that JMRI no longer accepts. Once I figure out what is going on I'll update you with the details and how to fix it.
     
  3. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
  4. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Thanks Mike.

    Separately I am just trying to get the LCD to work. I have connected the Arduino SDA, SCL, 5V and GND to the LCD. It powers up but I get nothing on the screen. I uncommented #define ENABLE_LCD in config.h. There's no documentation with the screen but the chip is printed PCF8574. I assume, therefore that the I2C address might not be 0x3F - any pointers on how I would check?
     
  5. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
  6. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Atani likes this.
  7. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
    On the Mega since that is where the LCD should be connected.
     
  8. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Great, thank you. Turns out it was on 0x27 and that I had to turn the adjuster to actually see anything on the screen!
     
    Atani likes this.
  9. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Mike, I have been playing around with this now and compared to the ESP32 system I built last week this seems more stable - the other keeps losing connection I have recently noticed. I will try and paste any error message for it on the other thread when I get to it - I am traveling for business later tonight so not around again until the weekend. So, at the moment, this looks to be my system of choice. The LCD is fairly rudimentary compared to the ESP. Do you think you will add similar OLED support to this one so it shows the current, throttles, locos...etc?
     
  10. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Typically, having said the last bit I have now seen network timeouts here too. I tried to write the TrafficMonitor to log, but nothing got logged. My WIFI network seems fine but I am seeing these and then I lose any response through JMRI:

    2019-01-28 21:27:14,045 dccpp.DCCppReply ERROR - CommTypeReply Parser called on non-CommTypeReply message type N [AWT-EventQueue-0]
    2019-01-28 21:27:14,090 dccpp.DCCppReply ERROR - CommTypeReply Parser called on non-CommTypeReply message type N [AWT-EventQueue-0]
    2019-01-28 21:27:27,806 jmrix.AbstractMonPane WARN - startLogButtonActionPerformed: getSelectedFile() returns /Users/Andrew/Library/Preferences/JMRI/monitorLog.txt monitorLog.txt [AWT-EventQueue-0]
    2019-01-28 21:27:27,806 jmrix.AbstractMonPane WARN - startLogButtonActionPerformed: is attempting to use returned file path and file name /Users/Andrew/Library/Preferences/JMRI/monitorLog.txt [AWT-EventQueue-0]
    2019-01-28 21:27:44,116 dccpp.DCCppReply ERROR - CommTypeReply Parser called on non-CommTypeReply message type N [AWT-EventQueue-0]
    2019-01-28 21:27:44,116 dccpp.DCCppReply ERROR - CommTypeReply Parser called on non-CommTypeReply message type N [AWT-EventQueue-0]
    2019-01-28 21:28:14,295 dccpp.DCCppReply ERROR - CommTypeReply Parser called on non-CommTypeReply message type N [AWT-EventQueue-0]
    2019-01-28 21:28:14,298 dccpp.DCCppReply ERROR - CommTypeReply Parser called on non-CommTypeReply message type N [AWT-EventQueue-0]
    2019-01-28 21:28:48,836 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 0 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:06,966 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 12 0 consecutive timeouts = 1 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:11,968 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 0 0 consecutive timeouts = 2 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:16,973 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 12 0 consecutive timeouts = 3 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:21,978 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 0 0 consecutive timeouts = 4 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:26,982 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: s consecutive timeouts = 5 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:31,989 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 12 0 consecutive timeouts = 6 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:36,990 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 0 0 consecutive timeouts = 7 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    2019-01-28 21:29:41,994 jmrix.AbstractMRTrafficController WARN - Timeout on reply to message: t 1 35 12 0 consecutive timeouts = 8 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
     
  11. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    It seems I then have to reset the basestation to reconnect
     
  12. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
    Highly unlikely at this point, I haven't touched the arduino code in quite some time nor have an environment to test it in at this time.

    I'd be curious to see what is on the Mega serial output, it may give a few more clues. I'm not sure what might be causing it to go offline. On the ESP32 I have seen it to be a bit picky at times but generally stable. There are a few issues in the esp32 code which I'm working on resolving but they are generally not related to the wifi connection which should automatically reconnect on disconnect. I don't think the esp8266 code has that support at this time.
     
  13. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Thanks - acknowledged on the OLED!

    When I am back I will try and capture the Mega serial monitor output.
     
  14. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    @Atani

    Hi Mike I captured in the attached text file the outputs of the JMRI console, the DCC++ Traffic Monitor and the Serial Monitor. The DCC++ traffic monitor didn't capture much because it scrolled off window.

    The station was behaving fine but generating message reply errors from 2019-02-01 08:50:43 as you can see in the text file. Loco control, however was fine. These messages appear every 30secs.

    I was running 2 locos back and forth and then I stopped them and selected address 3741. You can see at this point that the JMRI console showed it timed out. At that time the Traffic Monitor was showing the throttle commands for it still. I then lost all control - power status went to unknown when I clicked the power button

    The serial output is at the end, covering the whole session from JMRO startup to when it hung. It isn't timestamped. It is interesting that there are seemingly an ever increasing number of "X"s.

    Once it hung I called turn the basestation power on and off still via the serial port connection. However, JMRI will not reconnect without a restart of JMRI and a reset of the arduino.
     

    Attached Files:

  15. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
    The <X> in the output can mean a number of things unfortunately, in the case of responding to <s> (which JMRI sends as heartbeat) it will respond with <X> for outputs, turnouts or sensors if none are defined. It will also respond with <X> if it doesn't understand the command being sent to it.

    It is unfortunate that the serial output doesn't include the JMRI commands that were received, that looks like an omission in my implementation.

    But from the rest of the output, it looks like JMRI is not processing the <N> response correctly, this is usually sent for the connection type (IP, SERIAL, etc) and this looks like a bug. I'll need to dig into it and see what is going on.

    Code:
    2019-02-01 09:03:32,131 jmrix.AbstractMRTrafficController     WARN  - Timeout on reply to message: t 3 3741 13 1
    consecutive timeouts = 0 in network.DCCppEthernetPacketizer [network.DCCppEthernetPacketizer Transmit thread]
    
    This looks like the source of the problems, it sent a message to the Arduino and it did not get a successful response, from the output:
    Code:
    <iDCC++ BASE STATION FOR ARDUINO MEGA / ARDUINO MOTOR SHIELD: V-2.0.0 / Jan 28 2019 20:43:04><N0:SERIAL><N1: 192.168.1.111><X><X><a MAIN 41><a PROG 0><X><X><X>.....
    
    it appears that the Arduino is not happy with the formatting of the commands for some reason. On this line add "Serial.println(com);" so we can see what JMRI is sending that the Arduino is not happy about. This will also confirm that the Arduino is receiving the right messages from JMRI.
     
  16. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    I have a question: Do you have the RX & TX connections for the serial and wireless going to the same inputs on the Arduino.

    This topic has been hard to follow for me so just asking.

    Dennis
     
  17. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Thanks Mike

    @RCMan

    My connections are:

    RX->TX and TX->RX.

    I uploaded a diagram in the file last Sunday at 9:48pm on page 3 of the thread if you can find it
     
  18. RCMan

    RCMan TrainBoard Member

    271
    132
    12

    OK, Are you using the USB port to power the Mega and look at the Serial Data using the USB?

    Is the TX1 & RX1 the data input for the USB? if so then you cannot connect the WiFi data parallel to those lines unless you remove the UBS cable.
     
  19. LMSFan72

    LMSFan72 TrainBoard Member

    118
    18
    9
    Thanks RCMan. I believe it is TX0 and RX0 that the USB uses, not TX1 and RX1.
     
  20. Atani

    Atani TrainBoard Member

    1,460
    1,698
    36
    For the Mega yes, that is the case.
     

Share This Page