urg_serial.h
Go to the documentation of this file.
1 #ifndef URG_SERIAL_H
2 #define URG_SERIAL_H
3 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #include "urg_c/urg_detect_os.h"
18 
19 #if defined(URG_WINDOWS_OS)
20 #include <windows.h>
21 #elif defined(ANDROID)
22 #include <termios.h>
23 #define tcdrain(fd) ioctl(fd, TCSBRK, 1)
24 #else
25 #include <termios.h>
26 #include <sys/select.h>
27 #endif
28 #include "urg_ring_buffer.h"
29 
30 
31 enum {
34 
36 };
37 
38 
40 typedef struct
41 {
42 #if defined(URG_WINDOWS_OS)
43  HANDLE hCom;
44  int current_timeout;
45 #else
46  int fd;
47  struct termios sio;
48 #endif
49 
51  char buffer[RING_BUFFER_SIZE];
52  char has_last_ch;
53  char last_ch;
54 } urg_serial_t;
55 
56 
58 extern int serial_open(urg_serial_t *serial, const char *device, long baudrate);
59 
60 
62 extern void serial_close(urg_serial_t *serial);
63 
64 
66 extern int serial_set_baudrate(urg_serial_t *serial, long baudrate);
67 
68 
70 extern int serial_write(urg_serial_t *serial, const char *data, int size);
71 
72 
74 extern int serial_read(urg_serial_t *serial,
75  char *data, int max_size, int timeout);
76 
77 
79 extern int serial_readline(urg_serial_t *serial,
80  char *data, int max_size, int timeout);
81 
82 
84 extern int serial_error(urg_serial_t *serial,
85  char *error_message, int max_size);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* !URG_SERIAL_H */
serial_set_baudrate
int serial_set_baudrate(urg_serial_t *serial, long baudrate)
ボーレートを設定する
Definition: urg_serial_linux.c:91
serial_read
int serial_read(urg_serial_t *serial, char *data, int max_size, int timeout)
データを受信する
Definition: urg_serial_linux.c:193
urg_serial_t
シリアル通信用
Definition: urg_serial.h:40
RING_BUFFER_SIZE
@ RING_BUFFER_SIZE
Definition: urg_serial.h:33
serial_error
int serial_error(urg_serial_t *serial, char *error_message, int max_size)
エラー文字列を格納して返す
urg_ring_buffer.h
リングバッファ
serial_write
int serial_write(urg_serial_t *serial, const char *data, int size)
データを送信する
Definition: urg_serial_linux.c:134
urg_serial_t::last_ch
char last_ch
Definition: urg_serial.h:53
ring_buffer_t
リングバッファの管理情報
Definition: urg_ring_buffer.h:15
serial_close
void serial_close(urg_serial_t *serial)
接続を閉じる
Definition: urg_serial_linux.c:82
serial_readline
int serial_readline(urg_serial_t *serial, char *data, int max_size, int timeout)
改行までのデータを受信する
Definition: urg_serial.c:40
urg_detect_os.h
OS の検出.
serial_open
int serial_open(urg_serial_t *serial, const char *device, long baudrate)
接続を開く
Definition: urg_serial_linux.c:38
RING_BUFFER_SIZE_SHIFT
@ RING_BUFFER_SIZE_SHIFT
Definition: urg_serial.h:32
ERROR_MESSAGE_SIZE
@ ERROR_MESSAGE_SIZE
Definition: urg_serial.h:35
urg_serial_t::ring
ring_buffer_t ring
Definition: urg_serial.h:50
urg_serial_t::fd
int fd
Definition: urg_serial.h:46
urg_serial_t::has_last_ch
char has_last_ch
Definition: urg_serial.h:52


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Wed Mar 2 2022 01:08:11