-
Notifications
You must be signed in to change notification settings - Fork 97
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
Feature/ais6 235 10 #195
base: master
Are you sure you want to change the base?
Feature/ais6 235 10 #195
Changes from 4 commits
2779fab
c8a0da4
85d0054
6f3b416
f18a673
eaaa3a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ enum AIS_FI { | |
AIS_FI_6_200_21_RIS_VTS_ETA = 21, | ||
AIS_FI_6_200_22_RIS_VTS_RTA = 22, | ||
AIS_FI_6_200_55_RIS_VTS_SAR = 55, | ||
|
||
AIS_FI_6_235_10_ATON_MONITORING_DATA = 10, | ||
AIS_FI_8_1_0_TEXT = 0, | ||
AIS_FI_8_1_11_MET_HYDRO = 11, | ||
AIS_FI_8_1_13_FAIRWAY_CLOSED = 13, | ||
|
@@ -698,6 +698,30 @@ ais6_1_40_append_pydict(const char *nmea_payload, PyObject *dict, | |
return AIS_OK; | ||
} | ||
|
||
AIS_STATUS | ||
ais6_235_10_append_pydict(const char *nmea_payload, PyObject *dict, | ||
const size_t pad) { | ||
assert(nmea_payload); | ||
assert(dict); | ||
assert(pad < 6); | ||
Ais6_235_10 msg(nmea_payload, pad); | ||
if (msg.had_error()) { | ||
return msg.get_error(); | ||
} | ||
|
||
DictSafeSetItem(dict, "ana_int", msg.ana_int); | ||
DictSafeSetItem(dict, "ana_ext1", msg.ana_ext1); | ||
DictSafeSetItem(dict, "ana_ext2", msg.ana_ext2); | ||
DictSafeSetItem(dict, "racon", msg.racon); | ||
DictSafeSetItem(dict, "light", msg.light); | ||
DictSafeSetItem(dict, "health", msg.health); | ||
DictSafeSetItem(dict, "stat_ext", msg.stat_ext); | ||
DictSafeSetItem(dict, "off_pos", msg.off_pos); | ||
DictSafeSetItem(dict, "spare2", msg.spare2); | ||
|
||
return AIS_OK; | ||
} | ||
|
||
PyObject* | ||
ais6_to_pydict(const char *nmea_payload, const size_t pad) { | ||
assert(nmea_payload); | ||
|
@@ -722,58 +746,67 @@ ais6_to_pydict(const char *nmea_payload, const size_t pad) { | |
AIS_STATUS status = AIS_UNINITIALIZED; | ||
|
||
switch (msg.dac) { | ||
case AIS_DAC_1_INTERNATIONAL: // IMO. | ||
switch (msg.fi) { | ||
case AIS_FI_6_1_0_TEXT: // OLD ITU 1371-1. | ||
status = ais6_1_0_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_1_ACK: // OLD ITU 1371-1. | ||
status = ais6_1_1_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_2_FI_INTERROGATE: // OLD ITU 1371-1. | ||
status = ais6_1_2_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_3_CAPABILITY_INTERROGATE: // OLD ITU 1371-1. | ||
status = ais6_1_3_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_4_CAPABILITY_REPLY: // OLD ITU 1371-1. | ||
status = ais6_1_4_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_5_ACK: // ITU 1371-5. | ||
status = ais6_1_5_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_12_DANGEROUS_CARGO: // Not to be used after 1 Jan 2013. | ||
status = ais6_1_12_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_14_TIDAL_WINDOW: // Not to be used after 1 Jan 2013. | ||
status = ais6_1_14_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_18_ENTRY_TIME: | ||
status = ais6_1_18_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_20_BERTHING: | ||
status = ais6_1_20_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_25_DANGEROUS_CARGO: | ||
status = ais6_1_25_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
// TODO(schwehr): AIS_FI_6_1_28_ROUTE. | ||
// TODO(schwehr): AIS_FI_6_1_30_TEXT. | ||
case AIS_FI_6_1_32_TIDAL_WINDOW: // IMO Circ 289 | ||
status = ais6_1_32_append_pydict(nmea_payload, dict, pad); | ||
case AIS_DAC_1_INTERNATIONAL: // IMO. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't reindent this all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. back to original indenting. |
||
switch (msg.fi) { | ||
case AIS_FI_6_1_0_TEXT: // OLD ITU 1371-1. | ||
status = ais6_1_0_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_1_ACK: // OLD ITU 1371-1. | ||
status = ais6_1_1_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_2_FI_INTERROGATE: // OLD ITU 1371-1. | ||
status = ais6_1_2_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_3_CAPABILITY_INTERROGATE: // OLD ITU 1371-1. | ||
status = ais6_1_3_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_4_CAPABILITY_REPLY: // OLD ITU 1371-1. | ||
status = ais6_1_4_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_5_ACK: // ITU 1371-5. | ||
status = ais6_1_5_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_12_DANGEROUS_CARGO: // Not to be used after 1 Jan 2013. | ||
status = ais6_1_12_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_14_TIDAL_WINDOW: // Not to be used after 1 Jan 2013. | ||
status = ais6_1_14_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_18_ENTRY_TIME: | ||
status = ais6_1_18_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_20_BERTHING: | ||
status = ais6_1_20_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_25_DANGEROUS_CARGO: | ||
status = ais6_1_25_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
// TODO(schwehr): AIS_FI_6_1_28_ROUTE. | ||
// TODO(schwehr): AIS_FI_6_1_30_TEXT. | ||
case AIS_FI_6_1_32_TIDAL_WINDOW: // IMO Circ 289 | ||
status = ais6_1_32_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
case AIS_FI_6_1_40_PERSONS_ON_BOARD: // OLD ITU 1371-1. | ||
status = ais6_1_40_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
default: | ||
// TODO(schwehr): Raise an exception? | ||
DictSafeSetItem(dict, "not_parsed", true); | ||
} | ||
break; | ||
case AIS_FI_6_1_40_PERSONS_ON_BOARD: // OLD ITU 1371-1. | ||
status = ais6_1_40_append_pydict(nmea_payload, dict, pad); | ||
case AIS_DAC_235_UNITED_KINGDOM_OF_GREAT_BRITAIN_AND_NORTHERN_IRELAND: // IMO. | ||
switch (msg.fi) { | ||
case AIS_FI_6_235_10_ATON_MONITORING_DATA: // IALA-A126. | ||
status = ais6_235_10_append_pydict(nmea_payload, dict, pad); | ||
break; | ||
default: | ||
// TODO(schwehr): Raise an exception? | ||
DictSafeSetItem(dict, "not_parsed", true); | ||
} | ||
break; | ||
default: | ||
// TODO(schwehr): Raise an exception? | ||
DictSafeSetItem(dict, "not_parsed", true); | ||
} | ||
break; | ||
|
||
default: | ||
// TODO(schwehr): Raise an exception? | ||
DictSafeSetItem(dict, "not_parsed", true); | ||
} | ||
|
||
if (status != AIS_OK) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ def DictDiff(a, b): | |
def Compare(x, y): | ||
if x == y: | ||
return True | ||
if x in [None, 'nan'] and y in [None, 'nan']: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need this? And that says that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified because |
||
return True | ||
x = TextToNumber(x) | ||
y = TextToNumber(y) | ||
if isinstance(x, six.string_types) and isinstance(y, six.string_types): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
!
not is missing. Also, why is astatic_cast<bool>
better?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From ais type 6 documentation, it should not be negated
!
:The decoding of the messages type 6 from the tests:
are not correct, as confirmed by decoding the AIS messages for instance here.
Therefore changed tests that are affected + this line.
@schwehr reverted to not using
static_cast<bool>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use original source documentation for AIS message 6. I certainly could have been wrong, but unless you quote an official standard like
ITU M.1371
, I am not going to change it. gpsd aivdm docs were written by ESR with feedback from me beforeITU M.1371
was freely available. I had a purchased copy; ESR did not.So, I believe that I set this up as a
bool
calledretransmit
based on discussions at RTCM SC121 back in the 2007-2009 time frame.3.4 Message 6: Addressed binary message; table 54:
I took the flag as a should retransmit.
No matter the correct answer, changing it in this pr is out of scope. Please don't do it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schwehr you are right, topic is out of scope for this PR. Will use original source doc in another issue. 👍
Reverted.