Manually get unipi(/TCP Modbus) data
-
The issue at hand is that I don't know how to retreive data from the defaultConnections created with the IDE.
The HMI creates UI's for this and has some way to parse the binary data returned by the service calls.My question is how I could do the same?
So I call:
127.0.0.1/api.cgi
with POST data{"ver":1,"v":["svc://DefaultConnection/916[0,1]]}
This returns
{ "ver": 1, "code": "ok", "msg": "", "v": [ { "i": "svc://DefaultConnection/916[0,1]", "v": "41CD7936", "q": "good", "t": 636586125890000000 } ] }
How can I parse this result into the actual data?
Or even better, is there another way of retrieving this data?Thanks
-
Hi @lesliejobse!
Apologies for the somewhat belated reply. Mervis API replies are based on the sscp protocol; as you probably have figured out already, the "916" is the SSCP id of the variable. You can read these in a plaintext format from a file with the name [project hash].vlist, which should be in your IDE project folder.
The SSCP ids can be regenerated under certain conditions (the IDE will show a warning when it happens), but they should not be recycled - i.e. your variable can potentially move to a different id if you change its type (or size) in the IDE, but the old id should simply remain invalid, rather than point to another value. This is obviously important if you need to make minor changes to the ST/FBD progam itself.
In the reply contents the variables correspond to the following:
i - the variable id, along with the connection path
v - the variable value in hexadecimal (your value looks like a 32bit float of 25,6, based on the converter here: http://www.binaryconvert.com/result_float.html?hexadecimal=41CD7936)
q - whether the value is current. this will contain a fault code if due to a communication error the data isn't current (you will receive the data which has been read last)
t - time in the windows time format, which corresponds to the time when the value was acquired by Mervis from the HWThere are other means of retrieving the data, but in most respects they are all similar. This is also really the only secure way that the data can be exposed from Mervis.
Kind Regards,
Tom -
Would you be willing to share a screenshot of the page if you do make an interesting HMI outside of the generated one? We are very keen to see what people can do with the Mervis HM interface.