Web Server imX6

Hello,

I’m very new to that topic. I would like to send Data via Ethernet CAble to my PC’s Internet Browser. What do I have to do? On my iMX6 there is Linux running.

Thanks
Michael

hi Michael_l

Could you provide the version of the hardware and software of your module? Please give us more details about your application? Which data do you want to send (images, text, …)?

Hi,

  • Hardware version: V1.1.C Angstrom v2017.12
  • Kernel Apalis-iMX6_LXDE-Image 2.8b3.111 20180626

I want to use the apalis board to get Data from a Camera. I want to send a JPEG from Apalis Board to my PC. On the same time i want to see in the same browser window some text, like CAN-messages that Apalis has received.

Use nodejs and ffmpeg to achieve this.

# opkg install nodejs nodejs-npm ffmpeg
# mkdir webserver, # cd webserver
# npm init
# npm install shelljs socket.io

First create a client file called ‘index.html’ with the following components (you can work out the exact code):

<head>
src=socket.io.js                                    // point to the socket.io javascript source

<script>
var socket = socket.io();                           // create the client socket

// create function to request server to take an image
function capture() {socket.send({command: 'image'})}  

// wait till the server says the image has been taken and is in the file system. 
socket.on('image', function( ){   $("#cameraPanel").html(<img src='./pic.jpg'>")  ;})

<body>
<button onclick="capture()" </button>               // create button to request an image
<div id="cameraPanel"</div>                         // create panel to place the resulting image

Then create a server file called ‘index.js’ with the following components

var http = require('http');
var server = http.createServer(    ....            // this creates the web server
server.listen(80);                                 // listen for client requests
var io = require('socket.io').listen('server');    // create a server socket
io.sockets.on('connection', function (socket) {    // client connected throughh 'socket'
      ......            
    io.sockets.on('message', function (msg){       // a messge has been received from the client
    if (msg.command == 'image' {                   // the message was the command to take an image
        shell.exec("ffmpeg  ...... pic.jpg" .....  // take picture by executing ffmpeg in shell command
        socket.emit('image');                      // let the client  know the image is available
}}});

Once you have filled in the rest of the code (probably an extra 10 lines) then:

$ npm run node index.js

Then access via port 80. it really is that simple.

@lachlanp: Thanks for the solution.
@Michael_I: Did you try this out?

Yes. it is part of another program. I have recently tested it on Colibir iMX6ULL using wifi as an access point and also via ethernet. Note that the code is not complete. I just copied some of the lines over. you will need to convert the basis of this for your needs.