open_connection
This is a function for connecting with the robot controller using TCP/IP communication. As TCP/IP is internally fixed, there is no need to designate it separately. When two or more robot controllers are used, the IP address should be changed in the T/P application.
Definition
DRFLEx.h within class CDRFLEx, public section (line 572)
bool open_connection(string strIpAddr = "192.168.137.100", unsigned int usPort= 12345) { return _open_connection(_rbtCtrl, strIpAddr.c_str(), usPort); };
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
strIpAddr |
string |
“192.168.137.100” |
Controller IP address to connect. |
Return
Value |
Type |
Description |
|---|---|---|
0 |
int |
Error — failed to establish a TCP/IP connection. |
1 |
int |
Success — successfully connected to the controller. |
Example
CDRFLEx drfl;
bool bConnected = drfl.open_connection("192.168.137.100");
if (bConnected) {
SYSTEM_VERSION tSysVerion = { '\0', };
DrFl.get_system_version(&tSysVerion);
cout << "System version: " << tSysVerion._szController << endl;
}
This example connects the external PC to the robot controller using its IP address. When the connection is successful, it retrieves and prints the controller’s system version information.