Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Yocto for Raspberry Pi

You're reading from  Yocto for Raspberry Pi

Product type Book
Published in Jun 2016
Publisher Packt
ISBN-13 9781785281952
Pages 214 pages
Edition 1st Edition
Languages
Concepts
Authors (2):
TEXIER Pierre-Jean TEXIER Pierre-Jean
Profile icon TEXIER Pierre-Jean
Petter Mabäcker Petter Mabäcker
Profile icon Petter Mabäcker
View More author details

Table of Contents (18) Chapters

Yocto for Raspberry Pi
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Meeting the Yocto Project Building our First Poky Image for the Raspberry Pi Mastering Baking with Hob and Toaster Understanding BitBake Creating, Developing, and Deploying on the Raspberry Pi Working with External Layers Deploying a Custom Layer on the Raspberry Pi Diving into the Raspberry Pi's Peripherals and Yocto Recipes Making a Media Hub on the Raspberry Pi Playing with an LCD Touchscreen and the Linux Kernel Contributing to the Raspberry Pi BSP Layer Home Automation Project - Booting a Custom Image

Creating the main application


The main project contains several files. To best present things, we'll only concentrate on two files:

  • server.js: This is the file that will create our web server and send data to the HTML web page

  • index.html: This is the page that will open the web browser to display the data received

server.js

The server.js file creates a server on the listening port 3344 and will be responsible for creating a socket (rpi_temperature) that contains the CPU temperature of Raspberry Pi. The socket function uses, among others, the vcgencmd command ( https://github.com/raspberrypi/firmware/blob/master/opt/vc/bin/vcgencmd ), permitting us to monitor the CPU temperature, as shown here:

setInterval(function() 
{ 
    child = exec("vcgencmd measure_temp | awk -F:", function      (error, stdout, stderr)  
    { 
        if (error !== null)  
        { 
            console.log('exec error: ' + error); 
        } 
        else 
        { 
            var date = new Date().getTime(); 
  ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}