-
Notifications
You must be signed in to change notification settings - Fork 0
/
972b.h
60 lines (49 loc) · 1.78 KB
/
972b.h
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
53
54
55
56
57
58
59
60
#ifndef _972B_H_
#define _972B_H_
#include <Arduino.h>
// Constants
#define DEFAULT_ADDR "253"
// Structure for NAK codes
struct NAKCode {
int code;
const char* description;
};
struct NACKResult {
String description;
bool found;
};
struct CommandResult {
bool outcome;
String resultStr;
};
class PressureTransducer {
public:
PressureTransducer(String addr=DEFAULT_ADDR, HardwareSerial& serial=Serial2);
static int getNumNackCodes();
void sendCommand(String command="", String parameter="");
String readResponse();
CommandResult status();
void changeBaudRate(String newBaudRate="9600");
void setRS485Delay(String delaySetting="ON");
void printResponse(const String& response);
void queryRS485Delay();
CommandResult setupSetpoint(String setpoint, String direction, String hysteresis="", String enableMode="ON");
CommandResult requestPressure(String measureType="PR3");
void printPressure(String measureType="PR3");
String parseResponse(const String& response);
void setResponseTimeout(unsigned long timeout);
CommandResult setPressureUnits(String units="MBAR");
CommandResult setUserTag(String tag="EBEAM1");
static const String INCOMPLETE_RESPONSE;
static const String RESPONSE_TOO_LONG;
static double sciToDouble(String sciString);
private:
HardwareSerial& serialPort;
String deviceAddress;
static NAKCode nakCodes[];
NACKResult decodeNAK(String codeStr);
bool checkForLockError(String response);
unsigned long responseTimeout = 3000; // Default timeout (ms)
const int maxResponseLength = 256; // Default maximum response character length
};
#endif // _972B_H_