- LiTime Speicher und Akkus         
Ergebnis 1 bis 8 von 8

Thema: ASURI IR TRANSRESIVER daten auf pc empfangen

  1. #1
    Neuer Benutzer Öfters hier
    Registriert seit
    30.12.2005
    Beiträge
    13

    ASURI IR TRANSRESIVER daten auf pc empfangen

    Anzeige

    LiFePo4 Akku selber bauen - Video
    hi leute!
    ======

    ich ich habe mir den asuro roboter gekauft nun bin ich vor einiger zeit draufgekommen(durch hilfe dieses forums) dass der sender meines ir transresivers nicht funkt und bis der USB transresiver vom conrad kommt wollte ich noch ein programm schreiben dass signale von meinem ir transresiver entgegennimmt und auf dem bildschirm ausgibt!(das funkt auch schon mit minicom immer waenn ich mit der fernbedienung auf eine taste druecke kommt was an bei minicom!) hier mal mein programm:
    Code:
    /*ledController whith FERNBEDIENUNG!
     *(C) by linuxuser
     *e-mail: unix4ever@gmx.net
     */
    
    #include <sys/ioctl.h>
    #include <sys/kd.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    #define INDEVICE "/dev/ttyS0"
    #define OUTDEVICE "/dev/tty1"
    
    #define BLOCKSIZE 8
    
    int main(void){
        int readBytes;
        int input;
        int output;
        
        char buffer[BLOCKSIZE];
    
        /*open the input device*/
        input = open(INDEVICE, O_RDONLY|O_NOCTTY|O_NONBLOCK);    
    
        /*open the output device*/
        output = open(OUTDEVICE, O_WRONLY);
    
        if(input == -1 || output == -1){
            fprintf(stderr, "ERROR konnte die Devices nicht oeffnen");
            return 1;
        }/*end if*/
        
        while(1){
            printf("hallo\n");
            readBytes = read(input, buffer, BLOCKSIZE);
            perror("Fehler ");
            printf("%s,%d, - %d\n", buffer, buffer, readBytes);
        }
    
        return 0;
    }/*end main*/
    aber irgendwie funkt es nicht so richtig als ausgabe bekomme ich(diese natuerlich oefter da O_NONBLOCK und endlosschleife):
    Code:
    hallo
    Fehler : Resource temporarily unavailable
    ,-1080603244, - -1
    koennte mir vielleicht einer sagen was ich falsch mache/vergesse?
    DANKE das waere super
    mfg
    linuxuser

  2. #2
    Benutzer Stammmitglied
    Registriert seit
    08.05.2005
    Ort
    München
    Alter
    52
    Beiträge
    59
    Hallo,

    hast du schon überprüft, ob du schreibrechte auf das Output Device hast?

    Ausserdem ließt du von ttyS0 und schreibts auf tty1.
    Kann es sein, das es das Output Device (COM2) gar nicht an deinem Computer gibt?

    Martin

  3. #3
    Neuer Benutzer Öfters hier
    Registriert seit
    30.12.2005
    Beiträge
    13
    tschuldigung das tty1 brauch ich gar nicht(erst spaeter dann!)
    so sollte es sein:
    Code:
    /*ledController whith FERNBEDIENUNG!
     *(C) by linuxuser
     *e-mail: unix4ever@gmx.net
     */
    
    #include <sys/ioctl.h>
    #include <sys/kd.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    #define INDEVICE "/dev/ttyS0"
    
    #define BLOCKSIZE 8
    
    int main(void){
        int readBytes;
        int input;
        
        char buffer[BLOCKSIZE];
    
        /*open the input device*/
        input = open(INDEVICE, O_RDONLY|O_NOCTTY|O_NONBLOCK);    
    
        if(input == -1){
            fprintf(stderr, "ERROR konnte die Devices nicht oeffnen");
            return 1;
        }/*end if*/
        
        while(1){
            printf("hallo\n");
            readBytes = read(input, buffer, BLOCKSIZE);
            perror("Fehler ");
            printf("%s,%d, - %d\n", buffer, buffer, readBytes);
        }
    
        return 0;
    }/*end main*/
    und /dev/ttS0 also COM1 habe ich!

  4. #4
    Erfahrener Benutzer Roboter Genie
    Registriert seit
    12.06.2005
    Ort
    Südwestdeutschland
    Beiträge
    1.138
    Blog-Einträge
    3
    Vielleicht kannst Du da was finden:
    https://www.roboternetz.de/phpBB2/vi...=145553#145553
    Gruss,
    stochri

  5. #5
    Neuer Benutzer Öfters hier
    Registriert seit
    30.12.2005
    Beiträge
    13
    hi leute! ich habs jetzt hinbekommen...

    Code:
    /* A SIMPLE LED CONTROLER
     * you are able to change the led
     * state with a FERNBEDIEHNUNG
     * (C) 2006 --linuxuser--
     * e-mail: unix4ever@gmx.at
     * Version 1.0
     */
    
    #include <sys/ioctl.h>
    #include <sys/kd.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <errno.h>
    #include <termios.h>
    #include <ctype.h>
    #include <assert.h>
    
    #define OUTPUT "/dev/tty1"
    #define INPUT  "/dev/ttyS0"
    
    #define ENDLOS 1
    #define FAIL 0
    #define SUCC 1
    
    #define BAUDRATE B2400
    
    /*lights*/
    #define NOLIGHT  0x0
    #define ALLLIGHT 0X7
    #define RLIGHT   0X1
    #define MLIGHT   0x4
    #define LLIGHT   0x2
    
    /*keys on the "FERNBEDIENUNG"*/
    #define FBDK_OFF 0xFE06
    #define FBDK_CD  0x4015FE33
    
    
    int setLight(int output, const unsigned int state){
        /*a very primitive method*/
        if(ioctl(output, KDSETLED, state)){
            fprintf(stderr, "KONNTE LICHT NICHT EINSCHALTEN!!!\n");
            return FAIL;
        }/*end if*/
    
        return SUCC;
    }/*end if*/
    
    int main(void){
        int states[5] = {NOLIGHT, ALLLIGHT, RLIGHT, MLIGHT, LLIGHT}; /*all implemented states*/
        int recived_bytes; /*how many bytes have recived?*/
        unsigned int inputByte = 0; /*the byte comes in from the COM1 port*/
        unsigned int buffer = 0;
        int output; /*the keyboard*/
        int input;  /*COM1*/
        struct termios newtio; /*settings for the RS-232 "CONSOL"*/
        int i = 0;
    
        /*open the input*/
        input = open(INPUT, O_RDWR | O_NOCTTY | O_NDELAY);
        if(input == -1){
            fprintf(stderr, "Fehler beim oeffnen der Seriellen schnittstelle: %s!\n", INPUT);
        }/*end if*/
    
        /*open the output*/
        output = open(OUTPUT, O_WRONLY);
        if(output == -1){
            fprintf(stderr, "FEHLER bein oeffnen des outputS: %s!\n", OUTPUT);
            return 0;
        }/*end if*/
        
        /*configure the RS-232 port*/
        fcntl(input, F_SETFL, FNDELAY);
        newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD ;
        newtio.c_iflag = IGNPAR | ICRNL ;
        newtio.c_oflag = 0;
        newtio.c_lflag &= ~(ICANON);
        
        /*set configuration*/
        tcflush(input, TCIOFLUSH);
        tcsetattr(input, TCSANOW, &newtio);  
    
        /*start the main loop*/
        while(ENDLOS){
            system("clear");
            /*read the input*/
            recived_bytes = read(input, &inputByte, 4);
            /*put the input out on the consol*/
            printf("(c)Rainer Sickinger\nGelesenesBytes: 0x%x\n", inputByte);
            if(buffer != inputByte){
                setLight(output, states[i]);
                i++;
                if(i == 4) i = 0;
            }/*end if*/
            buffer = inputByte;
            sleep(1);
        }/*end while*/
        
        /*close the file deskriptorz*/
        close(input);
        close(output);
    
        return 0;
    }/*end main*/
    DANKE nochmal!

  6. #6
    Neuer Benutzer Öfters hier
    Registriert seit
    30.12.2005
    Beiträge
    13
    Zitat Zitat von --linuxuser--
    hi leute! ich habs jetzt hinbekommen...

    Code:
    /* A SIMPLE LED CONTROLER
     * you are able to change the led
     * state with a FERNBEDIEHNUNG
     * (C) 2006 --linuxuser--
     * e-mail: unix4ever@gmx.at
     * Version 1.0
     */
    
    #include <sys/ioctl.h>
    #include <sys/kd.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <errno.h>
    #include <termios.h>
    #include <ctype.h>
    #include <assert.h>
    
    #define OUTPUT "/dev/tty1"
    #define INPUT  "/dev/ttyS0"
    
    #define ENDLOS 1
    #define FAIL 0
    #define SUCC 1
    
    #define BAUDRATE B2400
    
    /*lights*/
    #define NOLIGHT  0x0
    #define ALLLIGHT 0X7
    #define RLIGHT   0X1
    #define MLIGHT   0x4
    #define LLIGHT   0x2
    
    /*keys on the "FERNBEDIENUNG"*/
    #define FBDK_OFF 0xFE06
    #define FBDK_CD  0x4015FE33
    
    
    int setLight(int output, const unsigned int state){
        /*a very primitive method*/
        if(ioctl(output, KDSETLED, state)){
            fprintf(stderr, "KONNTE LICHT NICHT EINSCHALTEN!!!\n");
            return FAIL;
        }/*end if*/
    
        return SUCC;
    }/*end if*/
    
    int main(void){
        int states[5] = {NOLIGHT, ALLLIGHT, RLIGHT, MLIGHT, LLIGHT}; /*all implemented states*/
        int recived_bytes; /*how many bytes have recived?*/
        unsigned int inputByte = 0; /*the byte comes in from the COM1 port*/
        unsigned int buffer = 0;
        int output; /*the keyboard*/
        int input;  /*COM1*/
        struct termios newtio; /*settings for the RS-232 "CONSOL"*/
        int i = 0;
    
        /*open the input*/
        input = open(INPUT, O_RDWR | O_NOCTTY | O_NDELAY);
        if(input == -1){
            fprintf(stderr, "Fehler beim oeffnen der Seriellen schnittstelle: %s!\n", INPUT);
        }/*end if*/
    
        /*open the output*/
        output = open(OUTPUT, O_WRONLY);
        if(output == -1){
            fprintf(stderr, "FEHLER bein oeffnen des outputS: %s!\n", OUTPUT);
            return 0;
        }/*end if*/
        
        /*configure the RS-232 port*/
        fcntl(input, F_SETFL, FNDELAY);
        newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD ;
        newtio.c_iflag = IGNPAR | ICRNL ;
        newtio.c_oflag = 0;
        newtio.c_lflag &= ~(ICANON);
        
        /*set configuration*/
        tcflush(input, TCIOFLUSH);
        tcsetattr(input, TCSANOW, &newtio);  
    
        /*start the main loop*/
        while(ENDLOS){
            system("clear");
            /*read the input*/
            recived_bytes = read(input, &inputByte, 4);
            /*put the input out on the consol*/
            printf("(c)Rainer Sickinger\nGelesenesBytes: 0x%x\n", inputByte);
            if(buffer != inputByte){
                setLight(output, states[i]);
                i++;
                if(i == 4) i = 0;
            }/*end if*/
            buffer = inputByte;
            sleep(1);
        }/*end while*/
        
        /*close the file deskriptorz*/
        close(input);
        close(output);
    
        return 0;
    }/*end main*/
    DANKE nochmal!

  7. #7
    Erfahrener Benutzer Roboter Genie
    Registriert seit
    12.06.2005
    Ort
    Südwestdeutschland
    Beiträge
    1.138
    Blog-Einträge
    3
    Hallo -linuxuser-,
    warum hast Du es noch mal geschrieben, hat sich was geändert ?

    Gruss,
    stochri

  8. #8
    Neuer Benutzer Öfters hier
    Registriert seit
    30.12.2005
    Beiträge
    13
    O TSCHULDIGUNG ich habe wohl statt auf EDIT auf ZITAT gedrueckt!

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

LiTime Speicher und Akkus