[Ovmsdev] What does CarOn mean?

Tom Saxton tom at idleloop.com
Tue Jun 17 13:42:36 HKT 2014


Hi Nikolay,

That code won't quite work for two reasons.

The third data byte has index 2.

Also, since the CarOn field is a single bit, you have to set it to 0 or 1.
Your code is setting to either 0x00 or 0x04, both of which will set the
CarOn bit to zero because they both have the low bit off. I would do it this
way:

car_doors1bits.CarON = (can_databuffer[2] & 0x04) >> 2;

or

car_doors1bits.CarON = (can_databuffer[2] & 0x04) ? 1 : 0;

I'm not sure which of those will produce the smallest code on the PIC. If
the compiler is really smart, it will produce the same optimal code for
either. I favor the second for clarity.

    Tom

On 6/16/14, 6:42 AM, "Nikolay Shishkov" <nshishkov at yahoo.com> wrote:

Thanks Mark, 
With some help I found a message on the canbus that reflects the status of
the "Ready" light in the car.
Please note that the key position may be in "on", that does not mean that
the car can drive. I have seen this behavior (the switch is on, but then it
takes half second and the car is "ready", most of the time) in the old RAV4
EV, Nissan Leaf, the Mitsubishi Miev trio of cars, Think City EV.
I don't remember how it works in the Roadster or the Model S.
So if no one minds I will be setting the CarON when the "Ready" bit is set
in that CANBus message.
Can someone please confirm that my code will extract the correct bit - I
think I got it right, but sometimes I confuse the zerobased indexing and the
endianness of a system.
The CAN bus message id is 0x424 -

Here with ready OFF:
424 43 00 08 00 00 AE 01 FF

And here with ready ON:
424 43 00 0C 00 00 AE 01 FF
So I am looking for the the 3rd bit in the 3rd byte of the message and I am
thinking of doing something like this:
car_doors1bits.CarON = can_databuffer[3] & (1<<2);
or maybe 
car_doors1bits.CarON = can_databuffer[3] & 4;
Is this correct?
Nikolay




Nikolay,
unsigned char car_doors1 [bit 7]
A bit used to signal whether the car is turned on or off. Set to 1 if the
car ignition switch is ON, otherwise 0.


If the state of the ignition switch is not readable on the bus, the vehicle
not being in 'P' gear or handbrake not appied (and not charging), would be
acceptable.

Regards, Mark.

On 15 Jun, 2014, at 9:38 pm, Nikolay Shishkov <nshishkov at yahoo.com
<http://lists.teslaclub.hk/mailman/listinfo/ovmsdev> > wrote:

> As the subject says - what does CarOn mean? Is it key in position 3, or car in
"Ready" state? Or something even more remote like shifter not in "P"?
> 
> Nikolay

_______________________________________________ OvmsDev mailing list
OvmsDev at lists.teslaclub.hk
http://lists.teslaclub.hk/mailman/listinfo/ovmsdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20140616/3fb895a7/attachment.htm>


More information about the OvmsDev mailing list