changeset 92:c71c6a44e69f

dump-uniqid: a tool to dump UBX-SEC-UNIQID messages These contain the device serial number. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 22 Feb 2021 18:08:23 -0500
parents 80059db17cc5
children 71cae6a9a299
files .hgignore CMakeLists.txt dump-uniqid.c
diffstat 3 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Feb 22 10:03:09 2021 -0500
+++ b/.hgignore	Mon Feb 22 18:08:23 2021 -0500
@@ -12,6 +12,7 @@
 broadcast-log
 capture
 dump-ecef
+dump-uniqid
 dump-sat
 dump-ubx
 print-state
--- a/CMakeLists.txt	Mon Feb 22 10:03:09 2021 -0500
+++ b/CMakeLists.txt	Mon Feb 22 18:08:23 2021 -0500
@@ -90,6 +90,15 @@
 	ublox8
 )
 
+add_executable(dump-uniqid
+	dump-common.c
+	dump-uniqid.c
+)
+
+target_link_libraries(dump-uniqid
+	ublox8
+)
+
 add_executable(dump-sat
 	dump-common.c
 	dump-sat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dump-uniqid.c	Mon Feb 22 18:08:23 2021 -0500
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019-2021 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * 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,
+			 enum ubx_msg_id msgid,
+			 uint64_t tick)
+{
+	struct ubx_sec_uniqid *msg;
+	uint8_t local_raw[len];
+
+	if (msgid != UBX_SEC_UNIQID)
+		return;
+
+	memcpy(&local_raw, raw, len);
+	msg = (struct ubx_sec_uniqid *) local_raw;
+
+	ASSERT3U(msg->version, ==, 1);
+
+	printf("{\"msg\":\"UBX-SEC-UNIQID\","
+	       "\"unique\":\"%02x%02x%02x%02x%02x\"}\n",
+	       msg->unique[0], msg->unique[1],
+	       msg->unique[2], msg->unique[3],
+	       msg->unique[4]);
+}