18 #ifndef PRBT_HARDWARE_SUPPORT_PILZ_MODBUS_SERVER_MOCK_H 19 #define PRBT_HARDWARE_SUPPORT_PILZ_MODBUS_SERVER_MOCK_H 26 #include <condition_variable> 28 #include <modbus/modbus.h> 53 void start(
const char* ip,
const unsigned int port);
63 void startAsync(
const char* ip,
const unsigned int port);
65 void setHoldingRegister(std::initializer_list<std::pair<unsigned int, uint16_t> > reg_list);
102 bool init(
const char* ip,
unsigned int port);
165 ROS_DEBUG_NAMED(
"ServerMock",
"Waiting for worker Thread of ServerMock to be joined.");
167 ROS_DEBUG_NAMED(
"ServerMock",
"Waiting for worker Thread of ServerMock joined.");
177 #endif // PRBT_HARDWARE_SUPPORT_PILZ_MODBUS_SERVER_MOCK_H #define ROS_INFO_NAMED(name,...)
Offers a modbus server and read/write functionality via subscription/publication. ...
bool init(const char *ip, unsigned int port)
Allocates needed resources for running the server.
std::vector< uint16_t > RegCont
Convenience data type defining the data type for a collection of registers.
RegCont readHoldingRegister(const RegCont::size_type start_index, const RegCont::size_type num_reg_to_read)
Reads the specified number of registers, beginning at the specified start point from the holding regi...
void startAsync(const char *ip, const unsigned int port)
Start the modbus server asynchronously and make it accessible for clients.
const unsigned int terminate_register_idx_
Index of register for server shutdown signal.
void setHoldingRegister(std::initializer_list< std::pair< unsigned int, uint16_t > > reg_list)
std::mutex modbus_register_access_mutex
std::condition_variable running_cv_
const unsigned int holding_register_size_
void run()
Run the server and publish the register values as messages. The value of the modbus register is read ...
static constexpr uint32_t DISCONNECT_TIMEOUT_IN_SEC
#define ROS_DEBUG_NAMED(name,...)
std::atomic_bool terminate_
static constexpr uint32_t RESPONSE_TIMEOUT_IN_USEC
void terminate()
Terminate the Server. Reading or connecting to it will fail.
static constexpr uint32_t RESPONSE_TIMEOUT_IN_SEC
modbus_mapping_t * mb_mapping_
void start(const char *ip, const unsigned int port)
Start the modbus server and make it accessible for clients.
modbus_t * modbus_connection_
bool shutdownSignalReceived()
static constexpr uint16_t TERMINATE_SIGNAL
Register value which indicates that server has to shutdown.
std::mutex running_mutex_
static constexpr uint32_t DISCONNECT_TIMEOUT_IN_USEC
PilzModbusServerMock(const unsigned int &holding_register_size)