aboutsummaryrefslogtreecommitdiffstats
path: root/src/Xpl2Protocol.h
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-03-13 11:47:00 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-03-13 11:47:00 +0100
commita2b1ccf17845e55caef7f69a5e68f49a55b6a166 (patch)
treea7e8c414dbadeeb9bcac29478cf3fbf7e99a4a05 /src/Xpl2Protocol.h
parent34faf3cdea798c1948229ec1bb53c828e2b40bb7 (diff)
downloadQtXpl2-a2b1ccf17845e55caef7f69a5e68f49a55b6a166.tar.gz
QtXpl2-a2b1ccf17845e55caef7f69a5e68f49a55b6a166.zip
XPL2 protocol foundation: wire framing, typed API, KA_PING, GS_JC_VERSION
Add Xpl2Protocol namespace with buildMessage/parseMessage for wire serialization. Replace raw send/receive API on Xpl2Client with typed protocol methods and internal dispatch. Auto-reply to KA_PING on all sockets (qDebug only). Add GS_JC_VERSION as first typed command with controllerId, firmwareVersion, hardwareVersion, printheadCount properties. Upgrade mock server from echo to line-based command dispatch with 1s KA_PING timer and canned GS_JC_VERSION response. Unknown commands produce qWarning instead of echo. Overhaul demo: remove raw send UI and port config, add wireDebug toggle and Get JC Version button.
Diffstat (limited to 'src/Xpl2Protocol.h')
-rw-r--r--src/Xpl2Protocol.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Xpl2Protocol.h b/src/Xpl2Protocol.h
new file mode 100644
index 0000000..6d4a348
--- /dev/null
+++ b/src/Xpl2Protocol.h
@@ -0,0 +1,27 @@
+/**
+ * @file Xpl2Protocol.h
+ * @brief Wire framing for the XPL2 printhead protocol.
+ */
+#pragma once
+
+#include <QByteArray>
+#include <QVariantList>
+
+namespace Xpl2Protocol
+{
+
+constexpr char Terminator = '\n';
+
+struct ParsedMessage
+{
+ QByteArray command;
+ QVariantList params;
+ bool valid = false;
+};
+
+QByteArray buildMessage (const QByteArray &command,
+ const QVariantList &params = {});
+
+ParsedMessage parseMessage (const QByteArray &raw);
+
+} // namespace Xpl2Protocol