Skip to main content

Crate coe

Crate coe 

Source
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.
  • Going from alloc to std implements std::error::Error on all Error types.

Structs§

COEVersion
The Version of COE protocol used.
Packet
A COE Packet
Payload
A single Payload that can be sent in a CoE packet.

Enums§

AnalogueCOEValue
All the different analogue values representable in CoE. Ordering (and therefore numbering) is the one used internally in the CoE spec.
COEValue
Any Value that is representable in COE.
DigitalCOEValue
Representation of all existing digital values representable in COE
Format
The Format a COE Value can have.
FromDayOfMonthError
The Errors that can occur when parsing an integer as day of month
FromMonthOfYearError
The Errors that can occur when parsing an integer as day of month
ParseCOEError
All the Errors that can appear when parsing a COE packet.

Functions§

from_day_of_month
Convert the internal format for AnalogueCOEValue::DayOfMonth into two u8s containing day and month
from_month_of_year
Convert the internal format for AnalogueCOEValue::MonthOfYear into a u8 and u16 containing month and year
packets_from_payloads
Convert a slice of Payloads into (possibly multiple) Packets.
to_day_of_month
Convert a day and month into the internal format used in CoE.
to_month_of_year
Convert a month and year into a AnalogueCOEValue::DayOfMonth.