get_input_register_int
This function reads an integer value from the controller input register using the specified register address. It is typically used for PLC I/O register monitoring in Ethernet-based environments.
Definition
DRFLEx.h within class CDRFLEx, public section
bool get_input_register_int(unsigned short address, int& out_val, int timeout_ms = 300) {
return _get_input_register_int(_rbtCtrl, address, &out_val, timeout_ms);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
address |
unsigned short |
Input register address (int type, 0~23) |
|
out_val |
int& |
Input integer value to read |
|
timeout_ms |
int |
300 |
Timeout in milliseconds |
Return
Value |
Description |
|---|---|
0 |
Error: failed to read input register int |
1 |
Success: input register int read |
Example
#include "DRFLEx.h"
#include <iostream>
using namespace DRAFramework;
int main() {
CDRFLEx robot;
const char* ip = "192.168.137.120";
if (!robot.open_connection(ip)) {
std::cout << "Failed to connect: " << ip << std::endl;
return 1;
}
// Read int (timeout 300 ms)
// Initialize to 0 to indicate “not read yet” if the call fails.
int out_int = 0;
robot.get_input_register_int(0, out_int, 300);
std::cout << "addr=0, out_int=" << out_int << std::endl;
robot.close_connection();
return 0;
}
This example reads the input register integer value at address 0 (Int_Input_Register[0]).