init fixed

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5957 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
wherzig
2014-05-24 13:46:29 +00:00
parent d82bc8e7b9
commit 721c1e4bd4

View File

@@ -235,49 +235,48 @@ TRX_DoInit($)
# Get Status # Get Status
$init = pack('H*', "0D00000102000000000000000000"); $init = pack('H*', "0D00000102000000000000000000");
DevIo_SimpleWrite($hash, $init, 0); DevIo_SimpleWrite($hash, $init, 0);
$buf = DevIo_TimeoutRead($hash, 0.1); $buf = unpack('H*',DevIo_TimeoutRead($hash, 0.1));
if (! $buf) { if (! $buf) {
Log3 $name, 1, "TRX: Initialization Error: No character read"; Log3 $name, 1, "TRX: Initialization Error: No character read";
return "TRX: Initialization Error $name: no char read"; return "TRX: Initialization Error $name: no char read";
} elsif ($buf !~ m/\x0d\x01\x00.........../) { } elsif ($buf !~ m/0d0100....................../) {
my $hexline = unpack('H*', $buf); Log3 $name, 1, "TRX: Initialization Error hexline='$buf', expected 0d0100......................";
Log3 $name, 1, "TRX: Initialization Error hexline='$hexline'"; return "TRX: Initialization Error %name expected 0D0100, but char=$char received.";
return "TRX: Initialization Error %name expected char=0x2c, but char=$char received.";
} else { } else {
Log3 $name,1, "TRX: Init OK"; Log3 $name,1, "TRX: Init OK";
$hash->{STATE} = "Initialized"; $hash->{STATE} = "Initialized";
# Analyse result and display it: # Analyse result and display it:
if ($buf =~ m/\x0d\x01\x00(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)/) { if ($buf =~ m/0d0100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/) {
my $status = ""; my $status = "";
my $seqnbr = $1; my $seqnbr = $1;
my $cmnd = $2; my $cmnd = $2;
my $msg1 = ord($3); my $msg1 = $3;
my $msg2 = ord($4); my $msg2 = ord(pack('H*', $4));
my $msg3 = ord($5); my $msg3 = ord(pack('H*', $5));
my $msg4 = ord($6); my $msg4 = ord(pack('H*', $6));
my $msg5 = ord($7); my $msg5 = ord(pack('H*', $7));
my $freq = { my $freq = {
0x50 => '310MHz', '50' => '310MHz',
0x51 => '315MHz', '51' => '315MHz',
0x52 => '433.92MHz receiver only', '52' => '433.92MHz receiver only',
0x53 => '433.92MHz transceiver', '53' => '433.92MHz transceiver',
0x55 => '868.00MHz', '55' => '868.00MHz',
0x56 => '868.00MHz FSK', '56' => '868.00MHz FSK',
0x57 => '868.30MHz', '57' => '868.30MHz',
0x58 => '868.30MHz FSK', '58' => '868.30MHz FSK',
0x59 => '868.35MHz', '59' => '868.35MHz',
0x5A => '868.35MHz FSK', '5a' => '868.35MHz FSK',
0x5B => '868.95MHz' '5b' => '868.95MHz'
}->{$msg1} || 'unknown Mhz'; }->{$msg1} || 'unknown Mhz';
$status .= $freq; $status .= $freq;
$status .= ", " . sprintf "firmware=%d",$msg2; $status .= ", " . sprintf "firmware=%d",$msg2;
$status .= ", protocols enabled: "; $status .= ", protocols enabled: ";
$status .= "undecoded " if ($msg3 & 0x80); $status .= "undecoded " if ($msg3 & 0x80);
$status .= "RFU6 " if ($msg3 & 0x40); $status .= "RFU " if ($msg3 & 0x40);
$status .= "RFU5 " if ($msg3 & 0x20); $status .= "ByronSX " if ($msg3 & 0x20);
$status .= "RFU4 " if ($msg3 & 0x10); $status .= "RSL " if ($msg3 & 0x10);
$status .= "Lighting4 " if ($msg3 & 0x08); $status .= "Lighting4 " if ($msg3 & 0x08);
$status .= "FineOffset/Viking " if ($msg3 & 0x04); $status .= "FineOffset/Viking " if ($msg3 & 0x04);
$status .= "Rubicson " if ($msg3 & 0x02); $status .= "Rubicson " if ($msg3 & 0x02);