Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Socket Commands Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: February 16 2018 at 12:38 | IP Logged Quote smarty

[Solved - See below]
I have set up a PH_Socket.phsocket plugin (called
"TV1") to send commands directly to my new SONY XBR TV
(the TV has both serial and IP control). I have it
set up in the plugins area - full initialization data
(192.168.0.135 20060).

Through a utility program called "Packet Sender", I
send a TCP packet that looks like
(ASCII): *SEPOWR################\n

The TV then sends a response that looks like:
(ASCII): *SAPOWR0000000000000000\n
.........

I am trying to replicate this with the ph_picmd. This
is what I have tried:

ph_picmd(2,"TV1",1,0,0,"*SEPOWR################","")
ph_picmd(2,"TV1",1,0,0,"*SEPOWR################\013","
")
ph_picmd(2,"TV1",1,0,0,"*SEPOWR################\n","")

The formula executes (no error), but I don't see the
TV respond or the generic plugin trigger (command 1,
option 1) fire.

I think it may have something to do with the leading
asterisk, or the trailing carriage return that is on
the command.

It works with Packet Sender, but not PH. Ideas?


Edited by smarty - February 18 2018 at 07:41


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: February 17 2018 at 06:52 | IP Logged Quote smarty

[Solved - See below]

Also tried (this "00" command is for "Power Off"):

\042 = *
\013 = cr

ph_picmd(2,"ATV",1,0,0,"\042"+"2SCPOWR0000000000000000
"+"\013","")

I have verfied that the plugin is connected to the
right IP and port via:

ph_picmd(2,"ATV",5,0,0,"","") and
ph_picmd(2,"ATV",6,0,0,"","")

From the "Packet Sender" program, I was able to
capture/copy and paste this:


Time: 9:25:51.504 am
TO: 192.168.0.135:20060
From: You:51421
Method: TCP
Error:

ASCII:
*SCPOWR0000000000000001\n<CR><LF>


HEX:
2a 53 43 50 4f 57 52 30 30 30 30 30 30 30 30 30 30 30
30 30 30 30 31 0a 3c 43 52 3e 3c 4c 46 3e


The above works (from Packet Sender). Now to get PH
to replicate it.

Edited by smarty - February 18 2018 at 07:42


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: February 18 2018 at 07:50 | IP Logged Quote smarty

Update:
It appears that special character handling is the
issue.

The following command works:
ph_sendsocketdata1("192.168.0.135",20060,2,"*SCPOWR000
0000000000001\010")

This variation doesn't work:
ph_sendsocketdata1("192.168.0.135",20060,1,"*SCPOWR000
0000000000001\010")

The socket plugin ph_picmd below DOESN'T work:
ph_picmd(2,"ATV",1,0,0,"*2SCPOWR0000000000000000\010"
,"")

The issues appears to be the chararater handling of
the "/010" (line feed).

If I can't use the raw socket plugin (and its
associated generic plugin trigger), what trigger can
be used when my TV responds back?

Edited by smarty - February 18 2018 at 07:51


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: February 18 2018 at 18:18 | IP Logged Quote dhoward

Steve,

I took a look at the source code for the PH socket plugin and it doesnt provide any "escape" character handling on the sending of data. What
this means is that you'll have to embed any special characters directly into the string that you're sending from PowerHome using the PH escape
characters.

For a newline, this will be "~n". A carriage return is "~r". A carriage return / line feed pair would look like this: "~r~n". You can also
create any character by using the tilde followed by a 3 digit ASCII character code. So a line feed can also be represented as "~010". You can
also use hex if you prefer like this: "~h0a".

So, I believe the following will be the command you're looking for:

ph_picmd(2,"ATV",1,0,0,"*2SCPOWR0000000000000000~n","")

Hope this helps,

Dave.


Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: February 20 2018 at 06:53 | IP Logged Quote smarty

Dave,
   Perfect! THANK YOU SO MUCH!

Yes, the "~n" was what I was needing to get the raw socket plugin to execute properly.

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum