aboutsummaryrefslogtreecommitdiffstats
path: root/src/Xpl2Protocol.h
blob: 85d6895cacdb87c3caf5a0101e835e4fa7e26c90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * @file   Xpl2Protocol.h
 * @brief  Wire framing for the XPL2 printhead protocol.
 */
#pragma once

#include <QByteArray>
#include <QObject>
#include <QVariantList>

namespace Xpl2Protocol
{

Q_NAMESPACE

/** Extended success flag for CF_JC/PH_SET_JETTING_PARAMS responses. */
enum class JettingParamsResult
{
  NozzleDriveDutyCycle = -5,
  NozzleDriveFrequency = -4,
  Drive = -3,
  PwmFrequency = -2,
  DutyCycle = -1,
  Failed = 0,
  Ok = 1
};
Q_ENUM_NS (JettingParamsResult)

/** Extended success flag for CF_JC/PH_SETTER responses. */
enum class SetterResult
{
  IncorrectNewValue = -1,
  Failed = 0,
  Ok = 1
};
Q_ENUM_NS (SetterResult)

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