urg_connection.c
Go to the documentation of this file.
1 
10 #include "urg_c/urg_connection.h"
11 
12 
14  urg_connection_type_t connection_type,
15  const char *device, long baudrate_or_port)
16 {
17  connection->type = connection_type;
18 
19  switch (connection_type) {
20  case URG_SERIAL:
21  return serial_open(&connection->serial, device, baudrate_or_port);
22  break;
23 
24  case URG_ETHERNET:
25  return tcpclient_open(&connection->tcpclient,
26  device, baudrate_or_port);
27  break;
28  }
29  return -1;
30 }
31 
32 
34 {
35  switch (connection->type) {
36  case URG_SERIAL:
37  serial_close(&connection->serial);
38  break;
39 
40  case URG_ETHERNET:
41  tcpclient_close(&connection->tcpclient);
42  break;
43  }
44 }
45 
46 
47 int connection_set_baudrate(urg_connection_t *connection, long baudrate)
48 {
49  int ret = -1;
50 
51  switch (connection->type) {
52  case URG_SERIAL:
53  ret = serial_set_baudrate(&connection->serial, baudrate);
54  break;
55 
56  case URG_ETHERNET:
57  ret = 0;
58  break;
59  }
60 
61  return ret;
62 }
63 
64 
66  const char *data, int size)
67 {
68  switch (connection->type) {
69  case URG_SERIAL:
70  return serial_write(&connection->serial, data, size);
71  break;
72  case URG_ETHERNET:
73  return tcpclient_write(&connection->tcpclient, data, size);
74  break;
75  }
76  return -1;
77 }
78 
79 
81  char *data, int max_size, int timeout)
82 {
83  switch (connection->type) {
84  case URG_SERIAL:
85  return serial_read(&connection->serial, data, max_size, timeout);
86  break;
87  case URG_ETHERNET:
88  return tcpclient_read(&connection->tcpclient, data, max_size, timeout);
89  break;
90  }
91  return -1;
92 }
93 
94 
96  char *data, int max_size, int timeout)
97 {
98  switch (connection->type) {
99  case URG_SERIAL:
100  return serial_readline(&connection->serial, data, max_size, timeout);
101  break;
102  case URG_ETHERNET:
103  return tcpclient_readline(&connection->tcpclient,
104  data, max_size, timeout);
105  break;
106  }
107  return -1;
108 }
int connection_write(urg_connection_t *connection, const char *data, int size)
���M
int serial_write(urg_serial_t *serial, const char *data, int size)
�f�[�^�𑗐M����
�C�[�T�[�l�b�g�ڑ�
urg_connection_type_t
�ʐM�^�C�v
int connection_read(urg_connection_t *connection, char *data, int max_size, int timeout)
��M
int tcpclient_readline(urg_tcpclient_t *cli, char *userbuf, int buf_size, int timeout)
read one line from socket.
int tcpclient_write(urg_tcpclient_t *cli, const char *userbuf, int req_size)
write to socket.
int serial_set_baudrate(urg_serial_t *serial, long baudrate)
�{�[���[�g��ݒ肷��
void tcpclient_close(urg_tcpclient_t *cli)
destructor of tcp client module
int connection_open(urg_connection_t *connection, urg_connection_type_t connection_type, const char *device, long baudrate_or_port)
�ڑ�
void serial_close(urg_serial_t *serial)
�ڑ���‚���
urg_serial_t serial
�V���A���ڑ�
int connection_set_baudrate(urg_connection_t *connection, long baudrate)
�ʐM�̏���
int serial_open(urg_serial_t *serial, const char *device, long baudrate)
�ڑ����J��
int tcpclient_read(urg_tcpclient_t *cli, char *userbuf, int req_size, int timeout)
read from socket.
int serial_readline(urg_serial_t *serial, char *data, int max_size, int timeout)
���s�܂ł̃f�[�^����M����
Definition: urg_serial.c:40
void connection_close(urg_connection_t *connection)
�ؒf
int tcpclient_open(urg_tcpclient_t *cli, const char *server_ip_str, int port_num)
constructor of tcp client module
Definition: urg_tcpclient.c:67
int serial_read(urg_serial_t *serial, char *data, int max_size, int timeout)
�f�[�^����M����
urg_connection_type_t type
�ڑ��^�C�v
�ʐM���\�[�X
int connection_readline(urg_connection_t *connection, char *data, int max_size, int timeout)
���s�����܂ł̎�M
urg_tcpclient_t tcpclient
�C�[�T�[�l�b�g�ڑ�
�V���A��, USB �ڑ�


urg_c
Author(s): Satofumi Kamimura , Katsumi Kimoto, Adrian Boeing
autogenerated on Thu Jun 6 2019 19:27:49