Skip to content

Commit

Permalink
Add ObjectPool reading, writing and manipulations (#23)
Browse files Browse the repository at this point in the history
* Add ObjectPool reading, writing and manipulations

* Update src/object_pool/mod.rs

Co-authored-by: Adrian Del Grosso <[email protected]>
Signed-off-by: Thom de Jong <[email protected]>

* Update src/object_pool/mod.rs

Co-authored-by: Adrian Del Grosso <[email protected]>
Signed-off-by: Thom de Jong <[email protected]>

* Update src/object_pool/mod.rs

Co-authored-by: Adrian Del Grosso <[email protected]>
Signed-off-by: Thom de Jong <[email protected]>

* integrating unit tests for object pool (to be continued)

* continue unit test and adding more specific option specifications

* continue unit test from_iop

* continue unit test from_iop and simplification of pool object design

* GwnDaan review fixes

* reader.rs refactoring

* pass id to read functions

* format

* fix build

* format

* clippy warnings

* writer.rs refactoring (for unit testing)

* implement code planes

* Renaming and typing

* example doc

* some validation stuff

* ..

* validate bool

* fix read_bool

* colour refactoring and rework

* add working set specific unit test

* rework from_iop unit test (to be continued)

* todo working set read test

* added nullable object id

* .iop update

* lint

* ..

* refactoring

* lint

* corrected test read_working_set_test

* refactor object attributes

* fix bug -> u8 not u16

* complete object option encapsulation

* add EQ to NAME

* remove todo

* remove tests to fix them later

---------

Signed-off-by: Thom de Jong <[email protected]>
Signed-off-by: Daan Steenbergen <[email protected]>
Co-authored-by: Adrian Del Grosso <[email protected]>
Co-authored-by: Jannes Brands <[email protected]>
Co-authored-by: Jannes Brands <[email protected]>
Co-authored-by: Daan Steenbergen <[email protected]>
  • Loading branch information
5 people authored Dec 5, 2023
1 parent 44006ea commit da74b03
Show file tree
Hide file tree
Showing 14 changed files with 5,000 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ description = "A Free ISO-11783 and J1939 CAN Stack"
keywords = ["agriculture", "can", "canbus", "isobus", "j1939", "agritech", "smart-farming", "iso11783"]

[dependencies]
bitvec = "1.0.1"
rand = "0.8.5"
socketcan = { version = "2.0.0", optional = true }
strum_macros = "0.25.2"

[features]
default = []
Expand Down
Binary file added resources/test/AgIsoStack-rs-test-pool.iop
Binary file not shown.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

pub mod driver;
pub mod network_management;
pub mod object_pool;
8 changes: 7 additions & 1 deletion src/network_management/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum NameField {
SelfConfigurableAddress(bool),
}

#[derive(Copy, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct NAME {
raw_name: u64,
}
Expand Down Expand Up @@ -198,6 +198,12 @@ impl From<NAME> for u64 {
}
}

impl From<NAME> for [u8; 8] {
fn from(name: NAME) -> Self {
name.raw_name.to_le_bytes()
}
}

#[derive(Default)]
pub struct NameBuilder {
self_configurable_address: bool,
Expand Down
339 changes: 339 additions & 0 deletions src/object_pool/colour.rs

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/object_pool/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pub mod colour;
pub mod reader;
pub mod writer;

mod object;
mod object_attributes;
mod object_id;
mod object_pool;
mod object_type;
mod vt_version;

use crate::network_management::name::NAME;

pub use colour::Colour;
pub use object_pool::ObjectPool;
pub use object_type::ObjectType;

#[derive(Debug)]
pub enum ParseError {
DataEmpty,
UnknownObjectType,
}
Loading

0 comments on commit da74b03

Please sign in to comment.