dsm-api-v2
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
usr
local
include
digitalSTROM
ds485.h
Go to the documentation of this file.
1
/*
2
This file is part of the digitalSTROM ds485-core library.
3
4
Copyright (C) 2010 digitalSTROM.org, Schlieren, Switzerland
5
6
digitalSTROM ds485-core library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
as published by the Free Software Foundation version 2
9
of the License.
10
11
digitalSTROM ds485-core library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with digitalSTROM ds485-core library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
*/
20
21
#ifndef _ds485_h
22
#define _ds485_h
23
24
#include <
digitalSTROM/ds.h
>
25
#include <digitalSTROM/ds485-const.h>
26
#define DS485_MAX_PAYLOAD_SIZE 127
27
#define DS485_MAX_PAYLOAD_SIZE_RAW DS485_MAX_PAYLOAD_SIZE + 1
28
#define DS485_CONTAINER_DATA_LENGTH DS485_MAX_PAYLOAD_SIZE
29
#define DS485_CONTAINER_SIZE (sizeof(ds485_container_t) - (DS485_CONTAINER_DATA_LENGTH))
30
34
enum
{
35
DS485_INTERNAL_ERROR_OK
= 0,
36
DS485_INTERNAL_ERROR_GENERAL
= -1,
37
DS485_INTERNAL_ERROR_EMPTY_TX_QUEUE
= -2,
38
DS485_INTERNAL_ERROR_INVALID_BUS_ADDR
= -3,
39
};
40
44
typedef
enum
{
45
DS485_STATE_ISOLATED
= 1,
46
DS485_STATE_JOIN
,
47
DS485_STATE_CONNECTED
,
48
DS485_STATE_ACTIVE
,
49
DS485_STATE_DISCONNECTED
,
50
}
bus_state_t
;
51
55
typedef
enum
{
56
DS485_CONTAINER_REQUEST
= 1,
57
DS485_CONTAINER_RESPONSE
,
58
DS485_CONTAINER_EVENT
59
}
container_type_t
;
60
61
typedef
enum
{
62
DS485_FLAG_NONE
= 1,
63
DS485_FLAG_BROADCAST
= 2,
64
}
container_flags_t
;
65
69
typedef
struct
ds485_container
{
70
dsid_t
destinationId
;
71
dsid_t
sourceId
;
72
container_type_t
containerType
;
73
container_flags_t
containerFlags
;
74
uint8_t
length
;
75
union
{
76
struct
{
77
unsigned
char
transactionId
;
78
unsigned
char
data
[
DS485_MAX_PAYLOAD_SIZE
];
79
};
80
unsigned
char
raw_data
[
DS485_MAX_PAYLOAD_SIZE_RAW
];
81
};
82
#ifdef SWIG
83
} ds485_container_t;
84
#else
85
}
__attribute__
((packed)) ds485_container_t;
86
#endif
87
91
typedef
struct
{
92
/* TX */
93
uint32_t
txToken
;
94
uint16_t
txStartupRequest
;
95
uint16_t
txStartupResponse
;
96
uint16_t
txJoinRequest
;
97
uint16_t
txJoinResponse
;
98
uint16_t
txGetAddressRequest
;
99
uint16_t
txGetAddressResponse
;
100
uint16_t
txSetAddressRequest
;
101
uint16_t
txSetAddressResponse
;
102
uint16_t
txSetSuccessorAddressRequest
;
103
uint16_t
txSetSuccessorAddressResponse
;
104
uint16_t
txResponse
;
105
uint16_t
txDataRequest
;
106
uint16_t
txDataResponse
;
107
uint16_t
txDataEvent
;
108
/* RX */
109
uint16_t
rxResponse
;
110
uint16_t
rxDataRequest
;
111
uint16_t
rxDataResponse
;
112
uint16_t
rxDataEvent
;
113
/* Actions */
114
uint16_t
startRegisterStation
;
115
uint16_t
doneRegisterStation
;
116
uint16_t
enterOperational
;
117
uint16_t
successorLost
;
118
}
DS485Statistics
;
119
120
/***
121
* External references - have to be supplied by platform module
122
*/
123
127
#define RX_FLAG_CRC_ERROR 0x01
128
#define RX_FLAG_FRAME_ERROR 0x02
129
#define RX_FLAG_PROTOCOL_ERROR 0x04
130
#define RX_FLAG_NOTFORME 0x10
131
#define RX_FLAG_INVALID_ADDRESS 0x80
132
133
#define RX_FLAG_ERRORS (RX_FLAG_CRC_ERROR | RX_FLAG_FRAME_ERROR | RX_FLAG_PROTOCOL_ERROR)
134
138
#define DS485_FILTER_ALL_RESPONSES 0x01
139
140
#endif
Generated on Wed Apr 30 2014 08:56:32 for dsm-api-v2 by
1.8.4