RocNet Communications Examples?

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

Re: RocNet Communications Examples?

Post by Liviu M » 30.10.2016, 20:48

Hi Rob,
I think I found the answer for the first point in the rocnet-constants.h file:

Code: Select all

#define RN_CLASS_IO      0x01
#define RN_CLASS_DCC     0x02
#define RN_CLASS_RFID    0x04
Regards,
Liviu

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

Re: RocNet Communications Examples?

Post by Liviu M » 01.11.2016, 10:22

Hi,
Liviu M wrote: 2. manuID: manufacturer ID? Do you have any imposed rules for this ID (like the NMRA)?
5. subipH/subipL: board ID? Should be the same as the senderID I'll use in building the answer?
Reading the Dagnall's code (thanks for sharing!), I've got answers for the above two questions:
2. Dagnall used the NMRA code for DIY (13), I suppose I'll do the same.
5. Parts of the IP address of the board (IPAddress[2] && IPAddress[3]).

Cheers,
Liviu

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

Re: RocNet Communications Examples?

Post by Liviu M » 01.11.2016, 19:12

Hi Rob,

trying to implement the replaying messages (actually the identify answer is working :)), I think I found a documentation error at message type.
In wiki, for the message type the documentation says:

Code: Select all

Code
bit 	     7 	    6 	  5 	        4 	3 	2 	1 	0
function 	0 	2 bit type (0-3) 	    5 bit code (0-31)
Type
    0 request
    1 event
    2 reply
=> request type: 0b000xxxxx => nothing to change to the code
=> event type: 0b001xxxxx => OR-ing the code with 0x20 is needed
=> reply type: 0b010xxxxx => OR-ing the code with 0x40 is needed

But Rocrail detects my message as (identify) answer when I'm OR-ing the code with 0x20 - event type, not 0x40 - reply type.

Code: Select all

#define MSG_REPLY         0x20

mess[nrBytes++] = RN_STATIONARY_IDENTIFY | MSG_REPLY; //code - identify + REPLAY
Do I make a mistake, or the documentation is wrong?

Thanks,
Liviu

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

Re: RocNet Communications Examples?

Post by rjversluis » 02.11.2016, 08:30

Hi Liviu,

can you point me directly to the part of the Wiki?

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

Re: RocNet Communications Examples?

Post by Liviu M » 02.11.2016, 09:04

Hi Rob,
On theRocnet protocol page, in Packet Content section, in the bit description of different message components there are Network ID, Node ID High/Low, Group and Code subsections.
I mean the Code one, more precisely the Type description.

I hope is better now,
Liviu

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

Re: RocNet Communications Examples?

Post by rjversluis » 02.11.2016, 09:11

it is defined as follows:

Code: Select all

/* action types */
#define RN_ACTIONTYPE_REQUEST  0
#define RN_ACTIONTYPE_EVENT    1
#define RN_ACTIONTYPE_REPLY    2
#define RN_ACTIONTYPE_REPLYEXP 3

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

Re: RocNet Communications Examples?

Post by Liviu M » 02.11.2016, 09:20

Hi Rob,
Thanks for the info. I should make some more checks, but I can do them only in the evening.
In my opinion, somewhere is a bit shifting operation "to short" with one bit, but as I said, should check if it is on my side or yours. :)

Cheers,
Liviu

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

Re: RocNet Communications Examples?

Post by Liviu M » 02.11.2016, 19:13

Hi Rob,
I think I found it. :)
I think that the following if block (rocnet.c)

Code: Select all

    if( actionType != RN_ACTIONTYPE_EVENT) {
      TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "ignore identify command...");
      break;
    }
should be

Code: Select all

    if( actionType != RN_ACTIONTYPE_REPLY) {
      TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "ignore identify command...");
      break;
    }
Regards,
Liviu

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

Re: RocNet Communications Examples?

Post by Liviu M » 02.11.2016, 20:04

Hi Rob,
thinking a little bit further, maybe I've misunderstood the protocol and I shouldn't use RN_ACTIONTYPE_REPLY, but RN_ACTIONTYPE_EVENT.
I suppose I should do it, because making the change I proposed above will break all the installed Nodes.

Cheers,
Liviu

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 03.11.2016, 17:34

Hi Livu , Rob.
Sorry I have been off line, I have no problem with Livu "Hijacking" the thread, it is good to see all this activity. :wink:
What does the RN ACTIONTYPE affect / do ?? Forgive me for not doing my research before asking!!!...


FYI I have updated some of my code, so it should not need to be programmed directly for MQTT broker address and Access point.
If it cannot log into the router, it now sets up an AP, where you can select your networks and passwords etc. It then looks for an MQTT broker, and when it finds it, saves the address for next time. The code is still poor on style :oops: but does work :) ....https://github.com/dagnall53/RocNetNodeAutoConnect

One thing I have not implemented, but want to, is a "reply" from the servo when it gets to the demanded position (for points) ..
Also, in my code, I do not think I have the Node "reporting" fully understood .. Specifically the "Stationary" - "Identify" "Class" byte:
I set this to 5 as a semi random choice and
My nodes report as being "accessory,RFID", 8 i/o. - I am not sure what this may affect in RocRail?
My code currently reports:
GCA-Pio3 0x40,0x41 ,0x46
Pi-04 0x3C
and Pi 07 0x48 0x49 0x4c and 0x4E (!!) Obviously this is not "correct", but I would like to understand the messaging better so I can make it "correct".
I presume that these are I2C addresses for the Pi 03,04 and 07, -It would be good to fully document what the Class variable does.. so that if I add a local Node, I2C bus later, I can make them report "correctly"..

PS.. I have just published the 3D line side box for the NodeMCU on Thingyverse: http://www.thingiverse.com/thing:1867599 if you are interested..

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

Re: RocNet Communications Examples?

Post by Liviu M » 03.11.2016, 20:16

Hi Dagnall.
Dagnall wrote: What does the RN ACTIONTYPE affect / do ??
Without the right ACTIONTYPE in the answer to the query command, the Rocrail ignores the answer. At the beginning I wasn't payed attention to it and Rocrail ignored my replies. The right message format I've took from your code

Code: Select all

 sendMessage[6] = 8 + 32; // action group and code bit 6 (32) = set for REPLY
The 32 In your code is the ACTIONTYPE.
At the beggining I was thinking that the ACTIONTYPE should be REPLY, now I'm not sure anymore.
Dagnall wrote:It would be good to fully document what the Class variable does..
I found some info about the classes in the rocnet-constants.h file:

Code: Select all

#define RN_CLASS_IO      0x01
#define RN_CLASS_DCC     0x02
#define RN_CLASS_RFID    0x04
Dagnall wrote:PS.. I have just published the 3D line side box
Nice! My layout is N-scale, not enough place. :mrgreen:

Cheers,
Liviu

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 04.11.2016, 19:40

Thanks!
I can say that my code does work... :)
But I should try to use the same variable names as RocRail! :oops:


PS
I do have some "000" track, the precursor to N gauge...
This is very old "Lone Star" Electric track and an old Lone star diesel, But I think the magnets have gone, the rubber drive belts certainly have!
I do remember when they were first introduced!.

Making me feel very very old....

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

Re: RocNet Communications Examples?

Post by Liviu M » 06.11.2016, 16:25

Hi,
slowly my board starts to behave as expected. :)
I can program the board (configure it to emulate a PI02 & PI03), I can turn ON/OFF a LED on the board by switch commands in the layout and I can sent a "sensor event" to Rocrail by pressing a button on the board.
The code is, as usual, on github and can be installed as a library in an Arduino-like development environment.
However, since the board/IDE I'm using for development is quite unusual, I suppose my code is in the moment almost uninteresting/useless for anyone but me.
I'll try to change the situation and make it more "Arduino friendly". Unfortunately I don't have (yet) any Ethernet shield.
I'll test it sometime in the future with an ESP8266, but no idea when I'll have the time.

Regards,
Liviu
Last edited by Liviu M on 25.02.2017, 16:46, edited 1 time in total.

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

Re: RocNet Communications Examples?

Post by Liviu M » 06.11.2016, 18:18

Now the "library" and the example compile also for ESP8266 & Arduinos. I've adapted the examples for the "Arduinos" also, but they are totally untested (for the ESP the EEPROM.init() is missing, for example).

Regards,
Liviu

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: RocNet Communications Examples?

Post by Dagnall » 11.11.2016, 14:09

Livu, Interesting, I have just downloaded your RN from the gitgub, it seems to compile for the ESP8266 NodeMCU, but does give some errors,
WARNING: Category 'Toys' in library RN is not valid. Setting to 'Uncategorized'
WARNING: library RN-master claims to run on [TivaC architecture(s) and may be incompatible with your current board which runs on LM4C1294] architecture(s).
I also have a few questions:
What is this code doing/for/setting?

Code: Select all

 "const char* mqtt_server = "broker.mqtt-dashboard.com";"
It seems to be an internet based broker, but I assumed you would use a local one.. and you seem to set a local one with mqttServer[] ...
and also, what are these settings for:?

Code: Select all

IPAddress myIp = IPAddress(192,168,1,111);
IPAddress myGw = IPAddress(192,168,1,2);
Cheers
Dagnall

Post Reply

Return to “RocNet”