butterfly_prog: Fix serial initalization

This commit is contained in:
Olaf Rempel 2020-10-20 23:56:31 +02:00
parent 9192149be2
commit 7d74f62c00

View File

@ -238,9 +238,6 @@ static uint32_t butterfly_get_memsize(struct multiboot * p_mboot,
* ************************************************************************* */
static void butterfly_close_device(bfly_privdata_t * p_priv)
{
/* delay close() / tcsetattr() */
usleep(100000);
tcsetattr(p_priv->fd, TCSANOW, &p_priv->oldtio);
close(p_priv->fd);
} /* butterfly_close_device */
@ -268,9 +265,10 @@ static int butterfly_open_device(bfly_privdata_t * p_priv)
struct termios newtio;
memset(&newtio, 0, sizeof(newtio));
newtio.c_iflag |= IGNBRK;
newtio.c_cflag |= SERIAL_BAUDRATE | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNBRK;
newtio.c_cflag = (CS8 | CREAD | CLOCAL);
cfsetispeed(&newtio, SERIAL_BAUDRATE);
cfsetospeed(&newtio, SERIAL_BAUDRATE);
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
@ -282,6 +280,9 @@ static int butterfly_open_device(bfly_privdata_t * p_priv)
return -1;
}
/* needed for some slow USB2Serial adapters */
usleep(200000);
return 0;
} /* butterlfy_open_device */