Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and S88

Moderator: Moderators

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby wunger » 12.11.2015, 21:56

Bert,
can you please advise if the CAN-BUS Interface (I use CAN_UDP_gwV18d_GFP) supposed to supports as well DCC Turn-arround decoders ? I usually use MM Locos & Decoders and all works perfect. But when I try to use the Turn-arround Test Function in RR the whole interface stops working than and I can not control any MM Loco or MM Turn-arround decorders. DCC Loko Decoders work fine as well...
Regards Wolfgang
wunger
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 12.11.2015, 22:09

Hi Wolfgang,

Well it was supposed to handle DCC switch decoders. But only in the same way as MM K83 supposed to operate. Ie 8 ports for 4 devices. In any way it should not hang. Can you give some more information or better upload a trace from the Arduino serial port with UDP- and queuelogging enabled? Please upgrade first to the v25.
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 15.11.2015, 22:46

Some testing with a DCC operated accessoiry with a timed command type showed an error in the Gleisbox firmware V1.39. This in conjunction with a while statement with insufficient parenthesizes was causing a loop in the Arduino gateway. The sketch V25a contains a workaround for this issue and some other improvements (I hope). The sketch is tested with Arduino 1.6.6.
Last edited by woodyboy on 18.11.2015, 22:46, edited 2 times in total.
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby torstenSch » 18.11.2015, 10:50

Good morning Bert,

I would like to raise a different issue.
Using rocrail, CAN_UDP_gwV20a and MS2, Rocrail is configured via LAN, but from the setting like screenshot in your post "von woodyboy » 16.07.2014, 21:23."
I observe the following issue on a minimal set:
1) Powering MS2, connect CAN_UDP to Laptop via USB for seeing the Arduino monitor, than starting rocrail, start power on track (via rocrail)
2a) Switching turnout 1 via MS2 is fine, rocrail turnout lights as expected
2b) Switching turnout 1 via rocrail is fine, rocrail turnout lights as expected

but: After 2b), MS2 may be used to switch turnout 1, but rocrail will not update. Switching via Rocrail will not lead to changes on track at all. After some time, message "ERROR, device decaddr 0 type MM decaddr: 1 not found in list currentSend" will appear on CAN_UDP monitor, after that updates are taken again (some queing seems to happen).

Any clue, where to look for?

Thanks!

Brgds,

TOrsten
You do not have the required permissions to view the files attached to this post.
torstenSch
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 18.11.2015, 13:57

Hi Torsten,

Look for V25.....
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby torstenSch » 18.11.2015, 14:26

Hi Bert,

you are to fast for me :lol:

Thanks, I'll update the code to V25.

Brgds,

Torsten
torstenSch
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 18.11.2015, 22:45

Hi Torsten,

Attached V25a. This has some better DCC firmware error correction and gives some information when receiving a accessoiry command from the CAN bus. These commands are not queued because the Gleisbox receives them as well as the bridge do. So command queuing from CAN is meaningless.
Last edited by woodyboy on 21.11.2015, 23:14, edited 1 time in total.
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby torstenSch » 19.11.2015, 09:49

Hi Bert,

will try.

Do you get on this and last V25 the errors, too, if compiling unter 1.6.6?
Code: Select all
\\ads.dlh.de\Lhuser$\LPA\FRA11C_18\Homes\U070420\Documents\Arduino\CAN_UDP_gwV25a\CAN_UDP_gwV25a.ino:59:0: warning: "UDP_TX_PACKET_MAX_SIZE" redefined [enabled by default]

 #define UDP_TX_PACKET_MAX_SIZE 13

 ^

In file included from C:\Program Files\Arduino\libraries\Ethernet\src/Dhcp.h:7:0,

                 from C:\Program Files\Arduino\libraries\Ethernet\src/Ethernet.h:9,

                 from \\ads.dlh.de\Lhuser$\LPA\FRA11C_18\Homes\U070420\Documents\Arduino\CAN_UDP_gwV25a\CAN_UDP_gwV25a.ino:49:

C:\Program Files\Arduino\libraries\Ethernet\src/EthernetUdp.h:42:0: note: this is the location of the previous definition

 #define UDP_TX_PACKET_MAX_SIZE 24

 ^

\\ads.dlh.de\Lhuser$\LPA\FRA11C_18\Homes\U070420\Documents\Arduino\CAN_UDP_gwV25a\CAN_UDP_gwV25a.ino: In function 'void loop()':

\\ads.dlh.de\Lhuser$\LPA\FRA11C_18\Homes\U070420\Documents\Arduino\CAN_UDP_gwV25a\CAN_UDP_gwV25a.ino:1209:45: warning: iteration 8u invokes undefined behavior [-Waggressive-loop-optimizations]

       message.data[i] = packetRxBuffer[i + 5];

                                             ^

\\ads.dlh.de\Lhuser$\LPA\FRA11C_18\Homes\U070420\Documents\Arduino\CAN_UDP_gwV25a\CAN_UDP_gwV25a.ino:1208:5: note: containing loop

     for (int i = 0; i < 13; i++) {

     ^


I extracted all parts of the ZIP.

Thanks,

Brgds,

Torsten
torstenSch
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby torstenSch » 19.11.2015, 15:15

Hi Bert,

seems to be
line 382:
Code: Select all
  for (int i = 0; i < 8; i++) {
    message.data[i] = packetRxBuffer[i + 5];
  }
and
line 1208
Code: Select all
    for (unsigned int i = 0; i < 13; i++) {
      message.data[i] = packetRxBuffer[i + 5];
    }

Defined (and filled): byte packetRxBuffer[13]; (which doesn't match), but
data is defined byte data[8];
, but i is <13.
Shouldn't the loop be 0 to message.length?
Brgds,

Torsten
torstenSch
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby wunger » 19.11.2015, 20:28

Hello Bert,
on the issue related to using DCC turm-arround issue I mentioned few days ago.
To generate the error you just need to start the feature Switch Control (http://wiki.rocrail.net/doku.php?id=switch-ctrldlg-en) and press any buttons.
In the traced is switche Q & udp trace on as you requested. I started with switching lights on a Loco to test if all works . When I press and button on the switch test nothing happens for quitre a while. Than the error in the trace occurs and than I can control again the Loco. When I press any button once more, the Arduino stops working completly.
Regards Wolfgang
You do not have the required permissions to view the files attached to this post.
wunger
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 19.11.2015, 22:36

Hi Torsten,

Thanks for reviewing the code. Line 1208 is definitely wrong, it goes beyond the array boundary. Tomorrow I'll try to review/correct the code.
@Wolfgang, this error is solved in v25 and later.

Btw, My systems both Windows and Ubuntu neither has your reported Arduino 1.6.6 errors.
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby torstenSch » 20.11.2015, 09:22

Good morning Bert,

I use the arduino-1.6.6-windows.exe from the arduino-site, just installed, nothing changed. The issue with the e UDP_TX_PACKET_MAX_SIZE could be by exchanged libs with the new version. But I didn't change the warning settings, just plain install.

After my fixes described, the parallel changes to the turnout are handled without blockage!

Thanks for the update 25a.

Brgds,

Torsten
torstenSch
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 20.11.2015, 19:51

Attached a version with fixes as proposed by Torsten, thanks for reporting! :thumb_up: The structure name for message has slightly changed so you have to overwrite the gateway library.

BTW the message about the UDP packetsize is to free unused SRAM in the Arduino. You can ignore this message. Rocrail never sends a packet larger than 13 bytes for the MGBOX/MCS2 library.
Last edited by woodyboy on 21.11.2015, 23:17, edited 1 time in total.
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby wunger » 21.11.2015, 21:13

Hello Bert,
thanks for the new Version, but I could not get it to work.
I deleted the old Libraries and replaced with the new version and run update Libraries. I updated the IPs and than I compiled and uploaded without issues to my Arduino. But than nothing happens when I press power on on Rocrail..
The serial trace states - " No Gleisbox detected - waiting for Rocrail "...
When I loaded back Version 18 (with the related Libraries) everything works straight ahead..

Has there anything changed in the Code which could explain this issue ?

Regards Wolfgang
wunger
 

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Postby woodyboy » 21.11.2015, 23:13

Hi Wolfgang,

Maybe a stupid question, but have you reset the Arduino after uploading the sketch? My experiences are that sometimes, better: more or less, the Ethernet shield does not restart correct after uploading a new sketch. Power cycle or press the reset button at the Ethernetshield will solve this issue.

Attached the version that has passed an extended testing session this evening, it has handled nearly 34000 packets without any error. But I must confess, I don't use any DCC switch decoder.
You do not have the required permissions to view the files attached to this post.
Regards,

Bert

Equipment: Roco WLANMaus, MS2, Gleisbox 2x(separated switch & rollingstock). Ubuntu 16. Edits booster. Arduino: S88 CANbus interface & Ethernet-CANbus gateway
woodyboy
 

PreviousNext

Return to DIY Hardware