Support
Wiki Documentation
Support Forum
Mobile
- andRoc Android
- Rocweb Browser
- WIO-Control ESP32
- Rocview Tablet
DIY
User
Wiki writer
Special
Legal
Support
Wiki Documentation
Support Forum
Mobile
DIY
User
Wiki writer
Special
Legal
Inhoud → Central Stations → RocNet
Dit is een binary Open Source protocol bedoeld voor communicatie tussen twee of meer, in een peer-to-peer-netwerk geplaatste, hardware units.
Software boxen zullen gemaakt worden in C. De broncode C kan, gedeeltelijk, tevens gebruikt worden voor geïntegreerde software (PIC/Atmel)
Werk in uitvoering, en toegankelijk voor kommentaar, advies en hulp.
De opzet van een binair protocol met 8 bit data load maakt het moeilijk om een unieke start byte te bepalen. Meestal is de startbyte tweemaal verzonden of verwijdert wanneer deze code in de rest van het pakket voorkomt, wat resulteert in ongedefinieerde pakket lengtes.
Indien de overhead van een 8 bit data load vergeleken wordt met het 7 bit slim size, dan is het duidelijk voor een klein protocol met low data transport om voor 7 bit te kiezen. Voor protocollen die veel data bevatten is de 7 bit data load geen goede keuze.
Het adresbereik ligt in de range van 1 tot 16383
Het idee is om een netwerk te bouwen met twee of meerdere sturing-units.
Dit zijn verschillende unit-types:
Ieder heeft zijn eigen uniek ID nodig wat gebruikt wordt als zender/ontvanger parameter in de hoofding.
De unit die alle berichten verwerkt en tevens veel zendt kan je de "master" noemen maar eigenlijk is dit een speler als eender andere unit. Dus in het geval van Rocrail is dit de "master".
Header | |||||||
group | address | action | data | ||||
group | addrH | addrL | code | length | n data bytes |
---|
Header | ||||||||
network | receipient | sender | action | data | ||||
netid | rcptH | rcptL | sndrH | sndrL | group | code | length | n data bytes |
---|
Groep units in een groot systeem.
Iedere unit in het netwerk heeft zijn eigen ID. Indien 0, dan moeten alle units het pakket filteren.
Het ID van de zender unit.
Direct addressing of I/O and decoders.
Indien de actie een adres nodig heeft, dan komt dit in de eerste twee bytes van het datadeel .
Het variabele deel van het pakket welke actie afhankelijk is.
Voor I/O en Lok acties zijn de eerste 2 bytes nodig om het adres te bepalen.
De lengte mag nul zijn indien geen verdere info nodig is voor de welbepaale actie.
The protocol does not feature a checksum byte, but the packet is valid when the first byte has the 7th bit high and all following bytes low.
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
function | 1 | extended=1 | command=0, event=1 | 5 bits ID (0-31) |
The network byte is the only one in the packet with bit 7 high to signal the start of a transmission.
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
function | 0 | 7 bits high address (0-127) |
Address = addrL + addrH * 128
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
function | 0/1 | small=0 | command=0, event=1 | 5 bit group code (0-31) |
In case of small package format bit 7 signals the start of a transmission.
The event bit is set incase of sensor reporting, throttle actions, SCD, ….
If the type is an event or reply, no real I/O action should be taken on the specified address; mostly the I/O with this address signals a state change.
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
function | 0 | number of data bytes |
bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|
function | 0 | 7 data bits |
Code | Description | Remark |
---|---|---|
1 | General | Command Station |
2 | Output | Switches, signals, … |
3 | Input | Sensors, buttons, … |
4 | Mobile decoders | Locomotives and functions |
5 | Stationary decoders | Multiport for inputs and outputs |
6 | Programming mobile | DCC CVs |
7 | Programming stationary | Including command stations |
8 | GP Data transfer | General purpose data transfer between modules |
act | description | data 1 | reply data 1 | reply data 2 |
---|---|---|---|---|
0 | NOP | 0 | ||
1 | query | status | ||
2 | track power | 0 = off, 1 = on | status | |
3 | halt | status | ||
4 | version | versionH | versionL | |
5 | PT on/off | on/off | on/off |
The address is optional and can be used to point at a single booster.
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|
0 | PT busy | idle | power |
act | description | data 1 | data 2 | data 3 | data 4 | reply data 1 |
---|---|---|---|---|---|---|
1 | switch port | 0 = off, 1 = on | status | |||
2 | switch multi port¹ | port maskH | port maskL | valueH | valueL | status |
¹) Offset is address specified in the header.(small) Also use able for a coil pair.
act | description | data 1 | data 2 | reply data 1 | reply data 2 | reply data 3 | reply data 4 |
---|---|---|---|---|---|---|---|
1 | port status | status | |||||
2 | multi port status¹ | port maskH | port maskL | port maskH | port maskL | valueH | valueL |
3 | report² | addrH | addrL | info1 | info2 |
¹) Offset is address specified in the header.(small)
²) A report is for extended inputs which for example provide the address of the passing train.
request | reply | ||||||||
---|---|---|---|---|---|---|---|---|---|
code | description | data 1 | data 2 | data 1 | data 2 | data 3 | data 4 | data 5 | data 6 |
1 | setup | protocol: 0=DCC14, 1=DCC28, 2=DCC128, 3=MM1, … | number of functions | ||||||
2 | velocity | 0…127 | direction: 1=FWD 0=REV, lights F0 | protocol | |||||
3 | fg1 | 0…15 where bit 0=F1, 1=F2, 2=F3, 3=F4 | protocol | ||||||
4 | fg2 | 0…15 where bit 0=F5, 1=F6, 2=F7, 3=F8 | protocol | ||||||
5 | fg3 | 0…15 where bit 0=F9, 1=F10, 2=F11, 3=F12 | protocol | ||||||
6 | fg4 | 0…15 where bit 0=F13, 1=F14, 2=F15, 3=F16 | protocol | ||||||
7 | query | velocity | direction | fg1 | fg2 | fg3 | fg4 | ||
8 | dispatch put ¹ | ack | |||||||
9 | dispatch get ² | ack | addrH | addrL | |||||
10 | dispatch free ³ | ack | |||||||
11 | link | addrH | addrL | ack | |||||
12 | unlink | addrH | addrL | ack |
¹) Set mobile decoder ready for use with a throttle.
²) Get the dispatched mobile decoder address. (The address set in the header is ignored.)
³) Free the mobile decoder from the throttle.
Extended Setup:
code | description | data 1 | data 2 | data 3 - 10 |
---|---|---|---|---|
1 | setup | protocol | number of functions | ASCII coded name |
If the length byte contains a length > 6 the loco name is following.
Value | Description |
---|---|
0 | OK |
code | description | data 1 | data 2 | data 3 | reply data 1 |
---|---|---|---|---|---|
1 | single port | 0,1 (off,on) | protocol | delay | status |
2 | port pair | 0,1 (close,throw) address is first port of pair | protocol | delay | status |
3 | multi port | port mask | 0…127 where address is offset | protocol | status n |
4 | query single port | status | |||
5 | query port pair | status | |||
6 | query multi port | status n | |||
7 | report¹ | status n |
¹) All connected stationary decoders should report status if receipient is set to zero.
For programming stationary decoders the address represents the module address.
code | description | data 1 | data 2 | data 3 | data 4 | reply data 1 | reply data 2 | reply data 3 | reply data 4 |
---|---|---|---|---|---|---|---|---|---|
1 | write | registerH | registerL | valueH | valueL | registerH | registerL | valueH | valueL |
2 | read | registerH | registerL | registerH | registerL | valueH | valueL | ||
3 | copy | destH | destL | data n | ack |