-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDIBusController.hpp
58 lines (44 loc) · 1.33 KB
/
SDIBusController.hpp
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
#ifndef __SDI_BUS_CONTROLLER_HPP
#define __SDI_BUS_CONTROLLER_HPP
#include <Arduino.h>
#include "SDISerial.hpp"
// protocol timing constants
#define SDI_BREAK_TIME_MS 12
#define SDI_MARKING_TIME_MS 9
#define SDI_SENSOR_RESPONSE_TIME_MS 780 //???? this is time for initial response... tricky
#define SDI_SENSOR_MAXIMUM_TIME_MS 780
//class SDIRemoteSensor{};
enum SDIBusError {
OK=0,
BUSY=1,
ADDRESS_IN_USE=2,
BAD_ADDRESS=3,
NO_SPACE=4,
TIMEOUT=5,
UNREGISTERED_SENSOR=6,
RESPONSE_ERROR=7
};
extern SDIBusError SDIBusErrno;
struct SDIDeviceIdentification{
char addr[2] = {0};
char sdiVersion[3] = {0};
char vendor[9] = {0};
char modelNum[7] = {0};
char sensorVersion[4] = {0};
char optional[14] = {0};
};
class SDIBusController {
// friend class SDIRemoteSensor;
private:
SDIStream &mySDIStream;
bool isValidAddress(char addr);
public:
SDIBusController(SDIStream &serial);
virtual int addressQuery(char *outAddr); // Use when there is only 1 sensor connected
virtual int acknowledgeActive(char addr);
virtual int identify(char addr, struct SDIDeviceIdentification* devInfo);
virtual int refresh(char addr, int altno, int *waitTime, int *numExpected);
virtual int getData(char addr, float* buffer, int numExpected);
virtual int changeAddress(char oldAddr, char newAddr);
};
#endif