My code is rather overly complicated for the sake of explanation . . . but
here goes.

In my snippet below I'm using socket.io, which for this explanation is not
really important. Except since I'm using socket.io.emit(), basically
sending the value of *stdout* to the client, and dealing with the "data" on
the client side(browser) by using client side javascript. You could very
easily deal with the data on the server backend. Such as the commented out
line *console.log(stdout);  *, but for a webserver type application
console.log() is not very useful for other than testing output.

Anyway, the executable of course is "temperv14" with a cmd line switch of
"-F" which instructs the command to only output a float / double value
representing the temperature in Fahrenheit. Nothing else. Which made
dealing with the data on the client side trivial.

io.on('connection', function(socket){

*var exec = require('child_process').exec;        var child =
exec('temperv14 -f', function(err, stdout, stderr) {*
        if (err) {
                 console.log(err);
        } else {
                //console.log(stdout);
                *io.emit('temperature', stdout + 'F');*
        }
        });
});


On Wed, Jun 10, 2015 at 12:50 PM, William Hermans <[email protected]> wrote:

> I did the same thing with a TEMPer v1.4 USB thermometer dongle. Running
> the application through Nodejs, and then parsing the output in a callback.
> Let me see if I can find my code, or notes.
>
> On Wed, Jun 10, 2015 at 12:45 PM, William Hermans <[email protected]>
> wrote:
>
>> Nodejs + child_process.exec to run the GPS executable, and then in a
>> callback parse the output. Then do with it as you wish. Something like this:
>>
>> http://www.dzone.com/snippets/execute-unix-command-nodejs
>>
>> In that example though the person is just printing the output of pwd to
>> stdout, etc. But the concept is the same-ish.
>>
>> On Wed, Jun 10, 2015 at 12:25 PM, William Pretty Security <
>> [email protected]> wrote:
>>
>>> Hello Group;
>>>
>>>
>>>
>>> I have a webpage server running on a BBB. This page currently serves
>>> (streams) video from my robot.
>>>
>>> I would like to also display the Lat/Long from the onboard GPS.
>>>
>>>
>>>
>>> I have CGPS installed and working. It writes text to the console.
>>>
>>> What I would like to know is how to send this text to a text box or
>>> whatever on the web page.
>>>
>>> I’m thinking node.js + java script?
>>>
>>>
>>>
>>> Thanks;
>>>
>>>
>>>
>>> Bill
>>>
>>>
>>>
>>> "All that is necessary for the triumph of evil is that good men do
>>> nothing" Edmond Burke *(1729 - 1797)*
>>>
>>>
>>> http://www.packtpub.com/building-a-home-security-system-with-beaglebone/book
>>>
>>> http://ca.linkedin.com/pub/bill-pretty/2b/b07/602
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to