Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GetValue support #4

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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 data/vss-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use the full name. When official release is created replace the copied *.json-fi
Build and run kuksa_databroker using the new VSS file according to [documentation](../../README.md), e.g.

```sh
$cargo run --bin databroker -- --metadata ../data/vss-core/vss_release_4.0.json
$cargo run --bin databroker -- --metadata ./data/vss-core/vss_release_4.0.json
```

Use the client to verify that changes in VSS are reflected, by doing e.g. set/get on some new or renamed signals.
Expand Down
6 changes: 3 additions & 3 deletions databroker-cli/src/kuksa_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ pub async fn kuksa_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
}
}
Err(err) => {
cli::print_error(cmd, &format!("Malformed token: {err}"))?
cli::print_error(cmd, format!("Malformed token: {err}"))?
}
}
}
Expand Down Expand Up @@ -350,12 +350,12 @@ pub async fn kuksa_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
}
}
Err(err) => {
cli::print_error(cmd, &format!("Malformed token: {err}"))?
cli::print_error(cmd, format!("Malformed token: {err}"))?
}
},
Err(err) => cli::print_error(
cmd,
&format!(
format!(
"Failed to open token file \"{token_filename}\": {err}"
),
)?,
Expand Down
6 changes: 3 additions & 3 deletions databroker-cli/src/sdv_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
}
}
Err(err) => {
cli::print_error(cmd, &format!("Malformed token: {err}"))?
cli::print_error(cmd, format!("Malformed token: {err}"))?
}
}
}
Expand Down Expand Up @@ -295,12 +295,12 @@ pub async fn sdv_main(_cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
}
}
Err(err) => {
cli::print_error(cmd, &format!("Malformed token: {err}"))?
cli::print_error(cmd, format!("Malformed token: {err}"))?
}
},
Err(err) => cli::print_error(
cmd,
&format!(
format!(
"Failed to open token file \"{token_filename}\": {err}"
),
)?,
Expand Down
13 changes: 6 additions & 7 deletions databroker/src/grpc/kuksa_val_v2/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ impl From<&proto::Datapoint> for broker::Datapoint {
impl From<broker::Datapoint> for Option<proto::Datapoint> {
fn from(from: broker::Datapoint) -> Self {
match from.value {
broker::DataValue::NotAvailable => None,
broker::DataValue::NotAvailable => Some(proto::Datapoint {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a discussion point. For GetValue we expect a ValueState:.Failure to be returned if a value not yet exist, but not for subscribe. One solution is to map here but filter higher up (in subscribe)

value_state: Some(proto::datapoint::ValueState::Failure(
proto::ValueFailure::NotProvided.into(),
)),
timestamp: None,
}),
broker::DataValue::Bool(value) => Some(proto::Datapoint {
value_state: Some(proto::datapoint::ValueState::Value(proto::Value {
typed_value: Some(proto::value::TypedValue::Bool(value)),
Expand Down Expand Up @@ -196,10 +201,7 @@ impl From<&i32> for broker::ValueFailure {
fn from_i32(value: i32) -> proto::ValueFailure {
// Use a match statement to convert the i32 to the corresponding enum variant
match value {
1 => proto::ValueFailure::InvalidValue,
2 => proto::ValueFailure::NotProvided,
3 => proto::ValueFailure::UnknownSignal,
4 => proto::ValueFailure::AccessDenied,
5 => proto::ValueFailure::InternalError,
_ => proto::ValueFailure::Unspecified,
}
Expand All @@ -209,10 +211,7 @@ impl From<&proto::ValueFailure> for broker::ValueFailure {
fn from(value_failure: &proto::ValueFailure) -> Self {
match value_failure {
proto::ValueFailure::Unspecified => broker::ValueFailure::Unspecified,
proto::ValueFailure::InvalidValue => broker::ValueFailure::InvalidValue,
proto::ValueFailure::NotProvided => broker::ValueFailure::NotProvided,
proto::ValueFailure::UnknownSignal => broker::ValueFailure::UnknownSignal,
proto::ValueFailure::AccessDenied => broker::ValueFailure::AccessDenied,
proto::ValueFailure::InternalError => broker::ValueFailure::InternalError,
}
}
Expand Down
Loading
Loading