[Ovmsdev] Framework V3.1

Michael Balzer dexter at expeedo.de
Sat Jan 7 20:38:07 HKT 2017


You can now see these error in the "*-OVM-ServerLogs" CSV as well, I've
just extended the logging a bit to also capture logins and terminations.

For sending data, it's mostly a question of the available modem send
buffer and actual network MTU. You can query the available max send size
by...

AT+CIPSEND=?

...which will normally be around 1460. You need to add base64 encoding
and line termination overhead, but that still allows for multiple data
rows to be added to one send.

That's done simply by doing multiple net_msg_encode_puts() between
net_msg_start() and net_msg_send().

Doing multiple net_msg_start() in series without adding proper delays
will not work reliably, because the modem needs time to transmit an
IPSEND and flush the buffer. The new net_wait4modem() function will
assume the modem is ready after 50 ms of RX silence, but that may not be
enough to really get the modem ready for the next IPSEND.

That's the reason the framework uses the net_msg_sendpending semaphore
to know when the modem is definitely available again.

So:

- If your messages fit (encoded!) into the 1460 byte MTU (better leave
some headroom), you can just do this:

net_msg_start();
for (index = 0; index < MAX_CAN_DUMP; index++) { prep net_scratchpad,
call net_msg_encode_puts() }
net_msg_send();

This is the most efficient way.

- If they don't fit, you need to split your send. Good practice is to
use some notification flags and hook into the idle() or ticker() calls,
checking the net_msg_sendpending semaphore.

- If you really need to do multiple sends in series, add at least a 3
seconds delay after the net_msg_send() to give the modem enough time to
finish the transmission.

Regard,
Michael


Am 07.01.2017 um 09:30 schrieb Tom Parker:
>
> Interesting. I haven't changed anything in that code for a long time,
> but I also hadn't noticed it was causing problems so might have been
> broken for a long time? How do I see these errors? Running my own
> server? Watching the comms with the modem?
>
> It's supposed to send me up to the most recent of 3 different CAN
> frames (chosen at compile time), once per minute. Looking through the
> server logs (nice email feature on your server) I see it fairly
> reliably sends the first frame each minute, but usually not the
> others. The car is moving, so it's on, so all three frames are present
> on the bus, so I'm reasonably sure it is trying to send the other 2.
> I'm sending 3 messages one after the other in this code triggered from
> ticker60
> https://carrott.org/git/Open-Vehicle-Monitoring-System.git/blob/refs/heads/report-more-data:/vehicle/OVMS.X/vehicle_nissanleaf.c#l241
>
> Can I just send messages one after the other? The message framework
> was... complicated. I see in the twizzy telemetry it may only send one
> message each time it's called?
>
> On 07/01/17 08:52, Michael Balzer wrote:
>> Tom,
>>
>> I did some more log digging:
>>
>> a) Since yesterday, your log entries haven't contained any garbage
>> characters.
>>
>> b) "Unable to decode" messages now/still occur on a regular and quite
>> predictable base.
>>
>> The rule seems to be: the next message sent by the car after a "H
>> NL-COM-CAN" message will be broken.
>>
>> This happens independant of the time span between the "H" message and
>> the next, and as the following messages are of varying sizes also
>> independant of the message type.
>>
>> So this looks like a memory corruption coupled to the "H NL-COM-CAN"
>> message generation process, that kills your encryption (or more...).
>>
>> Examples:
>>
>> 2017-01-06 07:40:32.557128 +0100 info  main: #26 C NZLLEAF rx msg H
>> NL-COM-CAN,3,86400,054A120070020000003B
>> 2017-01-06 07:41:13.198896 +0100 info  main: #26 C NZLLEAF rx
>> 6Rm2CahmvSvTu/P7nJMLkUiRqFS1rww6BrxQY7zBF0sQwamaOHBMRbuWby0Gs8P9nrMcW45Ft73uZT93u6sHGTOkUgcdh/fzeGF4gcPSpql4/cC+bksNFJKEjykWVMLJ+cNrvlh5E7DCmA==
>> 2017-01-06 07:41:13.199028 +0100 error main: #26 NZLLEAF error -
>> Unable to decode message - aborting connection
>>
>> 2017-01-06 13:10:03.385363 +0100 info  main: #41 C NZLLEAF rx msg H
>> NL-COM-CAN,3,86400,054AA00070020000003A
>> 2017-01-06 13:10:12.587657 +0100 info  main: #41 C NZLLEAF rx
>> zZ186U6RmvLkP272bNAP5xk3bRXt5P6Z/X+F86EaNtymnduvZT1o2UKu6+r4LUDGRCXe4vd/jQ==
>> 2017-01-06 13:10:12.587918 +0100 error main: #41 NZLLEAF error -
>> Unable to decode message - aborting connection
>>
>> 2017-01-06 20:35:34.710329 +0100 info  main: #68 C NZLLEAF rx msg H
>> NL-COM-CAN,3,86400,054A1200700200000039
>> 2017-01-06 20:35:39.556488 +0100 info  main: #68 C NZLLEAF rx
>> Tl4PXkvivM+Iq+eeIgNCHKcwqUhY4i/+0igGrXgx/kR89xTBlY3uYQVwRXZfZQnvwDAi+IsojhjncnNVDDhEZ9B6YTv/RGjtx0qdtAEOwBEQPRIwejEtBnNaHpNu8Cu2dwHDUQ8c
>> 2017-01-06 20:35:39.556746 +0100 error main: #68 NZLLEAF error -
>> Unable to decode message - aborting connection
>>
>>
>> Regards,
>> Michael
>>
>>
>> Am 05.01.2017 um 13:20 schrieb Michael Balzer:
>>> Also, the "S" corruption originates from just a single wrong
>>> character inserted in the encoded protocol message, i.e.
>>>
>>> +cGF352j_<F3>_FeLiJ59cMLlOXpRJhGa7sMGM9Rg/WeXeJuwKGCiuqv8p4FVNCKiHEsEnf9WeNbnm6JGPz7yxD7KjlQtOSVFtHXH2DGUa+C0x5ZaZRiSv6HpLxBkvIEBEu0f4EBPjF+X
>>> or
>>> +dUShf7R71hcb7msV8SCXu55xEwG9Z3Dx9G4UNuO9V7t7JFnGYwSmrf5aWouO+rm1PdZfQgLENbGLMVbv/tRfkEA+vZRPapkU_<DB>_KSO92hqvnrVcgJOVYNiglaXPqMt92lKXatEVO1
>>>
>>> -- IMO that cannot originate from the base64 encoding, so can only
>>> come from some UART TX related problem (?)
>>>
>>> May be a serial log can show what's happening here.
>>>
>>>
>>>
>>> Am 05.01.2017 um 13:06 schrieb Michael Balzer:
>>>> Tom,
>>>>
>>>> from my logs archive:
>>>>
>>>> a) I found "duplicate car login" and "unable to decode" errors from
>>>> your car beginning on 2016-12-14 15:50 (UTC)
>>>> ...that was with firmware 2.8.7/NL1.0/V2/V2E9
>>>>
>>>> b) garbage characters first occurred in the "S" messages beginning
>>>> with 2017-01-01 12:16
>>>> ...that was right after changing your firmware to 2.9.2/NL1.0/V2/V2E9
>>>>
>>>> The "L" message corruptions due to the stp_l2f bug started on
>>>> 2017-01-04 03:05 with 3.1.1/NL1.0/V2/V2E9.
>>>>
>>>> The "S" corruptions only occur with your car (on my server).
>>>>
>>>> My earliest log kept is from 2016-12-10, and your car messages were
>>>> clean and error free until 2016-12-14 15:50.
>>>> Can you tell what has changed on 2016-12-14 15:50?
>>>>
>>>> Regards,
>>>> Michael
>>>>
>>>>
>>>> Am 05.01.2017 um 04:08 schrieb Tom Parker:
>>>>> On 05/01/17 02:00, Michael Balzer wrote:
>>>>>
>>>>>> Checking the server log I found another bug I introduced some
>>>>>> time ago in the server push notification code.
>>>>>> I just restarted the fixed server, tell me if the authentication
>>>>>> notifications still occur.
>>>>>
>>>>> The authentication success/failed messages are still occurring.
>>>>>
>>>>> At 10:39 today I got a trunk open while in valet mode alert via
>>>>> SMS but not via email and communication stopped. I'm not setting
>>>>> the trunk or valet bits in the leaf firmware.
>>>>>
>>>>> I'm logging the server traffic with client.pl and I see this,
>>>>> where <FA> represents the raw hex 0xfa and ^E is probably whatever
>>>>> ctrl-e is.
>>>>>
>>>>> Thu Jan  5 10:29:24 2017  Server message decodes to: MP-0 T0
>>>>> Thu Jan  5 10:29:24 2017  Server message decodes to: MP-0
>>>>> S77,K,0,0,stopped,standard,105,0,0,0,0,0,0,0,0,0,0,-1,0.00,-1,-1,0,0,-1,0,0,-1,-1<FA>_<8D>D<80>~^^D<A0>^Ev<D7>O<FA>
>>>>> ~^N
>>>>> Thu Jan  5 10:29:24 2017  Server message decodes to: MP-0 T0
>>>>> Thu Jan  5 10:29:24 2017  Server message decodes to: MP-0 Z0
>>>>> Thu Jan  5 10:29:35 2017  Server message decodes to: MP-0 Z1
>>>>> Thu Jan  5 10:39:25 2017  Server message decodes to: MP-0 Z0
>>>>>
>>>>> I think there must still be a corruption bug somewhere. It might
>>>>> be time to bisect.
>>>>> _______________________________________________
>>>>> OvmsDev mailing list
>>>>> OvmsDev at lists.teslaclub.hk
>>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>>>
>>>>
>>>
>>>
>>> -- 
>>> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
>>> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
>>>
>>>
>>> _______________________________________________
>>> OvmsDev mailing list
>>> OvmsDev at lists.teslaclub.hk
>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>
>> -- 
>> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
>> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
>>
>>
>> _______________________________________________
>> OvmsDev mailing list
>> 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

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20170107/33557c12/attachment.htm>


More information about the OvmsDev mailing list