| Author | 
         | 
          
      
        
         
         smarty Super User 
          
  
  Joined: May 21 2006 Location: United States
 Online Status: Offline Posts: 729
          | 
        
         
          
           | Posted: February 16 2018 at 12:38 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
[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 | 
         
          
         | 
        
       
       
        |   | 
       
        
         
         smarty Super User 
          
  
  Joined: May 21 2006 Location: United States
 Online Status: Offline Posts: 729
          | 
        
         
          
           | Posted: February 17 2018 at 06:52 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
[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 | 
         
          
         | 
        
       
       
        |   | 
       
        
         
         smarty Super User 
          
  
  Joined: May 21 2006 Location: United States
 Online Status: Offline Posts: 729
          | 
        
         
          
           | Posted: February 18 2018 at 07:50 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
         | 
        
       
       
        |   | 
       
        
         
         dhoward Admin Group 
          
  
  Joined: June 29 2001 Location: United States
 Online Status: Offline Posts: 4447
          | 
        
         
          
           | Posted: February 18 2018 at 18:18 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
          
         | 
        
       
       
        |   | 
       
        
         
         smarty Super User 
          
  
  Joined: May 21 2006 Location: United States
 Online Status: Offline Posts: 729
          | 
        
         
          
           | Posted: February 20 2018 at 06:53 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
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 | 
         
          
         | 
        
       
       
        |   |       
      | 
    
   
  |