Audyt: poprawki integracji ESP32-S2/CC1101/LM317T i testy regresji
check / check-without-hardware (push) Canceled after 0s
check / check-without-hardware (push) Canceled after 0s
- EXT1 wake: pociagniecia RTC przycisku/LF przed deep sleep (pull-up cyfrowy nie dziala przy wylaczonej domenie RTC_PERIPH) - konsola: odrzucanie NaN/nieskonczonosci; przenosny modul parse z testami - zasilanie: dzielnik ADC R2 180 kOhm (zakres do ~16 V zamiast nasycania ADC powyzej ~11,8 V) - package_release: merge_bin --flash-freq 80m zgodne z lolin_s2_mini - tpms_frame.py: saturacja temperatury zgodna z firmware - testy: sciezka checksum w negatywach, test_parse, poprawny diagram bitow
This commit is contained in:
1 parent
d53299ba11
commit
882962b156
16 files changed
+231
-62
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "parse.h"
|
||||
|
||||
bool parse_u32(const char *text, uint32_t lo, uint32_t hi, uint32_t *out,
|
||||
int base)
|
||||
{
|
||||
if (text == NULL || *text == '\0' || *text == '-') {
|
||||
return false;
|
||||
}
|
||||
errno = 0;
|
||||
char *end = NULL;
|
||||
unsigned long value = strtoul(text, &end, base);
|
||||
if (errno != 0 || end == text || *end != '\0'
|
||||
|| value < lo || value > hi) {
|
||||
return false;
|
||||
}
|
||||
*out = (uint32_t)value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parse_i32(const char *text, int32_t lo, int32_t hi, int32_t *out)
|
||||
{
|
||||
if (text == NULL || *text == '\0') {
|
||||
return false;
|
||||
}
|
||||
errno = 0;
|
||||
char *end = NULL;
|
||||
long value = strtol(text, &end, 10);
|
||||
if (errno != 0 || end == text || *end != '\0' || value < lo || value > hi) {
|
||||
return false;
|
||||
}
|
||||
*out = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parse_float(const char *text, float lo, float hi, float *out)
|
||||
{
|
||||
if (text == NULL || *text == '\0') {
|
||||
return false;
|
||||
}
|
||||
errno = 0;
|
||||
char *end = NULL;
|
||||
float value = strtof(text, &end);
|
||||
/* Odwrocone porownanie odrzuca tez NaN (obie strony falszywe). */
|
||||
if (errno != 0 || end == text || *end != '\0'
|
||||
|| !(value >= lo && value <= hi)) {
|
||||
return false;
|
||||
}
|
||||
*out = value;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user