How to start gathering CAN frames using candump from within browser

Hello,
I am wondering how to approach such a problem - I want to be able to run candump from command line (or its counterpart implemented in any programming language) from web browser.
How would you implement such a feature? What tools would you use?

Regards,
Peter

Either pipe the output of candump to a file, or write your own application to actually parse the PGN values, then dump the parsed data into a file. Then have a second application take that data, and send it out over a websocket to the browser.

You’ll need a file lock on this shared file, and it might be wise to use a POSIX IPC shared memory file to accomplish this.

That is how I would, and have already done it.

You also pipe the output to netcat, then netcat to connect to a remote system, and deal with all the data there - Live. But I’ve found the beaglebone fast enough to parse 1Mbit/second CANBUS data(real-time), and act as a web / websocket server with less than 10% processor load. The choice is yours.

Either pipe the output of candump to a file, or write your own application
to actually parse the PGN values, then dump the parsed data into a file.
Then have a second application take that data, and send it out over a
websocket to the browser.

You'll need a file lock on this shared file, and it might be wise to use a
POSIX IPC shared memory file to accomplish this.

That is how I would, and have already done it.

You also pipe the output to netcat, then netcat to connect to a remote
system, and deal with all the data there - Live. But I've found the
beaglebone fast enough to parse 1Mbit/second CANBUS data(real-time), and
act as a web / websocket server with less than 10% processor load. The
choice is yours.

You *could* also pipe the output to netcat*

Thanks for suggestions.
Do you have any further hints/examples/similar implementations that I could read, understand and eventually base on?

W dniu niedziela, 14 maja 2017 20:49:10 UTC+2 użytkownik William Hermans napisał:

On Sun, 14 May 2017 12:38:31 -0700 (PDT), Piotr C
<cerberxes@gmail.com> declaimed the
following:

Thanks for suggestions.
Do you have any further hints/examples/similar implementations that I could
read, understand and eventually base on?

  Are you thinking snapshot (web page does not update on its own), timed
(web page refreshes at intervals), continuous updates.

  All three involve different HTTP/HTML capabilities.

1) Simple grab last n-data points from file, format into table, return web
page

2) Similar to #1, but add an auto-redirect (to itself) to reload the page

3) Probably talking AJAX here to have Javascript running in browser
opening a connection to a "CAN packet server" which will transmit each
decoded packet to the browser where the Javascript dynamically updates the
web page DOM.

The code I wrote is not, and will not be available to the public.

There is no real way for me to show you how to do what all needs being
done. Here is why. By it's self, websockets is not necessarily an easy
concept to understand let alone write code for implementation. As such the
easiest way to get started, would be to use Nodejs and socket.io. At this
point, you need to understand how to install, and use Nodejs + socket.io,
as well as probably how to use Express as well. Keeping in mind that having
to know all this is just so you can understand the basics. After this, you
*may* be ready to move onto using websockets from a web / websocket server
written in C, or C++.

Not to mention having to know how the CANBUS protocol you're using works,
knowing how socketCAN works under linux, and knowing how a multitude of
other software technologies work. So you can bring it all together, to make
your application work.

So can I help you understand how to create such software ? No, not really.
This is something you're going to need to spend a lot of time on, before
things almost become clear as to how you need to proceed.

By the way, websockets put simply, is a TCP connection between systems, that is always connected. So there is no need for Ajax, or any of that old school HTML mumbo jumbo.

Well, here is a guide that I wrote a bit over a year and a half ago, which I had forgotten: http://www.embeddedhobbyist.com/2015/09/linux-can-development/

I’m not sure how useful that would be for your overall application, but it’ll show you how to setup the socketCAN can-utils stuff.