aboutsummaryrefslogtreecommitdiff
path: root/include/libtio/stream.h
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2019-04-28 21:08:28 +0200
committerThomas Touhey <thomas@touhey.fr>2019-04-28 21:08:28 +0200
commit30a5c6e2a5bd757a24262231e70c3a912cdfcbee (patch)
tree847d39a9ad02b6764f17fdc2b82c6bd2165a7f79 /include/libtio/stream.h
parenta77576473eab464772cef97f8b1f72a98abbb891 (diff)
Updated serial attributes and copied stuff for partial Windows handles support
Diffstat (limited to 'include/libtio/stream.h')
-rw-r--r--include/libtio/stream.h64
1 files changed, 41 insertions, 23 deletions
diff --git a/include/libtio/stream.h b/include/libtio/stream.h
index aec0e4f..2b9cf0f 100644
--- a/include/libtio/stream.h
+++ b/include/libtio/stream.h
@@ -104,14 +104,20 @@ struct tio_serial_attrs {
/* Here are the different speeds you can set, in bauds: */
+# define TIO_B110 110
+# define TIO_B300 300
+# define TIO_B600 600
# define TIO_B1200 1200
# define TIO_B2400 2400
# define TIO_B4800 4800
# define TIO_B9600 9600
+# define TIO_B14400 14400
# define TIO_B19200 19200
# define TIO_B38400 38400
# define TIO_B57600 57600
# define TIO_B115200 115200
+# define TIO_B128000 128000
+# define TIO_B256000 256000
/* Here are the control characters you can define:
* `TIO_XON`: the XON character to re-enable transmission (software control);
@@ -168,42 +174,50 @@ struct tio_serial_attrs {
# define TIO_DTRDIS 0x0000
# define TIO_DTRENB 0x0008
+# define TIO_DTRNOHAND 0x0000
# define TIO_DTRHAND 0x0010
# define TIO_RTSDIS 0x0000
# define TIO_RTSENB 0x0020
+# define TIO_RTSNOHAND 0x0000
# define TIO_RTSHAND 0x0040
/* The XON/XOFF software control settings.
+ *
* XOFF disables the transmission temporarily, usually because the device at
* the other end can't manage so much data at once, whereas XON re-enables the
* transmission, probably because the device at the other end has finished
* processing the data you sent it and is ready to process some more.
- * `TIO_XONDIS`: disable XON.
- * `TIO_XONENB`: enable XON.
- * `TIO_XOFFDIS`: disable XOFF.
- * `TIO_XOFFENB`: enable XOFF.
+ *
+ * XON/XOFF software flow control can be enabled on input (XIN) and
+ * output (XOFF). The XON and XOFF characters are common to both
+ * the input and the output.
+ *
+ * `TIO_XINDIS`: disable input XON/XOFF.
+ * `TIO_XINENB`: enable input XON/XOFF.
+ * `TIO_XOUTDIS`: disable output XON/XOFF.
+ * `TIO_XOUTENB`: enable output XON/XOFF.
*
* For example, to set some XON/XOFF settings:
* `flags = (flags & ~TIO_XONXOFFMASK) | TIO_XONENB | TIO_XOFFDIS;` */
-# define TIO_XONMASK 0x0080
-# define TIO_XOFFMASK 0x0100
-# define TIO_XONXOFFMASK 0x0180
-# define TIO_XOFFXONMASK 0x0180
+# define TIO_XINMASK 0x0080
+# define TIO_XOUTMASK 0x0100
+# define TIO_XINOUTMASK 0x0180
+# define TIO_XOUTINMASK 0x0180
-# define TIO_XONDIS 0x0000
-# define TIO_XONENB 0x0080
+# define TIO_XINDIS 0x0000
+# define TIO_XINENB 0x0080
-# define TIO_XOFFDIS 0x0000
-# define TIO_XOFFENB 0x0100
+# define TIO_XOUTDIS 0x0000
+# define TIO_XOUTENB 0x0100
/* When setting the attributes, sometimes you only want to set some of
* the attributes, here are flags to control what you set.
*
* `TIO_SERIALFLAG_SPEED`: set the speed.
- * `TIO_SERIALFLAG_XON`: set the XON character and settings.
- * `TIO_SERIALFLAG_XOFF`: set the XOFF character and settings.
+ * `TIO_SERIALFLAG_XIN`: set the XON/XOFF input settings and characters.
+ * `TIO_SERIALFLAG_XOUT`: set the XON/XOFF output settings and characters.
* `TIO_SERIALFLAG_STOP`: set the stop bits.
* `TIO_SERIALFLAG_PARITY`: set the parity.
* `TIO_SERIALFLAG_DTR`: set the DTR mode.
@@ -212,13 +226,15 @@ struct tio_serial_attrs {
* `TIO_SERIALFLAG_ALL`: everything. */
# define TIO_SERIALFLAG_SPEED 1
-# define TIO_SERIALFLAG_XON 2
-# define TIO_SERIALFLAG_XOFF 4
+# define TIO_SERIALFLAG_XIN 2
+# define TIO_SERIALFLAG_XOUT 4
# define TIO_SERIALFLAG_STOP 8
# define TIO_SERIALFLAG_PARITY 16
# define TIO_SERIALFLAG_DTR 32
# define TIO_SERIALFLAG_RTS 64
+# define TIO_SERIALFLAG_XINOUT 6
+# define TIO_SERIALFLAG_XOUTIN 6
# define TIO_SERIALFLAG_ALL 127
/* ---
@@ -307,7 +323,7 @@ typedef TIO_HOOK_TYPE(int) tio_seek_t
OF((void *, tio_off_t *, tio_whence_t));
typedef TIO_HOOK_TYPE(int) tio_set_serial_attrs_t
- OF((void *, tio_serial_attrs_t const *));
+ OF((void *, tio_serial_attrs_t const *, unsigned long));
typedef TIO_HOOK_TYPE(int) tio_scsi_t
OF((void *, tio_scsi_request_t *));
@@ -369,7 +385,8 @@ TIO_BEGIN_DECLS
/* Default stream serial settings utilities. */
TIO_EXTERN(int) tio_make_serial_attrs
- OF((tio_serial_attrs_t *tio__attrs, char const *tio__raw));
+ OF((tio_serial_attrs_t *tio__attrs, char const *tio__raw,
+ unsigned long tio__flags));
/* Open and close a stream.
*
@@ -388,7 +405,8 @@ TIO_EXTERN(int) tio_open_serial
OF((tio_stream_t **tio__streamp, tio_stream_t *tio__parent,
void *tio__cookie, unsigned int tio__flags,
tio_serial_functions_t const *tio__functions,
- tio_serial_attrs_t const *tio__attrs));
+ tio_serial_attrs_t const *tio__attrs,
+ unsigned long tio__attrs_flags));
TIO_EXTERN(int) tio_open_usb
OF((tio_stream_t **tio__streamp, tio_stream_t *tio__parent,
@@ -469,11 +487,11 @@ TIO_EXTERN(int) tio_get_size
/* Set and get the serial attributes of a stream. */
TIO_EXTERN(int) tio_set_serial_attrs
- OF((tio_stream_t *tio__stream, unsigned int tio__flags,
- tio_serial_attrs_t const *tio__attrs));
+ OF((tio_stream_t *tio__stream, tio_serial_attrs_t const *tio__attrs,
+ unsigned long tio__attrs_flags));
TIO_EXTERN(int) tio_get_serial_attrs
- OF((tio_stream_t *tio__stream, unsigned int tio__flags,
- tio_serial_attrs_t *tio__attrs));
+ OF((tio_stream_t *tio__stream, tio_serial_attrs_t *tio__attrs,
+ unsigned long tio__attrs_flags));
/* Set the timeouts of a stream. */