RocNet Communications Examples?

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 04.10.2016, 13:26

Try to understand the MQTT concept before implementing something which does not fit.
Sorry, But in this case you have misunderstood (or forgotten) a detail about the MQTT data publication sequence...
If (for some unlikely reason) the QOS1 publish from Rocrail is NOT received by the Broker, RocRail needs to resend the Publication.

As you say, the MQTT Broker deals with the message but can only do this once it has received it. after this, the Broker will deal with any resends to the clients if and when they are necessary.
But, if the message is not properly received by the Broker, it cannot send it on!

I only make this point because, as you pointed out a long time ago in this conversation, you chose QoS1 for totally reliable communications, and therefore I can see that to achieve this you need to allow for the (unusual!) case where a Rocrail message to the Broker is lost, and I had assumed that your would have done this.

If you do not do this, very occasionally publications from Rocrail may be lost, and points not set, or locomotives not started / stopped... Such errors will probably be very rare, but are not totally unknown.

For my WiFi connected node, a loss when sending to the Broker is probably much more likely than when Rocrail is sending to the Broker, so I am just finishing off adding QoS1 PUBACK checks for when I send sensor event stuff to the Broker.
If we are trying to have the best performance and no communications loss, Rocrail should really check it gets the correct PUBACK for each publication, and then resend if needed.

I hope we are still friends? :beer:

Dagnall

rjversluis
Site Admin
Posts: 40970
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: RocNet Communications Examples?

Post by rjversluis » 04.10.2016, 13:55

Rocrail does not yet check if a matching PUBACK did came for a certain MsgID. (I will add it if you can force it to fail.)
Its a TCP/IP connection and not an UDP. As long as the socket connection is not OK nothing will be published to the broker.
Before you will stick in such theoretically problems you should try to get your implementation running.
WiFi & UDP is not reliable, but WiFi and TCP/IP will bring an error in case the connection is lost.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 04.10.2016, 14:19

I have seen some unexpected actions when testing, but mainly I spent about 35 years working designing safety critical hardware, so I cannot stop myself considering possible failure modes. 8) I must try to relax... its supposed to be a Hobby!.
I will tell you if I can prove a Publish fails.!!.. :wink:

We should always strive for perfection...
D

rjversluis
Site Admin
Posts: 40970
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: RocNet Communications Examples?

Post by rjversluis » 04.10.2016, 14:32

Dagnall wrote:We should always strive for perfection...
D
Of course.
But MQTT is just another protocol, which is not mentioned because its a sub library, in the long list.
I also used to develop for process automation, but you never get it 100% solid prove. (PLC's and ModBus in the 90tees)

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 04.10.2016, 14:42

Yes, I realise that this is just a very small corner of your work!...

In my past work we really did have to try for 100%.. or people would die very quickly... one failure in 1 million was the standard, but we had to try and be better than this by perhaps 10 times or more.. Proving this reliability was one reason why we never used software...

Cheers, keep up the good work!
D

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 08.10.2016, 14:51

Rob,
I was wondering if it be possible for RocRail to switch on the "retained" flag for MQQT messages it sends?

I have been completing my tests on the ESP8266 node, Static nodes seem ok so far, but the mobile nodes suffer wifi loss ( as you have also experienced).

I have built some code that positively checks that any sensor messages sent by a node are positively confirmed to have been received by the MQTT broker.
This works well even if the node loses wifi for a short time.

With the Loco, however, I have found that the loco can lose QoS1 messages sent to it if there is a connection loss.
I can stop the loco when connection is lost, but I still lose the last command to the loco.
This appears to be because the broker does not keep retrying to send, but breaks the connection to the mobile node.

To try to overcome this, I was wondering if it be possible for RocRail to switch on the "retained" flag for messages it sends? (perhaps only for sends to mobile decoders? , or as a switched/optional feature?)
With retained set, I understand that, when re-connecting, each node should get the last message for that topic.
It is not a perfect solution, but in small systems, where a loco speed message is missed because the loco is in a wifi low signal area, when it regains contact, the last speed message should be sent.

You may have thought of this already and decided against? if so , I would be interested in your reasoning.

PS, I will be giving up on the RFID tags, at ~20ms , their speed of response is just too low.
I will be moving to hall sensors for the rest of my tests.

rjversluis
Site Admin
Posts: 40970
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: RocNet Communications Examples?

Post by rjversluis » 08.10.2016, 15:02

Hi Dagnall,

I added the retain flag at publish. (11.484)
I did not test it, so report.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 08.10.2016, 17:12

I was testing 11473, so will update and report!.
Who else /which other tread / is looking at MQQT? I should read what they are doing!

rjversluis
Site Admin
Posts: 40970
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: RocNet Communications Examples?

Post by rjversluis » 08.10.2016, 18:19


Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 10.10.2016, 13:50

rjversluis wrote:Hi Dagnall,

I added the retain flag at publish. (11.484)
I did not test it, so report.
YES SIR!.. :)
The retain flag is very helpful. When I lose communications, it now helps by re-sending the last speed etc. when I get re-connected.
I also have checks in my client so that if I lose connection, I stop the motor, so the loco should only be moving when communications are working.

One possible issue with the Retain is that if one has two or more locos, the "retain" will retain whichever loco message was sent last.

If this is to have Maximum general use for systems, (such as your GCA-Pi05 ) we may therefore need to have a sub topic for each loco so each loco would get (only) its own last message, (by each loco subscribing to rocnet/lc/{LOCOID}).
This would then mean that anyone currently subscribing to "rocnet/lc" would in future have to subscribe to "rocnet/lc/#" .....which might be a problem if lots of people are currently using MQTT ??
But anyone subscribing to "rocnet/#" would be ok...

I will keep experimenting :coding: and see if I can make the system resilient enough so that it does not need the "retain" for reliable operation.

Best regards
Dagnal

rjversluis
Site Admin
Posts: 40970
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: RocNet Communications Examples?

Post by rjversluis » 10.10.2016, 14:39

Hi Dagnal,

maybe you should invest in a better WiFi Access Point to avoid communication loss.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 10.10.2016, 17:45

rjversluis wrote:Hi Dagnal,

maybe you should invest in a better WiFi Access Point to avoid communication loss.
No, I think that the one I have with some dropout zones is MUCH better for testing the concept! I can find the weakness faster! :wink:
I have a dedicated wifi router for the actual garden railway!. :)

Just waiting for some new magnets so I can test the Hall sensors. :coffee:

To be more serious.. The ESP 8266 power consumption is much higher than I anticipated. Its about 60mA, peaks 100mA+ when sending. I was thinking of solar power, but that consumption is a bit higher than can be easily supported with small panels.
On the rest of the railway, I am using CAN-GCxx modules where it s close to the terminus, but even if I dig the wires in, I have had small animals eating through the CAN+12V wiring, which Is why I wanted to experiment wire-free.

All the best

Dagnall

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: RocNet Communications Examples?

Post by Liviu M » 29.10.2016, 18:26

Hi Rob, hi Dagnall,
because is about Rocnet communication and is in English, I'm hijacking this topic. Sorry Dagnall.

Rob, as you know, I'm playing with Rocnet + mqtt and I have a (first) question about the sensor messages.
The general Rocnet message format is (copy/paste from wiki):

Code: Select all

network 	receipient 	sender 	     action                   data 	                            crc
netid 	idH 	idL 	idH 	idL 	group 	code 	length 	n data bytes 	optional for 7-bit 
The sensor message is (also thanks to Tante Wiki):

Code: Select all

code 	description 	data 1 	data 2 	data 3 	data 4 	data n 
 1 	    report 	    addrH¹ 	addrL¹ 	status 	port 	identifier (RFID)
 
I would like to know what are the sensor's message addrH & addrL good for, since the sensor "address" is the same with the sender's id.
Comparing with LocoIO, at the beginning I was thinking that the sender's id is the "board addresses" and the addrH & addrL build the sensor's address, allowing for more sensors on one board.
I suppose I can still have more sensors on one board, I should just "rethink" the addressing concept.

Thanks,
Liviu

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: RocNet Communications Examples?

Post by Liviu M » 29.10.2016, 19:44

Hi Rob,
found it, thanks.

Liviu

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: RocNet Communications Examples?

Post by Liviu M » 30.10.2016, 18:07

Hi Rob,

me again. :oops:
I'm trying to implement the query/identify reports and have some troubles to understand all the terms.
When I'm issuing a "Query" in the Rocnet programming dialog, the message Rocrail send is:

Code: Select all

Topic: rocnet/dc
Payload (8 bytes): 
              0x00 0x00 0x00 0x00 0x01 0x03 0x08 0x00 
                |    |   |    |    |    |    |    |   
                |    |   |    |    |    |    |    |   
                |    |   |    |    |    |    |    length
                |    |   |    |    |    |    code == identify 
                |    |   |    |    |    group == stationary decoder    
                |    |   |    |    srcL == Rocrail
                |    |   |    srcH == Rocrail
                |    |   destL == broadcast
                |    destH == broadcast
                netId
and the answer should be:

Code: Select all

Expected answer:                
class | manuID | versionH | versionL | nr I/O | subipH | subipL               
May you help me to "interpret" the answer? Following I'll list my interpretation; maybe you can make your comments.
1. class: no idea
2. manuID: manufacturer ID? Do you have any imposed rules for this ID (like the NMRA)?
3. versionH/versionL : board version. LocoIO has some specific version numbers. Do you have any restrictions here?
4. nr I/O: the number of ports on the board. The different programming windows in the RocNetNode menu have 8 I/Os. Is the number fixed? Should be lower than?
5. subipH/subipL: board ID? Should be the same as the senderID I'll use in building the answer?

Thanks
Liviu

Post Reply

Return to “RocNet”