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
static const unsigned COMMAND_MESSAGE_REVISION
Definition: power_comm.h:39
float input_voltage
Definition: power_comm.h:70
unsigned char major_rev
Definition: power_comm.h:89
CommandStruct command
Definition: power_comm.h:158
unsigned int fan2_speed
Definition: power_comm.h:80
unsigned char pca_rev
Definition: power_comm.h:87
static const unsigned STATUS_MESSAGE_REVISION
Definition: power_comm.h:40
unsigned char fail_18V_count
Definition: power_comm.h:167
unsigned char estop_status
Definition: power_comm.h:86
unsigned char minor_rev
Definition: power_comm.h:90
unsigned char CB1_state
Definition: power_comm.h:65
unsigned char fan1_command
Definition: power_comm.h:149
unsigned char CB2_command
Definition: power_comm.h:146
float min_input_voltage
Definition: power_comm.h:91
unsigned int fan0_speed
Definition: power_comm.h:78
unsigned char pcb_rev
Definition: power_comm.h:88
float DCDC_12V_user
Definition: power_comm.h:94
unsigned int flags
Definition: power_comm.h:152
float ambient_temp
Definition: power_comm.h:77
float DCDC_12V_aux
Definition: power_comm.h:72
unsigned char fan2_command
Definition: power_comm.h:150
unsigned char start_count
Definition: power_comm.h:169
static const unsigned MESSAGE_ID_COMMAND
Definition: power_comm.h:43
unsigned char pump_fail_count
Definition: power_comm.h:170
unsigned int message_id
Definition: power_comm.h:57
unsigned int data_length
Definition: power_comm.h:58
unsigned char estop_button_status
Definition: power_comm.h:85
unsigned char fan0_command
Definition: power_comm.h:148
float CB2_voltage
Definition: power_comm.h:76
unsigned char DCDC_state
Definition: power_comm.h:67
unsigned char reset_count
Definition: power_comm.h:171
StatusStruct status
Definition: power_comm.h:136
unsigned int fan1_speed
Definition: power_comm.h:79
float DCDC_12V_out_voltage
Definition: power_comm.h:109
MessageHeader header
Definition: power_comm.h:135
unsigned char CB0_status
Definition: power_comm.h:82
float DCDC_12V_cpu0
Definition: power_comm.h:73
unsigned char CB0_command
Definition: power_comm.h:144
static const unsigned MESSAGE_ID_POWER
Definition: power_comm.h:42
CB_State
Definition: power_comm.h:49
unsigned char fan3_command
Definition: power_comm.h:151
Master_State
Definition: power_comm.h:48
float DCDC_19V_out_voltage
Definition: power_comm.h:110
static const unsigned MINIMUM_MESSAGE_REVISION
Definition: power_comm.h:35
float max_input_current
Definition: power_comm.h:92
static const unsigned TRANSITION_MESSAGE_REVISION
Definition: power_comm.h:38
float CB0_voltage
Definition: power_comm.h:74
unsigned char DCDC_command
Definition: power_comm.h:147
unsigned char CB2_state
Definition: power_comm.h:66
unsigned char trip_count
Definition: power_comm.h:166
float CB1_voltage
Definition: power_comm.h:75
unsigned char CB0_state
Definition: power_comm.h:64
static const unsigned MESSAGE_ID_TRANSITION
Definition: power_comm.h:44
unsigned char CB1_status
Definition: power_comm.h:83
static const unsigned CURRENT_MESSAGE_REVISION
Definition: power_comm.h:33
unsigned int serial_num
Definition: power_comm.h:55
unsigned char stop_count
Definition: power_comm.h:164
unsigned int fan3_speed
Definition: power_comm.h:81
CB_Command
Definition: power_comm.h:50
unsigned char estop_count
Definition: power_comm.h:165
const std::string header
unsigned char disable_count
Definition: power_comm.h:168
static const unsigned POWER_PORT
Definition: power_comm.h:46
unsigned int message_revision
Definition: power_comm.h:54
unsigned char CB2_status
Definition: power_comm.h:84
static const unsigned MESSAGE_ID_STATUS
Definition: power_comm.h:45
float input_current
Definition: power_comm.h:71
int message_to_get
Definition: power_comm.h:184
unsigned char CB1_command
Definition: power_comm.h:145
float DCDC_12V_cpu1
Definition: power_comm.h:93


pr2_power_board
Author(s): Curt Meyers, Blaise Gassend
autogenerated on Wed Mar 8 2023 03:37:51