connect.cc
Go to the documentation of this file.
1 /* Copyright 2017 UFACTORY Inc. All Rights Reserved.
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Author: Jimy Zhang <jimy92@163.com>
6  ============================================================================*/
7 #include "xarm/core/connect.h"
8 
12 #include "xarm/core/xarm_config.h"
13 
15  SerialPort *arm_port = new SerialPort(com, XARM_CONF::SERIAL_BAUD, 3, 128);
16  if (arm_port->is_ok() != 0) {
17  printf("Error: Serial RS485 connection failed\n");
18  return NULL;
19  }
20  UxbusCmdSer *arm_cmd = new UxbusCmdSer(arm_port);
21  printf("Serial RS485 connection successful\n");
22  return arm_cmd;
23 }
24 
25 UxbusCmdTcp *connect_tcp_control(char *server_ip) {
26  SocketPort *arm_port =
27  new SocketPort(server_ip, XARM_CONF::TCP_PORT_CONTROL, 3, 128);
28  if (arm_port->is_ok() != 0) {
29  printf("Error: Tcp Control connection failed\n");
30  return NULL;
31  }
32  UxbusCmdTcp *arm_cmd = new UxbusCmdTcp(arm_port);
33  printf("Tcp Control connection successful\n");
34  return arm_cmd;
35 }
36 
38  SocketPort *arm_report =
39  new SocketPort(server_ip, XARM_CONF::TCP_PORT_REPORT_NORM, 5, 149); // 145 + 4
40  if (arm_report->is_ok() != 0) {
41  printf("Error: Tcp Report Norm connection failed, ip: %s\n", server_ip);
42  return NULL;
43  }
44  printf("Tcp Report Norm connection successful\n");
45  return arm_report;
46 }
47 
49  SocketPort *arm_report =
50  new SocketPort(server_ip, XARM_CONF::TCP_PORT_REPORT_RICH, 5, 512);
51  if (arm_report->is_ok() != 0) {
52  printf("Error: Tcp Report Rich connection failed\n");
53  return NULL;
54  }
55  printf("Tcp Report Rich connection successful\n");
56  return arm_report;
57 }
58 
60  SocketPort *arm_report =
61  new SocketPort(server_ip, XARM_CONF::TCP_PORT_REPORT_DEVL, 10, 91); // 87 + 4
62  if (arm_report->is_ok() != 0) {
63  printf("Error: Tcp Report develop connection failed\n");
64  return NULL;
65  }
66  printf("Tcp Report develop connection successful\n");
67  return arm_report;
68 }
69 
70 SocketPort *connect_tcp_report(char *server_ip, std::string report_type) {
71  if (report_type == "dev")
72  return connect_tcp_report_devl(server_ip);
73  else if (report_type == "rich")
74  return connect_tcp_report_rich(server_ip);
75  else
76  return connect_tcp_report_norm(server_ip);
77 }
static const int TCP_PORT_REPORT_RICH
Definition: xarm_config.h:21
static const int TCP_PORT_CONTROL
Definition: xarm_config.h:19
SocketPort * connect_tcp_report(char *server_ip, std::string report_type)
Definition: connect.cc:70
int is_ok(void)
Definition: socket.cc:118
static const int TCP_PORT_REPORT_DEVL
Definition: xarm_config.h:22
SocketPort * connect_tcp_report_devl(char *server_ip)
Definition: connect.cc:59
static const int TCP_PORT_REPORT_NORM
Definition: xarm_config.h:20
UxbusCmdTcp * connect_tcp_control(char *server_ip)
Definition: connect.cc:25
static const int SERIAL_BAUD
Definition: xarm_config.h:18
UxbusCmdSer * connect_rs485_control(const char *com)
Definition: connect.cc:14
SocketPort * connect_tcp_report_rich(char *server_ip)
Definition: connect.cc:48
int is_ok(void)
Definition: ser.cc:85
Definition: ser.h:17
SocketPort * connect_tcp_report_norm(char *server_ip)
Definition: connect.cc:37


xarm_api
Author(s):
autogenerated on Sat May 8 2021 02:51:23