use remote-utils facilities for baud_rate
[deliverable/binutils-gdb.git] / gdb / serial.h
index 630ed43b1f9712cc10983fa99f1b2057a8d470b9..84916d32306d5e0e811b0bb171f0f80d7581db00 100644 (file)
@@ -42,6 +42,8 @@ struct serial_ops {
   int (*readchar) PARAMS ((serial_t, int timeout));
   int (*write) PARAMS ((serial_t, const char *str, int len));
   int (*flush_output) PARAMS ((serial_t));
+  int (*flush_input) PARAMS ((serial_t));
+  int (*send_break) PARAMS ((serial_t));
   void (*go_raw) PARAMS ((serial_t));
   serial_ttystate (*get_tty_state) PARAMS ((serial_t));
   int (*set_tty_state) PARAMS ((serial_t, serial_ttystate));
@@ -72,11 +74,23 @@ serial_t serial_fdopen PARAMS ((int fd));
 
 #define SERIAL_FDOPEN(FD) serial_fdopen(FD)
 
-/* Flush pending output.  */
+/* Flush pending output.  Might also flush input (if this system can't flush
+   only output).  */
 
 #define SERIAL_FLUSH_OUTPUT(SERIAL_T) \
   ((SERIAL_T)->ops->flush_output((SERIAL_T)))
 
+/* Flush pending input.  Might also flush output (if this system can't flush
+   only input).  */
+
+#define SERIAL_FLUSH_INPUT(SERIAL_T)\
+  ((*(SERIAL_T)->ops->flush_input) ((SERIAL_T)))
+
+/* Send a break between 0.25 and 0.5 seconds long.  */
+
+#define SERIAL_SEND_BREAK(SERIAL_T) \
+  ((*(SERIAL_T)->ops->send_break) (SERIAL_T))
+
 /* Turn the port into raw mode. */
 
 #define SERIAL_RAW(SERIAL_T) (SERIAL_T)->ops->go_raw((SERIAL_T))
@@ -102,9 +116,10 @@ serial_t serial_fdopen PARAMS ((int fd));
   ((*((SERIAL_T)->ops->noflush_set_tty_state)) \
     ((SERIAL_T), (NEW_TTYSTATE), (OLD_TTYSTATE)))
 
-/* Read one char from the serial device with TIMEOUT seconds timeout.
-   Returns char if ok, else one of the following codes.  Note that all
-   error codes are guaranteed to be < 0.  */
+/* Read one char from the serial device with TIMEOUT seconds to wait
+   or -1 to wait forever.  Use timeout of 0 to effect a poll. Returns
+   char if ok, else one of the following codes.  Note that all error
+   codes are guaranteed to be < 0.  */
 
 #define SERIAL_ERROR -1                /* General error, see errno for details */
 #define SERIAL_TIMEOUT -2
@@ -117,8 +132,8 @@ serial_t serial_fdopen PARAMS ((int fd));
 
 #define SERIAL_SETBAUDRATE(SERIAL_T, RATE) ((SERIAL_T)->ops->setbaudrate((SERIAL_T), RATE))
 
-/* Write LEN chars from STRING to the port SERIAL_T.  Returns 0 for success,
-   -1 for failure.  */
+/* Write LEN chars from STRING to the port SERIAL_T.  Returns 0 for
+   success, non-zero for failure.  */
 
 #define SERIAL_WRITE(SERIAL_T, STRING, LEN) ((SERIAL_T)->ops->write((SERIAL_T), STRING, LEN))
 
This page took 0.024011 seconds and 4 git commands to generate.