Expand description
coe is a library that (De-)serializes CoE packets.
The Protocol is owned by Technische Alternative RT GmbH.
§Getting Started
You can send packets, by creating the Packet as required and then converting the packet into a
Vec[u8].
ⓘ
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut test_packet = Packet::new();
// send to CAN-ID 58, at offset 1 (shows up as 2 in the GUI)
test_packet.try_push(Payload::new(58, 1, coe::COEValue::Analogue(AnalogueCOEValue::LiterPerPulse_Tens(123))))?;
let socket = UdpSocket::bind("0.0.0.0:34215").await?;
let mut buf = [0_u8; 252];
test_packet.try_serialize_into(&mut buf).expect("252 bytes is always large enough to fit a
CoE Packet");
// connect to the IP of your CMI
socket.connect("192.168.1.123:5442").await?;
socket.send(&buf).await?;
Ok(())
}§Feature Flags
The following feature flags are available:
std: This is the default feature set.serde: This makes Packets, Paylods and Values Serializable with Serde.
You can further opt-out of the default features with default-features = false your dependency listing for coe.
This makes coe depend only on core, for use in no_alloc / no_std environments.
You can reenable the following feature flags
alloc: This switches the implementation for a Packet from a fixed-size buffer to a Vec, which is usually more memory-efficient. It also enables the packets_from_payloads function and implements Display for Error types.- Going from
alloctostdimplements std::error::Error on all Error types.
Structs§
- The Version of COE protocol used.
- A COE Packet
- A single Payload that can be sent in a CoE packet.
Enums§
- All the different analogue values representable in CoE. Ordering (and therefore numbering) is the one used internally in the CoE spec.
- Any Value that is representable in COE.
- Representation of all existing digital values representable in COE
- The Format a COE Value can have.
- The Errors that can occur when parsing an integer as day of month
- The Errors that can occur when parsing an integer as day of month
- All the Errors that can appear when parsing a COE packet.
Functions§
- Convert the internal format for AnalogueCOEValue::DayOfMonth into two u8s containing day and month
- Convert the internal format for AnalogueCOEValue::MonthOfYear into a
u8andu16containing month and year - Convert a day and month into the internal format used in CoE.
- Convert a month and year into a AnalogueCOEValue::DayOfMonth.