summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gpsd_json.c2
-rwxr-xr-xjsongen.py54
-rw-r--r--www/AIVDM.txt2
3 files changed, 40 insertions, 18 deletions
diff --git a/gpsd_json.c b/gpsd_json.c
index 6a1e9079..39b86b90 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -1005,7 +1005,7 @@ void aivdm_json_dump(struct ais_t *ais, bool scaled, char *buf, size_t buflen)
"\"lon\":%d,\"lat\":%d,\"course\":%u,"
"\"heading\":%d,\"second\":%u,\"regional\":%d,"
"\"shipname\":\"%s\",\"shiptype\":%u,"
- "\"to_bow\":%u,\"stern\":%u,\"port\":%u,"
+ "\"to_bow\":%u,\"to_stern\":%u,\"to_port\":%u,"
"\"starboard\":%u,\"epfd\":%u,\"raim\":%s,"
"\"dte\":%u,\"assigned\":%s}\r\n",
ais->type19.reserved,
diff --git a/jsongen.py b/jsongen.py
index ac7447f6..f1b91926 100755
--- a/jsongen.py
+++ b/jsongen.py
@@ -258,9 +258,9 @@ ais_specs = (
('shipname', 'string', None),
('shiptype', 'uinteger', '0'),
('to_bow', 'uinteger', '0'),
- ('stern', 'uinteger', '0'),
- ('port', 'uinteger', '0'),
- ('starboard', 'uinteger', '0'),
+ ('to_stern', 'uinteger', '0'),
+ ('to_port', 'uinteger', '0'),
+ ('to_starboard', 'uinteger', '0'),
('epfd', 'uinteger', '0'),
('raim', 'boolean', 'false'),
('dte', 'integer', '1'),
@@ -450,28 +450,37 @@ ais_specs = (
('zonesize', 'uinteger', '0'),
),
},
+ # Structure of mesage 23 is a mystery
+ {
+ "initname" : "json_ais24",
+ "header": "\tAIS_HEADER,",
+ "structname": "ais->type24",
+ "fieldmap":(
+ # fieldname type default
+ ('partno', 'uinteger', '0'),
+ ('a.shipname', 'string', None), # Part A
+ ('b.shiptype', 'uinteger', '0'), # Part B
+ ('b.vendorid', 'string', None), # Part B
+ ('b.callsign', 'string', None), # Part B
+ ('b.mothership_mmsi', 'uinteger', '0'), # Part B
+ ('b.dim.to_bow', 'uinteger', '0'), # Part B
+ ('b.dim.to_stern', 'uinteger', '0'), # Part B
+ ('b.dim.to_port', 'uinteger', '0'), # Part B
+ ('b.dim.to_starboard', 'uinteger', '0'), # Part B
+ ),
+ },
)
# Give this global the string spec you need to convert with -g
# We do it this mildly odd way only because passing Python multiline
# string literals on the command line is inconvenient.
-stringspec = \
- "\"channel_a\":%u,\"channel_b\":%u,"\
- "\"mode\":%u,\"power\":%u,"\
- "\"ne_lon\":%d,\"ne_lat\":%d,"\
- "\"sw_lon\":%d,\"sw_lat\":%d,"\
- "\"addressed\":%s,\"band_a\":%s,"\
- "\"band_b\":%s,\"zonesize\":\":%u}\r\n"
+stringspec = ""
-# You should not need to modify anything below this liine.
+# You should not need to modify anything below this line.
def generate(spec):
- print """/*
- * This is code generated by jsongen.py. Do not hand-hack it.
- */
-"""
- outboard = []
+ global outboard
for (attr, itype, default) in spec["fieldmap"]:
if attr in spec.get("stringbuffered", []):
if attr not in outboard:
@@ -490,6 +499,8 @@ def generate(spec):
target = attr
else:
target = structname + "." + attr
+ if "." in attr:
+ attr = attr[attr.rfind(".")+1:]
print '\t{"%s",%s%s,%s.addr.%s = %s%s,' % \
(attr, " "*(12-len(attr)), itype, " "*(10-len(itype)), itype, deref, target)
leader = " " * 35
@@ -503,6 +514,11 @@ def generate(spec):
};
"""
+# No code for gernerating dump functions yet.
+# When we do this, remembeer that we have to suppress dump function
+# generation from any spec with a union dot in the field names;
+# those will have to be coded by hand.
+
def string_to_specifier(strspec):
"Compile a Python-style format string to an attribute-type fieldmap."
# Map C and Python-type format letters to JSON parser datatypes
@@ -556,5 +572,11 @@ if __name__ == '__main__':
if specify:
string_to_specifier(stringspec)
else:
+ print """/*
+ * This is code generated by jsongen.py. Do not hand-hack it.
+ */
+"""
+ outboard = []
for description in ais_specs:
generate(description)
+ print "/* Generated code ends. */"
diff --git a/www/AIVDM.txt b/www/AIVDM.txt
index d4d1c773..c401279e 100644
--- a/www/AIVDM.txt
+++ b/www/AIVDM.txt
@@ -974,7 +974,7 @@ Field Len Description Member Units
Nore that latitude and longitude are in units of a tenth of a minute;
sign interpretation and out-of-band values are as in the Common
-Navigation Clock. (Note, howeverm that the hex representastion of
+Navigation Clock. (Note, however, that the hex representation of
the out-of-band values differs; it is 181 \* 60 \* 10 = 0x1a838 for
longitude, 91 \* 60 \* 10 = 0xd548 for latitude.)