Page 1 of 1

RocNet Protocol documentation

Posted: 20.09.2016, 14:05
by Dagnall
Can I suggest an update for the ... et-prot-en ?

Code: Select all

18	set channel	channel#	valueH	valueL	
When I use the (excellent) "Fine Tune" tab, I am seeing a 4th data byte, with the value (0: Set offPos , 1: Set onPos)..
I'm not sure if there other settings for offsteps, on steps or options elsewhere.

Also, a note here for anyone else doing their own RocNet:
Where the documentation says (as an example..

Code: Select all

(write port event)	port# 	idH	idL	port
This means in effect that you can have many more than just the 4 data bytes shown.. as you will actually get multiple ports data sent in a single message : port1, idH(port1) , idl(port1) port(port1), port2, idH(port2) , idl(port2) port(port2),
Its really obvious when you see it ! :wink:

All the best

Re: RocNet Protocol documentation

Posted: 18.02.2017, 17:36
by Dagnall
An question about the protocol..And specifically the rocnet response to Identify.

Is there somewhere where "class" ( data1 of the "group 3, code 8" byte in the identify response) is documented. ?
I think "bit 0= accessory"" bit 1= dcc" "Bit 3=RFID", but what do the other bits represent??

I would also like to better understand the group 7 code 5 data format,
I cannot find any precise documentation for "iotype; flags; cstype; or csdevice" and It also seems to need a 5th data byte that is not shown in the documentation...?

At the moment i have built up my response message with the following code, which shows what these variables mean, based on the github info... But I am afraid I am still confused :oops: .. ..
Can you give a simple explanation of what each bit of the variables means... :)

Code: Select all

          sendMessage[8] = RN[15]; //    iotype      0=GPIO, 1=I2c-0, 2=I2C-1not pi
          sendMessage[9] = RN[16]; //    flags bit    0 = ack (data->sack ? 0x01:0x00) | (data->rfid ? 0x02:0x00) | (data->usepb ? 0x04:0x00) | (data->adcsensor ? 0x08:0x00);
          sendMessage[10] = RN[17]; //   cstype     :0=none, 1=dcc232, 2=sprog //(  for [9]>tl_info ? 0x10:0x00) | (data->tl_monitor ? 0x20:0x00) | (data->ismobile ? 0x40:0x00);
          sendMessage[11] = RN[18]; //  csdevice usb 0/1
          sendMessage[12] = RN[19];
is there somewhere where these variables are clearly defined??

Many thanks

Re: RocNet Protocol documentation

Posted: 18.02.2017, 17:47
by rjversluis
Hi Dagnall,

Code: Select all

#define RN_CLASS_IO      0x01
#define RN_CLASS_DCC     0x02
#define RN_CLASS_RFID    0x04
Those bits are saved in the class member variable:

Code: Select all

    TraceOp.trc( name, TRCLEVEL_INFO, __LINE__, 9999, "queryids request from %d to %d", sndr, rcpt );
    msg = allocMem(128);
    msg[RN_PACKET_NETID] = data->location;
    rnReceipientAddresToPacket( sndr, msg, 0 );
    rnSenderAddresToPacket( data->id, msg, 0 );
    msg[RN_PACKET_LEN] = 7 + StrOp.len(data->nickname);
    msg[RN_PACKET_DATA+0] = data->class;
    msg[RN_PACKET_DATA+1] = 70;
    msg[RN_PACKET_DATA+2] = revisionnr/256;
    msg[RN_PACKET_DATA+3] = revisionnr%256;
    msg[RN_PACKET_DATA+4] = 128;
    msg[RN_PACKET_DATA+5] = data->ip[data->ipsize-2];
    msg[RN_PACKET_DATA+6] = data->ip[data->ipsize-1];
    StrOp.copy((char*)&msg[RN_PACKET_DATA+7], data->nickname);

Re: RocNet Protocol documentation

Posted: 29.07.2017, 18:23
by Dagnall
Rob, sorry, some more questions.
Group 5, Message 7 is defined as 'read option' with data "iotype flags cstype csdevice".
I think I have these being sent correctly.

However.. the "OPTIONS " TAB also shows 'I2C Detect' with some addresses for 'GCA-Pi-02' ..03 ..04 ..07 and "rocdisplay"..
Where and how are these address variables sent to rocview??

I would like to set these correctly in my ESPWIFIRocnet code... which currently reports a
GGCA-Pi02 addresses of 0x22 0x24 .. (but these address change for unknown reasons with multiple 'get' )
"GCA-Pi07 address of "0x48 0x49 "

Many thanks

Re: RocNet Protocol documentation

Posted: 30.07.2017, 07:03
by rjversluis
Hi Dagnall,

a snippet:

Code: Select all

    iONode node = NodeOp.inst(, NULL, ELEMENT_NODE );
    wProgram.setmodid(node, sndr);
    wProgram.setcmd( node, wProgram.getoptions );
    wProgram.setval1( node, rn[RN_PACKET_DATA+0] );
    wProgram.setval2( node, rn[RN_PACKET_DATA+1] );
    wProgram.setval3( node, rn[RN_PACKET_DATA+2] );
    wProgram.setval4( node, rn[RN_PACKET_DATA+3] );
    /* I2C scan of 0x20, 0x30 and 0x40 */
    wProgram.setval5( node, rn[RN_PACKET_DATA+4]*256 + rn[RN_PACKET_DATA+5] );
    wProgram.setval6( node, rn[RN_PACKET_DATA+6]*256 + rn[RN_PACKET_DATA+7] );
    wProgram.setval7( node, rn[RN_PACKET_DATA+8]*256 + rn[RN_PACKET_DATA+9] );
    wProgram.setval8( node, rn[RN_PACKET_DATA+10] );
    if( rn[RN_PACKET_LEN] >= 13 )
      wProgram.setval9( node, rn[RN_PACKET_DATA+11]*256 + rn[RN_PACKET_DATA+12] );
    wProgram.setiid( node, data->iid );
    wProgram.setlntype(node, wProgram.lntype_rocnet);
    data->listenerFun( data->listenerObj, node, TRCLEVEL_INFO );
I now documented it in the Wiki.
The 16 bit I2C scan values are bitmaps.

BTW: I added the C-Headerfile: ... t-en#files

Re: RocNet Protocol documentation

Posted: 02.03.2018, 18:40
by Dagnall
Hi Rob, another question from me

I'm looking at adding a "wireless" RocMouse capability for my ESP8266 code.
I assumed that Rocrail looks for a (any?) Rocmouse message (Group 2, Code 5?) as soon as it sees "dispatch".
But I have tried this and it does not seem to "bind" the controller to the loco.
Presumably there is some "Rocmouse BIND" communications sequence needed between the controller and the mouse that I have not implemented...
Can you direct me to somewhere where this dispatch/rocmouse initiate (/bind?) code command sequence is shown in detail?

Also :
Can you please add the description /details lines for the RN_MOBILE_ROCMOUSE_BIND (6) and
RN_MOBILE_ACK (7) to the mobile actions section in ... et-prot-en

Many thanks

Re: RocNet Protocol documentation

Posted: 03.04.2018, 13:16
by Dagnall
Rob, Thanks for the link to the XML scripts. ... n#commands
They were very interesting. I have now got Loco speed, and sound commanded over MQTT client.

But while looking through the data , I saw some very interesting entries: :

Code: Select all locosetup (1)	childnode of rocnet						No
acceleration	int		-	10	-	No
deceleration	int		-	10	-	No
nrpulses	int	Number of sensor pulses per wheel rotation.	-	3	-	No
scale	float	G scale	-	29.0	-	No
A the moment my ESP "Rocnet" mobile controller stores acc and dec as standard CV's, but wheel diameter and N pulses are stored as fixed numbers in the program.

So: first, are these XML script variables left over from your Rocnet mobile experiments?? ... in which case, should I ignore them!?
(I was planning on adding CV's for npulses and Wheeldiameter, but may change if you have a better approach...)

If they are important features that will remain and perhaps be used more in future, I would like to make ESPMQTTRocnetSound compatible with them. ( you can expect more questions. :) ..)

for example,
Is the "mobile" boolean used to set Rocnet Class = DCC?
How do you propose to set / read wheeldiameter using Rocview Rocnet or RocPro programming...?

What would you suggest?

Cheers as ever

Re: RocNet Protocol documentation

Posted: 03.04.2018, 13:48
by rjversluis

those entries are for:
Has nothing todo with DCC or something else.

Re: RocNet Protocol documentation

Posted: 05.04.2018, 12:27
by Dagnall
That is what I expected.
I have not set my code to respond that it is GCA-Pi05 in case it causes compatibility issues.
I have, however, set my code so it responds as a "Rocnet Class" DCC, to discriminate it from the "accessory" decoders.

Just out of interest, have many Pi-05 been built /used?


If you ever decide to add a new RocNet Class of "MobileDecoder", perhaps Nodeclass bit 4 = "MobileDecoder".. :wink:

Re: RocNet Protocol documentation

Posted: 16.01.2019, 15:25
by Dagnall
I am "back" working on my code for the ESP8266 based version of the Rocnet node, and am confused by some behaviors of the RocView tabs .

First. I can modify how many IO my node reports, (example Identified: rocnetid=14 class=Accessory vid=13 revision=21 nrio=16 subip=0.56 nickname=[node 14])
But the Rocnet Index shows only that the Node has 8 I/O. :!: What does the Identifier nrio mean if not to say how may IO are attached? :?:

Second, This node reports that it has two I2cGCA-Pi02 (0x20 and 0x21). But pressing the (<) and (>) in the Rocview /programming/rocnet/piO2 Port setup tab.setup does not move from "I/O 1 -0x20A -32A" so I can only program the first 8 of the I/O.
I would have thought it should have moved to display the next sets of :?: ??

In contrast, I report a single Pi-03 at 0x40, but the Pi03 channel setup moves from 0x40A all the way to 0x47B when I press (>).. :!: which is NOT what I expected.

What I would like is consistent behaviour and ideally that that the Pi-3 setting display only allowed access to the 16 0x40 reported found addresses, and that the Pi-02 display would allow me access to the ports reported as present by the 0x20 and 0x21 response.

What am I missing? Is this a bug or is my code somehow confusing RocView? :?:

(I am using RocView 14724)
Some images below to illustrate what I see.. the RocView clearly shows the Rocnet "Identified message" was recieved and that nrio should have been 16 for rocnetid=14
index Capture.JPG
node display Capture.JPG

Re: RocNet Protocol documentation

Posted: 16.01.2019, 15:29
by rjversluis

test with the original GCA-Pi modules to see the diff.

Re: RocNet Protocol documentation

Posted: 16.01.2019, 16:02
by Dagnall
rjversluis wrote:
16.01.2019, 15:29

test with the original GCA-Pi modules to see the diff.
So what does it do with the original module? Does it react differently?