How to start gathering CAN frames using candump from within browser

511 views
Skip to first unread message

Piotr C

unread,
May 14, 2017, 2:34:33 PM5/14/17
to BeagleBoard
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

William Hermans

unread,
May 14, 2017, 2:48:03 PM5/14/17
to beagl...@googlegroups.com
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.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/1d2d1199-26d5-44d9-a1c0-18438894aad8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Hermans

unread,
May 14, 2017, 2:49:10 PM5/14/17
to beagl...@googlegroups.com
On Sun, May 14, 2017 at 11:47 AM, William Hermans <yyr...@gmail.com> wrote:
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*

Piotr C

unread,
May 14, 2017, 3:38:31 PM5/14/17
to BeagleBoard
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, May 14, 2017 at 11:47 AM, William Hermans <yyr...@gmail.com> wrote:
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*
On Sun, May 14, 2017 at 11:34 AM, Piotr C <cerb...@gmail.com> wrote:
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

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Dennis Lee Bieber

unread,
May 14, 2017, 6:31:42 PM5/14/17
to beagl...@googlegroups.com
On Sun, 14 May 2017 12:38:31 -0700 (PDT), Piotr C
<cerb...@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.

--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

William Hermans

unread,
May 14, 2017, 7:04:43 PM5/14/17
to beagl...@googlegroups.com

On Sun, May 14, 2017 at 12:38 PM, Piotr C <cerb...@gmail.com> wrote:
Thanks for suggestions.
Do you have any further hints/examples/similar implementations that I could read, understand and eventually base on?

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.

William Hermans

unread,
May 14, 2017, 7:07:45 PM5/14/17
to beagl...@googlegroups.com
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.

William Hermans

unread,
May 15, 2017, 9:41:10 PM5/15/17
to beagl...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages