mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
autocreate/usb: check for symlinks, change DevIo message
git-svn-id: https://svn.fhem.de/fhem/trunk@4876 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1054e5443c
commit
47c369b6db
@ -408,18 +408,27 @@ CommandUsb($$)
|
||||
# Check if it already used
|
||||
foreach my $d (keys %defs) {
|
||||
if($defs{$d}{DeviceName} &&
|
||||
$defs{$d}{DeviceName} =~ m/$dev/ &&
|
||||
$defs{$d}{FD}) {
|
||||
$msg = "already used by the fhem device $d";
|
||||
Log3 undef, 4, $msg; $ret .= $msg . "\n";
|
||||
goto NEXTDEVICE;
|
||||
|
||||
my $dn = $defs{$d}{DeviceName};
|
||||
my $match = ($dn =~ m/$dev/);
|
||||
if(!$match) {
|
||||
$dn =~ s/@.*//;
|
||||
$match = (readlink($dn) =~ m/$dev/) if(-l $dn);
|
||||
}
|
||||
|
||||
if($match) {
|
||||
$msg = "already used by the fhem device $d";
|
||||
Log3 undef, 4, $msg; $ret .= $msg . "\n";
|
||||
goto NEXTDEVICE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Open the device
|
||||
my $dname = $thash->{DeviceName};
|
||||
$dname =~ s,DEVICE,$dir/$dev,g;
|
||||
my $hash = { NAME=>$name, DeviceName=>$dname };
|
||||
my $hash = { NAME=>$name, DeviceName=>$dname, DevioText=>"Probing" };
|
||||
DevIo_OpenDev($hash, 0, 0);
|
||||
if(!defined($hash->{USBDev})) {
|
||||
DevIo_CloseDev($hash); # remove the ReadyFn loop
|
||||
|
@ -104,8 +104,8 @@ DevIo_OpenDev($$$)
|
||||
($dev, $baudrate) = split("@", $dev);
|
||||
|
||||
$hash->{PARTIAL} = "";
|
||||
Log3 $name, 3, "Opening $name device $dev"
|
||||
if(!$reopen);
|
||||
Log3 $name, 3, ($hash->{DevioText} ? $hash->{DevioText} : "Opening").
|
||||
" $name device $dev" if(!$reopen);
|
||||
|
||||
if($dev =~ m/^UNIX:(SEQPACKET|STREAM):(.*)$/) { # FBAHA
|
||||
my ($type, $fname) = ($1, $2);
|
||||
@ -216,7 +216,8 @@ DevIo_OpenDev($$$)
|
||||
|
||||
if($baudrate) {
|
||||
$po->reset_error();
|
||||
Log3 $name, 3, "Setting $name baudrate to $baudrate";
|
||||
Log3 $name, 3, "Setting $name baudrate to $baudrate"
|
||||
if(!$hash->{DevioText});
|
||||
$po->baudrate($baudrate);
|
||||
$po->databits(8);
|
||||
$po->parity('none');
|
||||
@ -243,14 +244,12 @@ DevIo_OpenDev($$$)
|
||||
}
|
||||
|
||||
$po->write_settings;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($reopen) {
|
||||
Log3 $name, 1, "$dev reappeared ($name)";
|
||||
} else {
|
||||
Log3 $name, 3, "$name device opened";
|
||||
Log3 $name, 3, "$name device opened" if(!$hash->{DevioText});
|
||||
}
|
||||
|
||||
$hash->{STATE}="opened";
|
||||
|
Loading…
Reference in New Issue
Block a user