Replaced Logger usage with LOG_x (#548)
This commit is contained in:
committed by
GitHub
parent
ecad2248d9
commit
9d5993930d
@@ -1,26 +1,25 @@
|
||||
#include <Tactility/hal/gps/GpsDevice.h>
|
||||
#include <Tactility/hal/gps/GpsInit.h>
|
||||
#include <Tactility/hal/gps/Probe.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/uart_controller.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <minmea.h>
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
constexpr uint32_t GPS_UART_BUFFER_SIZE = 256;
|
||||
|
||||
static const auto LOGGER = Logger("GpsDevice");
|
||||
constexpr auto* TAG = "GpsDevice";
|
||||
|
||||
int32_t GpsDevice::threadMain() {
|
||||
uint8_t buffer[GPS_UART_BUFFER_SIZE];
|
||||
|
||||
auto* uart = device_find_by_name(configuration.uartName);
|
||||
if (uart == nullptr) {
|
||||
LOGGER.error("Failed to find UART {}", configuration.uartName);
|
||||
LOG_E(TAG, "Failed to find UART %s", configuration.uartName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -33,13 +32,13 @@ int32_t GpsDevice::threadMain() {
|
||||
|
||||
error_t error = uart_controller_set_config(uart, &uartConfig);
|
||||
if (error != ERROR_NONE) {
|
||||
LOGGER.error("Failed to configure UART {}: {}", configuration.uartName, error_to_string(error));
|
||||
LOG_E(TAG, "Failed to configure UART %s: %s", configuration.uartName, error_to_string(error));
|
||||
return -1;
|
||||
}
|
||||
|
||||
error = uart_controller_open(uart);
|
||||
if (error != ERROR_NONE) {
|
||||
LOGGER.error("Failed to open UART {}: {}", configuration.uartName, error_to_string(error));
|
||||
LOG_E(TAG, "Failed to open UART %s: %s", configuration.uartName, error_to_string(error));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ int32_t GpsDevice::threadMain() {
|
||||
if (model == GpsModel::Unknown) {
|
||||
model = probe(uart);
|
||||
if (model == GpsModel::Unknown) {
|
||||
LOGGER.error("Probe failed");
|
||||
LOG_E(TAG, "Probe failed");
|
||||
setState(State::Error);
|
||||
return -1;
|
||||
}
|
||||
@@ -57,7 +56,7 @@ int32_t GpsDevice::threadMain() {
|
||||
mutex.unlock();
|
||||
|
||||
if (!init(uart, model)) {
|
||||
LOGGER.error("Init failed");
|
||||
LOG_E(TAG, "Init failed");
|
||||
setState(State::Error);
|
||||
return -1;
|
||||
}
|
||||
@@ -76,7 +75,7 @@ int32_t GpsDevice::threadMain() {
|
||||
|
||||
if (bytes_read > 0U) {
|
||||
|
||||
LOGGER.info("[{}] {}", bytes_read, reinterpret_cast<const char*>(buffer));
|
||||
LOG_I(TAG, "[%d] %s", (int)bytes_read, reinterpret_cast<const char*>(buffer));
|
||||
|
||||
switch (minmea_sentence_id((char*)buffer, false)) {
|
||||
case MINMEA_SENTENCE_RMC:
|
||||
@@ -87,11 +86,9 @@ int32_t GpsDevice::threadMain() {
|
||||
(*subscription.onData)(getId(), rmc_frame);
|
||||
}
|
||||
mutex.unlock();
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("RMC {} lat, {} lon, {} m/s", minmea_tocoord(&rmc_frame.latitude), minmea_tocoord(&rmc_frame.longitude), minmea_tofloat(&rmc_frame.speed));
|
||||
}
|
||||
LOG_D(TAG, "RMC %f lat, %f lon, %f m/s", minmea_tocoord(&rmc_frame.latitude), minmea_tocoord(&rmc_frame.longitude), minmea_tofloat(&rmc_frame.speed));
|
||||
} else {
|
||||
LOGGER.error("RMC parse error: {}", reinterpret_cast<const char*>(buffer));
|
||||
LOG_E(TAG, "RMC parse error: %s", reinterpret_cast<const char*>(buffer));
|
||||
}
|
||||
break;
|
||||
case MINMEA_SENTENCE_GGA:
|
||||
@@ -102,11 +99,9 @@ int32_t GpsDevice::threadMain() {
|
||||
(*subscription.onData)(getId(), gga_frame);
|
||||
}
|
||||
mutex.unlock();
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("GGA {} lat, {} lon", minmea_tocoord(&gga_frame.latitude), minmea_tocoord(&gga_frame.longitude));
|
||||
}
|
||||
LOG_D(TAG, "GGA %f lat, %f lon", minmea_tocoord(&gga_frame.latitude), minmea_tocoord(&gga_frame.longitude));
|
||||
} else {
|
||||
LOGGER.error("GGA parse error: {}", reinterpret_cast<const char*>(buffer));
|
||||
LOG_E(TAG, "GGA parse error: %s", reinterpret_cast<const char*>(buffer));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -116,7 +111,7 @@ int32_t GpsDevice::threadMain() {
|
||||
}
|
||||
|
||||
if (uart_controller_close(uart) != ERROR_NONE) {
|
||||
LOGGER.warn("Failed to stop UART {}", configuration.uartName);
|
||||
LOG_W(TAG, "Failed to stop UART %s", configuration.uartName);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -127,13 +122,13 @@ bool GpsDevice::start() {
|
||||
lock.lock();
|
||||
|
||||
if (thread != nullptr && thread->getState() != Thread::State::Stopped) {
|
||||
LOGGER.warn("Already started");
|
||||
LOG_W(TAG, "Already started");
|
||||
return true;
|
||||
}
|
||||
|
||||
threadInterrupted = false;
|
||||
|
||||
LOGGER.info("Starting thread");
|
||||
LOG_I(TAG, "Starting thread");
|
||||
setState(State::PendingOn);
|
||||
|
||||
thread = std::make_unique<Thread>(
|
||||
@@ -146,7 +141,7 @@ bool GpsDevice::start() {
|
||||
thread->setPriority(tt::Thread::Priority::High);
|
||||
thread->start();
|
||||
|
||||
LOGGER.info("Starting finished");
|
||||
LOG_I(TAG, "Starting finished");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include <Tactility/Logger.h>
|
||||
#include <tactility/check.h>
|
||||
#include <Tactility/hal/gps/Cas.h>
|
||||
#include <Tactility/hal/gps/GpsDevice.h>
|
||||
#include <Tactility/hal/gps/Ublox.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
#include <tactility/check.h>
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/uart_controller.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
static const auto LOGGER = Logger("Gps");
|
||||
constexpr auto* TAG = "Gps";
|
||||
|
||||
bool initMtk(::Device* uart);
|
||||
bool initMtkL76b(::Device* uart);
|
||||
@@ -118,7 +118,7 @@ GpsResponse getACKCas(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t
|
||||
// Check for an ACK-ACK for the specified class and message id
|
||||
if ((msg_cls == 0x05) && (msg_msg_id == 0x01) && payload_cls == class_id && payload_msg == msg_id) {
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.info("Got ACK for class {:02X} message {:02X} in {} ms", class_id, msg_id, kernel::getMillis() - startTime);
|
||||
LOG_I(TAG, "Got ACK for class %02X message %02X in %zu ms", class_id, msg_id, kernel::getMillis() - startTime);
|
||||
#endif
|
||||
return GpsResponse::Ok;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ GpsResponse getACKCas(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t
|
||||
// Check for an ACK-NACK for the specified class and message id
|
||||
if ((msg_cls == 0x05) && (msg_msg_id == 0x00) && payload_cls == class_id && payload_msg == msg_id) {
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.warn("Got NACK for class {:02X} message {:02X} in {} ms", class_id, msg_id, millis() - startTime);
|
||||
LOG_W(TAG, "Got NACK for class %02X message %02X in %zu ms", class_id, msg_id, millis() - startTime);
|
||||
#endif
|
||||
return GpsResponse::NotAck;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ bool init(::Device* uart, GpsModel type) {
|
||||
return initUc6580(uart);
|
||||
}
|
||||
|
||||
LOGGER.info("Init not implemented {}", static_cast<int>(type));
|
||||
LOG_I(TAG, "Init not implemented %d", static_cast<int>(type));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -219,14 +219,14 @@ bool initAtgm336h(::Device* uart) {
|
||||
int msglen = makeCASPacket(buffer, 0x06, 0x07, sizeof(_message_CAS_CFG_NAVX_CONF), _message_CAS_CFG_NAVX_CONF);
|
||||
uart_controller_write_bytes(uart, buffer, msglen, 250);
|
||||
if (getACKCas(uart, 0x06, 0x07, 250) != GpsResponse::Ok) {
|
||||
LOGGER.warn("ATGM336H: Could not set Config");
|
||||
LOG_W(TAG, "ATGM336H: Could not set Config");
|
||||
}
|
||||
|
||||
// Set the update frequence to 1Hz
|
||||
msglen = makeCASPacket(buffer, 0x06, 0x04, sizeof(_message_CAS_CFG_RATE_1HZ), _message_CAS_CFG_RATE_1HZ);
|
||||
uart_controller_write_bytes(uart, buffer, msglen, 250);
|
||||
if (getACKCas(uart, 0x06, 0x04, 250) != GpsResponse::Ok) {
|
||||
LOGGER.warn("ATGM336H: Could not set Update Frequency");
|
||||
LOG_W(TAG, "ATGM336H: Could not set Update Frequency");
|
||||
}
|
||||
|
||||
// Set the NEMA output messages
|
||||
@@ -238,7 +238,7 @@ bool initAtgm336h(::Device* uart) {
|
||||
msglen = makeCASPacket(buffer, 0x06, 0x01, sizeof(cas_cfg_msg_packet), cas_cfg_msg_packet);
|
||||
uart_controller_write_bytes(uart, buffer, msglen, 250);
|
||||
if (getACKCas(uart, 0x06, 0x01, 250) != GpsResponse::Ok) {
|
||||
LOGGER.warn("ATGM336H: Could not enable NMEA MSG: {}", fields[i]);
|
||||
LOG_W(TAG, "ATGM336H: Could not enable NMEA MSG: %u", fields[i]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/hal/gps/Ublox.h"
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/uart_controller.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
static const auto LOGGER = tt::Logger("Gps");
|
||||
constexpr auto* TAG = "Gps";
|
||||
|
||||
#define GPS_UART_BUFFER_SIZE 256
|
||||
|
||||
@@ -65,13 +65,13 @@ GpsResponse getAck(::Device* uart, const char* message, uint32_t waitMillis) {
|
||||
if ((bytesRead == 767) || (b == '\r')) {
|
||||
if (strnstr((char*)buffer, message, bytesRead) != nullptr) {
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.debug("Found: {}", message); // Log the found message
|
||||
LOG_D(TAG, "Found: %s", message); // Log the found message
|
||||
#endif
|
||||
return GpsResponse::Ok;
|
||||
} else {
|
||||
bytesRead = 0;
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.debug("{}", debugmsg);
|
||||
LOG_D(TAG, "%s", debugmsg.c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -85,11 +85,11 @@ GpsResponse getAck(::Device* uart, const char* message, uint32_t waitMillis) {
|
||||
*/
|
||||
#define PROBE_SIMPLE(UART, CHIP, TOWRITE, RESPONSE, DRIVER, TIMEOUT, ...) \
|
||||
do { \
|
||||
LOGGER.info("Probing for {} ({})", CHIP, TOWRITE); \
|
||||
LOG_I(TAG, "Probing for %s (%s)", CHIP, TOWRITE); \
|
||||
uart_controller_flush_input(UART); \
|
||||
uart_controller_write_bytes(UART, (const uint8_t*)(TOWRITE "\r\n"), strlen(TOWRITE "\r\n"), TIMEOUT); \
|
||||
if (getAck(UART, RESPONSE, TIMEOUT) == GpsResponse::Ok) { \
|
||||
LOGGER.info("Probe detected {} {}", CHIP, #DRIVER); \
|
||||
LOG_I(TAG, "Probe detected %s %s", CHIP, #DRIVER); \
|
||||
return DRIVER; \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -138,7 +138,7 @@ GpsModel probe(::Device* uart) {
|
||||
if (ublox_result != GpsModel::Unknown) {
|
||||
return ublox_result;
|
||||
} else {
|
||||
LOGGER.warn("No GNSS Module");
|
||||
LOG_W(TAG, "No GNSS Module");
|
||||
return GpsModel::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <Tactility/hal/gps/Satellites.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <tactility/log.h>
|
||||
|
||||
namespace tt::hal::gps {
|
||||
|
||||
static const auto LOGGER = Logger("Satellites");
|
||||
constexpr auto* TAG = "Satellites";
|
||||
|
||||
constexpr bool hasTimeElapsed(TickType_t now, TickType_t timeInThePast, TickType_t expireTimeInTicks) {
|
||||
return (TickType_t)(now - timeInThePast) >= expireTimeInTicks;
|
||||
@@ -33,9 +34,7 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findUnusedRecord() {
|
||||
if (!result.empty()) {
|
||||
auto* record = &result.front();
|
||||
record->inUse = true;
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Found unused record");
|
||||
}
|
||||
LOG_D(TAG, "Found unused record");
|
||||
return record;
|
||||
} else {
|
||||
return nullptr;
|
||||
@@ -53,9 +52,7 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findRecordToRecycle() {
|
||||
for (int i = 0; i < records.size(); ++i) {
|
||||
// First try to find a record that is "old enough"
|
||||
if (hasTimeElapsed(now, records[i].lastUpdated, expire_duration)) {
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("! [{}] {} < {}", i, records[i].lastUpdated, expire_duration);
|
||||
}
|
||||
LOG_D(TAG, "! [%d] %u < %u", i, records[i].lastUpdated, expire_duration);
|
||||
candidate_index = i;
|
||||
break;
|
||||
}
|
||||
@@ -64,17 +61,13 @@ SatelliteStorage::SatelliteRecord* SatelliteStorage::findRecordToRecycle() {
|
||||
if (records[i].inUse && records[i].lastUpdated < candidate_age) {
|
||||
candidate_index = i;
|
||||
candidate_age = records[i].lastUpdated;
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("? [{}] {} < {}", i, records[i].lastUpdated, candidate_age);
|
||||
}
|
||||
LOG_D(TAG, "? [%d] %u < %u", i, records[i].lastUpdated, candidate_age);
|
||||
}
|
||||
}
|
||||
|
||||
assert(candidate_index != -1);
|
||||
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Recycled record {}", candidate_index);
|
||||
}
|
||||
LOG_D(TAG, "Recycled record %d", candidate_index);
|
||||
|
||||
return &records[candidate_index];
|
||||
}
|
||||
@@ -101,9 +94,7 @@ void SatelliteStorage::notify(const minmea_sat_info& data) {
|
||||
record->inUse = true;
|
||||
record->lastUpdated = kernel::getTicks();
|
||||
record->data = data;
|
||||
if (LOGGER.isLoggingDebug()) {
|
||||
LOGGER.debug("Updated satellite {}: elevation {}, azimuth {}, snr {}", record->data.nr, record->data.elevation, record->data.elevation, record->data.snr);
|
||||
}
|
||||
LOG_D(TAG, "Updated satellite %d: elevation %d, azimuth %d, snr %d", record->data.nr, record->data.elevation, record->data.elevation, record->data.snr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#include <Tactility/hal/gps/Ublox.h>
|
||||
#include <Tactility/hal/gps/UbloxMessages.h>
|
||||
#include <Tactility/kernel/Kernel.h>
|
||||
#include <Tactility/Logger.h>
|
||||
|
||||
#include <tactility/device.h>
|
||||
#include <tactility/drivers/uart_controller.h>
|
||||
#include <tactility/log.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace tt::hal::gps::ublox {
|
||||
|
||||
static const auto LOGGER = Logger("Ublox");
|
||||
constexpr auto* TAG = "Ublox";
|
||||
|
||||
bool initUblox6(::Device* uart);
|
||||
bool initUblox789(::Device* uart, GpsModel model);
|
||||
@@ -21,7 +21,7 @@ bool initUblox10(::Device* uart);
|
||||
auto msglen = makePacket(TYPE, ID, DATA, sizeof(DATA), BUFFER); \
|
||||
uart_controller_write_bytes(UART, BUFFER, msglen, TIMEOUT_MILLIS / portTICK_PERIOD_MS); \
|
||||
if (getAck(UART, TYPE, ID, TIMEOUT_MILLIS) != GpsResponse::Ok) { \
|
||||
LOGGER.info("Sending packet failed: {}", #ERRMSG); \
|
||||
LOG_I(TAG, "Sending packet failed: %s", #ERRMSG); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -85,7 +85,7 @@ GpsResponse getAck(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t wa
|
||||
while (kernel::getTicks() - startTime < waitTicks) {
|
||||
if (ack > 9) {
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.info("Got ACK for class {:02X} message {:02X} in {}ms", class_id, msg_id, kernel::getMillis() - startTime);
|
||||
LOG_I(TAG, "Got ACK for class %02X message %02X in %zums", class_id, msg_id, kernel::getMillis() - startTime);
|
||||
#endif
|
||||
return GpsResponse::Ok; // ACK received
|
||||
}
|
||||
@@ -98,7 +98,7 @@ GpsResponse getAck(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t wa
|
||||
if (sCounter == 26) {
|
||||
#ifdef GPS_DEBUG
|
||||
|
||||
LOGGER.info("%s", debugmsg.c_str());
|
||||
LOG_I(TAG, "%s", debugmsg.c_str());
|
||||
#endif
|
||||
return GpsResponse::FrameErrors;
|
||||
}
|
||||
@@ -113,9 +113,9 @@ GpsResponse getAck(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t wa
|
||||
} else {
|
||||
if (ack == 3 && b == 0x00) { // UBX-ACK-NAK message
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.info("%s", debugmsg.c_str());
|
||||
LOG_I(TAG, "%s", debugmsg.c_str());
|
||||
#endif
|
||||
LOGGER.warn("Got NAK for class {:02X} message {:02X}", class_id, msg_id);
|
||||
LOG_W(TAG, "Got NAK for class %02X message %02X", class_id, msg_id);
|
||||
return GpsResponse::NotAck; // NAK received
|
||||
}
|
||||
ack = 0; // Reset the acknowledgement counter
|
||||
@@ -123,8 +123,8 @@ GpsResponse getAck(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t wa
|
||||
}
|
||||
}
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.info("%s", debugmsg.c_str());
|
||||
LOGGER.warn("No response for class %02X message %02X", class_id, msg_id);
|
||||
LOG_I(TAG, "%s", debugmsg.c_str());
|
||||
LOG_W(TAG, "No response for class %02X message %02X", class_id, msg_id);
|
||||
#endif
|
||||
return GpsResponse::None; // No response received within timeout
|
||||
}
|
||||
@@ -190,7 +190,7 @@ static int getAck(::Device* uart, uint8_t* buffer, uint16_t size, uint8_t reques
|
||||
} else {
|
||||
// return payload length
|
||||
#ifdef GPS_DEBUG
|
||||
LOGGER.info("Got ACK for class {:02X} message {:02X} in {}ms", requestedClass, requestedId, kernel::getMillis() - startTime);
|
||||
LOG_I(TAG, "Got ACK for class %02X message %02X in %zums", requestedClass, requestedId, kernel::getMillis() - startTime);
|
||||
#endif
|
||||
return needRead;
|
||||
}
|
||||
@@ -214,8 +214,7 @@ static struct uBloxGnssModelInfo {
|
||||
} ublox_info;
|
||||
|
||||
GpsModel probe(::Device* uart) {
|
||||
LOGGER.info("Probing for U-blox");
|
||||
constexpr auto DETECTED_MESSAGE = "{} detected, using {} Module";
|
||||
LOG_I(TAG, "Probing for U-blox");
|
||||
|
||||
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00};
|
||||
checksum(cfg_rate, sizeof(cfg_rate));
|
||||
@@ -224,10 +223,10 @@ GpsModel probe(::Device* uart) {
|
||||
// Check that the returned response class and message ID are correct
|
||||
GpsResponse response = getAck(uart, 0x06, 0x08, 750);
|
||||
if (response == GpsResponse::None) {
|
||||
LOGGER.warn("No GNSS Module");
|
||||
LOG_W(TAG, "No GNSS Module");
|
||||
return GpsModel::Unknown;
|
||||
} else if (response == GpsResponse::FrameErrors) {
|
||||
LOGGER.warn("UBlox Frame Errors");
|
||||
LOG_W(TAG, "UBlox Frame Errors");
|
||||
}
|
||||
|
||||
uint8_t buffer[256];
|
||||
@@ -265,12 +264,12 @@ GpsModel probe(::Device* uart) {
|
||||
break;
|
||||
}
|
||||
|
||||
LOGGER.info("Module Info:");
|
||||
LOGGER.info("Soft version: {}", ublox_info.swVersion);
|
||||
LOGGER.info("Hard version: {}", ublox_info.hwVersion);
|
||||
LOGGER.info("Extensions: {}", ublox_info.extensionNo);
|
||||
LOG_I(TAG, "Module Info:");
|
||||
LOG_I(TAG, "Soft version: %s", ublox_info.swVersion);
|
||||
LOG_I(TAG, "Hard version: %s", ublox_info.hwVersion);
|
||||
LOG_I(TAG, "Extensions: %u", ublox_info.extensionNo);
|
||||
for (int i = 0; i < ublox_info.extensionNo; i++) {
|
||||
LOGGER.info(" %s", ublox_info.extension[i]);
|
||||
LOG_I(TAG, " %s", ublox_info.extension[i]);
|
||||
}
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
@@ -283,29 +282,30 @@ GpsModel probe(::Device* uart) {
|
||||
char* ptr = nullptr;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
strncpy((char*)buffer, &(ublox_info.extension[i][8]), sizeof(buffer));
|
||||
LOGGER.info("Protocol Version: {}", (char*)buffer);
|
||||
LOG_I(TAG, "Protocol Version: %s", (char*)buffer);
|
||||
if (strlen((char*)buffer)) {
|
||||
ublox_info.protocol_version = strtoul((char*)buffer, &ptr, 10);
|
||||
LOGGER.info("ProtVer={}", ublox_info.protocol_version);
|
||||
LOG_I(TAG, "ProtVer=%u", ublox_info.protocol_version);
|
||||
} else {
|
||||
ublox_info.protocol_version = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#define DETECTED_MESSAGE "%s detected, using %s Module"
|
||||
if (strncmp(ublox_info.hwVersion, "00040007", 8) == 0) {
|
||||
LOGGER.info(DETECTED_MESSAGE, "U-blox 6", "6");
|
||||
LOG_I(TAG, DETECTED_MESSAGE, "U-blox 6", "6");
|
||||
return GpsModel::UBLOX6;
|
||||
} else if (strncmp(ublox_info.hwVersion, "00070000", 8) == 0) {
|
||||
LOGGER.info(DETECTED_MESSAGE, "U-blox 7", "7");
|
||||
LOG_I(TAG, DETECTED_MESSAGE, "U-blox 7", "7");
|
||||
return GpsModel::UBLOX7;
|
||||
} else if (strncmp(ublox_info.hwVersion, "00080000", 8) == 0) {
|
||||
LOGGER.info(DETECTED_MESSAGE, "U-blox 8", "8");
|
||||
LOG_I(TAG, DETECTED_MESSAGE, "U-blox 8", "8");
|
||||
return GpsModel::UBLOX8;
|
||||
} else if (strncmp(ublox_info.hwVersion, "00190000", 8) == 0) {
|
||||
LOGGER.info(DETECTED_MESSAGE, "U-blox 9", "9");
|
||||
LOG_I(TAG, DETECTED_MESSAGE, "U-blox 9", "9");
|
||||
return GpsModel::UBLOX9;
|
||||
} else if (strncmp(ublox_info.hwVersion, "000A0000", 8) == 0) {
|
||||
LOGGER.info(DETECTED_MESSAGE, "U-blox 10", "10");
|
||||
LOG_I(TAG, DETECTED_MESSAGE, "U-blox 10", "10");
|
||||
return GpsModel::UBLOX10;
|
||||
}
|
||||
}
|
||||
@@ -314,7 +314,7 @@ GpsModel probe(::Device* uart) {
|
||||
}
|
||||
|
||||
bool init(::Device* uart, GpsModel model) {
|
||||
LOGGER.info("U-blox init");
|
||||
LOG_I(TAG, "U-blox init");
|
||||
switch (model) {
|
||||
case GpsModel::UBLOX6:
|
||||
return initUblox6(uart);
|
||||
@@ -325,7 +325,7 @@ bool init(::Device* uart, GpsModel model) {
|
||||
case GpsModel::UBLOX10:
|
||||
return initUblox10(uart);
|
||||
default:
|
||||
LOGGER.error("Unknown or unsupported U-blox model");
|
||||
LOG_E(TAG, "Unknown or unsupported U-blox model");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -374,9 +374,9 @@ bool initUblox10(::Device* uart) {
|
||||
auto packet_size = makePacket(0x06, 0x09, _message_SAVE_10, sizeof(_message_SAVE_10), buffer);
|
||||
uart_controller_write_bytes(uart, buffer, packet_size, 2000 / portTICK_PERIOD_MS);
|
||||
if (getAck(uart, 0x06, 0x09, 2000) != GpsResponse::Ok) {
|
||||
LOGGER.warn("Unable to save GNSS module config");
|
||||
LOG_W(TAG, "Unable to save GNSS module config");
|
||||
} else {
|
||||
LOGGER.info("GNSS module configuration saved!");
|
||||
LOG_I(TAG, "GNSS module configuration saved!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -384,7 +384,7 @@ bool initUblox10(::Device* uart) {
|
||||
bool initUblox789(::Device* uart, GpsModel model) {
|
||||
uint8_t buffer[256];
|
||||
if (model == GpsModel::UBLOX7) {
|
||||
LOGGER.debug("Set GPS+SBAS");
|
||||
LOG_D(TAG, "Set GPS+SBAS");
|
||||
auto msglen = makePacket(0x06, 0x3e, _message_GNSS_7, sizeof(_message_GNSS_7), buffer);
|
||||
uart_controller_write_bytes(uart, buffer, msglen, 800 / portTICK_PERIOD_MS);
|
||||
} else { // 8,9
|
||||
@@ -394,12 +394,12 @@ bool initUblox789(::Device* uart, GpsModel model) {
|
||||
|
||||
if (getAck(uart, 0x06, 0x3e, 800) == GpsResponse::NotAck) {
|
||||
// It's not critical if the module doesn't acknowledge this configuration.
|
||||
LOGGER.debug("reconfigure GNSS - defaults maintained. Is this module GPS-only?");
|
||||
LOG_D(TAG, "reconfigure GNSS - defaults maintained. Is this module GPS-only?");
|
||||
} else {
|
||||
if (model == GpsModel::UBLOX7) {
|
||||
LOGGER.info("GPS+SBAS configured");
|
||||
LOG_I(TAG, "GPS+SBAS configured");
|
||||
} else { // 8,9
|
||||
LOGGER.info("GPS+SBAS+GLONASS+Galileo configured");
|
||||
LOG_I(TAG, "GPS+SBAS+GLONASS+Galileo configured");
|
||||
}
|
||||
// Documentation say, we need wait at least 0.5s after reconfiguration of GNSS module, before sending next
|
||||
// commands for the M8 it tends to be more. 1 sec should be enough
|
||||
@@ -448,9 +448,9 @@ bool initUblox789(::Device* uart, GpsModel model) {
|
||||
auto packet_size = makePacket(0x06, 0x09, _message_SAVE, sizeof(_message_SAVE), buffer);
|
||||
uart_controller_write_bytes(uart, buffer, packet_size, 2000 / portTICK_PERIOD_MS);
|
||||
if (getAck(uart, 0x06, 0x09, 2000) != GpsResponse::Ok) {
|
||||
LOGGER.warn("Unable to save GNSS module config");
|
||||
LOG_W(TAG, "Unable to save GNSS module config");
|
||||
} else {
|
||||
LOGGER.info("GNSS module configuration saved!");
|
||||
LOG_I(TAG, "GNSS module configuration saved!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -482,9 +482,9 @@ bool initUblox6(::Device* uart) {
|
||||
auto packet_size = makePacket(0x06, 0x09, _message_SAVE, sizeof(_message_SAVE), buffer);
|
||||
uart_controller_write_bytes(uart, buffer, packet_size, 2000);
|
||||
if (getAck(uart, 0x06, 0x09, 2000) != GpsResponse::Ok) {
|
||||
LOGGER.warn("Unable to save GNSS module config");
|
||||
LOG_W(TAG, "Unable to save GNSS module config");
|
||||
} else {
|
||||
LOGGER.info("GNSS module config saved!");
|
||||
LOG_I(TAG, "GNSS module config saved!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user