Hi members of the Symcon forum,
I am new hear and new to IP-Symcon and I trying to learn “everything” (reading a lot hear on the forum and Symcons documentation) but I am struggling a bit with the Google translations. And I have not found a script example with enough documentation that a new beginner like myself could figure out so I would appreciate some help.
I am trying to control a Sharp Aquos TV with TCP/IP control features.
For some reason the forum editor removes my padding blank spaces
The TV takes commands of 8 characters length e.g POWR?, POWR0, POWR1 etc. (commands are padded with trailing blank spaces) followed by a „\r“ (carrier return).
The string sent to the TV to see if it is powered on or off locks like this “POWR? \r”. If the TV is on it returns “1”, and if it is off it returns “0”.
The only other return messages are “OK” and “ERR’”.
When the e.g. power on command (“POWR1 \r”) is sent the TV replies with “OK” if command is successfully carried out, if not “ERR’” is replied.
The Socket connection needs to be binding or it will not be possible to determine which request is being answered.
So fare I have created a Client Socket in Symcon that connects to the TV and 2 scripts.
Script 1
<?
echo "On";
includeScript(20443 /*[Aquos]*/);
function includeScript($scriptID)
{
$s = IPS_GetScript($scriptID);
include($s['ScriptFile']);
}
?>
Script 2
<?
CSCK_SendText(37475 /*[Client Socket]*/, "POWR1 \r"); //Sends the text "Any record" on the client socket with ID 12345
?>
When I click on “On” (generated with echo „On“) in in the WebFront script 1 is run which calls script 2 that uses Client Socket (37475).
This works, the TV powers on but what do I do next? How do I take care of the return value?
Should I be using CSCK_SendText or something else? I was recommended to look at the RegisterVariable documentation but that made little sense to me (most likely do to my lack of knowledge regrding Symcon and php)
I am hoping somebody hear in the forum could give me some pointers, what to do next and where to look!
Thanks in advance.
yoggi