Seite 2 von 2

Re: Steuerung der Onkyo AV Receiver

Verfasst: Do Jun 11, 2020 10:14 am
von Sun1453
Hallo Adi und Robert, @adimaster @Robert_Mini

Habe jetzt eine Node für Node Red entdeckt. Mit Node Red werde ich mal schauen was da aktuell geht. Eventuell ist es aber auch für Stefan [@StefanW ] und sein Team interessant. Es sind nur wenige Dateien und vielleicht könnt ihr das Informationen ziehen. FR

https://github.com/estbeetoo/node-red-contrib-eiscp

https://flows.nodered.org/node/node-red-contrib-eiscp

Re: Steuerung der Onkyo AV Receiver

Verfasst: Di Jun 16, 2020 1:35 pm
von Sun1453
Weitere Infos die helfen könnten:

Code: Alles auswählen

Code:

#!/usr/bin/perl -w

use strict;
use IO::Socket;


my $host =  '192.168.4.52';
my $port = '60128';

my $logfile = '/var/log/iscp.log';

my %actions = (
"PWR00", '/usr/local/bin/groupwrite "ip:127.0.0.1" "3/3/0" "0"',
"PWR01", '/usr/local/bin/groupwrite "ip:127.0.0.1" "3/3/0" "1"',
"ZPW00", '/usr/local/bin/groupwrite "ip:127.0.0.1" "3/3/2" "0"',
"ZPW01", '/usr/local/bin/groupwrite "ip:127.0.0.1" "3/3/2" "1"',
"MVL", '/usr/local/bin/groupswrite "ip:127.0.0.1" "3/3/1" "VALUE"',
"ZVL", '/usr/local/bin/groupswrite "ip:127.0.0.1" "3/3/3" "VALUE"',
"SLI", '/usr/local/bin/groupswrite "ip:127.0.0.1" "3/3/5" "VALUE"',
"SLZ", '/usr/local/bin/groupswrite "ip:127.0.0.1" "3/3/6" "VALUE"'
);





# --------------------------
# nothing to edit after this
# --------------------------

# daemonize

my $pid= fork();
exit if $pid;
die "Couldn't fork: $!" unless defined($pid);

for my $handle (*STDIN,*STDOUT,*STDERR){
open($handle, "+<", "/dev/null") || die "can't reopen $handle to /dev/null: $!";
}

use POSIX;
POSIX::setsid() or die "Can't start a new session: $!";

my $time_to_die=0;

sub signal_handler {
$time_to_die=1;
}

$SIG{INT}=$SIG{TERM}=$SIG{HUP}=\&signal_handler;

until ($time_to_die) {



my $sock = new IO::Socket::INET(
                   PeerAddr => $host,
                   PeerPort => $port,
                   Proto    => 'tcp');
$sock or die "no socket :$!";
$sock->autoflush(1);

my $socklocal = new IO::Socket::INET(
                    LocalPort => $port,
                    Type => SOCK_STREAM,
                    Listen => 5,
                    Reuse => 1 );

$socklocal or die "no socket :$!";

my($kid,$line,$cmd,$length,$code,$in);
die "fork fail: $!" unless defined($kid = fork);
if ($kid) {
    while (my $client=$socklocal->accept) {
        $in=<$client>;
        $cmd="!1".$in;
        $length=length($cmd)+1;
        $code =chr($length);

        # setup the string we are sending ...
        $line  = "ISCP\x00\x00\x00\x10\x00\x00\x00$code\x01\x00\x00\x00".$cmd."\x0D";

        # send it !
        print $sock $line;
    }
    # kill the child process
    kill(TERM => $kid);
} else {

    # child reads from socket
    while (defined($sock->recv(my $data,1024))) {
        my $chunk=substr($data,18,5);
        while ((my $key, my $value)=each(%actions)) {
            if (!index($chunk, $key)) {
                if (index($value, "VALUE")>0) {
                    $_=$chunk;
                    my $result=s/$key//;
                    $chunk=$_;
                    substr($value, index($value, 'VALUE'),5 )=$chunk
                }
        open FILE, ">>", "$logfile" or die $!;
        my $t = time();
        my $now = localtime($t);
        print FILE "$now \t Chunk $chunk \t Key $key \t Value $value\n";
        close(FILE);

                system($value);
            }
        }
    }
    close $sock;
}
}