[Ovmsdev] Volt/Ampera

mikeljo at mac.com mikeljo at mac.com
Wed Feb 6 20:10:29 HKT 2013


Hi mark,

i am a little bit confused.

In ovms.h you define this:
extern unsigned char car_doors1;
typedef struct {
  unsigned FrontLeftDoor:1;
  unsigned FrontRightDoor:1;
  unsigned ChargePort:1;
  unsigned PilotSignal:1;
  unsigned Charging:1;
  unsigned :1;
  unsigned HandBrake:1;
  unsigned CarON:1;
} car_doors1bits_t;
#define car_doors1bits (*((car_doors1bits_t*)&car_doors1))

so you can use the struct (car_doors1bits_t) as integer "variable" car_doors1 and as single bit car_doors1bits and vice versa.

Then you use the integer in vehicle_voltampera.c: (only a few examples!)
car_doors1 |= 0x0c;     // Set charge and pilot bits

and
    car_doors1 |= 0x40;     //  PARK
    car_doors1 &= ~0x80;    // CAR OFF

witch bits is now what?

My understanding is that the MSB is "FrontLeftDoor" and the LSB is "CarON".
If i am right, than this is wrong: "car_doors1 &= ~0x80;    // CAR OFF"
this will clear FrontLeftDoor.

And this is "partial" right: "car_doors1 |= 0x0c;     // Set charge and pilot bits"
this will set Charging and the unnamed bit. But should set charging and PilotSignal. Then it must be 0x18

Can you or anybody else check?
I think it is better to use the bits direct. Like this:  car_doors1bits.ChargePort = 1


Bye
Michael J.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.teslaclub.hk/pipermail/ovmsdev/attachments/20130206/095e9036/attachment.html>


More information about the OvmsDev mailing list