[Ovmsdev] CAN BUS logging to flash storage

Mark Webb-Johnson mark at webb-johnson.net
Wed Jan 10 08:27:25 HKT 2018

Probably best to split this off as a separate eMail thread.

I think the implementation would be relatively simple.

Create a canlog class with a FILE* m_log member variable, and a virtual function Log() that is called with a direction (tx/rx) and frame to log.
The constructor should be passed the vfs file path to log to. It should fopen the m_log file to that.
The destructor should fclose the m_log file.
Create a canlog_crtd class, derived from canlog, that supports Log() to log to m_log in CRTD format.
Optionally create other canlog_* classes, for other logging formats that we want to support.
Add a canlog* m_log member variable in canbus.
Initialise m_log to NULL in the constructor.
In the destructor, if m_log is not null, delete it’s object and set it to NULL.
Have a command ‘can log’ like ‘can trace’ that specifies a vfs file path (remember to check it with OvmsConfig ProtectedPath) and logging format. It will then ’new’ a canlog_* style object (depending on logging format).
In can::IncomingFrame, log incoming CAN messages with m_log->Log(), in the same way as m_trace is handled.
In canbus::Write, log outgoing CAN messages with m_log->Log(), in the same way as m_trace is handled.


Regards, Mark.

> On 10 Jan 2018, at 8:07 AM, Mark Webb-Johnson <mark at webb-johnson.net> wrote:
> Now SD CARD support is coming, anybody want to step forward and extend components/can to support CAN bus logging to a file (in crtd format, or perhaps support one or two popular formats)? Implementation would be in class canbus, very similar to m_trace; just need to have a FILE* m_log and appropriate commands / logging of packet write/read in the same place that trace does it.

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

More information about the OvmsDev mailing list