Hallo,
langsam verzweifel ich ;-)
Mein Vorhaben:
Auf einem RasPi läuft ein Python-Script, das ein Plugin auf dem Wiregate starten soll.
Idee:
RasPi: UDP-Packet über Python senden
Wiregate: Plugin hört auf Socket
So weit so gut, ich bekomms aber nicht hin, mit den Hilfen im Forum leider auch nicht - meist bezieht sich das m.E. darauf, dass das Wiregate Pakete sendet!?
Python-Script (Auszug):
Wiregate-Plugin (Auszug):
Und dann muss ich am Wiregate-WebIf noch einen Socket erstellen!?
2015-07-05 14_28_10-Seriell_LAN_Socketverbindungen.png
Die 192.168.100.63 ist der RasPi, Port 8993 ist noch frei.
Wo ist mein Fehler, was vergesse ich?
Danke schon mal!!!
langsam verzweifel ich ;-)
Mein Vorhaben:
Auf einem RasPi läuft ein Python-Script, das ein Plugin auf dem Wiregate starten soll.
Idee:
RasPi: UDP-Packet über Python senden
Wiregate: Plugin hört auf Socket
So weit so gut, ich bekomms aber nicht hin, mit den Hilfen im Forum leider auch nicht - meist bezieht sich das m.E. darauf, dass das Wiregate Pakete sendet!?
Python-Script (Auszug):
import socket
def doKlingel():
# addressing information of target
IPADDR = 'IP_des_Wiregate'
PORTNUM = 8993
# enter the data content of the UDP packet
PACKETDATA = 1
# initialize a socket, think of it as a cable
# SOCK_DGRAM specifies that this is UDP
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
# TCP Socket: SOCK_STREAM
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
try:
# connect the socket, think of it as connecting the cable to the address location
try:
s.connect((host, port))
except:
print 'Socket nicht aufgebaut'
sys.exit()
# send the command
s.send(PACKETDATA)
print "Packet gesendet " + str(PACKETDATA)
except:
pass
print "Packet nicht gesendet"
# close the socket
s.close()
def doKlingel():
# addressing information of target
IPADDR = 'IP_des_Wiregate'
PORTNUM = 8993
# enter the data content of the UDP packet
PACKETDATA = 1
# initialize a socket, think of it as a cable
# SOCK_DGRAM specifies that this is UDP
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
# TCP Socket: SOCK_STREAM
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
try:
# connect the socket, think of it as connecting the cable to the address location
try:
s.connect((host, port))
except:
print 'Socket nicht aufgebaut'
sys.exit()
# send the command
s.send(PACKETDATA)
print "Packet gesendet " + str(PACKETDATA)
except:
pass
print "Packet nicht gesendet"
# close the socket
s.close()
if (!$socket[$socknum]) { # socket erstellen
$socket[$socknum] = IO::Socket::INET->new(LocalPort => $recv_port,
Proto => "udp",
LocalAddr => $recv_ip,
#PeerPort => $send_port,
#PeerAddr => $send_ip,
#ReuseAddr => 1
)
or return ("open of $recv_ip : $recv_port failed: $!");
$socksel->add($socket[$socknum]); # add socket to select
$plugin_socket_subscribe{$socket[$socknum]} = $plugname; # subscribe plugin
return "opened Socket $socknum";
} elsif ($fh) {
my $line = <$fh>;
chomp($line);
if (!$line) { # catch empty line
if ($debug==1) {plugin_log($plugname, "line ist leer!"); }
return;
}
if ($debug==1) { # for debug : printout received string as hex and ascii
my $str = unpack('H*', "$line");
plugin_log($plugname, $str);
plugin_log($plugname, $line);
}
foreach my $element (@elements) {
knx_write($element->{ga},$element->{value},$element->{dpt});
if ($debug == 1) { plugin_log($plugname, "$element->{name} auf $element->{value} gesetzt"); }
}
}
$socket[$socknum] = IO::Socket::INET->new(LocalPort => $recv_port,
Proto => "udp",
LocalAddr => $recv_ip,
#PeerPort => $send_port,
#PeerAddr => $send_ip,
#ReuseAddr => 1
)
or return ("open of $recv_ip : $recv_port failed: $!");
$socksel->add($socket[$socknum]); # add socket to select
$plugin_socket_subscribe{$socket[$socknum]} = $plugname; # subscribe plugin
return "opened Socket $socknum";
} elsif ($fh) {
my $line = <$fh>;
chomp($line);
if (!$line) { # catch empty line
if ($debug==1) {plugin_log($plugname, "line ist leer!"); }
return;
}
if ($debug==1) { # for debug : printout received string as hex and ascii
my $str = unpack('H*', "$line");
plugin_log($plugname, $str);
plugin_log($plugname, $line);
}
foreach my $element (@elements) {
knx_write($element->{ga},$element->{value},$element->{dpt});
if ($debug == 1) { plugin_log($plugname, "$element->{name} auf $element->{value} gesetzt"); }
}
}
2015-07-05 14_28_10-Seriell_LAN_Socketverbindungen.png
Die 192.168.100.63 ist der RasPi, Port 8993 ist noch frei.
Wo ist mein Fehler, was vergesse ich?
Danke schon mal!!!
Kommentar