mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-12 02:39:57 +00:00
98_autocreate.pm: usb scan fixes (Forum #100054)
git-svn-id: https://svn.fhem.de/fhem/trunk@19372 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d0c464f0d9
commit
e3fd2c73ee
@ -531,8 +531,8 @@ my @usbtable = (
|
||||
matchList => ["cu.usbserial(.*)", "cu.usbmodem(.*)",
|
||||
"ttyUSB(.*)", "ttyACM(.*)", "ttyAMA(.*)"],
|
||||
DeviceName=> "DEVICE\@19200",
|
||||
timeout => 1.1,
|
||||
maxLen => 32,
|
||||
timeout => 1.0, # msg every second
|
||||
maxLen => 127, # max packet ist 64 bytes
|
||||
response => "[GW][+-][0-9]{2}\.[0-9]{7}[JN][0-9]{5}".
|
||||
"\.[0-9][JN].*[0-9]{4}\x03",
|
||||
define => "ElsnerWS_PARAM ElsnerWS comtype=rs485 ".
|
||||
@ -650,8 +650,8 @@ CommandUsb($$)
|
||||
$answer = DevIo_TimeoutRead($hash, 0.1);
|
||||
|
||||
} elsif($thash->{timeout} && $thash->{maxLen}) {
|
||||
$answer = DevIo_TimeoutRead($hash,
|
||||
$thash->{timeout}, $thash->{maxLen});
|
||||
$answer = DevIo_TimeoutRead($hash, $thash->{timeout},
|
||||
$thash->{maxLen}, $thash->{response});
|
||||
|
||||
}
|
||||
if(AttrVal("global", "verbose", 0) >= 5) {
|
||||
|
@ -10,7 +10,7 @@ sub DevIo_SetHwHandshake($);
|
||||
sub DevIo_SimpleRead($);
|
||||
sub DevIo_SimpleReadWithTimeout($$);
|
||||
sub DevIo_SimpleWrite($$$;$);
|
||||
sub DevIo_TimeoutRead($$;$);
|
||||
sub DevIo_TimeoutRead($$;$$);
|
||||
|
||||
sub
|
||||
DevIo_setStates($$)
|
||||
@ -100,9 +100,9 @@ DevIo_SimpleReadWithTimeout($$)
|
||||
# NOTE1: FHEM WILL be blocked for $timeout seconds, DO NOT USE IT!
|
||||
# NOTE2: This works on Windows only for TCP connections
|
||||
sub
|
||||
DevIo_TimeoutRead($$;$)
|
||||
DevIo_TimeoutRead($$;$$)
|
||||
{
|
||||
my ($hash, $timeout, $maxlen) = @_;
|
||||
my ($hash, $timeout, $maxlen, $regexp) = @_;
|
||||
|
||||
my $answer = "";
|
||||
$timeout = 1 if(!$timeout);
|
||||
@ -111,11 +111,11 @@ DevIo_TimeoutRead($$;$)
|
||||
my $rin = "";
|
||||
vec($rin, $hash->{FD}, 1) = 1;
|
||||
my $nfound = select($rin, undef, undef, $timeout);
|
||||
last if($nfound <= 0);
|
||||
last if($nfound <= 0); # timeout
|
||||
my $r = DevIo_DoSimpleRead($hash);
|
||||
last if(!defined($r) || ($r == "" && $hash->{TCPDev}));
|
||||
$answer .= $r;
|
||||
last if(length($anser) >= $maxlen);
|
||||
last if(length($anser) >= $maxlen || ($regexp && $answer =~ m/$regexp/));
|
||||
}
|
||||
return $answer;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user