Example #1
0
void board_bub_ra()
{
    serialport_set_rts(0);
    serialport_set_dtr(1);
    espcomm_delay_ms(5);
    serialport_set_dtr(0);
}
Example #2
0
void board_bub_rb()
{
    serialport_set_dtr(1);
    serialport_set_rts(0);
    espcomm_delay_ms(5);
    serialport_set_dtr(0);
    espcomm_delay_ms(250); // wait for bootloader to engage
    serialport_set_rts(0);
}
Example #3
0
void board_wifio_rb()
{
    serialport_set_dtr(0);
    espcomm_delay_ms(5);
    serialport_set_dtr(1);
    espcomm_delay_ms(5);
    serialport_set_dtr(0);
    serialport_send_break();
}
Example #4
0
void board_ck_rb()
{
    serialport_set_rts(1);
    serialport_set_dtr(1);
    serialport_send_break();
    espcomm_delay_ms(5);
    serialport_set_rts(0);
    espcomm_delay_ms(250);          // wait for break to finish
    serialport_set_dtr(0);
}
Example #5
0
void board_nodemcu_rb()
{
    serialport_set_rts(1);
    serialport_set_dtr(0);
    espcomm_delay_ms(5);
    serialport_set_rts(0);
    serialport_set_dtr(1);
    espcomm_delay_ms(50);
    serialport_set_dtr(0);
}
Example #6
0
void board_wifio_ra()
{
    serialport_set_dtr(0);
    espcomm_delay_ms(5);
    serialport_set_dtr(1);
}
Example #7
0
int serialport_open(const char *device, unsigned int baudrate)
{
    LOGINFO("opening port %s at %d", device, baudrate);
    int flags = O_RDWR | O_NOCTTY;
#ifdef __APPLE__
    flags |= O_NONBLOCK;
#endif
    serial_port = open(device, flags);
    
    if(serial_port<0) 
    {
        LOGERR("cannot access %s\n",device);
        return 0;
    }
    
#ifdef __APPLE__
    flags = fcntl(serial_port, F_GETFL, 0);
    fcntl(serial_port, F_SETFL, flags & (~O_NONBLOCK));
#endif

    serialport_set_dtr(0);

    LOGDEBUG("tcgetattr");
    tcgetattr(serial_port,&term);

    serialport_set_baudrate(baudrate);

    term.c_cflag = (term.c_cflag & ~CSIZE) | CS8;
    term.c_cflag |= CLOCAL | CREAD;
    
    term.c_cflag &= ~(PARENB | PARODD);
    term.c_cflag &= ~CSTOPB;
    
    term.c_iflag = IGNBRK;
    
    term.c_iflag &= ~(IXON | IXOFF);
    
    term.c_lflag = 0;
    
    term.c_oflag = 0;
    
    
    term.c_cc[VMIN]=0;
    term.c_cc[VTIME]=1;
    timeout = 100;
    
    
    
    LOGDEBUG("tcsetattr");
    if (tcsetattr(serial_port, TCSANOW, &term)!=0)
    {
        LOGERR("setattr stage 1 failed");
        return 0;
    }

    
    if (tcgetattr(serial_port, &term)!=0)
    {
        LOGERR("getattr failed");
        return 0;
    }
    
    term.c_cflag &= ~CRTSCTS;
    
    if (tcsetattr(serial_port, TCSANOW, &term)!=0)
    {
        LOGERR("setattr stage 2 failed");
        return 0;
    }
    LOGDEBUG("serial open");
    return serial_port;
}