1 /* 2 * termios2.h 3 * 4 * Use termios2 interface to set custom baud rates to serial ports. 5 * 6 * by Nick Patavalis (npat@efault.net) 7 * 8 * ATTENTION: Linux-specific kludge! 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU General Public License as 12 * published by the Free Software Foundation; either version 2 of the 13 * License, or (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 23 * USA 24 */ 25 26 #ifndef TERMIOS2_H 27 #define TERMIOS2_H 28 29 #include <termios.h> 30 31 /* Replace termios functions, with termios2 functions */ 32 #define tcsetattr tc2setattr 33 #define tcgetattr tc2getattr 34 #define cfsetispeed cf2setispeed 35 #define cfgetispeed cf2getispeed 36 37 /* And define these new ones */ 38 #define cfsetospeed_custom cf2setospeed_custom 39 #define cfsetispeed_custom cf2setispeed_custom 40 #define cfgetospeed_custom(tiop) ((tiop)->c_ospeed) 41 #define cfgetispeed_custom(tiop) ((tiop)->c_ispeed) 42 43 /* Replacements for the standard tcsetattr(3), tcgetattr(3) 44 * functions. Same user interface, but these use the new termios2 45 * kernel interface (new ioctl's) which allow custom baud-rate 46 * setting. */ 47 48 int tc2setattr(int fd, int optional_actions, const struct termios *tios); 49 int tc2getattr(int fd, struct termios *tios); 50 51 /* Replacements for the standard cfgetispeed(3), cfsetispeed(3) 52 * functions. Use these to set / get standard *input* baudrates. You 53 * can still use cfgetospeed(3), cfsetospeed(3) to set / get the 54 * standard output baudrates. The new termios2 interface, unlike the 55 * old one, supports different input and output speeds for a 56 * device. The "speed" argument must be (and the return value will be) 57 * one of the standard "Bxxxx" macros. If cf2getispeed() or 58 * cfgetospeed(3) return CBAUDEX, then the respective baudrate is a 59 * custom one. Read the "termios.c_ispeed" / "termios.c_ospeed" fields 60 * to get the custom value (as a numeric speed). */ 61 62 int cf2setispeed(struct termios *tios, speed_t speed); 63 speed_t cf2getispeed(struct termios *tios); 64 65 /* Use these to set *custom* input and output baudrates for a 66 * device. The "speed" argument must be a numeric baudrate value 67 * (e.g. 1234 for 1234 bps). */ 68 69 int cf2setispeed_custom(struct termios *tios, int speed); 70 int cf2setospeed_custom(struct termios *tios, int speed); 71 72 /***************************************************************************/ 73 74 #endif /* of TERMIOS2_H */ 75 76 /***************************************************************************/ 77 78 /* 79 * Local Variables: 80 * mode:c 81 * tab-width: 4 82 * c-basic-offset: 4 83 * End: 84 */ 85