Interacting with Modbus device class
I am trying to develop a Tango device server in C ++ to interact with the Modbus class (http://www.tango-controls.org/developers/dsc/ds/318/).
The Tango device server I am developing has several scalar and spectrum attributes. When I read or write an attribute, I want to send a request to the Modbus device to execute the corresponding command. When receiving an answer, the attribute must accept the value read by Modbus.
I created class data member
modbusDevice - name of Modbus device server.
To execute any command I should use command_inout ():
For Modbus device commands such as ReadHoldingRegisters, ReadInputRegisters, PresetSingleRegister, PresetMultipleRegisters, the input argument is DevVarShortArray.
But I don't understand how to transfer DevVarShortArray using command_input().
Can someone give an example of this using command_inout () or suggest another way to interact with a Modbas device?
To send a DevVarShortArray, try this :
// command_inout requires a Tango::DeviceData and get a tango::Device data
// your argin / argout
const Tango::DevVarShortArray* answer;
// Setting parameters
argToSend = 0; // send 0 and 100 as argument
argToSend = 100;
// Put your DevVarShortArray into Tango::DeviceData
answerReadHoldingRegisters= ModbusDeviceServer->command_inout("ReadHoldingRegisters", argToSendReadHoldingRegisters);
// Get answer
answerReadHoldingRegisters >> answer;
Hope it helps.
For information, you have documentation on your Tango_root that is very hepful.
Thank you very much for your answer! You helped me a lot!