Comments (3)
Probably your best solution is to ignore the lookup value for this field; use analyzer -json -nv
instead of analyzer -json
so you always get the underlying value for a lookup, regardless of whether there is a description for that value. As you can see below, with -nv
you always receive a numeric value
, and possibly a name
string.
$ echo "2016-04-09T16:41:40.049Z,2,127488,16,255,8,00,7a,0c,ff,ff,7f,ff,ff" | ./rel/darwin-arm64/analyzer -json -nv
{"version":"5.0.1","units":"std","showLookupValues":true}
{"timestamp":"2016-04-09T16:41:40.049Z","prio":2,"src":16,"dst":255,"pgn":127488,"description":"Engine Parameters, Rapid Update","fields":{"Instance":{"value":0,"name":"Single Engine or Dual Engine Port"},"Speed":798.5}}
$ echo "2016-04-09T16:41:40.049Z,2,127488,16,255,8,02,7a,0c,ff,ff,7f,ff,ff" | ./rel/darwin-arm64/analyzer -json -nv
{"version":"5.0.1","units":"std","showLookupValues":true}
{"timestamp":"2016-04-09T16:41:40.049Z","prio":2,"src":16,"dst":255,"pgn":127488,"description":"Engine Parameters, Rapid Update","fields":{"Instance":{"value":2},"Speed":798.5}}
As you say starting with three motors there may be different orders to the engine numbering system, so you are better of using the underlying data from CANBoat then add your own naming order in a higher layer.
We cannot revert the fact that this is marked as a lookup field for compatibility reasons with downstream projects. A proper downstream project would not care if it changed between these two, but I have been told that they are not programmed defensively.
from canboat.
personally: this is not a showstopper.
Downstream projects are probably in a little bit trouble if they start to generate Enums (if their language supports it) out of Lookups, and these are actually only a subset of used/possible values, and see unknown enum value during decoding/parsing.
one suggestion - currently when lookup value is found - the field in JSON is string ("Instance":"Single Engine or Dual Engine Port"
) but in case value is not found - it is number ("Instance":2
). Maybe it would be better to output that unknown value also as string - at least you can use string method on that unknown value like known value and not have type related problems.
from canboat.
one suggestion - currently when lookup value is found - the field in JSON is string ("Instance":"Single Engine or Dual Engine Port") but in case value is not found - it is number ("Instance":2). Maybe it would be better to output that unknown value also as string - at least you can use string method on that unknown value like known value and not have type related problems.
I'm not changing the output without a VERY good reason. If I did this, there is no way for a consumer of this output to recognise that there is no lookup string available, and that this is a raw value.
If you are using a strongly typed parser that does not know how to handle different datatypes, use the -nv
style output.
from canboat.
Related Issues (20)
- analyzer -raw option should produce standard raw format
- analyzer: Negative time offsets are not printed correctly
- canboat.xsd says short where unsigned short is intended
- docs: RangeMax for ENTERTAINMENT_PLAY_STATUS_BITFIELD is incorrect
- analyzer: Explanation of 'Match' fields where the value matches should show lookup name, not value
- FieldType FIELDTYPE_LOOKUP defined but not used HOT 5
- Garmin GMI20 DIsplay: Backlight Level, Day Night Mode and Colours
- add pgn 65293 definition HOT 3
- PGN 65350
- PGN 127509 (Inverter Status) HOT 6
- Add Support for Yacht Device N2K Format. HOT 3
- analyzer unit conversions? HOT 2
- Argument for change to PGN 65379
- Hi, also i have same question, HOT 6
- Server connection drops with n2kd HOT 1
- PGN129799 : Channel Number incorrect HOT 5
- J1939 support? HOT 2
- Enhancment, Output in Comma Separated Variable (CSV) format
- Add PGN priorities
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from canboat.