You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 2, 2025. It is now read-only.
An experimental framework for working with someip in rust.
2
+
smip aims to make SOME/IP development in Rust feel as natural as building regular web services.
3
3
4
-
A service can be defined using attributes on function and structs.
4
+
Why is it better than something like vsomeip-rs?
5
5
6
-
For example:
6
+
vsomeip-rs is a Rust binding for the vsomeip C++ library. It exposes the C++ API directly to Rust developers, potentially leading to less Rust-idiomatic code.
7
+
Also vsomeip is a very low level someip implementation and is heavily callback oriented.
8
+
For example a service definition in vsomeip may look like this:
7
9
8
10
```rust
9
-
usesmip::Runtime;
11
+
usevsomeip_rs::*;
12
+
13
+
constSERVICE_ID:ServiceId=0x1111;
14
+
constINSTANCE_ID:InstanceId=0x2222;
15
+
constMETHOD_ID:MethodId=0x3333;
16
+
17
+
fnserver() {
18
+
letruntime=Runtime::get();
19
+
letapp=runtime.create_application_with_name("hello_world_service").expect("Failed to create server");
Methods on services are defined using callbacks. While this is fine for simple services, this can get very complicated for services with complex logic, or with many methods. This is where smip can be of use.
50
+
51
+
It offers a higher-level abstraction over the underlying protocol, making it easier to use and understand by providing a cleaner more structured way to define services by leveraging Rust's powerful macro system, something similar to [rocket.rs](https://rocket.rs/) but for SOME/IP.
52
+
53
+
# Example
54
+
Here's a simple example of defining a service and method using smip:
A service is represented by a struct with a `service` attribute for providing its `id` and other metadata. This struct will also hold all of the service's state.
91
+
92
+
SOME/IP methods are just rust methods with a special `smip_method` attribute attribute to indicate its id. Whatever you pass as an argument to your method is parsed automatically from the payload, and whatever you return from it serialized into a response and sent back.
93
+
All of these need to be in a special impl block marked with a `methods_impl` attribute for the framework to recognize them.
94
+
95
+
# Aim
96
+
97
+
Smip aims to be a SOME/IP framework and not an implementation of SOME/IP, so its not competing with vsomeip or sommar. Currently vsomeip is used as the underlying implementation but this can be swapped with any compliant implementation in the future.
98
+
99
+
Key Benefits:
100
+
* Macro-Based Definition: The smip macro simplifies the definition of services and methods, reducing the amount of code needed.
101
+
* Automatic Serialization/Deserialization: smip handles the serialization and deserialization of your service's data types, so you don't have to write it yourself.
102
+
* Rust-Idiomatic API: The framework's API is designed to be Rust-friendly, with a focus on clarity and simplicity.
103
+
* Improved Developer Experience: smip streamlines the development process, making it easier to create and manage SOME/IP services in Rust.
104
+
105
+
106
+
⚠️ **This is a highly experimental framework and doesn't support all features in SOME/IP.**
107
+
108
+
# Run
109
+
For a working demo see `examples/simple.rs` and `examples/simple_client.rs`:
110
+
111
+
To run locally,
112
+
```bash
113
+
cargo run --example simple
114
+
```
115
+
In another terminal,
116
+
```bash
117
+
cargo run --example simple_demo
118
+
```
119
+
120
+
- You may need to set the `LD_LIBRARY_PATH` environment to a path that contains the vsomeip library as this is dynamically loaded `LD_LIBRARY_PATH=/usr/local/lib`
0 commit comments