From e8d1e4909e119bf2cdcf2636e2f5c57ab1f440e1 Mon Sep 17 00:00:00 2001 From: Lloyd Rochester Date: Sun, 10 Jul 2022 22:20:23 -0600 Subject: [PATCH] bugfix --- README.md | 4 +++- src/lsm9ds1.c | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9602430..b1e4576 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,9 @@ We have the typical Autotools installation flow. We will compile the code from s Firstly, if we're running as non-root the user running the program will need access to SPI and GPIO. Use `raspi-config` to enable SPI. Then add the user to the following groups: ``` -$ usermod -a -G gpio spi pi # assumes the pi user +$ usermod -a -G gpio -G spi pi # assumes the pi user +$ sudo chown root:spi /dev/spidev* +$ sudo chmod g+rw /dev/spidev* ``` Note, this command will not take effect until the user logs in and out again. You can verify using the `groups` command. diff --git a/src/lsm9ds1.c b/src/lsm9ds1.c index 74361fe..ad742f4 100644 --- a/src/lsm9ds1.c +++ b/src/lsm9ds1.c @@ -511,17 +511,17 @@ lsm9ds1_ag_write_socket_udp(struct LSM9DS1 *dev, struct options *opts) socklen_t servsock_len; servsock_len = sizeof(opts->socket_udp_dest); - datagram.secs = htonl(dev->tv.tv_sec); - datagram.usecs = htonl(dev->tv.tv_usec); - datagram.g_x = htons(dev->g.x); - datagram.g_y = htons(dev->g.y); - datagram.g_z = htons(dev->g.z); - datagram.xl_x = htons(dev->xl.x); - datagram.xl_y = htons(dev->xl.y); - datagram.xl_z = htons(dev->xl.z); - datagram.m_x = htons(dev->m.x); - datagram.m_y = htons(dev->m.y); - datagram.m_z = htons(dev->m.z); + datagram.secs = dev->tv.tv_sec; + datagram.usecs = dev->tv.tv_usec; + datagram.g_x = dev->g.x; + datagram.g_y = dev->g.y; + datagram.g_z = dev->g.z; + datagram.xl_x = dev->xl.x; + datagram.xl_y = dev->xl.y; + datagram.xl_z = dev->xl.z; + datagram.m_x = dev->m.x; + datagram.m_y = dev->m.y; + datagram.m_z = dev->m.z; buffrx = sendto(opts->fd_socket_udp, &datagram, sizeof(datagram), 0, (struct sockaddr *)&opts->socket_udp_dest, servsock_len);