Page 1 of 1

TerraController

PostPosted: Fri Nov 01, 2019 12:10 pm
by tomavc
Has anybody succesfully controlled the TerraController with WD 6.1.0?
According to the Terra external control protocol I setup a tcp connection with port 23456 and the JSON command to apply a layout should be {"jsonrpc": "2.0", "method": "applylayoutbyname", "params": { "name": "LAYOUTNAME" }, "id": 1}.
When I send Tcpsend (1,"{"jsonrpc": "2.0", "method": "applylayoutbyname", "params": { "name": "LAYOUTNAME" }, "id": 1}") where "name" is the requested layout name the TerraController does not respond. Also when I try the JSON tester eg 192.168.50.130/jsontest the JSON tester appears but the command dropdownlist is empty.
Any suggesions?

Re: TerraController

PostPosted: Sat Nov 02, 2019 8:24 pm
by Justyn Roy
Hi!

Yes, I have a project or two using 6.0.1 and Terra.

There appear to be three issues here.

The first:
You need to send "[CR][LF]" at the end of your command.


Second - pay attention to your Quotation marks here:

You've properly put in TCPSend(1,"Command here") BUT - what is important, because this is JSON, we NEED to send the proper quotation marks downstream.
When you use double quotes in your Widget Command, you're starting and stopping your JSON string.
Instead, you need single quotes in the Widget Command to keep the double quotes in the JSON string in tact:

Code: Select all
Tcpsend(1,'{"jsonrpc": "2.0", "method": "applylayoutbyname", "params": { "name": "LAYOUTNAME" }, "id": 1}')



Third, you say "name" is the requested layout - this is the JSON Object that the Terra is calling, if you change "name", it won't be able to parse the "name" object location.
You need to change "LAYOUTNAME" to your layout name.

This way, the Terra will first see the Object location "method", which in this case is "applylayoutbyname".
Now Terra knows it only needs one object to complete this command - and it's looking for an object called "name".

As a note, the "id" integer at the end can be anything integer you want it to be, this is useful for parsing any returns/responses from the Terra.


Happy Widgeting!

Re: TerraController

PostPosted: Sun Nov 03, 2019 8:26 pm
by tomavc
Hi Justyn.

Thanks for your reply and good to hear that it can work but...
I changed the quotation marks and added [CR][LF] inside the curly brackets like this:
Tcpsend(2, ' {"jsonrpc etc....."id": 1, "[CR][LF]"} ')
But no switching and the TCP input node gives this response from the controller:
{"jsonrpc":"2.0","id":null,"error": {"code":-32700,"message":"Parse Error"}}

The jsontester is working now and changes layouts as expected.

Where do I go wrong?

Rutger Flierman
NO&B Amsterdam

Re: TerraController

PostPosted: Wed Nov 06, 2019 5:16 pm
by tomavc
Hi Justyn,

it's working finally.
In WD 4.7 the Tcpsend command is more easy because there are no quotation marks needed.
The commands looks like this: Tcpsend.1.{"jsonrpc": "2.0", "method": "applylayoutbyname", "params": { "name": "LAYOUTNAME" }, "id": 1}') [CR][LF]

The Terra JSON manual is confusing because regarding the "layout by name command" the manual says that "name" is the name of the layout to be applied....

Happy Widgeting indeed :)

Re: TerraController

PostPosted: Sun Nov 10, 2019 2:31 am
by Justyn Roy
Great news that you have it working.

Yes, you're right, the syntax in Widget V4 is different than in V6.

I had assumed you were using V6 as you are posting in the V6 thread of this forum.

I'm happy it's working and that the manual is making more sense to you now.


Cheers!