[Ovmsdev] Locations and scripts
mark at webb-johnson.net
Tue Jun 11 20:49:50 HKT 2019
It has become a little duplicated:
canbus* origin; // Origin of the frame
CAN_FIR_t FIR; // Frame information record
uint32_t MsgID; // Message ID
uint8_t u8; // Payload byte access
uint32_t u32; // Payload u32 access (Att: little endian!)
uint64_t u64; // Payload u64 access (Att: little endian!)
esp_err_t Write(canbus* bus=NULL, TickType_t maxqueuewait=0); // bus: NULL=origin
uint8_t Ignore:1; // 0x01
uint8_t Changed:1; // 0x02
uint8_t Discovered:1; // 0x04
uint8_t :1; // 0x08
uint8_t :1; // 0x10
uint8_t :1; // 0x20
uint8_t :1; // 0x40
uint8_t :1; // 0x80
uint8_t dc; // Data bytes changed
uint8_t dd; // Data bytes discovered
CAN_frame_t has origin for the can bus the message arrived on, while CAN_LogMsg_t has frame.origin and bus (presumably because bus is needed for status and text messages).
Then we have candump and canlog virtual interfaces (canlog supports ’trace’ and ‘crtd’, while candump supports ‘crtd’ and ‘pap’).
The users of these higher level structures are RETOOLS and CANLOG. I suggest the following changes:
Have a single format conversion virtual class, and then initial implementations for pcap, crtd and trace. That can virtualise the conversion of a CAN message to be logged/transmitted/received to/from the external format. This can include a factory for registration of types (by textual name), as well as support functions for command registration (including whether they have support for reading, writing, or both). This just provides format conversion and does not provide any file handling or transmission functions. Canlog and Candump get merged to form this.
Perhaps base this on CAN_LogMsg_t, but I suggest a more generic name (perhaps CAN_message_t, to differentiate that this is a can message rather than a simple frame). It is CAN_frame_t + additional support for stats and general text messages.
Tidy up the CAN_LogMsg_t bus vs frame.origin issue.
Simply put, separate the formatting into a standalone virtual implementations, then leave retools and canlog to handle the actual RE stuff or file logging, or whatever else is required with the data that gets converted.
Does that make sense?
> On 11 Jun 2019, at 3:01 PM, Michael Balzer <dexter at expeedo.de> wrote:
> when implementing the can log framework I introduced the CAN_LogMsg_t specifically to capture the original timestamp of the frame, so it wouldn't get lost if
> the logging task gets behind, and to transport other log data types than just frames to the loggers.
> I would also expect the RE tools stream to produce event info & statistics entries like can log does, as that is very helpful in analysing. Maybe rebasing
> candump on can log would be better?
> Am 11.06.19 um 08:37 schrieb Mark Webb-Johnson:
>> This really should be unified, and probably not too hard to do. Crazy to have two so similar frameworks. I think we can just have one virtual class for converting CAN frames to/from other formats, and then implementations for CRTD, PCAP, etc.
>> I do remember that last time I looked at this, canlog used CAN_LogMsg_t, and candump used CAN_frame_t (with CAN_LogMsg_t having some other fields for logging statistics, etc), and that made it non-trivial. Perhaps canlog should be built on top of candump?
>> I will have a look at it.
>> Regards, Mark.
>>> On 6 Jun 2019, at 4:06 PM, Michael Balzer <dexter at expeedo.de> wrote:
>>> Mark quoted from the RE tools candump_crtd class, which has its own crtd formatter.
>>> For the canlog framework I currently get the timestamp from esp_log_timestamp(). Should be easy to change that to gettimeofday().
>>> Am 05.06.19 um 18:39 schrieb Stephen Casner:
>>>> If by "unix julian time" you mean a timestamp like 1559751698 (the
>>>> time as I write this), than that is not what Greg and I have observed
>>>> in the CRTD logs. Here are the first lines in our files:
>>>> 151766.574 CXX Info Type:crtd; Path:'/sd/gps.crtd'; Filter:1:100-100; Vehicle:TR2N;
>>>> 383603.293 CXX Info Type:crtd; Path:'/sd/location.crtd'; Filter:1:100-100; Vehicle:TR1N;
>>>> Yet OVMS does have the current time from NTP:
>>>> OVMS# time
>>>> Time Zone:
>>>> UTC Time: 2019-06-05 16:35:45 UTC
>>>> Local Time: 2019-06-05 16:35:45 GMT
>>>> Provider: ntp
>>>> PROVIDER STRATUM UPDATE TIME
>>>> *ntp 1 57 Wed Jun 5 16:35:44 2019
>>>> Who calls candump_crtd::get() with the timeval that goes into the
>>>> sprintf() you mention?
>>>> -- Steve
>>>> On Wed, 5 Jun 2019, Mark Webb-Johnson wrote:
>>>>> The CRTD timestamps should be unix julian time (not uptime). Produced by this:
>>>>> sprintf(m_buf,"%ld.%06ld %sR%s %0*X",
>>>>> time->tv_sec, time->tv_usec,
>>>>> (frame->FIR.B.FF == CAN_frame_std) ? "11":"29",
>>>>> (frame->FIR.B.FF == CAN_frame_std) ? 3 : 8,
>>>>> Once module gets time from the vehicle (or gps), it should show the correct timestamps.
>>>>> Regards, Mark.
>>>> OvmsDev mailing list
>>>> OvmsDev at lists.openvehicles.com
>>> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
>>> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
>>> OvmsDev mailing list
>>> OvmsDev at lists.openvehicles.com
>> OvmsDev mailing list
>> OvmsDev at lists.openvehicles.com
> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
> OvmsDev mailing list
> OvmsDev at lists.openvehicles.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OvmsDev