LG MS450H MS400H
¿Quieres reaccionar a este mensaje? Regístrate en el foro con unos pocos clics o inicia sesión para continuar.

Proyecto CÓDIGO FUENTE "PipeManagement"

5 participantes

Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  alonso_c Dom Jun 27, 2010 4:30 pm

Bueno, pues vamos a ver si entre todos podemos obtener el código fuente del proyecto "PipeManagement".

Resulta que he encontrado por internet un script y un programa fuente en C que pudieran estar muy cerca del tal famoso "PipeManagement":

ATENCIÓN: Estos programas no están adaptados todavía a nuestro Living Box, se puede utilizar como ejemplo el primero de los scripts que pongo que utiliza las teclas '<' y '>' para subir y bajar el volumen.

Código fuente del script key.sh:
Código:
#!/bin/sh
while :
do
#echo "Press any key (for 2 seconds) to continue..."
key=`dd if=/dev/venus_irrp bs=4 count=1  2> /dev/null | hexdump -e '"%02x"'`
#if [ "$key" != "$last_key" ] ; then 
  #last_key=$key 
  echo $key 
  if [ "$key" = "f906b649" ] ; then 
    QUERY_STRING="1" 
  elif  [ "$key" = "f807b649" ] ; then 
    QUERY_STRING="2"   
  elif  [ "$key" = "be41b649" ] ; then 
    QUERY_STRING="3"
  elif  [ "$key" = "e916b649" ] ; then 
    QUERY_STRING="4"
  elif  [ "$key" = "bf40b649" ] ; then 
    QUERY_STRING="5"
  elif  [ "$key" = "aa55b649" ] ; then 
    QUERY_STRING="6"
  elif  [ "$key" = "f10eb649" ] ; then 
    QUERY_STRING="7"
  elif  [ "$key" = "b748b649" ] ; then 
    QUERY_STRING="8"
  elif  [ "$key" = "bd42b649" ] ; then 
    QUERY_STRING="9"
  elif  [ "$key" = "b34cb649" ] ; then 
    QUERY_STRING="0" ;
  elif  [ "$key" = "fb0408f7" ] ; then 
    QUERY_STRING="W" ;# UP
  elif  [ "$key" = "bc4308f7" ] ; then 
    QUERY_STRING="{" ;# HOME
  elif  [ "$key" = "f80708f7" ] ; then 
    QUERY_STRING="A" ;# LEFT
  elif  [ "$key" = "f50ab649" ] ; then 
    QUERY_STRING=" " ;# OK
  elif  [ "$key" = "f90608f7" ] ; then 
    QUERY_STRING="D" ;# RIGHT
  elif  [ "$key" = "bc43b649" ] ; then 
    QUERY_STRING="," ;# RETURN
  elif  [ "$key" = "fa0508f7" ] ; then 
    QUERY_STRING="X" ;# DOWN
  elif  [ "$key" = "a956b649" ] ; then 
    QUERY_STRING="S" ;# PLAY
  elif  [ "$key" = "fc03b649" ] ; then 
    QUERY_STRING="Z" ;# PAUSE
  elif  [ "$key" = "ea15b649" ] ; then 
    QUERY_STRING="Q" ;# STOP
  elif  [ "$key" = "f00fb649" ] ; then 
    QUERY_STRING="L" ;# PLAY SLOW
  elif  [ "$key" = "e817b649" ] ; then 
    QUERY_STRING="P" ;# PREV CHAPTER
  elif  [ "$key" = "f609b649" ] ; then 
    QUERY_STRING="f" ;# REWIND
  elif  [ "$key" = "f20db649" ] ; then 
    QUERY_STRING="F" ;# FORWARD
  elif  [ "$key" = "a857b649" ] ; then 
    QUERY_STRING="N" ;# NEXT CHAPTER
  elif  [ "$key" = "ae51b649" ] ; then 
    QUERY_STRING="V" ;# VOL+
  elif  [ "$key" = "ad52b649" ] ; then 
    QUERY_STRING="m" ;# MUTE
  elif  [ "$key" = "b04fb649" ] ; then 
    QUERY_STRING="v" ;# VOL-
  elif  [ "$key" = "b946b649" ] ; then 
    QUERY_STRING="s" ;# SUBTITLES
  elif  [ "$key" = "fd02b649" ] ; then 
    QUERY_STRING="s" ;# GOTO
  elif  [ "$key" = "ac53b649" ] ; then 
    QUERY_STRING="q" ;# SKIP -10
  elif  [ "$key" = "e619b649" ] ; then 
    QUERY_STRING="B" ;# SKIP 30
  elif  [ "$key" = "f40bb649" ] ; then 
    QUERY_STRING="+" ;# ??repeat title?
  elif  [ "$key" = "e51ab649" ] ; then 
    QUERY_STRING="O" ;# POWER
  elif  [ "$key" = "af50b649" ] ; then 
    QUERY_STRING="/" ;# SETUP MENU
  elif  [ "$key" = "fb04b649" ] ; then 
    QUERY_STRING="&" ;# COPY
  elif  [ "$key" = "b847b649" ] ; then 
    QUERY_STRING="\" ;# TV SYS
  elif  [ "$key" = "ba45b649" ] ; then 
    QUERY_STRING="a" ;# AUDIO SYS
  elif  [ "$key" = "b649b649" ] ; then 
    QUERY_STRING="#" ;# MENU
  elif  [ "$key" = "ab54b649" ] ; then 
    QUERY_STRING="#" ;# USB SCREEN / BROWSER
  elif  [ "$key" = "bb44b649" ] ; then 
    QUERY_STRING="}" ;#  DISPLAY
  elif  [ "$key" = "ef10b649" ] ; then 
    QUERY_STRING=" " ;#  SELECT
  ######################## NO CODES
  elif  [ "$key" = "00000000" ] ; then 
    QUERY_STRING="z" ;# ZOOM+
  elif  [ "$key" = "00000000" ] ; then 
    QUERY_STRING="j" ;# ZOOM-
  elif  [ "$key" = "00000000" ] ; then 
    QUERY_STRING="=" ;# REPEAT A/B
  elif  [ "$key" = "00000000" ] ; then 
    QUERY_STRING="E" ;# DELETE
  ######################## NO COMMANDS
  elif  [ "$key" = "f708b649" ] ; then 
    QUERY_STRING="k" ;#  OPTION
  elif  [ "$key" = "e718b649" ] ; then 
    QUERY_STRING="k" ;#  CONFIRM
  elif  [ "$key" = "ff00b649" ] ; then 
    QUERY_STRING="k" ;#  ANGLE
  elif  [ "$key" = "ec13b649" ] ; then 
    QUERY_STRING="k" ;#  EJECT
  elif  [ "$key" = "fa05b649" ] ; then 
    QUERY_STRING="k" ;#  TITLE
  fi
#fi

if [ "$QUERY_STRING" = "A" ] ; then
  QUERY_STRING="v" ;#  Tecla '<' baja el volumen
elif  [ "$QUERY_STRING" = "D" ] ; then 
  QUERY_STRING="V" ;#  Tecla '>' sube el volumen
fi

echo "$QUERY_STRING" >> /tmp/command_sender.txt
done

Bueno, esto es la versión sin necesidad de compilar un programa en C. Para ejecutarlo, basta con teclear /usr/local/etc/key.sh &
(suponiendo que el script key.sh está en /usr/local/etc)

Código fuente de un programita en C que debería de hacer algo similiar ir2command.c:
Código:

/* -----------------------------------------------------------------------------------------
 * Program:        ircode.c
 * Version:        1.0.0
 * Date:          27/11/2010
 * Author:        tskitishvili
 * Description:    translate PBO remote control codes into DvdPlayer textual commands.
 * Parameters:    none
 * Note:          1) put compiled executabe 'ircode' into /usr/local/etc/
 *                2) assign execute bit: chmod +x ircode
 *                3) add at the bottom of /usr/local/etc/rcS file:     
 *                    /usr/local/etc/ircode &
 * --------------------------------------------------------------------------------------- */

#include <termios.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/poll.h>

/* defines are taken from RemoteControl.h */
#define CMD_NOP 'k'
#define VENUS_IR_IOC_MAGIC         'r'
#define VENUS_IR_IOC_SET_IRIOTCDP   _IOW(VENUS_IR_IOC_MAGIC, 1, int)
#define VENUS_IR_IOC_FLUSH_IRRP      _IOW(VENUS_IR_IOC_MAGIC, 2, int)
#define VENUS_IR_IOC_SET_PROTOCOL   _IOW(VENUS_IR_IOC_MAGIC, 3, int)
#define VENUS_IR_IOC_SET_DEBOUNCE  _IOW(VENUS_IR_IOC_MAGIC, 4, int)
#define VENUS_IR_IOC_SET_IRPSR      _IOW(VENUS_IR_IOC_MAGIC, 5, int)
#define VENUS_IR_IOC_SET_IRPER      _IOW(VENUS_IR_IOC_MAGIC, 6, int)
#define VENUS_IR_IOC_SET_IRSF      _IOW(VENUS_IR_IOC_MAGIC, 7, int)
#define VENUS_IR_IOC_SET_IRCR      _IOW(VENUS_IR_IOC_MAGIC, 8, int)

#define POLL_INTERVAL              100
#define DRIVER_DEBOUNCE            100
#define IR_PROCOTOL_NEC            1

char getCommand(int ircode)
{
    // setup command mapping
    static char command[256];
    if (*command == CMD_NOP) return command[ircode];
    int i;
    for(i = 0; i<256; ++i) command[i] = CMD_NOP;
    command[0x06] = '1' ; 
    command[0x07] = '2' ; 
    command[0x41] = '3' ;
    command[0x16] = '4' ;
    command[0x40] = '5' ;
    command[0x55] = '6' ;
    command[0x0e] = '7' ;
    command[0x48] = '8' ;
    command[0x42] = '9' ;
    command[0x4c] = '0' ;
    command[0x4a] = 'W' ; /* UP */
    command[0x1b] = '{' ; /* HOME */
    command[0x12] = 'A' ; /* LEFT */
    command[0x0a] = ' ' ; /* OK */
    command[0x4b] = 'D' ; /* RIGHT */
    command[0x43] = ',' ; /* RETURN */
    command[0x4e] = 'X' ; /* DOWN */
    command[0x56] = 'S' ; /* PLAY */
    command[0x03] = 'Z' ; /* PAUSE */
    command[0x15] = 'Q' ; /* STOP */
    command[0x0f] = 'L' ; /* PLAY SLOW */
    command[0x17] = 'P' ; /* PREV CHAPTER */
    command[0x09] = 'f' ; /* REWIND */
    command[0x0d] = 'F' ; /* FORWARD  */
    command[0x57] = 'N' ; /* NEXT CHAPTER */
    command[0x51] = 'V' ; /* VOL+ */
    command[0x52] = 'm' ; /* MUTE */
    command[0x4f] = 'v' ; /* VOL- */
    command[0x46] = 's' ; /* SUBTITLES */
    command[0x02] = '-' ; /* GOTO */
    command[0x53] = 'q' ; /* SKIP -10 */
    command[0x19] = 'B' ; /* SKIP 30 */
    command[0x0b] = '+' ; /* REPEAT */
    command[0x1a] = 'O' ; /* POWER */
    command[0x50] = '/' ; /* SETUP MENU */
    command[0x04] = '&' ; /* COPY */
    command[0x47] = '\'; /* TV SYS */
    command[0x45] = 'a' ; /* AUDIO SYS */
    command[0x49] = '#' ; /* MENU */
    command[0x54] = '#' ; /* USB SCREEN / BROWSER */
    command[0x44] = '}' ; /* DISPLAY */
    command[0x10] = ' ' ; /* SELECT */
    command[0x00] = 'e' ; /* ANGLE */
    command[0x13] = '!' ; /* EJECT */
    command[0x18] = 'k' ; /* GREEN - CONFIRM */
    command[0x08] = 'k' ; /* BLUE - OPTION */
    command[0x05] = 'k' ; /* TITEL */
    return command[ircode];
}

// -----------------------------------------------------------------------------
// Main program
// -----------------------------------------------------------------------------
int main (int argc, char *argv[]) {

    int fd_irrp = open("/dev/venus_irrp", O_RDWR);
    if (fd_irrp == -1) {
        printf("Error to open device: /dev/venus_irrp \n");
        exit(1);
    }

    // setup poll structure
    struct pollfd pfds[1];
    pfds[0].fd = fd_irrp;
    pfds[0].events = POLLIN;

    // always flush the IR queue first
    if (ioctl(fd_irrp, VENUS_IR_IOC_FLUSH_IRRP, NULL) < 0)
        printf("Warning: Could not flush IR");
    if (ioctl(fd_irrp, VENUS_IR_IOC_SET_PROTOCOL, IR_PROCOTOL_NEC) < 0)
        printf("Warning: Could not set IR Protocol to [%d]", IR_PROCOTOL_NEC);
    if (ioctl(fd_irrp, VENUS_IR_IOC_SET_DEBOUNCE, DRIVER_DEBOUNCE) < 0)
        printf("Warning: Could not overwrite debounce configuration\n");

    while (1) { 
        if(poll(pfds, 1, POLL_INTERVAL) <= 0) {
            continue;
        }
        if((pfds[0].revents & POLLIN) ) {
            unsigned int key;
            read(fd_irrp, &key, sizeof(int)); // read keyboard key
            int deviceCode = key & 0x0000FFFF;
            int commandCode = (key & 0x00FF0000) >> 16;
            if (deviceCode == 0x0000B649) {
                char cmd =  getCommand(commandCode);
                if (cmd == CMD_NOP) continue;
                printf("%c\n", cmd); // print DvdPlayer command
            } else {
                //printf("Value:  0x%08X \n", key);
                //printf("Device:  0x%04X \n", deviceCode);
                //printf("EFC:    0x%02X \n", commandCode);
            }
        }
    }
    close(fd_irrp);
    return 0;
}

alonso_c

Mensajes : 72
Fecha de inscripción : 11/03/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  vic1972 Lun Jun 28, 2010 1:30 pm

Hola Alonso,
gracias por tus comentarios.

Como te comenté, estaba esperando a tener el aplicativo en un punto estable, para luego publicarlo por algun sistema de
gestión de proyectos con gestión de código fuente.

Ya que no queremos que luego tengamos por ahi versiones que no sepamos de que versión partió, si incluye modificaciones
que algun otro usuario haya introducido, etc, etc.

Asi que vamos a utilizar el sistema ProjectHosting de google, con su gestor de control de código fuente SVN.

El punto de inicio del portal es: [Tienes que estar registrado y conectado para ver este vínculo]

Saludos
Victor



vic1972
vic1972

Mensajes : 2260
Fecha de inscripción : 09/12/2009
Edad : 51
Localización : Malaga

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  alonso_c Lun Jun 28, 2010 7:41 pm

Gracias Víctor por publicar el código fuente.

Te hago un aporte: ¿No sería mejor eliminar el comando 'tail -f /tmp/command_sender.txt' del script 'rcS' y que sea el propio programa compilado PipeManagement el que realice los 'echo' directamente como pipe de entrada al DvdPlayer? Creo que es mucho más rápido y eficiente.

Sería cuestión de añadir un comando C al PipeManagement.c: printf(" \n"); para que hiciera el mismo efecto que hace el command_sender.txt

También he notado que se me queda algunas veces la pantalla en 'OFF' bloqueada cuando apago el LivingBox.

alonso_c

Mensajes : 72
Fecha de inscripción : 11/03/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  vic1972 Mar Jun 29, 2010 12:21 am

Hola,
se podria, pero no creo que haya mucha diferencia,
habria que crear un pipe con mkpipe InputPipeManagement, y luego ejecutar como

InputPipeManagement | DvdPlayer | PipeManagement
Intentalo si quieres y nos cuentas si funciona o no.

Actualmente estoy muy ocupado en otras batallas Wink

Sobre el blockage en OFF es cierto, ocurre con alguna frecuencia, estoy intentando averiguar porque ocurre.
vic1972
vic1972

Mensajes : 2260
Fecha de inscripción : 09/12/2009
Edad : 51
Localización : Malaga

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  alonso_c Mar Jun 29, 2010 5:03 pm

Creo que no me he explicado bien. Lo que quería decir es que la ejecución en rcS de la línea:

tail -f /tmp/command_sender.txt | DvdPlayer | /usr/local/etc/PipeManagement

sería mucho más óptimo si se ejecutara:

/usr/local/etc/PipeManagent | DvdPlayer

Esto es, quitar el comando 'tail -f /tmp/command_sender.txt' y los otros comandos de 'touch /tmp/command_sender.txt', etc.

De esta forma, se optimiza el rendimiento, carga más rápido el Living Box, y responde mejor a los comandos del mando a distancia.

Por otra parte, para conseguir el efecto de la pulsación del mando a distancia para que vaya directamente al canal, nada más encender el Living Box, decía que se podría hacer simplemente con el comando en C: 'printf(" \n");

Espero haberme explicado bien esta vez.

alonso_c

Mensajes : 72
Fecha de inscripción : 11/03/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  matthelas Mar Jun 29, 2010 8:28 pm

Hi Alonso,

As far as I understood, you need both to "input" commands to DvdPlayer (so xxxx | DvdPlayer) but also to parse the DvdPlayer output (so DvdPlayer | yyyy ) so that you can know what happened and "react".
This is more or less what Victor proposed:
InputPipeManagement | DvdPlayer | OutputPipeManagement
Or with more self speaking names:
InputCommands | DvdPlayer | OutputParsingAndReactionsIfNeededForwardedToInputCommands

Am I wrong?
Cheers,
Matt

matthelas

Mensajes : 145
Fecha de inscripción : 08/02/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  vic1972 Mar Jun 29, 2010 10:18 pm

Hello, thanks Matt, yes, exactly the most interesting part is the output messages DvdPlayer gives us,
so we need the pipe in the right part of DvdPlayer.

Of course, it will be nice, to have a single process doing everything; but I cannot think how can this be done.
Linking pipes could be a solution, but will increase complexity of the pipemanagement program.

Anyway, I think it is good we discuss this things, so we could get a better solution among all ideas.

regards
vic1972
vic1972

Mensajes : 2260
Fecha de inscripción : 09/12/2009
Edad : 51
Localización : Malaga

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  alonso_c Miér Jun 30, 2010 10:19 pm

Entiendo lo que indicas. Tanto el script que había puesto anteriormente, como el programa en C lo que hacen es leer directamente de la entrada del mando a distancia, sin necesidad de saber lo que ha pasado después en el DvdPlayer, pero claro está que es importante también saber qué ha interpretado o ejecutado el DvdPlayer.

alonso_c

Mensajes : 72
Fecha de inscripción : 11/03/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty No accedo al portal de google

Mensaje  Manolo Vie Mar 04, 2011 7:42 pm

Hola a todos,
No puedo acceder al portal del código fuente; hay que registrarse o algo parecido. Si meto mi cuenta de gmail me dice que no tengo permisos.

Gracias.

Manolo

Mensajes : 10
Fecha de inscripción : 16/01/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  evr Vie Mar 04, 2011 9:40 pm

Manolo escribió:No puedo acceder al portal del código fuente; hay que registrarse o algo parecido. Si meto mi cuenta de gmail me dice que no tengo permisos.
Está en sourceforge:

[Tienes que estar registrado y conectado para ver este vínculo]

[Tienes que estar registrado y conectado para ver este vínculo]. Puedes ver el SVN con el navegador (Develop -> Cdode -> SVN Browse ...) o descargarte una copia del árbol de desarrollo en tu directorio de trabajo mediante:

svn co [Tienes que estar registrado y conectado para ver este vínculo] .

Si necesitas más ayuda o información, ya sabes...

Saludos,

evr

Mensajes : 279
Fecha de inscripción : 12/10/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Gracias

Mensaje  Manolo Lun Mar 21, 2011 5:43 pm

Ok, gracias.
Un saludo.

Manolo

Mensajes : 10
Fecha de inscripción : 16/01/2010

Volver arriba Ir abajo

Proyecto  CÓDIGO FUENTE "PipeManagement" Empty Re: Proyecto CÓDIGO FUENTE "PipeManagement"

Mensaje  Contenido patrocinado


Contenido patrocinado


Volver arriba Ir abajo

Volver arriba

- Temas similares

 
Permisos de este foro:
No puedes responder a temas en este foro.