2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

OWX_ASYNC: Merge branch 'owx_async_protothreads'

git-svn-id: https://svn.fhem.de/fhem/trunk@5853 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
ntruchsess 2014-05-13 21:59:31 +00:00
parent adfea4b732
commit 21aae23fb5
7 changed files with 49 additions and 39 deletions

View File

@ -128,7 +128,7 @@ my %attrs = (
);
#-- some globals needed for the 1-Wire module
$owx_async_version=5.1;
$owx_async_version=5.2;
#-- Debugging 0,1,2,3
$owx_async_debug=0;
@ -1136,6 +1136,9 @@ sub OWX_ASYNC_RunTasks($) {
unless ($task->PT_SCHEDULE(@{$task->{ExecuteArgs}})) {
shift @$queue;
delete $master->{tasks}->{$owx_dev} unless @$queue;
if ($task->PT_RETVAL()) {
Log3 ($master->{NAME},2,"OWX_ASYNC: Error running task for $owx_dev: ".$task->PT_RETVAL());
}
}
OWX_ASYNC_Poll( $master );
} else {

View File

@ -42,6 +42,7 @@ my @clients = qw(
FRM_ROTENC
FRM_STEPPER
OWX
OWX_ASYNC
I2C_LCD
I2C_DS1307
I2C_PC.*

View File

@ -90,7 +90,7 @@ use ProtoThreads;
no warnings 'deprecated';
sub Log($$);
my $owx_version="5.13";
my $owx_version="5.14";
#-- fixed raw channel name, flexible channel name
my @owg_fixed = ("A","B","C","D");
my @owg_channel = ("A","B","C","D");
@ -1443,9 +1443,7 @@ sub OWXAD_GetPage($$$@) {
return "$owx_dev has returned invalid data"
if( length($res)!=22);
#-- for processing we also need the 3 command bytes
OWXAD_BinValues($hash,$context,1,undef,$owx_dev,$select,10,substr($res,12,10));
return undef;
return OWXAD_BinValues($hash,$context,1,undef,$owx_dev,$select,10,substr($res,12,10));
}
########################################################################################

View File

@ -99,7 +99,7 @@ no warnings 'deprecated';
sub Log3($$$);
my $owx_version="5.19";
my $owx_version="5.21";
#-- fixed raw channel name, flexible channel name
my @owg_fixed = ("A","B");
my @owg_channel = ("A","B");
@ -803,12 +803,9 @@ sub OWCOUNT_GetPage ($$$@) {
my $interface= $hash->{IODev}->{TYPE};
my $name = $hash->{NAME};
my $ret;
my $oldfinal= $final;
#-- check if memory usage has been disabled
my $nomemory = defined($attr{$name}{"nomemory"}) ? $attr{$name}{"nomemory"} : 0;
$final=0
if($nomemory==1);
#-- even if memory usage has been disabled, we need to read the page because it contains the counter values
if( ($nomemory==0) || ($nomemory==1 && (($page==14)||($page==15))) ){
@ -1600,7 +1597,7 @@ sub OWXCOUNT_BinValues($$$$$$$$) {
if( int(@data) < 42);
#return "invalid data"
# if (ord($data[17])<=0);
Log3 $name,1,"invalid CRC, ".ord($data[40])." ".ord($data[41])
return "invalid CRC, ".ord($data[40])." ".ord($data[41])
if (OWX_CRC16($select.substr($res,0,40),$data[40],$data[41]) == 0);
#-- first 3 command, next 32 are memory
@ -1709,7 +1706,6 @@ sub OWXCOUNT_GetPage($$$) {
return "$owx_dev has returned invalid data"
if( length($res)!=54);
return OWXCOUNT_BinValues($hash,$context,1,1,$owx_dev,$select,42,substr($res,12));
return undef;
}
########################################################################################

View File

@ -82,7 +82,7 @@ no warnings 'deprecated';
sub Log($$);
my $owx_version="5.14";
my $owx_version="5.15";
#-- flexible channel name
my $owg_channel;
@ -777,16 +777,13 @@ sub OWXMULTI_BinValues($$$$$$$$) {
#-- process results
my @data=split(//,$res);
if (@data != 9) {
Log 1, "invalid data length, ".int(@data)." instead of 9 bytes";
return;
return "invalid data length, ".int(@data)." instead of 9 bytes";
}
if ((ord($data[0]) & 112)!=0) {
Log 1, "conversion not complete or data invalid";
return;
return "conversion not complete or data invalid";
}
if (OWX_CRC8(substr($res,0,8),$data[8])==0) {
Log 1, "invalid CRC";
return;
return "invalid CRC";
}
#-- this must be different for the different device types
@ -854,7 +851,7 @@ sub OWXMULTI_GetValues($) {
my ($hash) = @_;
my ($i,$j,$k,$res,$res2);
my ($i,$j,$k,$res,$ret);
#-- ID of the device
my $owx_dev = $hash->{ROM_ID};
@ -914,7 +911,8 @@ sub OWXMULTI_GetValues($) {
if( $res eq 0 );
return "$owx_dev has returned invalid data"
if( length($res)!=20);
OWXMULTI_BinValues($hash,"ds2438.getvdd",1,undef,$owx_dev,undef,undef,substr($res,11));
$ret = OWXMULTI_BinValues($hash,"ds2438.getvdd",1,undef,$owx_dev,undef,undef,substr($res,11));
return $ret if (defined $ret);
#------------------------------------------------------------------------------------
#-- switch the device to current measurement off, V external only
#-- issue the match ROM command \x55 and the write scratchpad command
@ -957,8 +955,7 @@ sub OWXMULTI_GetValues($) {
if( $res eq 0 );
return "$owx_dev has returned invalid data"
if( length($res)!=20);
OWXMULTI_BinValues($hash,$context,1,undef,$owx_dev,undef,undef,substr($res,11));
return undef;
return OWXMULTI_BinValues($hash,$context,1,undef,$owx_dev,undef,undef,substr($res,11));
}
#######################################################################################
@ -1016,7 +1013,7 @@ sub OWXMULTI_PT_GetValues($) {
my ($thread,$hash) = @_;
my ($i,$j,$k,$res,$res2,$response);
my ($i,$j,$k,$res,$ret,$response);
#-- ID of the device
my $owx_dev = $hash->{ROM_ID};
@ -1106,7 +1103,10 @@ sub OWXMULTI_PT_GetValues($) {
unless (defined $res and length($res)==9) {
PT_EXIT("$owx_dev has returned invalid data");
}
OWXMULTI_BinValues($hash,"ds2438.getvdd",1,undef,$owx_dev,undef,undef,$res);
$ret = OWXMULTI_BinValues($hash,"ds2438.getvdd",1,undef,$owx_dev,undef,undef,$res);
if (defined $ret) {
PT_EXIT($ret);
}
#------------------------------------------------------------------------------------
#-- switch the device to current measurement off, V external only
#-- issue the match ROM command \x55 and the write scratchpad command
@ -1173,7 +1173,10 @@ sub OWXMULTI_PT_GetValues($) {
unless (defined $res and length($res)==9) {
PT_EXIT("$owx_dev has returned invalid data");
}
OWXMULTI_BinValues($hash,"ds2438.getvad",1,undef,$owx_dev,undef,undef,$res);
$ret = OWXMULTI_BinValues($hash,"ds2438.getvad",1,undef,$owx_dev,undef,undef,$res);
if (defined $ret) {
PT_EXIT($ret);
}
PT_END;
}

View File

@ -89,7 +89,7 @@ no warnings 'deprecated';
sub Log($$);
my $owx_version="5.14";
my $owx_version="5.15";
#-- fixed raw channel name, flexible channel name
my @owg_fixed = ("A","B","C","D","E","F","G","H");
my @owg_channel = ("A","B","C","D","E","F","G","H");
@ -1035,7 +1035,7 @@ sub OWXSWITCH_BinValues($$$$$$$$) {
if( int(@data) != 2){
return "state could not be set for device $owx_dev";
}
Log 1,"invalid CRC"
return "invalid CRC"
if (OWX_CRC16($command,$data[0],$data[1]) == 0);
#-- put into local buffer
$hash->{owg_val}->[0] = $value % 2;
@ -1082,7 +1082,7 @@ sub OWXSWITCH_BinValues($$$$$$$$) {
sub OWXSWITCH_GetState($@) {
my ($hash,$sync) = @_;
my ($select, $res, $res2, $res3, @data);
my ($select, $res, @data);
#-- ID of the device
my $owx_dev = $hash->{ROM_ID};
@ -1111,7 +1111,7 @@ sub OWXSWITCH_GetState($@) {
return "$owx_dev has returned invalid data"
if( length($res)!=16);
OWX_Reset($master);
OWXSWITCH_BinValues($hash,"ds2406.getstate",1,undef,$owx_dev,substr($res,9,3),undef,substr($res,12));
return OWXSWITCH_BinValues($hash,"ds2406.getstate",1,undef,$owx_dev,substr($res,9,3),undef,substr($res,12));
#-- family = 29 => DS2408
}elsif( $hash->{OW_FAMILY} eq "29" ) {
#=============== get gpio values ===============================
@ -1193,7 +1193,7 @@ sub OWXSWITCH_SetState($$) {
#-- issue the match ROM command \x55 and the write status command
# \x55 at address TA1 = \x07 TA2 = \x00
#-- reading 9 + 4 + 2 data bytes = 15 bytes
my $select=sprintf("\x55\x07\x00%c",$statneu);
$select=sprintf("\x55\x07\x00%c",$statneu);
OWX_Reset($master);
$res=OWX_Complex($master,$owx_dev,$select,2);
if( $res eq 0 ){
@ -1243,7 +1243,7 @@ sub OWXSWITCH_SetState($$) {
sub OWXSWITCH_PT_GetState($) {
my ($thread,$hash) = @_;
my ($select, $res, $res2, $res3, @data, $response);
my ($select, $ret, @data, $response);
#-- ID of the device
my $owx_dev = $hash->{ROM_ID};
@ -1276,7 +1276,10 @@ sub OWXSWITCH_PT_GetState($) {
unless (length($response->{readdata}) == 4) {
PT_EXIT("$owx_dev has returned invalid data");
}
OWXSWITCH_BinValues($hash,"ds2406.getstate",1,1,$owx_dev,$response->{writedata},4,$response->{readdata});
$ret = OWXSWITCH_BinValues($hash,"ds2406.getstate",1,1,$owx_dev,$response->{writedata},4,$response->{readdata});
if (defined $ret) {
PT_EXIT($ret);
}
#-- family = 29 => DS2408
}elsif( $hash->{OW_FAMILY} eq "29" ) {
#=============== get gpio values ===============================
@ -1295,7 +1298,10 @@ sub OWXSWITCH_PT_GetState($) {
unless (length($response->{readdata}) == 10) {
PT_EXIT("$owx_dev has returned invalid data")
};
OWXSWITCH_BinValues($hash,"ds2408.getstate",1,1,$owx_dev,$response->{writedata},10,$response->{readdata});
$ret = OWXSWITCH_BinValues($hash,"ds2408.getstate",1,1,$owx_dev,$response->{writedata},10,$response->{readdata});
if (defined $ret) {
PT_EXIT($ret);
}
#-- family = 3A => DS2413
}elsif( $hash->{OW_FAMILY} eq "3A" ) {
#=============== get gpio values ===============================
@ -1314,7 +1320,10 @@ sub OWXSWITCH_PT_GetState($) {
unless (length($response->{readdata}) == 2) {
PT_EXIT("$owx_dev has returned invalid data");
}
OWXSWITCH_BinValues($hash,"ds2413.getstate",1,1,$owx_dev,$response->{writedata},2,$response->{readdata});
$ret = OWXSWITCH_BinValues($hash,"ds2413.getstate",1,1,$owx_dev,$response->{writedata},2,$response->{readdata});
if (defined $ret) {
PT_EXIT($ret);
}
} else {
PT_EXIT("unknown device family $hash->{OW_FAMILY}\n");
}
@ -1386,8 +1395,9 @@ sub OWXSWITCH_PT_SetState($$) {
if( int(@data) != 2){
PT_EXIT("state could not be set for device $owx_dev");
}
Log 1,"invalid CRC"
if (OWX_CRC16($command,$data[0],$data[1]) == 0);
if (OWX_CRC16($command,$data[0],$data[1]) == 0) {
PT_EXIT("invalid CRC");
}
#-- put into local buffer
$hash->{owg_val}->[0] = $value % 2;

View File

@ -86,7 +86,7 @@ no warnings 'deprecated';
sub Log3($$$);
sub AttrVal($$$);
my $owx_version="5.16";
my $owx_version="5.18";
my %gets = (
"id" => "",
@ -504,7 +504,7 @@ sub OWTHERM_GetValues($@) {
my $name = $hash->{NAME};
my $value = "";
my $ret = "";
my $ret;
#-- check if device needs to be initialized
if( $hash->{READINGS}{"state"}{VAL} eq "defined"){
@ -1008,7 +1008,6 @@ sub OWXTHERM_GetValues($) {
return "$owx_dev has returned invalid data"
if( length($res)!=19);
return OWXTHERM_BinValues($hash,"ds182x.reading",1,undef,$owx_dev,undef,undef,substr($res,10,9));
return undef;
}
#######################################################################################