Hello,
Working on MODBUS communication and want to set value for two bytes in Parameter 2000 from QAction with protocol.SetParameter(2000,Val),. If this Prameter would be static it looks like this:
<Param id="2000">
<Name>Adres TempW2</Name>
<Description>Adres of TempW2</Description>
<Type>fixed</Type>
<Interprete>
<RawType>other</RawType>
<LengthType>fixed</LengthType>
<Length>2</Length>
<Value>0x000x11</Value>
</Interprete>
</Param>
What type must be variable Val (string, int, double…), how to calculate its value and how must be set xml tags in Param id="2000"?
<Param id="2000">
<Name>Adres TempW2</Name>
<Description>Adres of TempW2</Description>
<Type>?</Type>
<Interprete>
<RawType>?</RawType>
<LengthType>fixed</LengthType>
<Length>2</Length>
</Interprete>
</Param>
Thank you!
Hi,
This can be done by defining the parameter like this:
<Param id="2000">
<Name>Adres TempW2</Name>
<Description>Adres of TempW2</Description>
<Type>read</Type>
<Interprete>
<RawType>unsigned number</RawType>
<LengthType>fixed</LengthType>
<Length>2</Length>
<Type>double</Type>
</Interprete>
</Param>
In the QAction this can then be filled in like this:
int adresValue = 268;
protocol.SetParameter(2000, adresValue);
In the StreamViewer the communication will then look like this:
<< 08:01:52 - Send Command
000000 0C01
As you can see this is probably not as expected, as decimal value 268 is 0x010C and the StreamViewer is showing the bytes reversed. This is because by default little endian is used. So the little end (least significant byte) is sent first followed by the more significant.
How can this behavior be changed? This can be done by changing the endian to big (send big end (=most significant byte) first) and can be done in the interprete:
<Interprete>
<RawType>unsigned number</RawType>
<LengthType>fixed</LengthType>
<Length>2</Length>
<Type>double</Type>
<Endian>big</Endian>
</Interprete>
The StreamViewer will then look like this, which is more like expected:
<< 08:02:17 - Send Command
000000 010C
When looking at the behavior that is being described it seems to be pointing that the command is not being made. This means that either the value is filled in after the command has been made or the make command action is not executed at all.
Would it be possible as a test to add the following:
Before Command
command
before
action
2000
Make Command
command
make
With the used id 2000 then being the correct id of the command that is being used in the driver.
Please make sure that the value is filled in by the qaction before the group is executed.
Seems like I’m not able to reply with tags in the comments. Trying to reply now by replacing the “greater than” and “less than” characters with a single quote
‘Trigger id=”2000″‘
‘Name’Before Command’/Name’
‘On id=”2000″‘command’/On’
‘Time’before’/Time’
‘Type’action’/Type’
‘Content’
‘Id’2000’/Id’
‘/Content’
‘/Trigger’
‘Action id=”2000″‘
‘Name’Make Command’/Name’
‘On id=”2000″‘command’/On’
‘Type’make’/Type’
‘/Action’
It works perfect now! I added your “trigger” and “action”!
Without yours adds had:
1. QA which triggers on parameter,
2. In QA set value in parameter for command and set value in another parameter for trigger which invoke action to execute group with pair in which is command and response.
Obviously this is not enough…
With respect, thank you!
Hi, I’m glad to see that it’s working. To avoid having to create triggers and actions for every command, the trigger could have On id=”each” command and then remove the id attribute in the On tag of the make action. This way the make action will be executed for every command that will be sent. For more information about the behavior of commands, please check the DataMiner help on this location https://help.dataminer.services/development/#t=DataMinerDevelopmentLibrary_Customerpart1PDGPDGConnectionsCreating_commands_and_responses.htm and look for the section “makeCommandByProtocol”
Thank you. Try it but not works in our Dataminer.
<< 11:38:04 – Set_ON_T_OnLD
000000 0000000000 06010618C0 0000
Last four bits (LSB) are bits from parameter which is set with QA.
From QA sent integer number 268 and result is 0000. The results are always the same. When change "raw type" from unsigned number to "other" result is always 2020. We use VS2015 professional with 4.6.2 framework, DIS 2.31.1.21 and DMA 10.0.0.0 9449.