35 lines
903 B
C++
Executable File
35 lines
903 B
C++
Executable File
#include <ros/ros.h>
|
|
#include <boost/thread.hpp>
|
|
#include "delta_modbus/delta_modbus_tcp.h"
|
|
#include <diagnostic_msgs/DiagnosticArray.h>
|
|
|
|
|
|
/**********************************************************************
|
|
* MAIN
|
|
***********************************************************************/
|
|
int main(int argc, char** argv) {
|
|
ros::init(argc, argv, "test_delta_modbus_tcp");
|
|
ros::NodeHandle nh("~");
|
|
|
|
std::string node_name = ros::this_node::getName();
|
|
ROS_INFO("node_name: %s", node_name.c_str());
|
|
|
|
DELTA_NAMESPACE::PLC *plc = NULL;
|
|
|
|
std::string IP = "192.168.1.5";
|
|
int PORT = 502;
|
|
|
|
plc = new DELTA_NAMESPACE::PLC(IP, PORT);
|
|
plc->connect();
|
|
|
|
uint16_t D101;
|
|
bool M[2];
|
|
plc->getD(1, D101); plc->mulGetM(1, 2,M);
|
|
ROS_INFO("D1 %d M1 %x %x", D101, M[0], M[1]);
|
|
|
|
ros::spin();
|
|
plc = NULL;
|
|
delete(plc);
|
|
return 0;
|
|
}
|