RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Serial.h
浏览该文件的文档.
1#ifndef VRPN_SERIAL_H
2#define VRPN_SERIAL_H
3
4#include "vrpn_Configure.h" // for VRPN_API
5#include <stddef.h> // For size_t
6
7/// @file
8///
9/// @brief vrpn_Serial: Pulls all the serial port routines into one file to make
10/// porting to
11/// new operating systems easier.
12///
13/// @author Russ Taylor, 1998
14
15typedef enum {
16 vrpn_SER_PARITY_NONE,
17 vrpn_SER_PARITY_ODD,
18 vrpn_SER_PARITY_EVEN,
19 vrpn_SER_PARITY_MARK,
20 vrpn_SER_PARITY_SPACE
21} vrpn_SER_PARITY;
22
23/// @brief Open a serial port, given its name and baud rate.
24///
25/// Default Settings are 8 bits, no parity, 1 start and stop bits with no
26/// RTS (hardware) flow control. Also,
27/// set the port so that it will return immediately if there are no
28/// characters or less than the number of characters requested.
29///
30/// @returns the file descriptor on success,-1 on failure.
31extern VRPN_API int
32vrpn_open_commport(const char *portname, long baud, int charsize = 8,
33 vrpn_SER_PARITY parity = vrpn_SER_PARITY_NONE,
34 bool rts_flow = false);
35
36/// @name RTS Hardware Flow Control
37/// Set and clear functions for the RTS ("ready to send") hardware flow-
38/// control bit. These are used on a port that is already open. Some
39/// devices (like the Ascension Flock of Birds) use this to reset the
40/// device. Return 0 on success, nonzero on error.
41/// @{
42extern VRPN_API int vrpn_set_rts(int comm);
43extern VRPN_API int vrpn_clear_rts(int comm);
44/// @}
45
46extern VRPN_API int vrpn_close_commport(int comm);
47
48/// @brief Throw out any characters within the input buffer.
49/// @returns 0 on success, -1 on error.
50extern VRPN_API int vrpn_flush_input_buffer(int comm);
51
52/// @brief Throw out any characters (do not send) within the output buffer
53/// @returns 0 on success, tc err codes (whatever those are) on error.
54extern VRPN_API int vrpn_flush_output_buffer(int comm);
55
56/// @brief Wait until all of the characters in the output buffer are sent, then
57/// return.
58///
59/// @returns 0 on success, -1 on error.
60extern VRPN_API int vrpn_drain_output_buffer(int comm);
61
62/// @name Read routines
63///
64/// Read up the the requested count of characters from the input buffer,
65/// return with less if less (or none) are there. Return the number of
66/// characters read, or -1 if there is an error. The second of these
67/// will keep looking until the timeout period expires before returning
68/// (NULL pointer will cause it to block indefinitely).
69/// @{
70extern VRPN_API int
71vrpn_read_available_characters(int comm, unsigned char *buffer, size_t count);
72extern VRPN_API int vrpn_read_available_characters(int comm,
73 unsigned char *buffer,
74 size_t count,
75 struct timeval *timeout);
76/// @}
77
78/// @name Write routines
79///
80/// Write the specified number of characters. Some devices can't accept writes
81/// that
82/// are too fast, so need time between characters; the write_slowly function
83/// handles
84/// this case.
85/// @}
86extern VRPN_API int vrpn_write_characters(int comm, const unsigned char *buffer,
87 size_t bytes);
88extern VRPN_API int vrpn_write_slowly(int comm, const unsigned char *buffer,
89 size_t bytes, int millisec_delay);
90
91#endif
VRPN_API int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
VRPN_API int vrpn_open_commport(const char *portname, long baud, int charsize=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE, bool rts_flow=false)
Open a serial port, given its name and baud rate.
VRPN_API int vrpn_flush_output_buffer(int comm)
Throw out any characters (do not send) within the output buffer
VRPN_API int vrpn_drain_output_buffer(int comm)
Wait until all of the characters in the output buffer are sent, then return.