I am currently working on an Android app where I am trying to send a command with the Tango rest API. Until now, I have sent commands with only 0 or 1 parameters and I didn’t experience any problem. However, I now need to send a command which has two parameters (and perhaps more later), and the command isn’t received by my device server.
When I send the command, I receive a failure with the following JSON response :
{"errors":[{"reason":"TangoApi_CANNOT_EXECUTE_COMMAND","description":"Cannot execute command SetVoltage on SAGA_NG_001\/Laser_NG\/1","severity":"PANIC","origin":"Connection.command_inout()"},{"reason":"COMMAND_TO_EQUIPMENT_FAILED","description":" - result = 3\n","severity":"ERR","origin":"EquipmentLaser_NG::psSetVoltage"}],"quality":"FAILURE","timestamp":1624269539928}
{"reason":"TangoApi_CANNOT_EXECUTE_COMMAND","description":"Cannot execute command SetVoltage on SAGA_NG_001\/Laser_NG\/1","severity":"PANIC","origin":"Connection.command_inout()"}
{"reason":"COMMAND_TO_EQUIPMENT_FAILED","description":" - result = 3\n","severity":"ERR","origin":"EquipmentLaser_NG::psSetVoltage"}
I send the command with the following uri : “http://:8844/tango/rest/rc4/hosts/127.0.0.1/20000/devices/SAGA_NG_001/Laser_NG/1/commands/SetVoltage”
I don’t see in the previous JSON response what is the reason for the command to not be able to be executed.
Here are some points that could be importants :
I am using rest server rc4-0.1. I tried to switch to the rest server 1.22 by replacing the .jar file but I haven’t been able to make it work.
If I send the same commands, but with no or one parameter, they are also not received by the device. I don’t understand this behaviour, as I think that the device should receive the command and throw an error while parsing the parameters (because there are some missing parameters). However, when I put no or one parameter, I don’t receive the previous JSON response, but instead of that I get a failure with no JSON and the following message : “java.io.EOFException: No content to map to Object due to end of input”.
I think that the problem is linked to the commands who take 2 parameters, not to the parameters itself.
Do you have any idea about the reason of my problem ?
With the old jar, there was only the “rc4” key, so the new jar is successfully launched. However, when I go to “http://:8844/tango/rest/rc4/hosts”, I have the following error, and I have the same issue with “v10” and “v11” :
JSON {"errors":[{"reason":"No Tango host was specified","description":"","severity":"","origin":"org.tango.web.server.providers.TangoDatabaseProvider.filter(TangoDatabaseProvider.java:69)"}],"quality":"FAILURE","timestamp":1624028816045}
My TANGO_HOST environment variable is correctly set and I also give the tango host in parameter when I launch the jar. Here is my bat command for launching the jar :
bat start java -jar -DTANGO_HOST=127.0.0.1:20000 rest-server-1.22.jar test
[edit] : in order to run the 1.22 jar, I needed to update my Java Runtime. I installed the OpenJDK11.
Since some version rest-server does not have any default hosts, so you have to specify one in the URL e.g. “http://:8844/tango/rest/v11/hosts/localhost;port=20000”. Please note port matrix parameter, you need this to specify non-default Tango host port in v1.0&v1.1 or using old syntax “http://:8844/tango/rest/rc4/hosts/localhost/20000” for rc4
Commands should work when you pass an array. Are you able to execute those commands without REST api?
Indeed, with the url formatted as you said, I am able to browse my Tango database in v1.1 using Firefox. However it seems that the API I use for the REST communication can’t parse the response from the new version. After sending the command, in rc4 I get no error, in v11 I get :
For your second question : yes, these commands work with non-REST API and also on AtkPanel
The command takes a DevVarUShortArray. I tried all the following syntaxes to give the parameters, which all result to the same issue :
“[0,1]”, “0,1”, “{0,1}”, “(0,1)”
I couldn’t find the documentation of the REST API from the gitHub repository, the link at the end of your message helped me a lot.
I have been able to reproduce with a REST client the issue I had in V11 with my Android app (the com.google.gson.JsonParseException) : it is the response we get when “host” and “name” parameters are missing.
With the REST client I use for testing, I’ve been able to succesfully send the command with 2 parameters. I’ll let you know if this also works with my Android app, but I’m pretty confident that it will work
Thanks you for the link pgoryl, so it seems like there are 2 differents links for the same documentation (here and here)
Coming back to my Android app, I had a few issues to make my Android app work with the new 1.22 jar but it is finally working ! Thank you for your help