--- term-jmesmon.c	2015-06-13 17:22:34.856973558 +0200
+++ term.c	2019-07-10 19:21:50.893412759 +0200
@@ -592,7 +592,8 @@
 /***************************************************************************/
 
 int
-term_set_baudrate (int fd, speed_t baud_rate)
+//term_set_baudrate (int fd, speed_t baud_rate)
+term_set_baudrate (int fd, int baud_rate)
 {
 	int rval, i;
 	struct termios2 tio;
@@ -671,6 +672,34 @@
 /***************************************************************************/
 
 int
+term_set_stopbits (int fd, int stopbits) 
+{
+	int rval, i;
+	struct termios2 *tiop;
+
+	rval = 0;
+        do { /* dummy */
+
+		i = term_find(fd);
+		if ( i < 0 ) {
+			rval = -1;
+			break;
+		}
+
+		tiop = &term.nexttermios[i];
+
+                if(stopbits<2) tiop->c_cflag &= ~CSTOPB;
+                         else  tiop->c_cflag |= CSTOPB;
+                break;
+
+	} while (0);
+
+	return rval;
+}
+
+/***************************************************************************/
+
+int
 term_set_databits (int fd, int databits)
 {
 	int rval, i;
@@ -823,7 +852,7 @@
 int
 term_set(int fd,
 		 int raw,
-		 int baud, enum parity_e parity, int bits, enum flowcntrl_e fc,
+		 int baud, enum parity_e parity, int bits, int stopbits, enum flowcntrl_e fc,
 		 int local, int hup_close)
 {
 	int rval, r, i, ni;
@@ -862,6 +891,9 @@
 			r = term_set_databits(fd, bits);
 			if ( r < 0 ) { rval = -1; break; }
 			
+			r = term_set_stopbits(fd, stopbits);
+			if ( r < 0 ) { rval = -1; break; }
+			
 			r = term_set_flowcntrl(fd, fc);
 			if ( r < 0 ) { rval = -1; break; }
 			
@@ -1150,8 +1182,283 @@
 	return rval;
 }
 
+
 /**************************************************************************/
 
+int
+term_raise_rts(int fd)
+{
+	int rval, r, i;
+
+	rval = 0;
+
+	do { /* dummy */
+
+		i = term_find(fd);
+		if ( i < 0 ) {
+			rval = -1;
+			break;
+		}
+
+#ifdef __linux__
+		{
+			int opins = TIOCM_RTS;
+
+			r = ioctl(fd, TIOCMBIS, &opins);
+			if ( r < 0 ) {
+				term_errno = TERM_EDTRUP;
+				rval = -1;
+				break;
+			}
+		}
+#else
+// TODO: check if this would work on non-linux platforms on RTS
+		r = tcsetattr(fd, TCSANOW, &term.currtermios[i]);
+		if ( r < 0 ) {
+			/* FIXME: perhaps try to update currtermios */
+			term_errno = TERM_ESETATTR;
+			rval = -1;
+			break;
+		}
+#endif /* of __linux__ */
+	} while (0);
+
+	return rval;
+}
+
+/***************************************************************************/
+
+
+int
+term_lower_rts(int fd)
+{
+	int rval, r, i;
+
+	rval = 0;
+
+	do { /* dummy */
+
+		i = term_find(fd);
+		if ( i < 0 ) { 
+			rval = -1;
+			break;
+		}
+
+#ifdef __linux__
+		{
+			int opins = TIOCM_RTS;
+
+			r = ioctl(fd, TIOCMBIC, &opins);
+			if ( r < 0 ) {
+				term_errno = TERM_EDTRDOWN;
+				rval = -1;
+				break;
+			}
+		}
+#else
+// TODO: check if this would work on non-linux platforms on RTS
+		{
+			struct termios tio;
+
+			r = tcgetattr(fd, &tio);
+			if ( r < 0 ) {
+				term_errno = TERM_EGETATTR;
+				rval = -1;
+				break;
+			}
+			term.currtermios[i] = tio;
+			
+			cfsetospeed(&tio, B0);
+			cfsetispeed(&tio, B0);
+			
+			r = tcsetattr(fd, TCSANOW, &tio);
+			if ( r < 0 ) {
+				term_errno = TERM_ESETATTR;
+				rval = -1;
+				break;
+			}
+		}
+#endif /* of __linux__ */
+	} while (0);
+	
+	return rval;
+}
+
+
+/***************************************************************************/
+// TODO: nonstandard speeds
+
+int
+term_get_baudrate (int fd)
+{
+	int i;
+	int spd;
+	struct termios2 tio;
+
+	do { /* dummy */
+
+		i = term_find(fd);
+		if ( i < 0 ) {
+			spd = -1;
+			break;
+		}
+
+		tio = term.nexttermios[i];
+		spd=tio.c_ospeed;
+
+	} while (0);
+
+	return spd;
+}
+
+int
+term_get_databits (int fd)
+{
+ {
+ tcflag_t flg;
+ int i, bits;
+ do { /* dummy */
+ i = term_find(fd);
+ if ( i < 0 ) {
+ bits = -1;
+ break;
+ }
+ flg = term.currtermios[i].c_cflag & CSIZE;
+ switch (flg) {
+ case CS5: bits = 5; break;
+ case CS6: bits = 6; break;
+ case CS7: bits = 7; break;
+ case CS8:
+ default:  bits = 8; break;
+ }
+ } while (0);
+ return bits;
+ }
+}
+
+/***************************************************************************/
+
+int
+term_get_cflag (int fd) 
+{
+	int rval, i;
+	struct termios2 *tiop;
+
+	rval = 0;
+
+	do { /* dummy */
+
+		i = term_find(fd);
+		if ( i < 0 ) {
+			rval = -1;
+			break;
+		}
+
+		tiop = &term.nexttermios[i];
+
+		rval=tiop->c_cflag;
+
+	} while (0);
+
+	return rval;
+}
+
+/***************************************************************************/
+
+int
+term_get_iflag (int fd) 
+{
+	int rval, i;
+	struct termios2 *tiop;
+
+	rval = 0;
+
+	do { /* dummy */
+
+		i = term_find(fd);
+		if ( i < 0 ) {
+			rval = -1;
+			break;
+		}
+
+		tiop = &term.nexttermios[i];
+
+		rval=tiop->c_iflag;
+
+	} while (0);
+
+	return rval;
+}
+
+
+/***************************************************************************/
+
+
+int
+term_get_modem_flags(int fd)
+{
+	int rval, r;
+
+	rval = 0;
+
+	do { /* dummy */
+
+#ifdef __linux__
+		{
+			r = ioctl(fd, TIOCMGET, &rval);
+			if ( r < 0 ) {
+				term_errno = TERM_EDTRUP;
+				rval = -1;
+				break;
+			}
+		}
+#else
+/*
+		int i;
+		i = term_find(fd);
+		if ( i < 0 ) {
+			rval = -1;
+			break;
+		}
+
+	TODO: correct this!!!
+		r = tcsetattr(fd, TCSANOW, &term.currtermios[i]);
+		if ( r < 0 ) {
+			term_errno = TERM_ESETATTR;
+			rval = -1;
+			break;
+		}
+*/
+#endif /* of __linux__ */
+	} while (0);
+
+	return rval;
+}
+
+
+
+/*
+static int tiny_tiocmget(struct tty_struct *tty, struct file *file)
+{
+    struct tiny_serial *tiny = tty->driver_data;
+
+    unsigned int result = 0;
+    unsigned int msr = tiny->msr;
+    unsigned int mcr = tiny->mcr;
+*/
+//    result = ((mcr & MCR_DTR)  ? TIOCM_DTR  : 0) |  /* DTR is set */
+//             ((mcr & MCR_RTS)  ? TIOCM_RTS  : 0) |  /* RTS is set */
+//             ((mcr & MCR_LOOP) ? TIOCM_LOOP : 0) |  /* LOOP is set */
+//             ((msr & MSR_CTS)  ? TIOCM_CTS  : 0) |  /* CTS is set */
+//             ((msr & MSR_CD)   ? TIOCM_CAR  : 0) |  /* Carrier detect is set*/
+//             ((msr & MSR_RI)   ? TIOCM_RI   : 0) |  /* Ring Indicator is set */
+//             ((msr & MSR_DSR)  ? TIOCM_DSR  : 0);   /* DSR is set */
+/*
+    return result;
+}
+*/
+
+/***************************************************************************/
 /*
  * Local Variables:
  * mode:c
