FreeCalypso > hg > freecalypso-tools
view libserial-newlnx/openport.c @ 612:52980e3a51c7
fc-loadtool: added operation time reporting to flash program-bin
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 24 Feb 2020 21:56:53 +0000 |
parents | 9d9c241f2c84 |
children | f82551c77e58 |
line wrap: on
line source
/* * This module implements the basic serial port opening operation. */ #include <sys/types.h> #include <sys/file.h> #include <sys/ioctl.h> #include <linux/serial.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int target_fd; open_serial_port(ttyport) char *ttyport; { struct serial_struct kernel_serial_settings; target_fd = open(ttyport, O_RDWR|O_NONBLOCK); if (target_fd < 0) { perror(ttyport); exit(1); } ioctl(target_fd, TIOCEXCL); /* * It appears that some miscreants have modified recent Linux kernel * versions (newer than linux-4.4.14 of Slackware 14.2) to insert * a delay of 10 ms before select system call returns when serial * input is ready; this Linux kernel misbehaviour majorly slows down * many of our operations. It appears that we need to set the * ASYNC_LOW_LATENCY flag in TIOCSSERIAL in order to get the old * sane behaviour back. */ ioctl(target_fd, TIOCGSERIAL, &kernel_serial_settings); kernel_serial_settings.flags |= ASYNC_LOW_LATENCY; ioctl(target_fd, TIOCSSERIAL, &kernel_serial_settings); return 0; }