2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00
git-svn-id: https://svn.fhem.de/fhem/trunk@1235 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-02-06 16:04:34 +00:00
parent 31507f44dc
commit bcf7a5daa6

View File

@ -292,10 +292,10 @@ my @usbtable = (
define => "CUL_PARAM CUL DEVICE\@9600 1PARAM34", }, define => "CUL_PARAM CUL DEVICE\@9600 1PARAM34", },
{ NAME => "TCM310", { NAME => "TCM310",
matchList => ["cu.usbserial(.*)", "cu.usbmodem(.*)", "ttyUSB(.*)"], matchList => ["cu.usbserial(.*)", "cu.usbmodem(.*)", "ttyUSB(.*)", "ttyACM(.*)"],
DeviceName=> "DEVICE\@57600", DeviceName=> "DEVICE\@57600",
request => pack("H*", "5500010005700838"), # get idbase request => pack("H*", "5500010005700838"), # get idbase
response => "^\x00\xFF....", response => "^\x55\x00\x05\x01",
define => "TCM310_PARAM TCM 310 DEVICE\@57600", }, define => "TCM310_PARAM TCM 310 DEVICE\@57600", },
{ NAME => "TCM120", { NAME => "TCM120",
@ -336,19 +336,21 @@ CommandUsb($$)
if($^O eq "linux") { if($^O eq "linux") {
# One device at a time to avoid endless loop # One device at a time to avoid endless loop
my $lsusb = `lsusb`; my $lsusb = `lsusb`;
my $culType; if($lsusb) {
$culType = "CUL_V4" if($lsusb =~ m/VID=03eb.PID=2ff0/s); # FritzBox my $culType;
$culType = "CUL_V3" if($lsusb =~ m/VID=03eb.PID=2ff4/s); # FritzBox $culType = "CUL_V4" if($lsusb =~ m/VID=03eb.PID=2ff0/s); # FritzBox
$culType = "CUL_V2" if($lsusb =~ m/VID=03eb.PID=2ffa/s); # FritzBox $culType = "CUL_V3" if($lsusb =~ m/VID=03eb.PID=2ff4/s); # FritzBox
$culType = "CUL_V4" if($lsusb =~ m/03eb:2ff0/); $culType = "CUL_V2" if($lsusb =~ m/VID=03eb.PID=2ffa/s); # FritzBox
$culType = "CUL_V3" if($lsusb =~ m/03eb:2ff4/); $culType = "CUL_V4" if($lsusb =~ m/03eb:2ff0/);
$culType = "CUL_V2" if($lsusb =~ m/03eb:2ffa/); $culType = "CUL_V3" if($lsusb =~ m/03eb:2ff4/);
if($culType) { $culType = "CUL_V2" if($lsusb =~ m/03eb:2ffa/);
$msg = "$culType: flash it with: CULflash none $culType"; if($culType) {
Log 4, $msg; $ret .= $msg . "\n"; $msg = "$culType: flash it with: CULflash none $culType";
if(!$scan) { Log 4, $msg; $ret .= $msg . "\n";
CommandCULflash(undef, "none $culType"); if(!$scan) {
sleep(4); # Leave time for linux to load th drivers CommandCULflash(undef, "none $culType");
sleep(4); # Leave time for linux to load th drivers
}
} }
} }
} }
@ -362,7 +364,7 @@ CommandUsb($$)
my $PARAM = $1; my $PARAM = $1;
$PARAM =~ s/[^A-Za-z0-9]//g; $PARAM =~ s/[^A-Za-z0-9]//g;
my $name = $thash->{NAME}; my $name = $thash->{NAME};
$msg = "$dev: checking if it is a $name"; $msg = "### $dev: checking if it is a $name";
Log 4, $msg; $ret .= $msg . "\n"; Log 4, $msg; $ret .= $msg . "\n";
# Check if it already used # Check if it already used
@ -370,7 +372,7 @@ CommandUsb($$)
if($defs{$d}{DeviceName} && if($defs{$d}{DeviceName} &&
$defs{$d}{DeviceName} =~ m/$dev/ && $defs{$d}{DeviceName} =~ m/$dev/ &&
$defs{$d}{FD}) { $defs{$d}{FD}) {
$msg = "$dev: already used by the $d fhem device"; $msg = "already used by the $d fhem device";
Log 4, $msg; $ret .= $msg . "\n"; Log 4, $msg; $ret .= $msg . "\n";
goto NEXTDEVICE; goto NEXTDEVICE;
} }
@ -382,22 +384,21 @@ CommandUsb($$)
my $hash = { NAME=>$name, DeviceName=>$dname }; my $hash = { NAME=>$name, DeviceName=>$dname };
DevIo_OpenDev($hash, 0, 0); DevIo_OpenDev($hash, 0, 0);
if(!defined($hash->{USBDev})) { if(!defined($hash->{USBDev})) {
$msg = "$dev: Cannot open the device, check the log"; DevIo_CloseDev($hash); # remove the ReadyFn loop
$msg = "cannot open the device";
Log 4, $msg; $ret .= $msg . "\n"; Log 4, $msg; $ret .= $msg . "\n";
goto NEXTDEVICE; goto NEXTDEVICE;
} }
# Clear the USB buffer # Clear the USB buffer
if($thash->{flush}) { DevIo_SimpleWrite($hash, $thash->{flush}, 0) if($thash->{flush});
DevIo_SimpleWrite($hash, $thash->{flush}, 0); DevIo_TimeoutRead($hash, 0.1);
DevIo_TimeoutRead($hash, 0.1);
}
DevIo_SimpleWrite($hash, $thash->{request}, 0); DevIo_SimpleWrite($hash, $thash->{request}, 0);
my $answer = DevIo_TimeoutRead($hash, 0.1); my $answer = DevIo_TimeoutRead($hash, 0.1);
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
if($answer !~ m/$thash->{response}/) { if($answer !~ m/$thash->{response}/) {
$msg = "$dev: got wrong answer for a $name"; $msg = "got wrong answer for a $name";
Log 4, $msg; $ret .= $msg . "\n"; Log 4, $msg; $ret .= $msg . "\n";
next; next;
} }
@ -405,7 +406,7 @@ CommandUsb($$)
my $define = $thash->{define}; my $define = $thash->{define};
$define =~ s/PARAM/$PARAM/g; $define =~ s/PARAM/$PARAM/g;
$define =~ s,DEVICE,$dir/$dev,g; $define =~ s,DEVICE,$dir/$dev,g;
$msg = "$dev: create as a fhem device with: define $define"; $msg = "create as a fhem device with: define $define";
Log 4, $msg; $ret .= $msg . "\n"; Log 4, $msg; $ret .= $msg . "\n";
if(!$scan) { if(!$scan) {