-
Notifications
You must be signed in to change notification settings - Fork 1
/
hexabus_typedefs.go
119 lines (86 loc) · 2.67 KB
/
hexabus_typedefs.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package hexabus
// Constants used inside Hexabus packets.
// They describe various packet types, data types and error responses.
// As well as the four header bytes, Hexabus bool type representation and
// paket flags.
const (
/* Header */
// The UDP Data of a Hexabus Packet starts with the Bytes 0x48 0x58 0x30 0x43
// (HX0C) to identify it as a Hexabus Packet
HEADER0, HEADER1, HEADER2, HEADER3 = 0x48, 0x58, 0x30, 0x43
/* Boolean values */
// boolean false
FALSE = 0x00
// boolean true
TRUE = 0x01
/* Packet types */
// Hexabus Error Packet
// An error occured -- check the error code field for more information
PTYPE_ERROR = 0x00
// Hexabus Info Packet
// Endpoint provides information
PTYPE_INFO = 0x01
// Hexabus Query Packet
// Endpoint is requested to provide information
PTYPE_QUERY = 0x02
// Hexabus Write Packet
// Endpoint is requested to set its value
PTYPE_WRITE = 0x04
// Hexabus EpInfo Packet
// Endpoint metadata
PTYPE_EPINFO = 0x09
// Hexabus EpQuery Packet
// Request endpoint metadata
PTYPE_EPQUERY = 0x0a
/* Flags */
// Hexabus Flag "No Flag set"
FLAG_NONE = 0x00
/* Data types */
// Hexabus Data Type "No data at all"
DTYPE_UNDEFINED = 0x00
// Data type Bool
DTYPE_BOOL = 0x01
// Data type uint8
DTYPE_UINT8 = 0x02
// Data type uint32
DTYPE_UINT32 = 0x03
// Data type date/time
DTYPE_DATETIME = 0x04
// Data type float
DTYPE_FLOAT = 0x05
// Data type 128String
// char string with 128 bytes, must be 0 terminated
DTYPE_128STRING = 0x06
// max char length = 127 + 0 termination
STRING_PACKET_MAX_BUFFER_LENGTH = 127
// Data type timestamp
// in secondes since device was booted up, 32 bit unsigned integer (4 bytes)
DTYPE_TIMESTAMP = 0x07
// Data type 16bytes
// 16 bytes of raw binary data
DTYPE_16BYTES = 0x09
// max byte length = 16 bytes
BYTES16_PACKET_MAX_BUFFER_LENGTH = 16
// Data type 66bytes
// 66 bytes of raw binary data
DTYPE_66BYTES = 0x08
// max byte 65 bytes DATA TYPE name is a typo since this type is
// used by the statemachine upload only, and that is 65 bytes
BYTES66_PACKET_MAX_BUFFER_LENGTH_ = 65
/* Error codes */
// reserved: No error
HXB_ERR_SUCCESS = 0x00
// A request for an endpoint which does not exist on the device was received
HXB_ERR_UNKNOWNEID = 0x01
// WRITE was received for a readonly endpoint
HXB_ERR_WRITEREADONLY = 0x02
// A packet failed the CRC check
// TODO How can we find out what information was lost?
HXB_ERR_CRCFAILED = 0x03
// A packet with a datatype that does not fit the endpoint was received
HXB_ERR_DATATYPE = 0x04
// A value was encountered that cannot be interpreted
HXB_ERR_INVALID_VALUE = 0x05
// lib hexabus version
VERSION = "1.0.0 beta"
)