-
Notifications
You must be signed in to change notification settings - Fork 1
Data link layer
uCAN defines its own protocol based on CAN extended frames. Only extended frames are valid in a uCAN network; standard frames are ignored. RTR frames are also not supported and are ignored.
Every node has a unique 8 bit address on a local network. Addresses can be assigned centrally, or autodiscovered on first connect by a node. This is governed by an ARP-type protocol, described as part of the [network layer](Network layer).
- Address 0 is reserved for the node in charge of YARP centralised address assignment, if one exists.
- Addresses 1-127 are reserved for allocation by the YARP address assignment node.
- Addresses 128-254 are 'self assignment' IDs; any node may assign itself an ID in this range.
- Address 255 is the 'broadcast' address.
Each node also has a globally unique 56-bit hardware address. Much like ethernet MAC addresses, hardware addresses should be globally unique across all uCAN nodes everywhere.
The hardware address space is divided up into sub-allocations for various different types of ID. This provides for a number of possible addressing schemes. As a rule, schemes that lead to less opportunity for error and duplicate IDs are to be preferred; this means avoiding schemes that rely on the user assigning an address or correctly programming it into EEPROM or program code, when possible.
Recommended schemes are, in rough order from best to worst:
- Embedded serial number from a dedicated SSN/UUID IC
- MAC address from an attached network interface
- PEN-based hardware ID, written to EEPROM or ROM at time of manufacture
- Randomly generated ID based on a hash of an embedded serial number
- PEN-based ID written by user to permanent storage (EEPROM/disk)
- Randomly generated ID based on a PRNG and written to permanent storage
- PEN-based ID embedded in source code by a user
The range 00:00:01/16 is reserved for addresses provided by microchip unique ID chips in the UID family, such as 24AA02UID and 11AA02UID.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x00 | 0x00 | 0x01 | Unique ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
PEN-based addresses consist of a 24 bit Private Enterprise Number, followed by a 24 bit device ID. The Private Enterprise Number is assigned by IANA; PENs can be applied for here free of charge. The device ID is assigned by the owner of the PEN; it is up to the owner of the PEN to ensure there are no duplicate node IDs.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x01 | PEN | Device ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Addresses starting 02/8 are reserved for MAC addresses. Since uCAN hardware IDs need only be unique for uCAN, this means a device with an ethernet interface can reuse an available global MAC address as a uCAN hardware address by prefixing the byte 0x02 to it.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x02 | MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Hardware IDs starting with 03/8 are reserved for Maxim Silicon Serial Number ICs such as DS2401.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| 0x03 | SSN |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
All addresses with the MSB set are stable identifiers generated by a randomised process. A 55-bit hash of a longer unique silicon serial number is a common application for this type of address.
This address space can also be used for simple randomised assignment, but it's recommended to use another scheme such as the PEN allocation described below for these cases, to avoid the possibility of collision.
The 29 bit extended message ID is broken into fields:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Pri|B| Proto |Subfields |Sender |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Pri: Priority (2 bits)
- B: Broadcast (1 bit)
- Prot: Protocol ID (4 bits)
- Subfields (14 bits)
- Sender (8 bits)
The priority of a message indicates how urgent or important it is; lower priority IDs denote more important messages, and win CAN bus arbitration. The four priority levels are:
- 00: EMERGENCY: This message must be delivered, as soon as possible. Reserved for unusual and important events.
- 01: URGENT: This message should be prioritised over normal traffic.
- 10: NORMAL: This is the default priority.
- 11: BULK: This message should be prioritised below normal traffic.
uCAN defines a number of different [network layer](Network layer) protocols. These are divided into unicast and broadcast protocols, a complete list of which are specified in the [network layer](Network layer) document.
A broadcast protocol is used entirely to send broadcast messages. One example of this is the event protocol, which sends event notifications to all listening nodes. Broadcast protocols have the broadcast bit set to 1, and may use the entire subfield field for protocol-specific data.
Broadcast subfield:
|-+-+-+-+-+-+-+-+-+-+-+-+-+-|
| Protocol data |
|-+-+-+-+-+-+-+-+-+-+-+-+-+-|
A unicast protocol can send either unicast or broadcast messages. Examples of this include the network management (YARP) and datagram protocols. Unicast protocols have the broadcast bit set to 0, and the subfield field is divided up as follows:
|-+-+-+-+-+-+-+-+-+-+-+-+-+-|
| Protocol | Rcpt Address |
|-+-+-+-+-+-+-+-+-+-+-+-+-+-|
- Protocol: Protocol data (6 bits)
- Rcpt Address: Recipient address (8 bits)
In the event that a unicast protocol message should be received by all nodes, the recipient address is set to 255.
The division of broadcast and unicast protocols in this manner makes it possible for a node with a typical mask-and-filter based CAN implementation to listen for all unicast messages specifically addressed to it regardless of protocol using only a single mask and filter.
The sender field contains the sender's node ID. In the (unusual) event that sender does not have a node ID, this should be specified as 255; this should only be used when a node is attempting to acquire a node ID using the YARP protocol.