You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2022/06/02 13:58:37 UTC
[plc4x] branch feature/plc4rs updated: Minor refactoring, reduce some warnings
This is an automated email from the ASF dual-hosted git repository.
jfeinauer pushed a commit to branch feature/plc4rs
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/plc4rs by this push:
new 33c600471a Minor refactoring, reduce some warnings
33c600471a is described below
commit 33c600471a29aa0ece15652c9c8c4e8cfd6351d0
Author: julian <j....@pragmaticminds.de>
AuthorDate: Thu Jun 2 15:58:27 2022 +0200
Minor refactoring, reduce some warnings
---
plc4rust/src/lib.rs | 9 +++------
plc4rust/src/modbus/driver_type.rs | 1 +
plc4rust/src/modbus/modbus_pdu.rs | 10 +++-------
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/plc4rust/src/lib.rs b/plc4rust/src/lib.rs
index 5b909e4448..426d5aa129 100644
--- a/plc4rust/src/lib.rs
+++ b/plc4rust/src/lib.rs
@@ -17,10 +17,7 @@
* under the License.
*/
-use std::any::Any;
-use std::collections::HashMap;
-use std::io::{Error, Read, Write};
-use std::io::ErrorKind::InvalidInput;
+use std::io::{Read, Write};
use crate::read_buffer::ReadBuffer;
use crate::write_buffer::WriteBuffer;
@@ -66,10 +63,10 @@ mod tests {
response: false
};
- let mut bytes: Vec<u8> = vec![];
+ let bytes: Vec<u8> = vec![];
let mut read_buffer = ReadBuffer::new(Endianess::BigEndian, &*bytes);
- let result = ModbusADU::parse(&mut read_buffer, Some(options));
+ let _ = ModbusADU::parse(&mut read_buffer, Some(options));
}
}
diff --git a/plc4rust/src/modbus/driver_type.rs b/plc4rust/src/modbus/driver_type.rs
index f84f5c247d..9d8e71fa54 100644
--- a/plc4rust/src/modbus/driver_type.rs
+++ b/plc4rust/src/modbus/driver_type.rs
@@ -83,6 +83,7 @@ impl Message for DriverType {
}
fn parse<T: Read>(reader: &mut ReadBuffer<T>, parameter: Option<Self::P>) -> Result<Self::M, Error> {
+ assert!(parameter.is_none());
let result = reader.read_u8()?;
match DriverType::try_from(result) {
Ok(result) => {
diff --git a/plc4rust/src/modbus/modbus_pdu.rs b/plc4rust/src/modbus/modbus_pdu.rs
index 13d846d5a2..8fc84e9c1f 100644
--- a/plc4rust/src/modbus/modbus_pdu.rs
+++ b/plc4rust/src/modbus/modbus_pdu.rs
@@ -223,17 +223,13 @@ pub enum ModbusPDU {
ModbusPDUError(ModbusPDUError)
}
-impl ModbusPDU {
-
- fn deserialize_special<T: Read>(reader: &mut ReadBuffer<T>, bit_response: bool) -> Result<ModbusPDU, Error> {
- todo!()
- }
-
+pub struct ModbusPDUOption {
+ bit_response: bool
}
impl Message for ModbusPDU {
type M = ModbusPDU;
- type P = u8;
+ type P = ModbusPDUOption;
fn get_length_in_bits(&self) -> u32 {
match self {