Author |
|
traviskleckner Senior Member
Joined: February 26 2007 Location: United States
Online Status: Offline Posts: 118
|
Posted: July 22 2008 at 18:33 | IP Logged
|
|
|
I'm trying to figure out the best way to connect to a remote device via sockets and send commands. I've got some perl scripts that run from the command line and do exactly what I want.
What's the best way to run a perl script from PowerHome?
Alternatively, does anyone know how to connect to a device via sockets from VBScript? I assume it's a winsock thing but haven't had much luck.
FYI, I'm trying to control SqueezeCenter.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: July 22 2008 at 19:35 | IP Logged
|
|
|
Until someone else chimes in, two ideas...
1. Use PH's socket support (ph_sendsocketdata or ph_sendudp and the socket receive trigger).
2. Control SqueezeCenter via its web server support with ph_geturl.
|
Back to Top |
|
|
traviskleckner Senior Member
Joined: February 26 2007 Location: United States
Online Status: Offline Posts: 118
|
Posted: July 23 2008 at 08:55 | IP Logged
|
|
|
I have a workaround using ph_run and then entering the path to the perl exe and the whole path to the script. It's not pretty but will work if I can't find a better solution. At this point I'm not concerned about getting any feedback from the device, so it's not a big deal.
On the other hand, ph_sendsocketdata seems like it would be perfect. The problem is I can't seem to get it to work.
I've tried various things but they all return "*ERROR* - TIMEOUT WAITING FOR RETURN"
I've tried various values at the end for the EOL character. I've tried various values for the host including it's name, localhost, it's IP and 127.0.0.1.
So far I have tried (and a couple other commands, but these are the most simple):
ph_sendsocketdata("127.0.0.1",9090,"status\x0A")
Which should return the status, works in my perl script.
ph_sendsocketdata("127.0.0.1",9090,"exit\x0A")
Which should do nothing but exit.
Edited by traviskleckner - July 23 2008 at 09:31
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: July 23 2008 at 13:43 | IP Logged
|
|
|
To me, anything is better than running a command line app from Windows.
I did some digging for the protocol and could not find a status command. Do you have a link to what you are using?
This is what I found.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: July 23 2008 at 13:57 | IP Logged
|
|
|
Travis,
I cant say for sure, but Im certain part of your problem is some confusion between the ph_sendsocketdata and ph_sendsocketdata1 functions (you should be using the latter). You've got special characters in your send data, but the ph_sendsocketdata function does not translate these.
Try:
Code:
ph_sendsocketdata1("127.0.0.1",9090,3,"status\x0A") |
|
|
I think this should do the trick for you.
Dave.
|
Back to Top |
|
|
traviskleckner Senior Member
Joined: February 26 2007 Location: United States
Online Status: Offline Posts: 118
|
Posted: July 23 2008 at 14:32 | IP Logged
|
|
|
Hot damn! That's it. Thanks Dave. This is why PowerHome support is so good. I'll take support from the developer over a manual any day. Dave, you really should start charging for version upgrades, you've earned it.
I thought had tried that but I was putting in 0 as the second parameter. Without the special characters I think the thing was timing out looking for the EOL character. When I was looking at the help I sort of assumed (incorrectly I see) that the conversion of the special characters happened on both functions and that the help was just lagging a little behind.
Tony, if your interested, the only help I am aware of is installed with Squeeze Center. The command line interface is under "Help > Technical Information > Command Line Interface." Whats interesting to me is that they built this interface exactly for what I am doing..."This format is designed for ease of integration into AMX, Crestron and other automation systems."
I've been playing with the server side but the hardware isn't hear yet. I've got a Squeezebox Duet and a second receiver coming. Once it's in place I hope to replace WinAmp and use the keypads for play/pause, next track, previous track and playlist select.
dhoward wrote:
Travis,
I cant say for sure, but Im certain part of your problem is some confusion between the ph_sendsocketdata and ph_sendsocketdata1 functions (you should be using the latter). You've got special characters in your send data, but the ph_sendsocketdata function does not translate these.
Try:
Code:
ph_sendsocketdata1("127.0.0.1",9090,3,"status\x0A") |
|
|
I think this should do the trick for you.
Dave.
|
|
|
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: July 23 2008 at 23:51 | IP Logged
|
|
|
OK, so I downloaded and installed SqueezeCenter but it doesn't work. Have you had luck?
|
Back to Top |
|
|
traviskleckner Senior Member
Joined: February 26 2007 Location: United States
Online Status: Offline Posts: 118
|
Posted: July 24 2008 at 12:53 | IP Logged
|
|
|
Tony,
Yeah, after using Dave's suggestion I've got it doing exactly what I need. The devices themselves are still not working as I expect (I can play Internet radio, but anything local gets all hosed up) but that's the fault of the SqueezeBoxes, not Powerhome.
Examples:
Play/Pause toggle: ph_sendsocketdata1("127.0.0.1",9090,3,"00:04:20:16:59:8b pause\x0A")
Back: ph_sendsocketdata1("127.0.0.1",9090,3,"00:04:20:16:59:8b button jump_rew\x0A")
Forward: ph_sendsocketdata1("127.0.0.1",9090,3,"00:04:20:16:59:8b button jump_fwd\x0A")
I've been playing with playlist controls too, but since the players are not playing music from local sources, it's still just playing. All in all, I am very happy with the performance of the socket control...it's easily as fast as it was to control Winamp.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: July 24 2008 at 13:27 | IP Logged
|
|
|
I tried using Winamp and WMP to play the Squeeze stream, but all I got was silence. Glad you had progress.
|
Back to Top |
|
|