diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-11-17 17:23:27 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-11-17 17:23:27 +0100 |
commit | d97e0e51835fdcf0d69708ab46574283643a18d5 (patch) | |
tree | b936edb4e37b458d295e615d924abf36c036a1c0 /sw | |
parent | 048682baaa215cb83326e191c86f84d15d4ffd15 (diff) | |
download | glutte-batteries-d97e0e51835fdcf0d69708ab46574283643a18d5.tar.gz glutte-batteries-d97e0e51835fdcf0d69708ab46574283643a18d5.tar.bz2 glutte-batteries-d97e0e51835fdcf0d69708ab46574283643a18d5.zip |
Fix CAPACITY length print
Diffstat (limited to 'sw')
-rw-r--r-- | sw/README.rst | 2 | ||||
-rw-r--r-- | sw/main.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sw/README.rst b/sw/README.rst index 9869c4d..c7ae7b6 100644 --- a/sw/README.rst +++ b/sw/README.rst @@ -24,7 +24,7 @@ secondes, une virgule, un champ de données, et termine par CR LF. +--------------------+-----------------------------------+ | `TEXT` | Un message informatif | | `ERROR` | Erreur ou avertissement | -| `CAPACITY` | Une valeur en mAh | +| `CAPA` | Une valeur en mAh | | `VBAT+` | Une valeur en mV | | `VBAT-` | Une valeur en mV | +--------------------+-----------------------------------+ diff --git a/sw/main.cpp b/sw/main.cpp index af348b7..ccf8b07 100644 --- a/sw/main.cpp +++ b/sw/main.cpp @@ -250,10 +250,10 @@ static void handle_thresholds(const timer_t& time_now) previous_capacity = current_capacity; } -static char timestamp_buf[16]; +static char timestamp_buf[24]; static void send_message(const char *message) { - snprintf(timestamp_buf, 15, "TEXT,%ld,", system_timer.get_seconds_atomic()); + snprintf(timestamp_buf, sizeof(timestamp_buf), "TEXT,%ld,", system_timer.get_seconds_atomic()); uart_puts(timestamp_buf); uart_puts(message); uart_puts_P(ENDL); @@ -263,13 +263,13 @@ static void send_message(const char *message) static void send_capacity(uint32_t capacity, const timer_t& time) { - snprintf(timestamp_buf, 15, "CAPACITY,%ld,%ld" ENDL, time.get_seconds_atomic(), capacity); + snprintf(timestamp_buf, sizeof(timestamp_buf), "CAPA,%ld,%ld" ENDL, time.get_seconds_atomic(), capacity); uart_puts(timestamp_buf); } static void send_voltage(uint32_t millivolts, bool bat_plus, const timer_t& time) { - snprintf(timestamp_buf, 15, "VBAT%c,%ld,%ld" ENDL, + snprintf(timestamp_buf, sizeof(timestamp_buf), "VBAT%c,%ld,%ld" ENDL, bat_plus ? '+' : '-', time.get_seconds_atomic(), millivolts); uart_puts(timestamp_buf); @@ -277,7 +277,7 @@ static void send_voltage(uint32_t millivolts, bool bat_plus, const timer_t& time static void flag_error(const error_type_t e) { - snprintf(timestamp_buf, 15, "ERROR,%ld,", system_timer.get_seconds_atomic()); + snprintf(timestamp_buf, sizeof(timestamp_buf), "ERROR,%ld,", system_timer.get_seconds_atomic()); uart_puts(timestamp_buf); switch (e) { case error_type_t::EEPROM_READ_WARNING: |