Hi,
I am trying to create different messages to be transferred between two hosts. The program structure that I am following is to create a master struct where all the variables to be passed in different messages are declared.
Then I have created different struct for different messages using the same variables from master struct, the values of which I am trying to pass is through pointers.
Below is the rough outline of what I am trying to do. I dont know whether this is the right approach or there is another better way to do it.
The errors that I am getting while compiling are:
1. expression must have a constant value
2. incomplete type is not allowed
Both are pointed when I try to create an instance of message structure and passing the pointers of master struct.
Please help.
Code:
struct Master{
char Bulk_Charging_Complete : 1;
char Charging_Complete : 1;
short Vehicle_Energy_Capacity;
char Vehicle_RESS_SOC;
short Vehicle_Maximum_Power_Limit : 13;
short Vehicle_Maximum_Current_Limit: 13;
short Vehicle_Maximum_Voltage_Limit: 13;
short Charger_Maximum_Power_Limit: 13;
short Charger_Maximum_Current_Limit: 13;
short Charger_Maximum_Voltage_Limit: 14;
short Charge_Current_Request: 13;
} Power;
/* create a pointer of type Master struct and point to instance of that struct type,i.e Power */
struct Master *power_pointer = &Power;
// creating a structure of a message, the value to its variables will be fetched by pointer to the master structure
struct {
short var1 : 1;
char var2 : 4;
short var3 : 1;
short var4 : 4;
}EV_msg_01;
// creating a structure of a message, the value to its variables will be fetched by pointer to the master structure
struct {
short var1 : 1;
short var2 : 4;
short var3 : 1;
short var4 : 4;
}station_msg_01;
struct EV_msg EV_msg_01 = {
power_pointer->Vehicle_Energy_Capacity,
power_pointer->Vehicle_RESS_SOC,
power_pointer->Vehicle_Maximum_Power_Limit,
power_pointer->Vehicle_Maximum_Current_Limit
};
struct station_msg_01 station_msg_01 = {
power_pointer->Charger_Maximum_Power_Limit,
power_pointer->Charger_Maximum_Current_Limit,
power_pointer->Charger_Maximum_Voltage_Limit,
power_pointer->Charge_Current_Request
};