[Ovmsdev] Higher resolution events

Mark Webb-Johnson mark at webb-johnson.net
Mon Nov 27 08:36:36 HKT 2017


So long as you are calling this in IncomingFrameCan* or IncomingPollReply, that is possibly acceptable, but bear in mind that any other incoming CAN frames will be queued up and possible lost (if the queue overflows) while you are in vTaskDelay.

Using timers means that the transmission will be in the context of the freertos timer task, but is generally acceptable for short quick jobs (like transmitting a single CAN frame).

Regards, Mark.

> On 27 Nov 2017, at 3:00 AM, Geir Øyvind Vælidalo <geir at validalo.net> wrote:
> 
> I use vTaskDelay(50 / portTICK_PERIOD_MS) to delay 50ms. Not sure if that is the correct way, though.
> 
> Geir
> 
> 
>> 26. nov. 2017 kl. 12:42 skrev Mark Webb-Johnson <mark at webb-johnson.net <mailto:mark at webb-johnson.net>>:
>> 
>> You definitely don’t want to be spinning - that won’t give you any precision on the delay (other tasks may pre-empt), and is also wasteful.
>> 
>> How about a timer (xTimerCreate). Have it fire once every 50ms/100ms. You can xTimerStart start it, and stop when done.
>> 
>> One trick to use is that the freertos objects contain a void* user data you can use to point to ‘this’ (your C++ object).
>> 
>> Regards, Mark.
>> 
>>> On 26 Nov 2017, at 1:38 PM, Tom Parker <tom at carrott.org <mailto:tom at carrott.org>> wrote:
>>> 
>>> Hi,
>>> 
>>> To implement the Leaf's remote climate control, I need to send a frame, wait 50ms and then repeat another frame every 100ms for 25 repetitions.
>>> 
>>> On the v2 hardware I implemented this with a 50ms delay and the ticker10th function. I wasn't able to find any delay functions in v3 so either I didn't look hard enough, nothing needs one, or busy-waiting isn't the right thing to do. Ticker10th isn't implemented. I could refactor the existing ticker task to fire 10 times a second instead of once per second, or I could register a new task for the climate control and cancel it after the the 25 repetitions. Or maybe something else altogether is appropriate?
>>> 
>>> Thoughts?
>>> 
>>> _______________________________________________
>>> OvmsDev mailing list
>>> OvmsDev at lists.teslaclub.hk <mailto:OvmsDev at lists.teslaclub.hk>
>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>> 
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.teslaclub.hk <mailto:OvmsDev at lists.teslaclub.hk>
>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
> 
> _______________________________________________
> 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/20171127/9ca3ef63/attachment.htm>


More information about the OvmsDev mailing list