summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/venus_api.c26
-rw-r--r--src/venus_api.h3
-rw-r--r--src/venus_gps.c19
3 files changed, 37 insertions, 11 deletions
diff --git a/src/venus_api.c b/src/venus_api.c
index c1ae5d4..839d9ed 100644
--- a/src/venus_api.c
+++ b/src/venus_api.c
@@ -107,6 +107,16 @@ void venus_msg_data_free(struct venus_msg *msg)
msg->data = NULL;
}
+void venus_msg_free(struct venus_msg *msg)
+{
+ if (!msg) {
+ return;
+ }
+
+ venus_msg_data_free(msg);
+ free(msg);
+}
+
uint8_t venus_checksum(void *data, uint16_t len)
{
int i;
@@ -384,36 +394,34 @@ int venus_conf_format(int fd, uint8_t type, uint8_t attr)
return 0;
}
-int venus_query_sw_version(int fd, uint8_t type)
+int venus_query_sw_version(int fd, uint8_t type, struct venus_msg *msg)
{
int err;
uint8_t data[2];
- struct venus_msg msg;
data[0] = ID_QUERY_SW_VERSION;
data[1] = type;
- msg.data = data;
- msg.len = sizeof(data);
- err = venus_write_msg(fd, &msg);
+ msg->data = data;
+ msg->len = sizeof(data);
+ err = venus_write_msg(fd, msg);
if (err < 0) {
log_error("venus_write_msg: %d", err);
return -1;
}
- err = venus_read_msg(fd, &msg);
+ err = venus_read_msg(fd, msg);
if (err < 0) {
log_error("venus_read_msg: %d", err);
return -1;
}
- venus_msg_data_free(&msg);
+ venus_msg_data_free(msg);
- err = venus_read_msg(fd, &msg);
+ err = venus_read_msg(fd, msg);
if (err < 0) {
log_error("venus_read_msg: %d", err);
return -1;
}
- venus_msg_data_free(&msg);
return 0;
}
diff --git a/src/venus_api.h b/src/venus_api.h
index 85387e0..79a1729 100644
--- a/src/venus_api.h
+++ b/src/venus_api.h
@@ -79,6 +79,7 @@ struct venus_msg {
speed_t value_to_baud(speed_t value);
speed_t baud_to_venus(speed_t baud);
void venus_msg_data_free(struct venus_msg *msg);
+void venus_msg_free(struct venus_msg *msg);
uint8_t venus_checksum(void *data, uint16_t len);
int venus_write_msg(int fd, struct venus_msg *msg);
@@ -89,7 +90,7 @@ int venus_system_restart(int fd, uint8_t mode, time_t utc, int16_t latitude,
int venus_factory_defaults(int fd, uint8_t type);
int venus_conf_serial(int fd, uint8_t com, uint8_t baud, uint8_t attr);
int venus_conf_format(int fd, uint8_t type, uint8_t attr);
-int venus_query_sw_version(int fd, uint8_t type);
+int venus_query_sw_version(int fd, uint8_t type, struct venus_msg *msg);
int venus_conf_nmea(int fd, uint8_t gga, uint8_t gsa, uint8_t gsv, uint8_t gll,
uint8_t rmc, uint8_t vtg, uint8_t zda, uint8_t attr);
int venus_tty_configure(int fd, speed_t baud_rate);
diff --git a/src/venus_gps.c b/src/venus_gps.c
index 5f4e7b1..c11bed1 100644
--- a/src/venus_gps.c
+++ b/src/venus_gps.c
@@ -502,6 +502,8 @@ int main(int argc, char *argv[])
char *cp;
int option_index;
int tty;
+ struct venus_msg msg;
+
#if CONFIG_CAN_DEFAULT
int factory_defaults = 0;
#endif
@@ -709,7 +711,22 @@ int main(int argc, char *argv[])
}
venus_conf_format(tty, MSG_TYPE_BINARY, UPDATE_ATTR_SRAM);
- venus_query_sw_version(tty, SW_TYPE_RESERVED);
+
+ tmp = venus_query_sw_version(tty, SW_TYPE_RESERVED, &msg);
+ if (tmp < 0) {
+ log_error("failed to query venus sw version info");
+ exit(1);
+ }
+ if (msg.len == 14 && msg.data[0] == ID_SW_VERSION) {
+ log_notice("Venus Software Type: 0x%02X", msg.data[1]);
+ log_notice("Venus Kernel Version: 0x%02X%02X%02X%02X",
+ msg.data[2], msg.data[3], msg.data[4], msg.data[5]);
+ log_notice("Venus ODM version: 0x%02X%02X%02X%02X",
+ msg.data[6], msg.data[7], msg.data[8], msg.data[9]);
+ log_notice("Venus Revision: 0x%02X%02X%02X%02X",
+ msg.data[10], msg.data[11], msg.data[12], msg.data[13]);
+ }
+ venus_msg_data_free(&msg);
#if CONFIG_CAN_DEFAULT
if (factory_defaults) {