summaryrefslogtreecommitdiff
path: root/driver_nmea2000.c
diff options
context:
space:
mode:
authorReinhard Arlt <reinhard.arlt@t-online.de>2015-05-07 15:01:27 +0200
committerReinhard Arlt <reinhard.arlt@t-online.de>2015-05-07 15:01:27 +0200
commit8e4167b72792d3dee04aaec41d4627a44d46703e (patch)
treeff2afed0f39aaae8a071b83076407b35f344477d /driver_nmea2000.c
parenta60101cbb3c578cb130580f7be04ec5203e8b6c2 (diff)
downloadgpsd-8e4167b72792d3dee04aaec41d4627a44d46703e.tar.gz
Fix char encoding in ais.type7 strings.
Diffstat (limited to 'driver_nmea2000.c')
-rw-r--r--driver_nmea2000.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index 73d08555..5748d357 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -607,6 +607,7 @@ static gps_mask_t hnd_129794(unsigned char *bu, int len, PGN *pgn, struct gps_de
uint32_t time;
time_t date1;
struct tm date2;
+ int cpy_stop;
ais->type5.ais_version = (unsigned int) ((bu[73] >> 0) & 0x03);
ais->type5.imo = (unsigned int) getleu32(bu, 5);
@@ -644,18 +645,39 @@ static gps_mask_t hnd_129794(unsigned char *bu, int len, PGN *pgn, struct gps_de
ais->type5.draught = (unsigned int) (getleu16(bu, 51)/10);
ais->type5.dte = (unsigned int) ((bu[73] >> 6) & 0x01);
- for (l=0;l<7;l++) {
- ais->type5.callsign[l] = (char) bu[9+l];
+ for (l=0,cpy_stop=0;l<7;l++) {
+ if (((char) bu[9+l] < ' ') || ((char) bu[9+l] > 0x7e)) {
+ cpy_stop = 1;
+ }
+ if (cpy_stop == 0) {
+ ais->type5.callsign[l] = (char) bu[9+l];
+ } else {
+ ais->type5.callsign[l] = 0;
+ }
}
ais->type5.callsign[7] = (char) 0;
- for (l=0;l<AIS_SHIPNAME_MAXLEN;l++) {
- ais->type5.shipname[l] = (char) bu[16+l];
+ for (l=0,cpy_stop=0;l<AIS_SHIPNAME_MAXLEN;l++) {
+ if (((char) bu[16+l] < ' ') || ((char) bu[16+l] > 0x7e)) {
+ cpy_stop = 1;
+ }
+ if (cpy_stop == 0) {
+ ais->type5.shipname[l] = (char) bu[16+l];
+ } else {
+ ais->type5.shipname[l] = 0;
+ }
}
ais->type5.shipname[AIS_SHIPNAME_MAXLEN] = (char) 0;
- for (l=0;l<20;l++) {
- ais->type5.destination[l] = (char) bu[53+l];
+ for (l=0,cpy_stop=0;l<20;l++) {
+ if (((char) bu[53+l] < ' ') || ((char) bu[53+l] > 0x7e)) {
+ cpy_stop = 1;
+ }
+ if (cpy_stop == 0) {
+ ais->type5.destination[l] = (char) bu[53+l];
+ } else {
+ ais->type5.destination[l] = 0;
+ }
}
ais->type5.destination[20] = (char) 0;
#if NMEA2000_DEBUG_AIS