| Crates.io | oze-canopen |
| lib.rs | oze-canopen |
| version | 0.1.0 |
| created_at | 2025-03-16 17:07:32.694076+00 |
| updated_at | 2025-03-16 17:07:32.694076+00 |
| description | OZON CANOpen library |
| homepage | https://github.com/ozontech/oze-canopen |
| repository | https://github.com/ozontech/oze-canopen |
| max_upload_size | |
| id | 1594568 |
| size | 114,979 |
CanOpen library for Rust. It is not implementing Object Dictionary and designed to work as sniffer or master node.
// init and start receiver, transmitter and interface monitor
let (interface, mut handles) = canopen::start(String::from("vcan0"), Some(100000));
// wait for connection
sleep(Duration::from_secs(1)).await;
// get SDO client for nodeID=4
let sdo_client = interface.get_sdo_client(4).unwrap();
// because only single SDO request is supported then we guard acces using mutex and now we wait to aquire access
let sdo_client = sdo_client.lock().await;
// Send SDO request upload request and wait for result
let result = sdo_client.upload(0x2110, 0x01).await.unwrap();
// print result
println!("{result:?}");
// Gracefully close canopen stack and join all spawned futures
handles.close_and_join().await;
More examples you can find in examples/ directory.
Unit tests are in src/ and has no external requirements, you can run it using cargo test.
Integration tests are in tests/. To run it successfully you need:
sudo modprobe vcansudo ip link add dev vcan0 type vcansudo ip link set up vcan0./demoLinuxDevice vcan0cargo test -- --test-threads 1After that you can check code coverage using cargo tarpaulin -j 1 --engine llvm
To generate rustdocs you need to execute
cargo doc
Copyright © 2024 LLC "Ozon Technologies"
Licensed under the Apache License, Version 2.0 (the "LICENSE");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.