--- gpsdecode.c.orig	2015-03-30 13:19:28.000000000 -0700
+++ gpsdecode.c	2016-01-03 00:15:12.000000000 -0800
@@ -31,6 +31,26 @@
  **************************************************************************/
 
 #ifdef AIVDM_ENABLE
+static const char *raw_hexdump(char *scbuf, size_t scbuflen, int structured,
+					  char *binbuf, size_t binbuflen)
+{
+    if (!structured)
+	return gpsd_hexdump(scbuf, scbuflen, binbuf, binbuflen);
+/* Data parsed as structured doesn't have correct raw data */
+#ifndef SQUELCH_ENABLE
+    size_t len =
+	(size_t) ((binbuflen >
+		   MAX_PACKET_LENGTH) ? MAX_PACKET_LENGTH : binbuflen) * 2;
+    if (len > scbuflen - 1) len = scbuflen - 1;
+
+    memset(scbuf, 'x', len);
+    scbuf[len] = '\0';
+#else /* SQUELCH defined */
+    scbuf[0] = '\0';
+#endif /* SQUELCH_ENABLE */
+    return scbuf;
+}
+
 static void aivdm_csv_dump(struct ais_t *ais, char *buf, size_t buflen)
 {
     char scratchbuf[MAX_PACKET_LENGTH*2+1];
@@ -124,9 +144,10 @@
 	    str_appendf(buf, buflen,
 			   "|%zd:%s",
 			   ais->type6.bitcount,
-			   gpsd_hexdump(scratchbuf, sizeof(scratchbuf),
-					ais->type6.bitdata,
-					BITS_TO_BYTES(ais->type6.bitcount)));
+			   raw_hexdump(scratchbuf, sizeof(scratchbuf),
+				       ais->type6.structured,
+				       ais->type6.bitdata,
+				       BITS_TO_BYTES(ais->type6.bitcount)));
 	break;
     case 7:			/* Binary Acknowledge */
     case 13:			/* Safety Related Acknowledge */
@@ -229,9 +250,10 @@
 	    str_appendf(buf, buflen,
 			   "|%zd:%s",
 			   ais->type8.bitcount,
-			   gpsd_hexdump(scratchbuf, sizeof(scratchbuf),
-					ais->type8.bitdata,
-					BITS_TO_BYTES(ais->type8.bitcount)));
+			   raw_hexdump(scratchbuf, sizeof(scratchbuf),
+				       ais->type8.structured,
+				       ais->type8.bitdata,
+				       BITS_TO_BYTES(ais->type8.bitcount)));
 	break;
     case 9:
 	str_appendf(buf, buflen,
--- test/sample.aivdm.chk.orig	2015-03-29 23:30:05.000000000 -0700
+++ test/sample.aivdm.chk	2016-01-03 00:27:19.000000000 -0800
@@ -7,9 +7,9 @@
 6|1|150834090|3|313240222|0|669|11|48:eb2f118f7ff1
 6|0|992509976|0|2500912|0|235|10|274|1|1|2|2|0|0|0
 6|0|265538450|0|2655651|0|1|40|16:0000
-6|0|230986000|2|970110950|1|1|12|56:30435445530000
-6|3|002443808|0|329176500|1|1|14|80:00000000000000000100
-6|3|002442101|1|244615956|1|1|18|80:01000000000000000000
+6|0|230986000|2|970110950|1|1|12|56:xxxxxxxxxxxxxx
+6|3|002443808|0|329176500|1|1|14|80:xxxxxxxxxxxxxxxxxxxx
+6|3|002442101|1|244615956|1|1|18|80:xxxxxxxxxxxxxxxxxxxx
 7|0|002655651|265538450|0|0|0
 7|1|655901842|158483613|321823389|836359488|0
 7|2|537411077|43101326|717096664|76161024|0
@@ -18,7 +18,7 @@
 8|0|992509977|1|11|-368039|3197693|18T17:15Z|3|6|12|15|742|50|323|224|2|153|16|1|103|256|104|257|10|126|203|20|42|35|25|23|48|124|3|223|6|53|0
 8|0|992509977|1|11|-368037|3197689|18T17:45Z|127|127|511|511|2047|127|1023|511|3|255|511|3|255|511|255|511|31|255|511|31|255|63|511|255|63|511|15|1023|7|511|3
 8|0|992509977|1|31|-368044|3197696|29T23:24Z|127|127|360|360|-1024|101|501|511|3|127|4001|3|255|360|255|360|31|255|360|31|255|63|360|255|63|360|13|501|7|510|3
-8|0|244650946|200|10|112:3032313033353437000000008601
+8|0|244650946|200|10|112:xxxxxxxxxxxxxxxxxxxxxxxxxxxx
 8|0|244650946|200|10|368:c32c70cf5d370c3064fa50198800b4987e9555557e083a544f082003b809ae511bfc75f0a7ff960808ccb6be7ed5
 9|0|111265591|15|0|0|7128960|34667073|0|28|0x0|0|0|0xc02a
 10|0|366814480|366832740
@@ -70,8 +70,8 @@
 4|0|002242115|2012-06-01T24:60:60Z|1|-5031130|26021408|7|0|0x208ca
 4|0|972158237|10196-00-24T09:57:37Z|1|123070132|65599231|14|1|0x8c8
 22|2|875794037|3396|373|1|0|837968222|254804543|1|0|1|7
-6|0|002444012|0|255803540|1|1|18|80:01000000000000000000
-6|3|002442102|0|244100055|1|1|30|80:01000000280000000000
-6|0|002444012|0|255803540|1|1|18|80:01000000000000000000
-6|3|002442101|2|246351000|0|1|32|80:00000000000000000100
-6|3|002442104|0|245679000|0|1|32|80:00000000000000000100
+6|0|002444012|0|255803540|1|1|18|80:xxxxxxxxxxxxxxxxxxxx
+6|3|002442102|0|244100055|1|1|30|80:xxxxxxxxxxxxxxxxxxxx
+6|0|002444012|0|255803540|1|1|18|80:xxxxxxxxxxxxxxxxxxxx
+6|3|002442101|2|246351000|0|1|32|80:xxxxxxxxxxxxxxxxxxxx
+6|3|002442104|0|245679000|0|1|32|80:xxxxxxxxxxxxxxxxxxxx
