mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-29 05:47:28 +01:00
hardware protocol v2: configuration, wiring and debug panel
Adds the WITH_HARDWARE_PROTOCOL_V2 build option and the eu07.ini entries which configure it: uart2 declares a serial link and may be repeated for several controllers, the remaining uart2* entries tune frame size, heartbeat, rate limits and logging. UART v1 is untouched and both may be active at the same time on different ports. The driver mode starts the manager when at least one link is configured and pumps it from the input polling loop, and the debug panel gains a Hardware Protocol v2 section reporting link and session condition, packet rates, round trip time, protocol and transport error counters and whatever diagnostics the device itself reports, with switches for protocol and frame logging.
This commit is contained in:
@@ -1040,6 +1040,77 @@ bool global_settings::ConfigParseHardware(cParser& Parser, const std::string& to
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_HARDWARE_PROTOCOL_V2
|
||||
// hardware protocol v2 (uart v2). the legacy uart entries above keep working unchanged, both
|
||||
// protocols may be used at the same time as long as they don't share a port
|
||||
if (token == "uart2")
|
||||
{
|
||||
Parser.getTokens(2, false);
|
||||
hardware::serial_link_config link;
|
||||
Parser >> link.port
|
||||
>> link.baud;
|
||||
if (false == link.port.empty())
|
||||
{
|
||||
hardware_conf.serial_links.emplace_back(link);
|
||||
hardware_conf.enable = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2framesize")
|
||||
{
|
||||
int framesize = static_cast<int>(hardware_conf.frame_size);
|
||||
ParseOneClamped(Parser, framesize, static_cast<int>(hardware::protocol_frame_size_min), static_cast<int>(hardware::protocol_frame_size_max));
|
||||
hardware_conf.frame_size = static_cast<std::size_t>(framesize);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2heartbeat")
|
||||
{
|
||||
ParseOneClamped(Parser, hardware_conf.heartbeat_interval_ms, 50, 10000);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2timeout")
|
||||
{
|
||||
ParseOneClamped(Parser, hardware_conf.heartbeat_timeout_count, 2, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2ratelimit")
|
||||
{
|
||||
Parser.getTokens(3);
|
||||
Parser >> hardware_conf.max_frames_per_second
|
||||
>> hardware_conf.max_payload_bytes_per_second
|
||||
>> hardware_conf.max_commands_per_second;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2pollinterval")
|
||||
{
|
||||
ParseOneClamped(Parser, hardware_conf.poll_interval_ms, 1, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2reconnect")
|
||||
{
|
||||
ParseOneClamped(Parser, hardware_conf.reconnect_interval, 0.1f, 60.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2debug")
|
||||
{
|
||||
ParseOne(Parser, hardware_conf.debug, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (token == "uart2debugframes")
|
||||
{
|
||||
ParseOne(Parser, hardware_conf.debug_frames, 1);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_ZMQ
|
||||
if (token == "zmq.address")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user