PDA

View Full Version : Command Line interface - X10 Remote



Bill Moseley
2005-05-11, 15:48
Looking for suggestions:

I have an X10 remote that connects to the serial port. I have a Perl
script (mouseremote.pl) that listens to the serial port and maps
keystrokes to commands that are issued via a system() call.

For example, I have the remote run these commands when in "CD" mode to
control xmms:

[CD]
Power xmms&
.VolUp xmms-shell -e 'upvolume 2'
.VolDown xmms-shell -e 'downvolume 2'
FF xmms-shell -e next
Pause xmms-shell -e pause
Play xmms-shell -e play
Rew xmms-shell -e previous
ab xmms-shell -e 'shuffle ON'
Disp xmms-shell -e 'shuffle OFF'
Stop xmms-shell -e stop
Mute xmms-shell -e pause

Is there a utility available to send commands to the slimserver via
a system call? I know I can connect to port 9090 -- but I'm wondering if
there's already a program available that will work with my existing
setup.

Thanks,



--
Bill Moseley
moseley (AT) hank (DOT) org

bill fumerola
2005-05-11, 17:28
On Wed, May 11, 2005 at 03:48:36PM -0700, Bill Moseley wrote:
> Is there a utility available to send commands to the slimserver via
> a system call? I know I can connect to port 9090 -- but I'm wondering if
> there's already a program available that will work with my existing
> setup.

you could use netcat[1] to simplify sending commands to tcp/9090.

-- bill

1. http://public.www.planetmirror.com/pub/lprng/TOOLS/netcat/nc110.tgz

radish
2005-05-11, 18:00
I use the following little perl script to tell my slimserver to do a rescan whenever I sync new music onto it, you may be able to adapt it to your needs.




use IO::Socket;

$server="servername";
$port=9090;

print "Connecting to SlimServer at ".$server.":".$port."...\n";

$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $server,
PeerPort => $port,
)
or die "ERROR: Cannot connect to SlimServer";

$remote->autoflush(1);

print $remote "rescan\n";

$response = <$remote>;
$response == "rescan" || die "ERROR: Bad response from SlimServer : $response\n";

print $remote "exit\n";
close $remote;

print "SlimServer is rescanning the music library\n";
exit;

Bill Moseley
2005-05-11, 18:34
On Wed, May 11, 2005 at 06:00:08PM -0700, radish wrote:
>
> I use the following little perl script to tell my slimserver to do a
> rescan whenever I sync new music onto it, you may be able to adapt it
> to your needs.

Thanks. I'll give it a try.

> $response == "rescan" || die "ERROR: Bad response from SlimServer : $response\n";

BTW - I think you want "eq" not "==".

--
Bill Moseley
moseley (AT) hank (DOT) org

radish
2005-05-12, 12:34
On Wed, May 11, 2005 at 06:00:08PM -0700,

BTW - I think you want "eq" not "==".

You're right - thanks!

Can you tell I'm not a professional perl coder? ;)

John Gorst
2005-05-12, 15:14
Bill Moseley wrote:
> Looking for suggestions:
>
> I have an X10 remote that connects to the serial port. I have a Perl
> script (mouseremote.pl) that listens to the serial port and maps
> keystrokes to commands that are issued via a system() call.
>
> For example, I have the remote run these commands when in "CD" mode to
> control xmms:
>
> [CD]
> Power xmms&
> .VolUp xmms-shell -e 'upvolume 2'
> .VolDown xmms-shell -e 'downvolume 2'
> FF xmms-shell -e next
> Pause xmms-shell -e pause
> Play xmms-shell -e play
> Rew xmms-shell -e previous
> ab xmms-shell -e 'shuffle ON'
> Disp xmms-shell -e 'shuffle OFF'
> Stop xmms-shell -e stop
> Mute xmms-shell -e pause
>
> Is there a utility available to send commands to the slimserver via
> a system call? I know I can connect to port 9090 -- but I'm wondering if
> there's already a program available that will work with my existing
> setup.

Enable XPL interface in server setup.
Go to www.xplproject.org.uk
Download the perl xpl command line sender and hub
You can then have you perl script send xpl messages by using the xplsend
perl script. Slimserver will recieve the xpl messages and act on them
(e.e. fast forward, stop etc).

You cna find info on slimserver and xpl on the help section of the
slimserver web interface.

HTH

dukeinlondon
2006-01-22, 15:54
I use the following little perl script to tell my slimserver to do a rescan whenever I sync new music onto it, you may be able to adapt it to your needs.




use IO::Socket;

$server="servername";
$port=9090;

print "Connecting to SlimServer at ".$server.":".$port."...\n";

$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $server,
PeerPort => $port,
)
or die "ERROR: Cannot connect to SlimServer";

$remote->autoflush(1);

print $remote "rescan\n";

$response = <$remote>;
$response == "rescan" || die "ERROR: Bad response from SlimServer : $response\n";

print $remote "exit\n";
close $remote;

print "SlimServer is rescanning the music library\n";
exit;


Thanks for that ! I've added the script to my transfer script.

I had to add



chomp $response;


for the response test to work.