Snippets para Debian en Olinuxino A13-WIFI


OLINUXINO A13 WIFI

1. BASIC
-Descargar "A13 Advanced Debian 4GB card image with XFCE4" del apartado "Official Debian images by Olimex" en: https://www.olimex.com/wiki/Prebuilt_SD_card_images_running_debian
- Descargar http://sourceforge.net/projects/win32diskimager/ para grabar imagen en SDcard con Windows.
- Una vez introducida la SDcard e iniciado Debian, logearse con root/password.
- dpkg-reconfigure console-setup (para configurar teclado español. Elegir UTF8)
- startxfce4

Notas:
1. Cerciorarse de la fecha que tenemos (#hwclock) de lo contrario nos dará KEYEXPIRED u otros tipos de errores cuando queramos instalar paquetes
# date --set "2000-02-25 16:25"
# hwclock --set --date="2000-02-25 16:25"


2. LOGIN AUTOMÁTICO EN TERMINAL
# nano /etc/inittab
Comentar 1:2345:respawn:/sbin/getty 38400 tty1
e insertar 1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1


#3. LOGIN AUTOMÁTICO EN X (no comprobado)
nano /etc/lightdm/lightdm.conf
autologin-user=root
autologin-user-timeout=0


4. WIFI
- # iwconfig // para ver número de wlan asignado
- # nano /etc/network/interfaces
1. cambiamos por el wlan correcto (en auto y iface) y decomentamos auto.
2. //WPA
wpa-ssid RED
wpa-psk PASSW
2. //WEP
wireless-essid RED
wireless-key s:XXXXXXXXXXXXX # Para una cadena ASCII
wireless-key XXXXXXXXXXXXX # Para una cadena hexadecimal
o
#iwconfig wlan0 essid nombre-punto-de-acceso
#iwconfig wlan0 key clave-de-acceso
#iwconfig wlan0 key s:clave-de-acceso (SI ASCII)
3. grabar y salir.
- #service networking restart (o /etc/init.d/networking stop y /etc/init.d/networking start)


5. IP
// IP DINAMICA
- #dhclient -r
- #dhclient wlanX
// IP FIJA
ifconfig wlan0 192.168.1.9 netmask 255.255.255.0
route add default gw 192.168.1.1
echo nameserver 192.168.1.1 > /etc/resolv.conf


6. NUEVO USUARIO PARA USAR VLC (CREADO DE FÁBRICA)
#sudo
#adduser vlc
#chmod 777 /dev/video* (Debe estar la cámara conectada)
#su vlc
#cvlc v4l2:// :v4l2-vdev=”/dev/video0″ :v4l-adev=”/dev/null” –sout 
‘#transcode{vcodec=mpg1,vb=1024,width=320,height=240}:standard{access=http,mux=ogg,dst=:8080}’

'#transcode{vcodec=h264,venc=x264,scale=0.75,vb=512}:std{access=http,mux=ps,dst=/stream.mp4}'



7. REPOS

#apt-get update
#nano /etc/apt/sources.list y añadir deb http://ftp.es.debian.org/debian/ sid main contrib non-free
#apt-get update
#apt-get dist-upgrade


8. ERROR DE GPG AL HACER APT-GET UPDATE. NO_PUBKEY.
# gpg --keyserver pgpkeys.mit.edu --recv-keys LLAVE
# gpg -a --export LLAVE | apt-key add -

Notas:
1. En /root/.gpg/gpg.conf añadir allow-non-selfsigned-uid
2. Comprobar hora del sistema (Notas del paso 1)
3. Usar #apt-key list y #apt-key del KEY para listar o borrar las llaves actuales.


#9. CHROME (no comprobado)
# apt-get update
# apt-get install synaptic
Desde synaptic instalamos chromium-browser


10. SERVIDOR APACHE
# apt-get install apache2 php5 libapache2-mod-php5

Notas:
1. Al entrar con el navegador en http://A13_IP mostrará el contenido que se tenga en /var/www y podremos tener un index.php que use por ejemplo <?php shell_exec("COMANDO") ?> para arrancar algún script SH o programa (permisos 777) y que active algún dispositivo conectado al A13 por puerto serie por ejemplo (PASO 14). Aunque este solo enviaría por serie, no recibiría datos. Para recibir datos seguir PASO 13.
2. Para reiniciar servidor apache /etc/init.d/apache2 restart
3. Otros ficheros de interés:
/etc/apache2/apache2.conf
/etc/apache2/mods-available/php5.conf
/etc/php5/apache2/php.ini 



11. TEST ACELERACIÓN GRÁFICA
#apt-get install mesa-utils
#glxinfo | grep rendering
#glxgears


12. WEBGL EN ICEWEASEL
# apt-get install libosmesa6 mesa-utils
En iceweasel > about:config > webgl.osmesalib /usr/lib/arm-linux-gnueabihf/libOSMesa.so.6


13. 
RS232 (UART1) POR WEB MEDIANTE NODEJS.  Disponible en SID (unstable)
- INICIAR EN PASO 7 y 10
# apt-get install nodejs npm
# npm install -g socket.io
# npm install -g serialport@1.0.0 (Esta versión, de lo contrario al compilar con node-gyp dará problemas)
# npm install -g node-gyp
# ln -s /usr/bin/nodejs /usr/bin/node 
# cd /usr/local/lib/node_modules/serialport (compilamos serialport)
# node-gyp clean
# node-gyp configure
# node-gyp build
(node-gyp rebuild = clean,configure y build)
(Para desinstalar: /usr/local/lib/node_modules# node-gyp uninstall serialport)
# cp /usr/local/lib/node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.min.js /var/www
# cd /var/www
- Creamos archivo nodeServer.js e index.html con lo siguiente:
nodeServer.js
var sys = require('util');
var io = require('/usr/local/lib/node_modules/socket.io').listen(3400);
var serialport = require('/usr/local/lib/node_modules/serialport');
var SerialPort = serialport.SerialPort;

io.sockets.on('connection', function (socket) {
  socket.emit('newconnection', { hello: 'world' });

  socket.on('dataclient', function (data) {
    sys.puts('DATO CLIENTE '+data.theword) // escribir en la consola
    serial.write(data.theword);
  });
 
  socket.on('disconnect', function () {
    sys.puts('user disconnected');
    serial = undefined;
  });

    var serial = new SerialPort("/dev/ttyS0", {baudrate:9600});
    serial.on('open', function() {
        sys.puts('conectado a ttyS0');
    });
    serial.on('data', function(dat){
        var str = dat.toString();
        sys.puts('DATO SERIAL '+str);
        socket.emit('datatcp', { data: str });
    });
});

index.html
<html>
    <head>
        <title>NODE</title>
        <script id="stormEngineC" src="socket.io.min.js"></script>
    </head>
    <body style="background:#FFF">
        <script>
            var ws;
            openWebSocket = function(ip, port) {
                ws = io.connect('ws://'+ip+':'+port+'/');
             
                ws.on('newconnection', function(data) {
                    console.log(data);
                    document.getElementById('DIVID_webSocketStatus').innerHTML = "<span style='color:#00CC00'><b>CONECTADO A WEBSOCKET</b></span>";
                });
                ws.on('datatcp', function(data) {
                    console.log(data);
                    document.getElementById('DIVID_webSocketResponse').innerHTML = data.data;
                });
            }
            sendTX = function(word) {
            ws.emit('dataclient', { theword: word });
            }
        </script>
        <table border='0' cellpadding='15' cellspacing="0">
            <tr>
                <td>
                    <div id="DIVID_webSocketStatus"></div>
                    <script>
                    if ("WebSocket" in window) {

                    }else{
                    document.getElementById('DIVID_webSocketStatus').innerHTML = "<span style='color:#CC0000'>Navegador NO soporta WebSocket</span>";
                    }
                    </script>
                </td>
                <td id="TDID_webSocket" align="left" valign="top" style='width:200px;'>
                    <input type="text" id="INPUTID_ipWebSocket" value="192.168.0.9"/>
                    <input type="text" id="INPUTID_portWebSocket" value="3400"/>
                    <a href="#" onclick="openWebSocket(document.getElementById('INPUTID_ipWebSocket').value, document.getElementById('INPUTID_portWebSocket').value)">Conectar a servidor WebSocket</a>
                </td>
            </tr>
            <tr>
                <td id="TDID_webSocketResponse">
                    <div id="DIVID_webSocketResponse"></div>
                </td>
                <td>
                    <input type="text" id="INPUTID_sendTX" value="L"/>
                    <button type="button" onclick="sendTX(document.getElementById('INPUTID_sendTX').value)">SEND</button>
                </td>
            </tr>
        </table>

    </body>
</html>

# nodejs nodeServer.js (desde /var/www)
- Entramos con el navegador en http://A13_IP


14. RS232 (UART1)
- Nos situamos en la carpeta de nuestro proyecto.
# wget http://www.teuniz.net/RS-232/RS-232.tar.gz
# tar -xzvf RS-232.tar.gz
- Creamos main.c con lo siguiente:
Copiar el código de http://robertereter.blogspot.com.es/2012/11/rs232-c-linux.html
- Compilamos y ejecutamos enviando letra L en ASCII:
# gcc main.c rs232.c -Wall -o test
# ./test 0x4C


Notas:
- # dmesg | grep tty // lista los puertos serie. /dev/ttyS0 (COM1 on windows)
- Podemos ejecutar "test" desde PHP con system("/var/www/test 0x46 2>&1"); y dando permisos:
# chmod 777 /dev/ttyS0
# chmod 777 test


15. FACE DETECTION CON NODE-OPENCV
- INICIAR EN PASO 7
# apt-get install nodejs npm
# npm install -g opencv@0.2.0 (la 0.3.0 da error)
- Creamos archivo nodeServerCam.js en el directorio de nuestro proyecto con lo siguiente:
nodeServerCam.js
var cv = require('/usr/local/lib/node_modules/opencv');

var camera = new cv.VideoCapture(0);
frame = function() {
    camera.read(function(err, im) {
        im.save('/tmp/cam.png',function(){
     
        // face detect
        cv.readImage("/tmp/cam.png", function(err, img) {
            img.detectObject(cv.FACE_CASCADE, {}, function(err, faces){
                for(var i=0, f=faces.length; i < f; i++) {
                        var x = faces[i];
                        img.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
                   
                }
                //serial.write(data.theword); //Ver PASO 13
                img.save("/tmp/camE.png", function(){frame();});
            })
        });
        });
    });
};
frame();
#chmod 777 /dev/video* (Debe estar la cámara conectada)
# nodejs nodeServerCam.js


16. WIFI TOOLS
# apt-get install aircrack-ng reaver










SCRIPT SH PARA AUTOGRABAR CON WEBCAM CONECTADA AL ARRANCAR Y EMITIR POR ETHERNET CON VLC
- INICIAR EN PASOS y 2
- nano /etc/init.d/startWebCam.sh
#!/bin/sh
ifconfig wlan7 down
ifconfig eth2 up
ifconfig eth2 192.168.0.9 netmask 255.255.255.0
route add default gw 192.168.0.1

chmod 777 /dev/video*


ping -c 1 192.168.0.1

if [ $? -eq 2 ]; then {
echo inet is not ready;
} else {
echo inet is ready;
su vlc -c 'cvlc v4l2:// :v4l2-vdev=”/dev/video0″ :v4l-adev=”/dev/null” –sout 
"#transcode{vcodec=mpg1,vb=1024,width=320,height=240}:standard{access=http,mux=ogg,dst=:8080}"; ';
echo 1 > /sys/devices/virtual/misc/sun4i-gpio/pin/pg9;
} fi

- nano /etc/rc.local (para lanzar al inicio)
sh /etc/init.d/startWebCam.sh &









CONNECTING WEB CAMERA TO A13-OLINUXINO FOR VIDEO STREAMING

DESCARGAR TOOLCHAIN GCC PARA ARM
- #apt-get install gcc-4.6-arm-linux-gnueabi ncurses-dev uboot-mkimage build-essential git
Fuentes: https://www.olimex.com/wiki/Build_Bootable_SD_Card_with_Debian

Comentarios

Entradas populares