Controller Area Network (CAN)
The can node-type allows the exchange of signals via a CAN bus.
Prerequisites
This node-type does not have any special library dependencies. It is always available.
Implementation
The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/can.cpp
Configuration
| interface_name | string Name of the Socket CAN interface |
object (Input configuration (received by VILLASnode)) | |
object (Output configuration (sent out by VILLASnode)) | |
| vectorize | integer Default: 1 This setting allows to send multiple samples in a single message to the destination nodes. The value of this setting determines how many samples will be combined into one packet. |
Array of Hook Object (object) or Hook Name (string) (hook_list) | |
| builtin | boolean (Builtin hook functions) Default: true By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled. |
{- "interface_name": "string",
- "in": {
- "signals": [
- {
- "can_id": 0,
- "can_size": 8,
- "can_offset": 0,
- "name": "Bus123_U",
- "unit": "V",
- "type": "integer",
- "init": 0,
- "enabled": true
}
], - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "out": {
- "signals": [
- {
- "can_id": 0,
- "can_size": 8,
- "can_offset": 0,
- "name": "Bus123_U",
- "unit": "V",
- "type": "integer",
- "init": 0,
- "enabled": true
}
], - "vectorize": 0,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
], - "builtin": true
}Example
node/etc/examples/nodes/can.conf
nodes = {
can_node1 = {
type = "can"
interface_name = "vcan0"
sample_rate = 500000
in = {
signals = (
{
name = "sigin1"
unit = "Volts"
type = "float"
enabled = true
can_id = 66
can_size = 4
can_offset = 0
},
{
name = "sigin2"
unit = "Volts"
type = "float"
enabled = true
can_id = 66
can_size = 4
can_offset = 4
},
{
name = "sigin3"
unit = "Volts"
type = "float"
enabled = true
can_id = 67
can_size = 8
can_offset = 0
}
)
}
out = {
signals = (
{
type = "float"
can_id = 66
can_size = 4
can_offset = 0
},
{
type = "float"
can_id = 66
can_size = 4
can_offset = 4
},
{
type = "float"
can_id = 67
can_size = 8
can_offset = 0
}
)
}
}
}