power_comm.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef POWER_COMM_H
31 #define POWER_COMM_H
32 
33 static const unsigned CURRENT_MESSAGE_REVISION = 3;
34 #define CURRENT_MESSAGE_SIZE (sizeof(PowerMessage))
35 static const unsigned MINIMUM_MESSAGE_REVISION = 2;
36 #define REVISION_2_MESSAGE_SIZE (sizeof(MessageHeader) + sizeof(StatusStruct_Rev2))
37 
38 static const unsigned TRANSITION_MESSAGE_REVISION = 2;
39 static const unsigned COMMAND_MESSAGE_REVISION = 2;
40 static const unsigned STATUS_MESSAGE_REVISION = 2;
41 
42 static const unsigned MESSAGE_ID_POWER = 0;
43 static const unsigned MESSAGE_ID_COMMAND = 1;
44 static const unsigned MESSAGE_ID_TRANSITION = 2;
45 static const unsigned MESSAGE_ID_STATUS = 3;
46 static const unsigned POWER_PORT = 6801; // port power board
47 
51 
52 typedef struct
53 {
54  unsigned int message_revision; //32 bit
55  unsigned int serial_num; //32 bit Unique ID number
56  char text[32]; //Description identifier
57  unsigned int message_id;
58  unsigned int data_length; //Length of the following structure
59 } __attribute__((__packed__)) MessageHeader;
60 
61 typedef struct
62 {
63  //Software State 0 = default, 1=Start, 2=Stop, 3=reset, 4=disable
64  unsigned char CB0_state;
65  unsigned char CB1_state;
66  unsigned char CB2_state;
67  unsigned char DCDC_state; // 1=on, 0=off
68 
69  //Status
72  float DCDC_12V_aux;
74  float CB0_voltage;
75  float CB1_voltage;
76  float CB2_voltage;
77  float ambient_temp;
78  unsigned int fan0_speed;
79  unsigned int fan1_speed;
80  unsigned int fan2_speed;
81  unsigned int fan3_speed;
82  unsigned char CB0_status;
83  unsigned char CB1_status;
84  unsigned char CB2_status;
85  unsigned char estop_button_status;
86  unsigned char estop_status;
87  unsigned char pca_rev;
88  unsigned char pcb_rev;
89  unsigned char major_rev;
90  unsigned char minor_rev;
95  float battery_voltage[4];
96 } __attribute__((__packed__)) StatusStruct;
97 
98 typedef struct
99 {
100  //Software State 0 = default, 1=Start, 2=Stop, 3=reset, 4=disable
101  unsigned char CB0_state; // CB_State enum
102  unsigned char CB1_state;
103  unsigned char CB2_state;
104  unsigned char DCDC_state; // Master_State enum
105 
106  //Status
107  float input_voltage;
108  float input_current;
111  float CB0_voltage;
112  float CB1_voltage;
113  float CB2_voltage;
114  float ambient_temp;
115  unsigned int fan0_speed;
116  unsigned int fan1_speed;
117  unsigned int fan2_speed;
118  unsigned int fan3_speed;
119  unsigned char CB0_status; //0-off 1-on
120  unsigned char CB1_status;
121  unsigned char CB2_status;
122  unsigned char estop_button_status;
123  unsigned char estop_status;
124  unsigned char pca_rev;
125  unsigned char pcb_rev;
126  unsigned char major_rev;
127  unsigned char minor_rev;
128  float min_input_voltage;
129  float max_input_current;
130 
131 } __attribute__((__packed__)) StatusStruct_Rev2;
132 
133 typedef struct
134 {
135  MessageHeader header;
136  StatusStruct status;
137 } __attribute__((__packed__)) PowerMessage;
138 
139 #define COMMAND_FLAG_RESET_STATS 0x1 //reset main statistics
140 #define COMMAND_FLAG_RESET_TRANSITION_STATS 0x2 //reset the transition statistics
141 
142 typedef struct
143 {
144  unsigned char CB0_command; //CB_Command enum
145  unsigned char CB1_command;
146  unsigned char CB2_command;
147  unsigned char DCDC_command;
148  unsigned char fan0_command;
149  unsigned char fan1_command;
150  unsigned char fan2_command;
151  unsigned char fan3_command;
152  unsigned int flags; //see COMMAND_FLAGS above
153 } __attribute__((__packed__)) CommandStruct;
154 
155 typedef struct
156 {
157  MessageHeader header;
158  CommandStruct command;
159 } __attribute__((__packed__)) CommandMessage;
160 
161 
162 typedef struct
163 {
164  unsigned char stop_count;
165  unsigned char estop_count;
166  unsigned char trip_count;
167  unsigned char fail_18V_count;
168  unsigned char disable_count;
169  unsigned char start_count;
170  unsigned char pump_fail_count;
171  unsigned char reset_count;
172 } __attribute__((__packed__)) TransitionCount;
173 
174 typedef struct
175 {
176  MessageHeader header;
177  TransitionCount cb[3]; // one for each circuit breaker
178 } __attribute__((__packed__)) TransitionMessage;
179 
180 
181 typedef struct
182 {
183  MessageHeader header;
185 } __attribute__((__packed__)) GetMessage;
186 
187 #endif
__attribute__::CB0_status
unsigned char CB0_status
Definition: power_comm.h:82
__attribute__::DCDC_command
unsigned char DCDC_command
Definition: power_comm.h:147
__attribute__::fan1_speed
unsigned int fan1_speed
Definition: power_comm.h:79
MESSAGE_ID_STATUS
static const unsigned MESSAGE_ID_STATUS
Definition: power_comm.h:45
__attribute__::trip_count
unsigned char trip_count
Definition: power_comm.h:166
__attribute__::header
MessageHeader header
Definition: power_comm.h:135
__attribute__::CB0_state
unsigned char CB0_state
Definition: power_comm.h:64
STATE_PUMPING
@ STATE_PUMPING
Definition: power_comm.h:49
__attribute__::serial_num
unsigned int serial_num
Definition: power_comm.h:55
__attribute__::fan3_command
unsigned char fan3_command
Definition: power_comm.h:151
__attribute__::fan3_speed
unsigned int fan3_speed
Definition: power_comm.h:81
__attribute__::disable_count
unsigned char disable_count
Definition: power_comm.h:168
COMMAND_START
@ COMMAND_START
Definition: power_comm.h:50
CURRENT_MESSAGE_REVISION
static const unsigned CURRENT_MESSAGE_REVISION
Definition: power_comm.h:33
MESSAGE_ID_TRANSITION
static const unsigned MESSAGE_ID_TRANSITION
Definition: power_comm.h:44
__attribute__::DCDC_12V_cpu0
float DCDC_12V_cpu0
Definition: power_comm.h:73
__attribute__::CB1_voltage
float CB1_voltage
Definition: power_comm.h:75
__attribute__::CB0_command
unsigned char CB0_command
Definition: power_comm.h:144
__attribute__::CB1_status
unsigned char CB1_status
Definition: power_comm.h:83
POWER_PORT
static const unsigned POWER_PORT
Definition: power_comm.h:46
__attribute__::DCDC_19V_out_voltage
float DCDC_19V_out_voltage
Definition: power_comm.h:110
__attribute__::CB2_state
unsigned char CB2_state
Definition: power_comm.h:66
__attribute__::max_input_current
float max_input_current
Definition: power_comm.h:92
MASTER_NOPOWER
@ MASTER_NOPOWER
Definition: power_comm.h:48
__attribute__::stop_count
unsigned char stop_count
Definition: power_comm.h:164
__attribute__::estop_count
unsigned char estop_count
Definition: power_comm.h:165
__attribute__::CB2_status
unsigned char CB2_status
Definition: power_comm.h:84
__attribute__::message_revision
unsigned int message_revision
Definition: power_comm.h:54
STATE_STANDBY
@ STATE_STANDBY
Definition: power_comm.h:49
__attribute__::major_rev
unsigned char major_rev
Definition: power_comm.h:89
__attribute__::message_to_get
int message_to_get
Definition: power_comm.h:184
COMMAND_RESET
@ COMMAND_RESET
Definition: power_comm.h:50
COMMAND_DISABLE
@ COMMAND_DISABLE
Definition: power_comm.h:50
__attribute__::pca_rev
unsigned char pca_rev
Definition: power_comm.h:87
STATUS_MESSAGE_REVISION
static const unsigned STATUS_MESSAGE_REVISION
Definition: power_comm.h:40
__attribute__::input_voltage
float input_voltage
Definition: power_comm.h:70
__attribute__::command
CommandStruct command
Definition: power_comm.h:158
MINIMUM_MESSAGE_REVISION
static const unsigned MINIMUM_MESSAGE_REVISION
Definition: power_comm.h:35
MASTER_STANDBY
@ MASTER_STANDBY
Definition: power_comm.h:48
NONE
@ NONE
Definition: power_comm.h:50
__attribute__::estop_status
unsigned char estop_status
Definition: power_comm.h:86
__attribute__::fan2_speed
unsigned int fan2_speed
Definition: power_comm.h:80
__attribute__::input_current
float input_current
Definition: power_comm.h:71
TRANSITION_MESSAGE_REVISION
static const unsigned TRANSITION_MESSAGE_REVISION
Definition: power_comm.h:38
COMMAND_STOP
@ COMMAND_STOP
Definition: power_comm.h:50
__attribute__::fan0_speed
unsigned int fan0_speed
Definition: power_comm.h:78
__attribute__::fail_18V_count
unsigned char fail_18V_count
Definition: power_comm.h:167
__attribute__::CB1_command
unsigned char CB1_command
Definition: power_comm.h:145
__attribute__::DCDC_12V_cpu1
float DCDC_12V_cpu1
Definition: power_comm.h:93
COMMAND_MESSAGE_REVISION
static const unsigned COMMAND_MESSAGE_REVISION
Definition: power_comm.h:39
CB_State
CB_State
Definition: power_comm.h:49
STATE_NOPOWER
@ STATE_NOPOWER
Definition: power_comm.h:49
__attribute__::minor_rev
unsigned char minor_rev
Definition: power_comm.h:90
STATE_DISABLED
@ STATE_DISABLED
Definition: power_comm.h:49
__attribute__::min_input_voltage
float min_input_voltage
Definition: power_comm.h:91
Master_State
Master_State
Definition: power_comm.h:48
__attribute__::CB1_state
unsigned char CB1_state
Definition: power_comm.h:65
__attribute__::CB2_command
unsigned char CB2_command
Definition: power_comm.h:146
STATE_ON
@ STATE_ON
Definition: power_comm.h:49
__attribute__::pcb_rev
unsigned char pcb_rev
Definition: power_comm.h:88
MASTER_OFF
@ MASTER_OFF
Definition: power_comm.h:48
__attribute__::start_count
unsigned char start_count
Definition: power_comm.h:169
__attribute__::fan1_command
unsigned char fan1_command
Definition: power_comm.h:149
MESSAGE_ID_COMMAND
static const unsigned MESSAGE_ID_COMMAND
Definition: power_comm.h:43
__attribute__
Definition: power_comm.h:52
MASTER_SHUTDOWN
@ MASTER_SHUTDOWN
Definition: power_comm.h:48
MESSAGE_ID_POWER
static const unsigned MESSAGE_ID_POWER
Definition: power_comm.h:42
__attribute__::ambient_temp
float ambient_temp
Definition: power_comm.h:77
__attribute__::reset_count
unsigned char reset_count
Definition: power_comm.h:171
CB_Command
CB_Command
Definition: power_comm.h:50
__attribute__::flags
unsigned int flags
Definition: power_comm.h:152
__attribute__::DCDC_12V_aux
float DCDC_12V_aux
Definition: power_comm.h:72
__attribute__::DCDC_12V_user
float DCDC_12V_user
Definition: power_comm.h:94
header
const std::string header
__attribute__::DCDC_state
unsigned char DCDC_state
Definition: power_comm.h:67
__attribute__::pump_fail_count
unsigned char pump_fail_count
Definition: power_comm.h:170
__attribute__::message_id
unsigned int message_id
Definition: power_comm.h:57
__attribute__::status
StatusStruct status
Definition: power_comm.h:136
__attribute__::CB2_voltage
float CB2_voltage
Definition: power_comm.h:76
MASTER_ON
@ MASTER_ON
Definition: power_comm.h:48
__attribute__::data_length
unsigned int data_length
Definition: power_comm.h:58
__attribute__::estop_button_status
unsigned char estop_button_status
Definition: power_comm.h:85
__attribute__::fan0_command
unsigned char fan0_command
Definition: power_comm.h:148
__attribute__::DCDC_12V_out_voltage
float DCDC_12V_out_voltage
Definition: power_comm.h:109
__attribute__::CB0_voltage
float CB0_voltage
Definition: power_comm.h:74
__attribute__::fan2_command
unsigned char fan2_command
Definition: power_comm.h:150


pr2_power_board
Author(s): Curt Meyers, Blaise Gassend
autogenerated on Tue Mar 7 2023 03:19:35