Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rodbus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A high-performance implementation of the [Modbus](http://modbus.org/) protocol u

## Function Codes

The [`client`](https://github.com/stepfunc/rodbus/blob/main/rodbus/examples/client.rs) and [`server`](https://github.com/stepfunc/rodbus/blob/main/rodbus/examples/server.rs) examples demonstrate simple
The [`client`](https://github.com/stepfunc/rodbus/blob/main/examples/client/src/main.rs) and [`server`](https://github.com/stepfunc/rodbus/blob/main/examples/server/src/main.rs) examples demonstrate simple
usage of the API.

The following function codes are supported:
Expand Down
39 changes: 7 additions & 32 deletions rodbus/src/decode.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Controls the decoding of transmitted and received data at the application, frame, and physical layer
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
#[cfg_attr(
feature = "serialization",
derive(serde::Serialize, serde::Deserialize)
Expand All @@ -19,13 +19,14 @@ pub struct DecodeLevel {
/// Controls how transmitted and received message at the application layer are decoded at the INFO log level
///
/// Application-layer messages are referred to as Protocol Data Units (PDUs) in the specification.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
#[cfg_attr(
feature = "serialization",
derive(serde::Serialize, serde::Deserialize)
)]
pub enum AppDecodeLevel {
/// Decode nothing
#[default]
Nothing,
/// Decode the function code only
FunctionCode,
Expand All @@ -41,13 +42,14 @@ pub enum AppDecodeLevel {
/// called "ADUs" in the Modbus specification.
///
/// On TCP, this is the MBAP decoding. On serial, this controls the serial line PDU.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
#[cfg_attr(
feature = "serialization",
derive(serde::Serialize, serde::Deserialize)
)]
pub enum FrameDecodeLevel {
/// Decode nothing
#[default]
Nothing,
/// Decode the header
Header,
Expand All @@ -56,13 +58,14 @@ pub enum FrameDecodeLevel {
}

/// Controls how data transmitted at the physical layer (TCP, serial, etc) is logged
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
#[cfg_attr(
feature = "serialization",
derive(serde::Serialize, serde::Deserialize)
)]
pub enum PhysDecodeLevel {
/// Log nothing
#[default]
Nothing,
/// Log only the length of data that is sent and received
Length,
Expand Down Expand Up @@ -104,16 +107,6 @@ impl DecodeLevel {
}
}

impl Default for DecodeLevel {
fn default() -> Self {
Self {
app: AppDecodeLevel::Nothing,
frame: FrameDecodeLevel::Nothing,
physical: PhysDecodeLevel::Nothing,
}
}
}

impl From<AppDecodeLevel> for DecodeLevel {
fn from(pdu: AppDecodeLevel) -> Self {
Self {
Expand Down Expand Up @@ -157,12 +150,6 @@ impl AppDecodeLevel {
}
}

impl Default for AppDecodeLevel {
fn default() -> Self {
Self::Nothing
}
}

impl FrameDecodeLevel {
pub(crate) fn enabled(&self) -> bool {
self.header_enabled()
Expand All @@ -185,12 +172,6 @@ impl FrameDecodeLevel {
}
}

impl Default for FrameDecodeLevel {
fn default() -> Self {
Self::Nothing
}
}

impl PhysDecodeLevel {
pub(crate) fn enabled(&self) -> bool {
self.length_enabled()
Expand All @@ -212,9 +193,3 @@ impl PhysDecodeLevel {
}
}
}

impl Default for PhysDecodeLevel {
fn default() -> Self {
Self::Nothing
}
}
Loading