Jump to content

Recommended Posts



Ok, cool. Yes Serial <-> USB is very doable on the Beaglebone, and what more you've probably realized it is something that could be easily done using Javascript( Nodejs ). The reason why I think that Nodej is an important part, is that in my mind this is a project that should have a web front end to display data, and perhaps have some web controls perhaps as well. e.g. a web appliance sort of interface. This is something that can be done with Nodejs really easily. Yes you already talked about that in a previous post, I forgot about . . .


It could also be done using C with libmongoose, thats a bit more involved, but perhaps totally worth it after you get something working with Node. I've done this personally, and it does take a while to learn libmongoose as documentation is sparse. SO I did a lot of trial and error, a well as reading a lot of the 10k + lines of code that is libmongoose . . .


If you need help getting the beaglebone setup with a proper up to date image. Let me know on the forums here. I actually know quite a lot . . . but not everything of course.



Oh and right, my bad . . .


I wonder if there is a beagle cape out there that accepts booster-xl boards?


No, you'd have to design one yourself. It's not too hard, however . .. My buddy had some  proto-bones made if you know what those are, and if they'll work for you . . .

Link to post
Share on other sites

I also wanted to talk some about creating a web server in C, and the pluses / minuses of it all. First, we do have libmongoose we can use and that's great, except if you need for a commercial application you're probably going to want to write your own code. Maybe even license the newer library from the same person who wrote libmongoose. Me, I'd probably want to write my own . . .


A web / web socket server in C is very much faster than Nodejs. Not that Node is really slow, Node just uses a lot more CPU to do the same things. But also there is definitely latency. Just doing some really simple ADC tests . . . I was able to get *maybe* 800 samples a second using Nodejs. Code that is just wrapping the sysfs ADC subsystem. In pure C similar code produces around 6500 samples a second . . . which it's self is a lot slower than the ADC. This is a huge performance difference. However if you do not need that speed. It's a lot simpler, and easier to implement a project in Nodejs. So there is a trade off between the two.


Additionally, the code size( on disk ) to get a web / web socket server implemented in C is considerably less. When I say this, I mean that an executable is roughly 200k Bytes in size, and then you just have the web front end stuff to serve to potential clients. With Nodejs, it would not be unheard of to have the project use more than 100M on disk . . . which again is an insane difference which may, or may not be important.


On the plus side for Node, everything is much easier to do, and personally, I really REALLY like the event driven asynchronous aspect to javascript. I'm also warming up to the idea of a loosely typed language. Which is probably hard for most "die hard" C programmers who are used to very strict types.


So those who are looking for something very R.A.D.( rapid application development ) Nodejs / Javascript is a great way to get a working prototype out there and running. Perhaps forever, or perhaps just as a proof of concept until a suitable replacement is written in C/C++.

Link to post
Share on other sites

By the way here is some sample code for writing to a serial device using Nodejs:

"use strict";

(function() {
        var adc = require('./adc.js');
        var fs = require('fs');
        var writeStream = fs.createWriteStream('/dev/ttyO0');
        function read_adc(channel){
                var log_sample = function(){
                        adc.read(channel, function(data){
                                var sample = (data & 0xFFF);
                                writeStream.write(channel + ':' + sample + "\n");
                setInterval(log_sample, 1000);
        var ain0 = new read_adc(0);       

This is really just a simple example of reading a single ADC channel and then sending that data out over serial. Then on the other end you just . . .

$ sudo cat /dev/ttyUSB0 /* or suitable path to a serial device  */

Of course, you could also write a nodejs app to "catch" and do something with  that data. . .

Link to post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...