xilebo noone | salut,
j ai enfin reussi a installer le module lirc (www.lirc.org) sous linux familiar (0.7) sur un PDA iPAQ 3850
pour lire les donnees sur le port infrarouge il suffit donc de faire un open sur /dev/lirc et ensuite de faire read... jusque la ca marche j arrive a lire des donnees.
par contre mon write ne marche pas . Pire, la fonction ne quitte pas avec un message d erreur mais elle bloque...
voici mon code :
Code :
- #include <unistd.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <string.h>
- #include <termios.h>
- #include <pthread.h>
- #include <time.h>
- #include "lirc.h"
- #define INVALID_HANDLE_VALUE -1
- #define STATE_PULSE 1
- #define STATE_SPACE 2
- static int hIR = INVALID_HANDLE_VALUE;
- static lirc_t irNECTrame[66];
- static void EncodeNec(lirc_t dwCode,lirc_t dwInstruction1,lirc_t dwInstruction2);
- int main(int /*argc*/,char * /*argv[]*/){
- int i;
- hIR = open("/dev/lirc" ,O_RDWR | O_NDELAY | O_NOCTTY);
- if (hIR == INVALID_HANDLE_VALUE) {
- printf("Unable to open IR port - %s\n", strerror(errno));
- return 0;
- }
- if (hIR != INVALID_HANDLE_VALUE) {
- unsigned long recMode;
- if (ioctl(hIR, LIRC_GET_REC_MODE, &recMode) == -1 ) {
- printf("error - %s\n", strerror(errno));
- }
- if (ioctl(hIR, LIRC_GET_SEND_MODE, &recMode) == -1 ) {
- printf("error - %s\n", strerror(errno));
- }
- i = 0;
- printf("Encoding ...\n" );
- EncodeNec(0x00000CF2,0x00000048,0x000000B7);
- printf("Sending ...\n" );
- while (i < 10) {
- int j;
- lirc_t k;
- for (j=0 ;j < 66 ; j++) {
- printf("%2.2X ",irNECTrame[j]);
- }
- printf("\n" );
- k = irNECTrame[0];
- j = write (hIR,&k,4);
- if (j == -1) {
- printf("error - %s\n", strerror(errno));
- }
- else {
- printf("trame %d : Written %d bytes...\n",i,j);
- }
- sleep(1);
- i++;
- }
- return 1;}
|
ai je fait une erreur quelque part ? |