User Tools

Site Tools


arduino:wio-canprot-en

WIO - Throttle - 32 I/O - LEDs - Servos - RFID - Displays - DCC

Setup

RCAN Protocol

The WIO-02 and WIO-PROG2 are using extended CAN frames, populated with the Rocrail RCAN protocol.
The used CAN baudrate is 125k, which is fast enough and allows long wires.
By using all of the 29 ID bits, will allow instructions with zero to eight bytes of data.
This protocol can be used parallel with other protocols using standard frames and the same baudrate.
Some CAN interfaces cannot be used for extended frames because the ID will be mangled. Use an other available Interface Type.

Extended Frame

Extended CAN Frame
EID Cnt Data[Cnt]
PRIO TYPE SID IC RID DLC DATA CAN usage
3 2 8 8 8 4 (0…8) x 8 Nr of bits
Extended 29bit ID: <PRIO 3bit> <TYPE 2bit> <SID 8bit>  <IC 8bit>   <RID 8bit>
             Mask: <0x1C000000><0x03000000><0x00FF0000><0x0000FF00><0x000000FF>


CAN usage Description Range Remark
PRIO ID Priority 0…7
TYPE Instruction type 0…3 cmd, evt, rsp, inf
SID Sender ID 1…255 1=Rocrail
IC Instruction Code 0x00…0xFF Group 0xFn + Opcode 0xnF
RID Receiver ID 0…255 0=broadcast
DLC Number of following data bytes 0…8
DATA 8 data bytes (0…8) x 0…255


Streaming

An exception on this header is streaming:
The PRIO and SID are used as 11bit down counter. This allows file sizes of max. 16kB.
The end of streaming is triggered if the down counter reaches zero.
The first data packet contains the file name with a max. length of 8 characters incl. extension.


PRIO_SENSOR  0x00
PRIO_HIGH    0x01
PRIO_MEDIUM  0x02
PRIO_CONFIG  0x03
PRIO_LOW     0x05
PRIO_INFO    0x07
 
TYPE_CMD 0x00
TYPE_EVT 0x01
TYPE_RSP 0x02
TYPE_ACK 0x03


Instruction Code

/*
IC = GRP | OPC
 
GRP = (IC & 0xF0)
OPC = (IC & 0x0F)
*/
 
#define GRP_SYS 0x00 // System
  #define SYS_NOTUSED 0x00 // See "Bootloader"
  #define SYS_STATE   0x01
  #define SYS_SOD     0x02
  #define SYS_CLOCK   0x03
  #define SYS_EBREAK  0x04
  #define SYS_POWER   0x05
 
#define GRP_CNF 0x10 // Configuration
  #define CNF_QUERY  0x10
  #define CNF_GET    0x11
  #define CNF_SET    0x12
  #define CNF_REBOOT 0x1F
 
#define GRP_PRG 0x20 // Programming
  #define PRG_GETCV 0x20
  #define PRG_SETCV 0x21
  #define PRG_PT    0x22
 
#define GRP_STR 0x30 // Streaming
  #define STR_TEXT_START 0x30 // datat[0] = display number
  #define STR_TEXT       0x31
  #define STR_FILE_START 0x32 // data = filename
  #define STR_FILE       0x33
  #define STR_PLAY       0x34 // data = filename
  #define STR_LIST       0x35 // SPIFFS directory listing
 
#define GRP_PRT 0x40 // Port I/O
  #define PRT_PORT   0x40
  #define PRT_SIGNAL 0x41
 
#define GRP_DCC 0x50 // DCC Command Station
  #define DCC_DIRV     0x50
  #define DCC_FUN      0x51
  #define DCC_BINSTATE 0x52
  #define DCC_ACC      0x53
 
#define GRP_INF 0x60 // Unsolicited events like Sensors, RailCom, RFID scanner, ...
  #define INF_PORT 0x60
  #define INF_RFID 0x61
  #define INF_BIDI 0x62
  #define INF_ENV  0x63 // temperature, humidity, pressure, light

Bootloader

Group GRP_SYS and command zero, Instruction Code 0x00, are not used to avoid CANBUS bootloader EID conflicts.
This could happen in case the SID is 8 and RID is 4 or 5.

:X00080004N -> Bootloader command
:X00080005N -> Bootloader data


GRP_CNF

CNF_IDX_OPTIONS     0
CNF_IDX_PORTGROUP_0 1 //  0... 7
CNF_IDX_PORTGROUP_1 2 //  8...15
CNF_IDX_PORTGROUP_2 3 // 16...23
CNF_IDX_PORTGROUP_3 4 // 24...31

Query Cmd

<PRIO_CONFIG><TYPE_CMD><SID><CNF_QUERY><RID><DLC=0>:

Query Rsp

<PRIO_CONFIG><TYPE_CMD><SID><CNF_QUERY><RID><DLC=8>:<MANU><PRODUCT><TYPE><OPT1><OPT2><OPT3><VER_MAJ><VER_MIN>

Get Cmd

<PRIO_CONFIG><TYPE_CMD><SID><CNF_GET><RID><DLC=1>:<CNF_OPTIONS>
<PRIO_CONFIG><TYPE_CMD><SID><CNF_GET><RID><DLC=1>:<CNF_PORTGROUP_n>

Get Rsp

<PRIO_CONFIG><TYPE_RSP><SID><CNF_GET><RID><DLC=7>:<CNF_PORTGROUP_n><options1><options2><options3><pulselength><canid><subtype>
<PRIO_CONFIG><TYPE_RSP><SID><CNF_GET><RID><DLC=5>:<CNF_PORTGROUP_n><nib0+nib1><nib2+nib3><nib4+nib5><nib6+nib7>
One nible represents a port type, 0…15.

Set Cmd

<PRIO_CONFIG><TYPE_CMD><SID><CNF_SET><RID><DLC=7>:<CNF_PORTGROUP_n><options1><options2><options3><pulselength><canid><subtype>
<PRIO_CONFIG><TYPE_CMD><SID><CNF_SET><RID><DLC=5>:<CNF_PORTGROUP_n><nib0+nib1><nib2+nib3><nib4+nib5><nib6+nib7>

arduino/wio-canprot-en.txt · Last modified: 2020/07/13 18:22 by rjversluis