diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-05-12 19:40:33 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-05-12 19:40:33 -0400 |
commit | 0f41053dc0c556368f5adfb264b3fa43614efbde (patch) | |
tree | 31460fc899b9ae884ad5b86e73b746cc65f28380 /driver_superstar2.c | |
parent | f1f6d08d2011f1b09b66e41a29dc18020a15f072 (diff) | |
download | gpsd-0f41053dc0c556368f5adfb264b3fa43614efbde.tar.gz |
A simpler way to avoid endianness problems.
Doesn't require htons(3) and wacky header magic.
Diffstat (limited to 'driver_superstar2.c')
-rw-r--r-- | driver_superstar2.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/driver_superstar2.c b/driver_superstar2.c index f7e0cdfc..03bab599 100644 --- a/driver_superstar2.c +++ b/driver_superstar2.c @@ -8,12 +8,6 @@ #include <stdio.h> #include <stdlib.h> -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> /* for htons(3) */ -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> /* for htons(3) */ -#endif /* HAVE_ARPA_INET_H */ #include <string.h> #include <math.h> #include <ctype.h> @@ -385,8 +379,8 @@ superstar2_write(struct gps_device_t *session, char *msg, size_t msglen) for (i = 0; i < (ssize_t) (msglen - 2); i++) c += (unsigned short)msg[i]; c += 0x100; - c = htons(c); - (void)memcpy(msg + (int)msg[3] + 4, &c, 2); + msg[(int)msg[3] + 4] = (char)((c >> 8) & 0xff); + msg[(int)msg[3] + 5] = (char)(c & 0xff); gpsd_report(LOG_IO, "writing superstar2 control type %d len %zu:%s\n", (int)msg[1] & 0x7f, msglen, gpsd_hexdump_wrapper(msg, msglen, LOG_IO)); |