Пример #1
0
int silitek_init(void)
{
    if (!tty_create_lock(drv.device)) {
        logprintf(LIRC_ERROR, "could not create lock files");
        return 0;
    }

    drv.fd = open(drv.device, O_RDWR | O_NOCTTY | O_NDELAY);
    if (drv.fd < 0) {
        logprintf(LIRC_ERROR, "could not open %s", drv.device);
        logperror(LIRC_ERROR, "silitek_init()");
        tty_delete_lock();
        return 0;
    }

    if (!tty_reset(drv.fd)) {
        logprintf(LIRC_ERROR, "could not reset %s", drv.device);
        silitek_deinit();
        return 0;
    }

    if (!tty_setbaud(drv.fd, 1200)) {
        logprintf(LIRC_ERROR, "could not set baud rate on %s", drv.device);
        silitek_deinit();
        return 0;
    }

    return 1;
}
Пример #2
0
int silitek_init(void) {
    if(!tty_create_lock(hw.device)) {
        logprintf(LOG_ERR, "could not create lock files");
        return(0);
    }

    if((hw.fd = open(hw.device, O_RDWR | O_NOCTTY | O_NDELAY)) < 0) {
        logprintf(LOG_ERR, "could not open %s", hw.device);
        logperror(LOG_ERR, "silitek_init()");
        tty_delete_lock();
        return(0);
    }

    if(!tty_reset(hw.fd)) {
        logprintf(LOG_ERR,"could not reset %s", hw.device);
        silitek_deinit();
        return(0);
    }

    if(!tty_setbaud(hw.fd, 1200)) {
        logprintf(LOG_ERR,"could not set baud rate on %s", hw.device);
        silitek_deinit();
        return(0);
    }

    return(1);
}