# HG changeset patch # User Josef 'Jeff' Sipek # Date 1579533391 18000 # Node ID fbf26ed4884d04fdbca6be8e6f743a3bce8c8cce # Parent 50756644a037eeaea8209af3c6c4e0615d3f4ac1 dump-sat: a utility to dump UBX-NAV-SAT messages Signed-off-by: Josef 'Jeff' Sipek diff -r 50756644a037 -r fbf26ed4884d .hgignore --- a/.hgignore Mon Jan 20 10:16:28 2020 -0500 +++ b/.hgignore Mon Jan 20 10:16:31 2020 -0500 @@ -12,6 +12,7 @@ broadcast-log capture dump-ecef +dump-sat dump-ubx print-state reframe diff -r 50756644a037 -r fbf26ed4884d CMakeLists.txt --- a/CMakeLists.txt Mon Jan 20 10:16:28 2020 -0500 +++ b/CMakeLists.txt Mon Jan 20 10:16:31 2020 -0500 @@ -90,6 +90,15 @@ ublox8 ) +add_executable(dump-sat + dump-common.c + dump-sat.c +) + +target_link_libraries(dump-sat + ublox8 +) + add_executable(dump-ubx dump-common.c dump-ubx.c diff -r 50756644a037 -r fbf26ed4884d dump-sat.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dump-sat.c Mon Jan 20 10:16:31 2020 -0500 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019-2020 Josef 'Jeff' Sipek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "dump-common.h" + +void process_ubx_message(const struct ubx_header *header, + const uint8_t *raw, size_t len, + uint64_t tick) +{ + struct ubx_nav_sat *msg; + uint8_t local_raw[len]; + int i; + + if ((header->class != UBX_CLASS_NAV) || (header->id != 0x35)) + return; + + memcpy(&local_raw, raw, len); + msg = (struct ubx_nav_sat *) local_raw; + + ASSERT3U(msg->version, ==, 1); + + msg->itow = le32_to_cpu(msg->itow); + + for (i = 0; i < msg->num_svs; i++) { + msg->sv[i].azim = le16_to_cpu(msg->sv[i].azim); + msg->sv[i].prres = le16_to_cpu(msg->sv[i].prres); + msg->sv[i].flags = le32_to_cpu(msg->sv[i].flags); + + printf("{\"msg\":\"UBX-NAV-SAT\",\"itow\":%.3f," + "\"gnss\":%u,\"sv\":%u," + "\"cno\":%u,\"az\":%d,\"el\":%d}\n", + msg->itow / 1000., + msg->sv[i].gnssid, msg->sv[i].svid, + msg->sv[i].cno, + (int16_t) msg->sv[i].azim, + (int8_t) msg->sv[i].elev); + } +}