mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
add switch for windows use of Win32::Serialport in _Define and Poll
(sorry untested, dont have these devices) git-svn-id: https://svn.fhem.de/fhem/trunk@178 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
45d2f94c2d
commit
f6827f1ab2
@ -125,7 +125,13 @@ WS300_Define($$)
|
||||
$hash->{READINGS}{WS300Device}{VAL} = "Initializing";
|
||||
$hash->{READINGS}{WS300Device}{TIME} = TimeNow;
|
||||
|
||||
my $po = new Device::SerialPort ($a[2]);
|
||||
if ($^O=~/Win/) {
|
||||
eval ("use Win32::SerialPort;");
|
||||
my $po = new Win32::SerialPort ($DeviceName);
|
||||
}else{
|
||||
eval ("use Device::SerialPort;");
|
||||
my $po = new Device::SerialPort ($DeviceName);
|
||||
}
|
||||
if(!$po)
|
||||
{
|
||||
$hash->{STATE} = "error opening device";
|
||||
@ -534,7 +540,11 @@ NEXTPOLL:
|
||||
$hash->{READINGS}{WS300Device}{VAL} = "disconnected";
|
||||
$hash->{READINGS}{WS300Device}{TIME} = TimeNow;
|
||||
sleep(1);
|
||||
my $po = new Device::SerialPort($devname);
|
||||
if ($^O=~/Win/) {
|
||||
my $po = new Win32::SerialPort ($devname);
|
||||
}else{
|
||||
my $po = new Device::SerialPort ($devname);
|
||||
}
|
||||
if($po)
|
||||
{
|
||||
$po->reset_error();
|
||||
|
@ -3,7 +3,7 @@ package main;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Device::SerialPort;
|
||||
|
||||
|
||||
sub EM_Write($$);
|
||||
sub EmCrc($$);
|
||||
@ -60,7 +60,14 @@ EM_Define($$)
|
||||
}
|
||||
|
||||
Log 3, "EM opening device $dev";
|
||||
my $po = new Device::SerialPort ($dev);
|
||||
if ($^O=~/Win/) {
|
||||
eval ("use Win32::SerialPort;");
|
||||
my $po = new Win32::SerialPort ($dev);
|
||||
}else{
|
||||
eval ("use Device::SerialPort;");
|
||||
my $po = new Device::SerialPort ($dev);
|
||||
}
|
||||
|
||||
return "Can't open $dev: $!" if(!$po);
|
||||
Log 3, "EM opened device $dev";
|
||||
$po->close();
|
||||
@ -277,7 +284,12 @@ EmGetData($$)
|
||||
$d = EmMakeMsg(pack('H*', $d));
|
||||
|
||||
return undef if(!$dev);
|
||||
my $serport = new Device::SerialPort ($dev);
|
||||
if ($^O=~/Win/) {
|
||||
my $serport = new Win32::SerialPort ($dev);
|
||||
}else{
|
||||
my $serport = new Device::SerialPort ($dev);
|
||||
}
|
||||
|
||||
if(!$serport) {
|
||||
Log 1, "EM: Can't open $dev: $!";
|
||||
return undef;
|
||||
|
Loading…
Reference in New Issue
Block a user