Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Give kuksa-client ability to encode array values to set and get them #542

Merged

Conversation

lukasmittag
Copy link
Contributor

@lukasmittag lukasmittag commented May 4, 2023

Example:

setValue  Vehicle.Cabin.SeatPosCount [1, 2, 3]
getValue Vehicle.Cabin.SeatPosCount
{
    "path": "Vehicle.Cabin.SeatPosCount",
    "value": {
        "value": {
            "values": [
                "1",
                "2",
                "3"
            ]
        },
        "timestamp": "2023-05-04T08:01:32.326616+00:00"
    }
}

@lukasmittag lukasmittag marked this pull request as draft May 4, 2023 08:28
@lukasmittag
Copy link
Contributor Author

While testing myself found the issue that setting with 12,24,35 would not work because then it would set 1,2,2,4,3,5

@lukasmittag lukasmittag force-pushed the feature/kuksa_client_array_support branch from be27833 to c1f87ce Compare May 4, 2023 11:21
@lukasmittag lukasmittag linked an issue May 4, 2023 that may be closed by this pull request
@lukasmittag lukasmittag marked this pull request as ready for review May 4, 2023 12:34
@erikbosch
Copy link
Contributor

Two observations:

It seems quotes are required (for me at least) if including blanks. Do we possibly have (or need) some documentation giving examples on how you specify different values on the command line.

Test Client> setValue Vehicle.Cabin.SeatPosCount [1, 2, 3]
usage: setValue [-h] [-a ATTRIBUTE] Path Value
setValue: error: unrecognized arguments: 2, 3]
Test Client> setValue Vehicle.Cabin.SeatPosCount "[1, 2, 3]"
OK

Secondly it seems that we cannot set an empty array:

Test Client> setValue Vehicle.Cabin.SeatPosCount []
{
    "error": "ValueError in casting the value."
}

Copy link
Contributor Author

This is documented in the README. If you want to use spaces between elements [1,2,3] would work. This is an old issue/problem. Maybe we could fix that too some time.

@lukasmittag
Copy link
Contributor Author

Two observations:

It seems quotes are required (for me at least) if including blanks. Do we possibly have (or need) some documentation giving examples on how you specify different values on the command line.

Test Client> setValue Vehicle.Cabin.SeatPosCount [1, 2, 3]
usage: setValue [-h] [-a ATTRIBUTE] Path Value
setValue: error: unrecognized arguments: 2, 3]
Test Client> setValue Vehicle.Cabin.SeatPosCount "[1, 2, 3]"
OK

Secondly it seems that we cannot set an empty array:

Test Client> setValue Vehicle.Cabin.SeatPosCount []
{
    "error": "ValueError in casting the value."
}

To the second comment. Is this even a use case? Do we want to support this? But yes I see that there is some improvement there. Will try something out.

@lukasmittag lukasmittag force-pushed the feature/kuksa_client_array_support branch from c1f87ce to f91cd28 Compare May 8, 2023 08:22
@lukasmittag
Copy link
Contributor Author

The newest commit allows the ability to set arrays with spaces like [1, 2, 3] therefore what now is possible to is setValue Vehicle.Speed 1 1 1 and this gets an

{
    "error": "ValueError in casting the value."
}

I think this is fine. Opinions?

@lukasmittag lukasmittag requested a review from erikbosch May 9, 2023 06:42
@lukasmittag lukasmittag force-pushed the feature/kuksa_client_array_support branch from 4496725 to 6e04e2c Compare May 9, 2023 09:13
@SebastianSchildt
Copy link
Contributor

From reading the comments, seems fine to me

@erikbosch Do you consider this done now?

@lukasmittag
Copy link
Contributor Author

Not done.
Test Client> setValue Vehicle.OBD.DTCList ["hh","jj"]
OK

 

Test Client> getValue Vehicle.OBD.DTCList
{
    "path": "Vehicle.OBD.DTCList",
    "value": {
        "value": {
            "values": [
                ""hh"",
                ""jj""
            ]
        },
        "timestamp": "2023-05-12T09:36:24.159561+00:00"
    }
}
it includes " " into the array values

@lukasmittag
Copy link
Contributor Author

Needs a rework of trailing whitespaces too
Test Client> setValue Vehicle.Powertrain.FuelSystem.SupportedFuel [E5_95, E10_95]
{
"error": {},
"errors": [
{
"path": "Vehicle.Powertrain.FuelSystem.SupportedFuel",
"error": {
"code": 400,
"reason": "value out of bounds",
"message": "given value exceeds type's boundaries"
}
}
]
}

Test Client> setValue Vehicle.Powertrain.FuelSystem.SupportedFuel [E5_95,E10_95]
OK

Test Client> getValue Vehicle.Powertrain.FuelSystem.SupportedFuel
{
"path": "Vehicle.Powertrain.FuelSystem.SupportedFuel",
"value": {
"value": {
"values": [
"E5_95",
"E10_95"
]
},
"timestamp": "2023-05-12T10:14:42.818985+00:00"
}
}

Copy link
Contributor

@SebastianSchildt SebastianSchildt left a comment

Choose a reason for hiding this comment

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

lgtm 🌵

@SebastianSchildt SebastianSchildt merged commit 31cb713 into eclipse:master May 26, 2023
@erikbosch erikbosch deleted the feature/kuksa_client_array_support branch October 31, 2024 12:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KUKSA client and the handling of Arrays for a datapoint
3 participants