25 lines
838 B
C++
25 lines
838 B
C++
#pragma once
|
|
|
|
#include "fgc/IMotorController.h"
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace fgc {
|
|
|
|
// Parse a firmware `ST` status line:
|
|
//
|
|
// ST Y:<state>,<xactual>,<xenc>,<drv_hex>,<sg>,<cs>,<pwm>,<flags> [P:...]
|
|
//
|
|
// where <state> is B/R/H/A/E and <flags> is an optional run of status letters
|
|
// (S=standstill, s=stall, o/O=overtemp, L/R=endstops, e=eeprom). Returns nullopt
|
|
// for any line that is not a well-formed `ST` line (acks and other async output
|
|
// like OK/ERR/DG/DUMP are handled by the caller). A missing/garbled axis segment
|
|
// yields nullopt rather than partial data.
|
|
std::optional<MotorTelemetry> parseTelemetryLine(const std::string& line);
|
|
|
|
// Parse a single "Y:..." / "P:..." axis segment. Exposed for unit testing.
|
|
std::optional<AxisTelemetry> parseAxisSegment(const std::string& seg);
|
|
|
|
} // namespace fgc
|