31#ifndef WHEELLY_PROTOCOL_H
32#define WHEELLY_PROTOCOL_H
516 return (c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z') || (c >=
'0' && c <=
'9');
526 return (c >=
'A' && c <=
'Z') ? (char)(c -
'A' +
'a') : c;
534 for (; a[i] !=
'\0' && b[i] !=
'\0'; i++)
538 return a[i] ==
'\0' && b[i] ==
'\0';
550 while (s[n] !=
'\0' && s[n] !=
'.' && n <
sizeof(stem) - 1)
556 if (s[n] !=
'\0' && s[n] !=
'.')
return false;
558 static const char *reserved[] =
560 "CON",
"PRN",
"AUX",
"NUL",
561 "COM1",
"COM2",
"COM3",
"COM4",
"COM5",
"COM6",
"COM7",
"COM8",
"COM9",
562 "LPT1",
"LPT2",
"LPT3",
"LPT4",
"LPT5",
"LPT6",
"LPT7",
"LPT8",
"LPT9"
564 for (
size_t i = 0; i <
sizeof(reserved) /
sizeof(reserved[0]); i++)
578 if (s == NULL || s[0] ==
'\0')
return NAME_EMPTY;
593 for (
size_t i = 0; i < n; i++)
613 if (out == NULL || out_size == 0)
return;
624 bool separator_pending =
false;
625 char separator =
'_';
629 for (
size_t i = 0; in[i] !=
'\0' && w < limit; i++)
633 if (separator_pending && w > 0 && w < limit) out[w++] = separator;
634 separator_pending =
false;
635 if (w < limit) out[w++] = in[i];
637 else if (!separator_pending)
639 separator_pending =
true;
651 const char fallback[] =
"Filter";
653 while (fallback[i] !=
'\0' && i + 1 < out_size)
655 out[i] = fallback[i];
668 while (out[stem] !=
'\0' && out[stem] !=
'.') stem++;
669 for (
size_t i = w; i > stem; i--) out[i] = out[i - 1];
682 for (
int i = 1; i < count; i++)
684 for (
int j = 0; j < i; j++)
686 if (names[i] != NULL && names[j] != NULL &&
const size_t FILTER_NAME_MAX
const char KIND_APPROACH[]
bool name_is_reserved(const char *s)
bool name_is_allowed(char c)
const char MOTION_SETTLING[]
const uint16_t RECOMMENDED_HOLD_MA
const char MOTION_MOVING[]
bool name_is_alnum(char c)
const int PROTOCOL_VERSION
const char CMD_TOLERANCE[]
bool name_equal_nocase(const char *a, const char *b)
const float FACTORY_DRIVE_RATIO
const float DRIVE_RATIO_MIN
const char MOTION_FAILED[]
const float DRIVE_RATIO_MAX
const char CMD_DIRECTION[]
const size_t WHEELLY_LINE_MAX
const char OUTCOME_NONE[]
const char ARG_SHORTEST[]
const unsigned long MOTOR_ACCEL_MAX
void sanitize_filter_name(const char *in, char *out, size_t out_size)
const unsigned long FACTORY_ACCEL
const unsigned long BOOST_SPEED_MAX
const unsigned FACTORY_SETTLE_MS
const float MODEL_CLUTCH_DIAMETER_MM
const int TOLERANCE_MAX_DEG
const unsigned long FACTORY_SPEED
const char PREFIX_ERROR[]
const unsigned MOTOR_MA_MAX
NameCheck check_filter_name(const char *s)
const unsigned FACTORY_RUN_MA
const float FACTORY_GOOD_DEG
int first_duplicate_name(const char *const *names, int count)
const char FACTORY_DIRECTION[]
const char PREFIX_COMMENT
const unsigned long MOTOR_SPEED_MAX
const unsigned SETTLE_MS_MAX
const float FACTORY_WARN_DEG
const unsigned long EKOS_FILTER_TIMEOUT_MS
const float MODEL_DISC_DIAMETER_MM