Interacting with Modbus device class
|
|
---|---|
Hello everyone. 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? Regards, Aleksei |
|
|
---|---|
Hi Aleksei, To send a DevVarShortArray, try this : // command_inout requires a Tango::DeviceData and get a tango::Device data Tango::DeviceData argToSendReadHoldingRegisters; Tango::DeviceData answerReadHoldingRegisters; // your argin / argout Tango::DevVarShortArray argToSend; const Tango::DevVarShortArray* answer; // Setting parameters argToSend.length(2); argToSend[0] = 0; // send 0 and 100 as argument argToSend[1] = 100; // Put your DevVarShortArray into Tango::DeviceData argToSendReadHoldingRegisters<< argToSend; // Send 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. Regards, Florian Pourchayre Thales Group |
|
|
---|---|
Hi Florian, Thank you very much for your answer! You helped me a lot! Regards, Aleksei |