mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
fixes
git-svn-id: https://svn.fhem.de/fhem/trunk@182 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
755d76baa9
commit
2682aa8ee6
@ -114,7 +114,7 @@ WS300_Define($$)
|
||||
{
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
my $po;
|
||||
if($a[0] eq "WS300Device")
|
||||
{
|
||||
$defptr{10} = $hash;
|
||||
@ -124,13 +124,13 @@ WS300_Define($$)
|
||||
$hash->{SENSOR} = 10;
|
||||
$hash->{READINGS}{WS300Device}{VAL} = "Initializing";
|
||||
$hash->{READINGS}{WS300Device}{TIME} = TimeNow;
|
||||
|
||||
|
||||
if ($^O=~/Win/) {
|
||||
eval ("use Win32::SerialPort;");
|
||||
my $po = new Win32::SerialPort ($DeviceName);
|
||||
$po = new Win32::SerialPort ($DeviceName);
|
||||
}else{
|
||||
eval ("use Device::SerialPort;");
|
||||
my $po = new Device::SerialPort ($DeviceName);
|
||||
$po = new Device::SerialPort ($DeviceName);
|
||||
}
|
||||
if(!$po)
|
||||
{
|
||||
@ -514,6 +514,7 @@ WS300_Poll($)
|
||||
my $hash = shift;
|
||||
my $bstring=" ";
|
||||
my $count;
|
||||
my $po;
|
||||
my $inchar='';
|
||||
my $escape=0;
|
||||
my $ll = GetLogLevel("WS300Device");
|
||||
@ -541,9 +542,9 @@ NEXTPOLL:
|
||||
$hash->{READINGS}{WS300Device}{TIME} = TimeNow;
|
||||
sleep(1);
|
||||
if ($^O=~/Win/) {
|
||||
my $po = new Win32::SerialPort ($devname);
|
||||
$po = new Win32::SerialPort ($devname);
|
||||
}else{
|
||||
my $po = new Device::SerialPort ($devname);
|
||||
$po = new Device::SerialPort ($devname);
|
||||
}
|
||||
if($po)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ EM_Define($$)
|
||||
{
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
my $po;
|
||||
$hash->{STATE} = "Initialized";
|
||||
|
||||
delete $hash->{PortObj};
|
||||
@ -62,10 +62,10 @@ EM_Define($$)
|
||||
Log 3, "EM opening device $dev";
|
||||
if ($^O=~/Win/) {
|
||||
eval ("use Win32::SerialPort;");
|
||||
my $po = new Win32::SerialPort ($dev);
|
||||
$po = new Win32::SerialPort ($dev);
|
||||
}else{
|
||||
eval ("use Device::SerialPort;");
|
||||
my $po = new Device::SerialPort ($dev);
|
||||
$po = new Device::SerialPort ($dev);
|
||||
}
|
||||
|
||||
return "Can't open $dev: $!" if(!$po);
|
||||
@ -282,12 +282,13 @@ EmGetData($$)
|
||||
{
|
||||
my ($dev, $d) = @_;
|
||||
$d = EmMakeMsg(pack('H*', $d));
|
||||
|
||||
my $serport;
|
||||
return undef if(!$dev);
|
||||
#OS depends
|
||||
if ($^O=~/Win/) {
|
||||
my $serport = new Win32::SerialPort ($dev);
|
||||
$serport = new Win32::SerialPort ($dev);
|
||||
}else{
|
||||
my $serport = new Device::SerialPort ($dev);
|
||||
$serport = new Device::SerialPort ($dev);
|
||||
}
|
||||
|
||||
if(!$serport) {
|
||||
@ -313,15 +314,19 @@ EmGetData($$)
|
||||
my $started = 0;
|
||||
my $complete = 0;
|
||||
for(;;) {
|
||||
my ($rout, $rin) = ('', '');
|
||||
vec($rin, $serport->FILENO, 1) = 1;
|
||||
my $nfound = select($rout=$rin, undef, undef, 1.0);
|
||||
|
||||
if($nfound < 0) {
|
||||
$rm = "EM Select error $nfound / $!";
|
||||
goto DONE;
|
||||
}
|
||||
last if($nfound == 0);
|
||||
#select will not work on windows, replaced with status
|
||||
#
|
||||
#my ($rout, $rin) = ('', '');
|
||||
#vec($rin, $serport->FILENO, 1) = 1;
|
||||
#my $nfound = select($rout=$rin, undef, undef, 1.0);
|
||||
#
|
||||
#if($nfound < 0) {
|
||||
# $rm = "EM Select error $nfound / $!";
|
||||
# goto DONE;
|
||||
#}
|
||||
#last if($nfound == 0);
|
||||
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags)=$serport->status;
|
||||
last if ($InBytes<1);
|
||||
|
||||
my $buf = $serport->input();
|
||||
if(!defined($buf) || length($buf) == 0) {
|
||||
|
@ -149,9 +149,11 @@ FileLog_Get($@)
|
||||
return "Usage: get $a[0] <from> <to> <column_list>" if(int(@a) != 4);
|
||||
my $fh = new IO::File $hash->{currentlogfile};
|
||||
seekTo($fh, $hash, $a[1]);
|
||||
# my @arr =
|
||||
# my @arr =
|
||||
my $data='';
|
||||
while(my $l = <$fh>) {
|
||||
last if($l gt $a[2]);
|
||||
$data.=$l;
|
||||
}
|
||||
close($fh);
|
||||
return "EOF" if(!defined($data));
|
||||
|
Loading…
Reference in New Issue
Block a user