[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] Bug in JSON encoding AIVDM type 9 messages
From: |
Stefan Roels |
Subject: |
Re: [gpsd-dev] Bug in JSON encoding AIVDM type 9 messages |
Date: |
Tue, 06 Oct 2015 06:37:13 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
Hi Jon,
The airtemp/dewpoint/watertemp patch does not work. Its the substraction
that causes the problem, so casting it to float after the substraction
is too late.
diff --git a/gpsd_json.c b/gpsd_json.c
index 757089b..1705440 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -2167,8 +2167,8 @@ void json_aivdm_dump(const struct ais_t *ais,
str_appendf(buf, buflen,
"\"airtemp\":%.1f,\"dewpoint\":%.1f,"
"\"pressure\":%u,\"pressuretend\":\"%s\",",
- ((float)(ais->type8.dac1fid11.airtemp
- DAC1FID11_AIRTEMP_OFFSET)) / DAC1FID11_AIRTEMP_DIV,
- ((float)(ais->type8.dac1fid11.dewpoint - DAC1FID11_DEWPOINT_OFFSET)) /
DAC1FID11_DEWPOINT_DIV,
+ ((float)ais->type8.dac1fid11.airtemp
- DAC1FID11_AIRTEMP_OFFSET) / DAC1FID11_AIRTEMP_DIV,
+ ((float)ais->type8.dac1fid11.dewpoint
- DAC1FID11_DEWPOINT_OFFSET) / DAC1FID11_DEWPOINT_DIV,
ais->type8.dac1fid11.pressure -
DAC1FID11_PRESSURE_OFFSET,
trends[ais->type8.dac1fid11.pressuretend]);
else
@@ -2195,7 +2195,7 @@ void json_aivdm_dump(const struct ais_t *ais,
else
str_appendf(buf, buflen,
"\"waterlevel\":%.1f,",
- (ais->type8.dac1fid11.waterlevel -
DAC1FID11_WATERLEVEL_OFFSET) / DAC1FID11_WATERLEVEL_DIV);
+ ((float)ais->type8.dac1fid11.waterlevel - DAC1FID11_WATERLEVEL_OFFSET)
/ DAC1FID11_WATERLEVEL_DIV);
if (scaled) {
str_appendf(buf, buflen,
I also have some sample data (with the proper decoded versions). All
examples come from AISHub (recorded months ago). I use a sample file
containing about 1000000 messages to cross check my own development with
gpsdecode.
!AIVDM,1,1,,A,address@hidden<address@hidden,2*7D
{"class":"AIS","device":"stdin","type":8,"repeat":1,"mmsi":2300061,"scaled":true,"dac":1,"fid":11,"lat":64.650,"lon":24.400,"timestamp":"20T18:27Z","wspeed":11,"wgust":12,"wdir":162,"wgustdir":167,"humidity":80,"airtemp":-12.7,"dewpoint":82.3,"pressure":1032,"pressuretend":"decreasing","visibility":25.5,"waterlevel":41.1,"leveltrend":"N/A","cspeed":25.5,"cdir":511,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":25.5,"waveperiod":63,"wavedir":511,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":92.3,"preciptype":7,"preciptype_text":"N/A","salinity":51.1,"ice":3,"ice_text":"N/A"}
!AIVDM,2,1,2,B,address@hidden<address@hidden<J>G7wfNwwww,0*32
!AIVDM,2,2,2,B,wwwwwwwwwwwwwwwwwwwwwt0,2*26
{"class":"AIS","device":"stdin","type":8,"repeat":1,"mmsi":2300057,"scaled":true,"dac":1,"fid":11,"lat":60.371,"lon":26.962,"timestamp":"20T18:27Z","wspeed":18,"wgust":22,"wdir":99,"wgustdir":99,"humidity":56,"airtemp":-3.1,"dewpoint":82.3,"pressure":1031,"pressuretend":"decreasing","visibility":25.5,"waterlevel":41.1,"leveltrend":"N/A","cspeed":25.5,"cdir":511,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":25.5,"waveperiod":63,"wavedir":511,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":92.3,"preciptype":7,"preciptype_text":"N/A","salinity":51.1,"ice":3,"ice_text":"N/A"}
!AIVDM,2,1,9,B,8>j`;MP0GhRHI1S`CrTW2?u2Ot1owwnews0F003wwwwwww0001wwwwwwwwh0,0*02
!AIVDM,2,2,9,B,00,4*18
{"class":"AIS","device":"stdin","type":8,"repeat":0,"mmsi":992611190,"scaled":true,"dac":1,"fid":31,"lat":54.411,"lon":18.777,"accuracy":false,"timestamp":"20T18:28Z","wspeed":17,"wgust":127,"wdir":132,"wgustdir":511,"humidity":127,"airtemp":1.4,"dewpoint":-0.1,"pressure":1013,"pressuretend":"N/A","visgreater":true,"visibility":12.7,"waterlevel":5.4,"leveltrend":"N/A","cspeed":0.0,"cdir":0,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":0.0,"waveperiod":0,"wavedir":0,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":-0.1,"preciptype":"N/A","salinity":51.1,"ice":"N/A"}
!AIVDM,1,1,,A,address@hidden<address@hidden;wwf>wwwwwwwwwwwwwwwwwwwwwwwwwt0,2*0E
{"class":"AIS","device":"stdin","type":8,"repeat":1,"mmsi":2300059,"scaled":true,"dac":1,"fid":11,"lat":60.111,"lon":21.699,"timestamp":"20T18:27Z","wspeed":9,"wgust":10,"wdir":69,"wgustdir":62,"humidity":95,"airtemp":-1.2,"dewpoint":82.3,"pressure":1027,"pressuretend":"decreasing","visibility":25.5,"waterlevel":41.1,"leveltrend":"N/A","cspeed":25.5,"cdir":511,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":25.5,"waveperiod":63,"wavedir":511,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":92.3,"preciptype":7,"preciptype_text":"N/A","salinity":51.1,"ice":3,"ice_text":"N/A"}
!AIVDM,1,1,,A,address@hidden<address@hidden<B0akj59>address@hidden:7wfNwwwwwwwwwwwwwwwwwwwwwwwwwt0,2*55
{"class":"AIS","device":"stdin","type":8,"repeat":1,"mmsi":2300061,"scaled":true,"dac":1,"fid":11,"lat":63.950,"lon":22.833,"timestamp":"20T18:28Z","wspeed":5,"wgust":6,"wdir":189,"wgustdir":178,"humidity":80,"airtemp":-7.2,"dewpoint":82.3,"pressure":1031,"pressuretend":"decreasing","visibility":25.5,"waterlevel":41.1,"leveltrend":"N/A","cspeed":25.5,"cdir":511,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":25.5,"waveperiod":63,"wavedir":511,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":92.3,"preciptype":7,"preciptype_text":"N/A","salinity":51.1,"ice":3,"ice_text":"N/A"}
!AIVDM,1,1,,A,address@hidden<address@hidden@pOwfNwwwwwwwwwwwwwwwwwwwwwwwwwt0,2*66
{"class":"AIS","device":"stdin","type":8,"repeat":1,"mmsi":2300057,"scaled":true,"dac":1,"fid":11,"lat":60.275,"lon":26.442,"timestamp":"20T18:27Z","wspeed":15,"wgust":18,"wdir":115,"wgustdir":106,"humidity":67,"airtemp":-2.1,"dewpoint":82.3,"pressure":1031,"pressuretend":"decreasing","visibility":25.5,"waterlevel":41.1,"leveltrend":"N/A","cspeed":25.5,"cdir":511,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":25.5,"waveperiod":63,"wavedir":511,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":92.3,"preciptype":7,"preciptype_text":"N/A","salinity":51.1,"ice":3,"ice_text":"N/A"}
!AIVDM,1,1,,A,address@hidden<HVh0BkM75P`MKU9>31iL:RBcGwfBwwwwwwwwwwwwwwwwwwwwwwwwwt0,2*5F
{"class":"AIS","device":"stdin","type":8,"repeat":1,"mmsi":2300059,"scaled":true,"dac":1,"fid":11,"lat":60.378,"lon":22.096,"timestamp":"20T18:28Z","wspeed":12,"wgust":14,"wdir":92,"wgustdir":84,"humidity":90,"airtemp":-1.4,"dewpoint":82.3,"pressure":1028,"pressuretend":"decreasing","visibility":25.5,"waterlevel":41.1,"leveltrend":"N/A","cspeed":25.5,"cdir":511,"cspeed2":25.5,"cdir2":511,"cdepth2":31,"cspeed3":25.5,"cdir3":511,"cdepth3":31,"waveheight":25.5,"waveperiod":63,"wavedir":511,"swellheight":25.5,"swellperiod":63,"swelldir":511,"seastate":15,"watertemp":92.3,"preciptype":7,"preciptype_text":"N/A","salinity":51.1,"ice":3,"ice_text":"N/A"}
!AIVDM,2,1,7,B,802`m000BkGTp0b<j59?000000000000000O,0*14
!AIVDM,2,2,7,B,p0000000000<address@hidden,2*1C
{"class":"AIS","device":"stdin","type":8,"repeat":0,"mmsi":2766080,"scaled":true,"dac":1,"fid":11,"lat":58.867,"lon":23.047,"timestamp":"20T18:30Z","wspeed":0,"wgust":0,"wdir":0,"wgustdir":0,"humidity":0,"airtemp":-60.0,"dewpoint":-20.0,"pressure":800,"pressuretend":"steady","visibility":0.0,"waterlevel":-10.0,"leveltrend":"steady","cspeed":25.5,"cdir":0,"cspeed2":0.0,"cdir2":0,"cdepth2":0,"cspeed3":0.0,"cdir3":0,"cdepth3":0,"waveheight":0.0,"waveperiod":3,"wavedir":0,"swellheight":0.0,"swellperiod":0,"swelldir":0,"seastate":0,"watertemp":429496729.6,"preciptype":0,"preciptype_text":"reserved","salinity":0.0,"ice":0,"ice_text":"no"}
I do also have some examples of the type 8 DAC 1 FID 16 messages that
should not be converted. I have no examples of the ones that should, but
from the documentation, it seems not sure that they actually exist.
!AIVDM,3,1,0,A,address@hidden@mE8;;address@hidden;gh0w00010Wk3<2FG,0*00
!AIVDM,3,2,0,A,ePm;address@hidden@0w00010W:s02F>,0*72
!AIVDM,3,3,0,A,Ghm4utWw2P,4*27
{"class":"AIS","device":"stdin","type":8,"repeat":0,"mmsi":2711009,"scaled":true,"dac":1,"fid":16,"data":"720:00025e8d136025bd890d5520b2ff0ac000000070202580430d4bbf003f000001027cc3302597b60d4b15003f000000c5c4a9802584cf
Regards,
Stefan
On 06-10-15 04:25, Jon Schlueter wrote:
after banging on these changes a bit more I came up with 3 patches that
have been applied to trunk.
more comments inline
On Mon, Oct 5, 2015 at 9:44 PM, Jon Schlueter <address@hidden
<mailto:address@hidden>> wrote:
Stefan Roels,
Can I get a couple of data samples for the following cases.
Type 8, DAC = 1 FID = 11: airtemp, dewpoint and watertemp
calculations go wrong due to unsigned ints.
We seem to be missing any data samples that exercises this data path.
Patch wrangled into shape in a different but should be equivalent way
but missing any sample data for regression testing
https://github.com/yazug/gpsd/commit/f1e39c0c30f4085b3e5e8a488e93af8a69b5f48f
- Type 8, DAC = 1 FID = 16: This should only be decoded as "Persons
on board" if the message length is either 72 or 136 bits long (if
even then).
- Type 8, DAC = 1 FID = 16: If decoded, the json output should use
the ais->type8.dac1fid16.persons field and not the type6 field
We seem to be missing any data samples that exercises the persons on
board data flow It would be nice to make sure we don't regress
backwards with other changes to the parser or storage logic.
Patch wrangled into shape that takes the changes in but missing any
sample data for regression testing
https://github.com/yazug/gpsd/commit/bc450ee1e006267f092e4ef8e0a26b288741be98
- Type 9: the ais->type9.speed field should be used instead of the
type1 field
We seem to be missing any data samples that exercise this test case
where it fails. I'm going to apply the patch but would like to make
sure we have test cases covering this data flow if we don't already
have any.
I was wrong the sample was added and this is now committed
http://git.savannah.gnu.org/cgit/gpsd.git/commit/?id=7a5aa615ba26763169757ebf53ea8611ed9856a4
Thanks much
Jon
jschlueter on freenode #gpsd
Re: [gpsd-dev] Bug in JSON encoding AIVDM type 9 messages, Jon Schlueter, 2015/10/08