power_comm.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027 * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef POWER_COMM_H
00031 #define POWER_COMM_H
00032 
00033 static const unsigned CURRENT_MESSAGE_REVISION = 3;
00034 #define CURRENT_MESSAGE_SIZE (sizeof(PowerMessage))
00035 static const unsigned MINIMUM_MESSAGE_REVISION = 2;
00036 #define REVISION_2_MESSAGE_SIZE (sizeof(MessageHeader) + sizeof(StatusStruct_Rev2))
00037 
00038 static const unsigned TRANSITION_MESSAGE_REVISION = 2;
00039 static const unsigned COMMAND_MESSAGE_REVISION = 2;
00040 static const unsigned STATUS_MESSAGE_REVISION = 2;
00041 
00042 static const unsigned MESSAGE_ID_POWER = 0;
00043 static const unsigned MESSAGE_ID_COMMAND = 1;
00044 static const unsigned MESSAGE_ID_TRANSITION = 2;
00045 static const unsigned MESSAGE_ID_STATUS = 3;
00046 static const unsigned POWER_PORT = 6801; // port power board
00047 
00048 enum Master_State { MASTER_NOPOWER, MASTER_STANDBY, MASTER_ON, MASTER_OFF, MASTER_SHUTDOWN };
00049 enum CB_State { STATE_NOPOWER, STATE_STANDBY, STATE_PUMPING, STATE_ON, STATE_DISABLED };
00050 enum CB_Command { NONE = 0, COMMAND_START = 1, COMMAND_STOP = 2, COMMAND_RESET = 3, COMMAND_DISABLE = 4 };
00051 
00052 typedef struct
00053 {
00054   unsigned int    message_revision; //32 bit 
00055   unsigned int    serial_num;       //32 bit  Unique ID number
00056   char            text[32];         //Description identifier
00057   unsigned int    message_id;
00058   unsigned int    data_length;      //Length of the following structure
00059 } __attribute__((__packed__)) MessageHeader;
00060 
00061 typedef struct
00062 {
00063   //Software State  0 = default, 1=Start, 2=Stop, 3=reset, 4=disable
00064   unsigned char   CB0_state;
00065   unsigned char   CB1_state;
00066   unsigned char   CB2_state;
00067   unsigned char   DCDC_state;  // 1=on, 0=off
00068 
00069   //Status
00070   float           input_voltage;
00071   float           input_current;
00072   float           DCDC_12V_aux;
00073   float           DCDC_12V_cpu0;
00074   float           CB0_voltage;
00075   float           CB1_voltage;
00076   float           CB2_voltage;
00077   float           ambient_temp;
00078   unsigned int    fan0_speed;
00079   unsigned int    fan1_speed;
00080   unsigned int    fan2_speed;
00081   unsigned int    fan3_speed;
00082   unsigned char   CB0_status;
00083   unsigned char   CB1_status;
00084   unsigned char   CB2_status;
00085   unsigned char   estop_button_status;
00086   unsigned char   estop_status;
00087   unsigned char   pca_rev;
00088   unsigned char   pcb_rev;
00089   unsigned char   major_rev;
00090   unsigned char   minor_rev;
00091   float           min_input_voltage;
00092   float           max_input_current;
00093   float           DCDC_12V_cpu1;
00094   float           DCDC_12V_user;
00095   float           battery_voltage[4];
00096 } __attribute__((__packed__)) StatusStruct;
00097 
00098 typedef struct
00099 {
00100   //Software State  0 = default, 1=Start, 2=Stop, 3=reset, 4=disable
00101   unsigned char   CB0_state;   // CB_State enum
00102   unsigned char   CB1_state;
00103   unsigned char   CB2_state;
00104   unsigned char   DCDC_state;  // Master_State enum
00105 
00106   //Status
00107   float           input_voltage;
00108   float           input_current;
00109   float           DCDC_12V_out_voltage;
00110   float           DCDC_19V_out_voltage;
00111   float           CB0_voltage;
00112   float           CB1_voltage;
00113   float           CB2_voltage;
00114   float           ambient_temp;
00115   unsigned int    fan0_speed; 
00116   unsigned int    fan1_speed;
00117   unsigned int    fan2_speed;
00118   unsigned int    fan3_speed;
00119   unsigned char   CB0_status;  //0-off 1-on
00120   unsigned char   CB1_status;
00121   unsigned char   CB2_status;
00122   unsigned char   estop_button_status;
00123   unsigned char   estop_status;
00124   unsigned char   pca_rev;
00125   unsigned char   pcb_rev;
00126   unsigned char   major_rev;
00127   unsigned char   minor_rev;
00128   float           min_input_voltage;
00129   float           max_input_current;
00130 
00131 } __attribute__((__packed__)) StatusStruct_Rev2;
00132 
00133 typedef struct 
00134 {
00135         MessageHeader header;
00136         StatusStruct  status;
00137 } __attribute__((__packed__)) PowerMessage;
00138 
00139 #define COMMAND_FLAG_RESET_STATS            0x1   //reset main statistics
00140 #define COMMAND_FLAG_RESET_TRANSITION_STATS 0x2   //reset the transition statistics
00141 
00142 typedef struct
00143 {
00144   unsigned char   CB0_command; //CB_Command enum
00145   unsigned char   CB1_command;
00146   unsigned char   CB2_command;
00147   unsigned char   DCDC_command;
00148   unsigned char   fan0_command;
00149   unsigned char   fan1_command;
00150   unsigned char   fan2_command;
00151   unsigned char   fan3_command;
00152   unsigned int    flags;  //see COMMAND_FLAGS above
00153 } __attribute__((__packed__)) CommandStruct;
00154 
00155 typedef struct
00156 {
00157   MessageHeader header;
00158   CommandStruct command;
00159 } __attribute__((__packed__)) CommandMessage;
00160 
00161 
00162 typedef struct
00163 {
00164   unsigned char   stop_count;
00165   unsigned char   estop_count;
00166   unsigned char   trip_count;
00167   unsigned char   fail_18V_count;
00168   unsigned char   disable_count;
00169   unsigned char   start_count;
00170   unsigned char   pump_fail_count;
00171   unsigned char   reset_count;
00172 } __attribute__((__packed__)) TransitionCount;
00173 
00174 typedef struct
00175 {
00176   MessageHeader header;
00177   TransitionCount cb[3]; // one for each circuit breaker
00178 } __attribute__((__packed__)) TransitionMessage;
00179 
00180 
00181 typedef struct 
00182 {
00183         MessageHeader header;
00184   int message_to_get;
00185 } __attribute__((__packed__)) GetMessage;
00186 
00187 #endif


pr2_power_board
Author(s): Curt Meyers, Blaise Gassend
autogenerated on Wed Aug 26 2015 15:40:44