2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 05:06:35 +00:00

CUL with directio

git-svn-id: https://svn.fhem.de/fhem/trunk@988 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2011-08-24 10:49:56 +00:00
parent 5e79ad3a82
commit 09071f2903
3 changed files with 62 additions and 27 deletions

View File

@ -7,6 +7,7 @@
- feature: .gplot files renamed from type to content - feature: .gplot files renamed from type to content
- bugfix: FS20 on-for-timer error reporting only in the logfile - bugfix: FS20 on-for-timer error reporting only in the logfile
- bugfix: FHEM2FHEM should work with CUL again, after syntax change - bugfix: FHEM2FHEM should work with CUL again, after syntax change
- feature: CUL directio mode (No Device::SerialPort needed)
- 2011-07-08 (5.1) - 2011-07-08 (5.1)
- feature: smallscreen optimizations for iPhone - feature: smallscreen optimizations for iPhone

View File

@ -106,7 +106,8 @@ CUL_Define($$)
my @a = split("[ \t][ \t]*", $def); my @a = split("[ \t][ \t]*", $def);
if(@a < 4 || @a > 5) { if(@a < 4 || @a > 5) {
my $msg = "wrong syntax: define <name> CUL devicename[\@baudrate] <FHTID>"; my $msg = "wrong syntax: define <name> CUL {none | devicename[\@baudrate] ".
"| devicename\@directio | hostname:port} <FHTID>";
Log 2, $msg; Log 2, $msg;
return $msg; return $msg;
} }
@ -949,6 +950,7 @@ CUL_SimpleWrite(@)
$hash->{USBDev}->write($msg) if($hash->{USBDev}); $hash->{USBDev}->write($msg) if($hash->{USBDev});
syswrite($hash->{TCPDev}, $msg) if($hash->{TCPDev}); syswrite($hash->{TCPDev}, $msg) if($hash->{TCPDev});
syswrite($hash->{DIODev}, $msg) if($hash->{DIODev});
select(undef, undef, undef, 0.001); select(undef, undef, undef, 0.001);
} }
@ -958,22 +960,21 @@ sub
CUL_SimpleRead($) CUL_SimpleRead($)
{ {
my ($hash) = @_; my ($hash) = @_;
my ($buf, $res);
if($hash->{USBDev}) { if($hash->{USBDev}) {
my $buf = $hash->{USBDev}->input(); $buf = $hash->{USBDev}->input();
#Log 1, "Got $buf";
return $buf; } elsif($hash->{DIODev}) {
} $res = sysread($hash->{DIODev}, $buf, 256);
$buf = undef if(!defined($res));
} elsif($hash->{TCPDev}) {
$res = sysread($hash->{TCPDev}, $buf, 256);
$buf = undef if(!defined($res));
if($hash->{TCPDev}) {
my $buf;
if(!defined(sysread($hash->{TCPDev}, $buf, 256))) {
CUL_Disconnected($hash);
return undef;
} }
return $buf; return $buf;
}
return undef;
} }
######################## ########################
@ -994,6 +995,10 @@ CUL_CloseDev($)
$hash->{USBDev}->close() ; $hash->{USBDev}->close() ;
delete($hash->{USBDev}); delete($hash->{USBDev});
} elsif($hash->{DIODev}) {
close($hash->{DIODev});
delete($hash->{DIODev});
} }
($dev, undef) = split("@", $dev); # Remove the baudrate ($dev, undef) = split("@", $dev); # Remove the baudrate
delete($selectlist{"$name.$dev"}); delete($selectlist{"$name.$dev"});
@ -1044,6 +1049,27 @@ CUL_OpenDev($$)
delete($readyfnlist{"$name.$dev"}); delete($readyfnlist{"$name.$dev"});
$selectlist{"$name.$dev"} = $hash; $selectlist{"$name.$dev"} = $hash;
} elsif(lc($baudrate) eq "directio") { # Without Device::SerialPort
if(!open($po, "+<$dev")) {
return undef if($reopen);
Log(3, "Can't open $dev: $!");
$readyfnlist{"$name.$dev"} = $hash;
$hash->{STATE} = "disconnected";
return "";
}
$hash->{DIODev} = $po;
if( $^O =~ /Win/ ) {
$readyfnlist{"$name.$dev"} = $hash;
} else {
$hash->{FD} = fileno($po);
delete($readyfnlist{"$name.$dev"});
$selectlist{"$name.$dev"} = $hash;
}
} else { # USB/Serial device } else { # USB/Serial device

View File

@ -2048,8 +2048,16 @@ A line ending with \ will be concatenated with the next one, so long lines
following command:<ul>modprobe usbserial vendor=0x03eb following command:<ul>modprobe usbserial vendor=0x03eb
product=0x204b</ul>In this case the device is most probably product=0x204b</ul>In this case the device is most probably
/dev/ttyUSB0.<br><br> /dev/ttyUSB0.<br><br>
You can also specify a baudrate if the device name contains the @ You can also specify a baudrate if the device name contains the @
character, e.g.: /dev/ttyACM0@38400<br><br> character, e.g.: /dev/ttyACM0@38400<br><br>
If the baudrate is "directio" (e.g.: /dev/ttyACM0@directio), then the
perl module Device::SerialPort is not needed, and fhem opens the device
with simple file io. This might work if the operating system uses sane
defaults for the serial parameters, e.g. some Linux distributions and
OSX. <br><br>
</ul> </ul>
Network-connected devices (CUN):<br><ul> Network-connected devices (CUN):<br><ul>
&lt;device&gt; specifies the host:port of the device. E.g. &lt;device&gt; specifies the host:port of the device. E.g.
@ -2547,16 +2555,16 @@ A line ending with \ will be concatenated with the next one, so long lines
<li>day-temp &lt;tmp&gt;<br> <li>day-temp &lt;tmp&gt;<br>
night-temp &lt;tmp&gt;<br> night-temp &lt;tmp&gt;<br>
Set the day or night temperature. Temp must be between 6 and 30 Set the day or night temperature. Temp must be between 6 and 30
Centigrade, and precision is half a degree. Celsius, and precision is half a degree.
<li>tempListSat HH:MM temp 24:00 temp ...<br> <li>tempListSat HH:MM temp ... 24:00 temp<br>
tempListSun HH:MM temp 24:00 temp ...<br> tempListSun HH:MM temp ... 24:00 temp<br>
tempListMon HH:MM temp 24:00 temp ...<br> tempListMon HH:MM temp ... 24:00 temp<br>
tempListTue HH:MM temp 24:00 temp ...<br> tempListTue HH:MM temp ... 24:00 temp<br>
tempListThu HH:MM temp 24:00 temp ...<br> tempListThu HH:MM temp ... 24:00 temp<br>
tempListWed HH:MM temp 24:00 temp ...<br> tempListWed HH:MM temp ... 24:00 temp<br>
tempListFri HH:MM temp 24:00 temp ...<br> tempListFri HH:MM temp ... 24:00 temp<br>
Specify a list of temperature intervals. Up to 24 intervals can be Specify a list of temperature intervals. Up to 24 intervals can be
spacified for each week day, the resolution is 10 Minutes. The specified for each week day, the resolution is 10 Minutes. The
last time spec must always be 24:00.<br> last time spec must always be 24:00.<br>
Example: set th tempListSat 06:00 19 23:00 22.5 24:00 19<br> Example: set th tempListSat 06:00 19 23:00 22.5 24:00 19<br>
</ul></li> </ul></li>
@ -2567,11 +2575,11 @@ A line ending with \ will be concatenated with the next one, so long lines
<ul> <ul>
<li>raw &lt;data&gt; ...<br> <li>raw &lt;data&gt; ...<br>
Only needed for experimentation. Only needed for experimentation.
send a list of "raw" commands. The first command will be immediately send a list of "raw" commands. The first command will be
sent, the next one after the previous one is acked by the target. The immediately sent, the next one after the previous one is acked by
length will be computed automatically, and the message counter will be the target. The length will be computed automatically, and the
incremented if the first two charcters are ++. message counter will be incremented if the first two charcters are
Example (enable AES):<pre> ++. Example (enable AES):<pre>
set hm1 raw ++A001F100001234560105000000001\ set hm1 raw ++A001F100001234560105000000001\
++A001F10000123456010802010AF10B000C00\ ++A001F10000123456010802010AF10B000C00\
++A001F1000012345601080801\ ++A001F1000012345601080801\