Skip to content

Commit

Permalink
00_SIGNALduino.pm
Browse files Browse the repository at this point in the history
Changed WriteFN back to previous format. Usage is: $iohash, 'function', 'message' : $io,'sendMSG','P16#01010101#R3';
WrtieFN will always call the SET Function. If no 'function' is provided, raw will be used as function.

Removed $hash->{CMDS} it is not needed. Instead using the Reading 'cmd'

Device gets the state opened if andythink is okay during init.
  • Loading branch information
sidey79 committed Mar 12, 2016
1 parent 458effa commit 86704c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ use Scalar::Util qw(looks_like_number);

sub SIGNALduino_Attr(@);
sub SIGNALduino_Clear($);
#sub SIGNALduino_HandleCurRequest($$);
#sub SIGNALduino_HandleWriteQueue($);
sub SIGNALduino_HandleWriteQueue($);
sub SIGNALduino_Parse($$$$@);
sub SIGNALduino_Read($);
sub SIGNALduino_ReadAnswer($$$$);
sub SIGNALduino_Ready($);
sub SIGNALduino_Write($$$;$);
sub SIGNALduino_Write($$$);

sub SIGNALduino_SimpleWrite(@);

Expand Down Expand Up @@ -830,7 +829,7 @@ SIGNALduino_Define($$)
$dev .= "\@57600";
}

$hash->{CMDS} = "";
#$hash->{CMDS} = "";
$hash->{Clients} = $clientsSIGNALduino;
$hash->{MatchList} = \%matchListSIGNALduino;

Expand Down Expand Up @@ -1093,7 +1092,7 @@ SIGNALduino_Set($@)
} else {
Log3 $name, 5, "$name/set: set $name $cmd $arg";
#SIGNALduino_SimpleWrite($hash, $arg);
return "Unknown argument $cmd, choose one of ".$hash->{CMDS};
return "Unknown argument $cmd, choose one of ". ReadingsVal($name,'cmd',' help me');
}

return undef;
Expand Down Expand Up @@ -1207,7 +1206,7 @@ sub SIGNALduino_parseResponse($$$)
{ # decode it
#$msg = hex($msg); # /125; only for col or coc
$msg = sprintf("%d %02d:%02d:%02d", $msg/86400, ($msg%86400)/3600, ($msg%3600)/60, $msg%60);
}
}

return $msg;
}
Expand Down Expand Up @@ -1294,12 +1293,12 @@ SIGNALduino_DoInit($)


# Cmd-String feststellen
my $cmds = SIGNALduino_Get($hash, $name, "cmds", 0);
SIGNALduino_Get($hash, $name, "cmds", 0);
#$cmds =~ s/$name cmds =>//g;
#$cmds =~ s/ //g;
$hash->{CMDS} = $cmds;
Log3 $hash, 3, "$name: Possible commands: " . $hash->{CMDS};
readingsSingleUpdate($hash, "state", "Programming", 1);
#$hash->{CMDS} = $cmds;
#Log3 $hash, 3, "$name: Possible commands: " . $hash->{CMDS};
#readingsSingleUpdate($hash, "state", "Programming", 1);

}
# if( my $initCommandsString = AttrVal($name, "initCommands", undef) ) {
Expand All @@ -1309,7 +1308,7 @@ SIGNALduino_DoInit($)
# }
# }
# $hash->{STATE} = "Initialized";
readingsSingleUpdate($hash, "state", "Initialized", 1);
readingsSingleUpdate($hash, "state", "opened", 1);

# Reset the counter
delete($hash->{XMIT_TIME});
Expand Down Expand Up @@ -1447,17 +1446,22 @@ SIGNALduino_XmitLimitCheck($$)


#####################################
## API to logical modules: Provide as Hash of IO Device, type of function ; command to call ; message to send
sub
SIGNALduino_Write($$$;$)
SIGNALduino_Write($$$)
{
my ($hash,$fn,$msg,$isNotRaw) = @_;
my ($hash,$fn,$msg) = @_;
my $name = $hash->{NAME};

Log3 $name, 5, "$name/write: adding to queue $fn$msg";
my $bstring = "$fn$msg";
$fn="RAW" if $fn eq "";

Log3 $name, 5, "$name/write: adding to queue $fn $msg";

#SIGNALduino_SimpleWrite($hash, $bstring);
SIGNALduino_AddSendQueue($hash,$bstring);

SIGNALduino_Set($hash,$name,$fn,$msg);
#SIGNALduino_AddSendQueue($hash,$bstring);

}


Expand Down
2 changes: 1 addition & 1 deletion controls_signalduino.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ UPD 2016_11_02_22:47:30 15601 FHEM/14_SD_WS09.pm
UPD 2016_11_02_22:47:30 7824 FHEM/14_SIGNALduino_RSL.pm
UPD 2016_11_02_22:47:30 9837 FHEM/14_SD_AS.pm
UPD 2016_11_02_22:49:40 9037 FHEM/14_SD_WS07.pm
UPD 2016_13_03_00:10:02 102808 FHEM/00_SIGNALduino.pm
UPD 2016_13_03_00:36:46 102924 FHEM/00_SIGNALduino.pm

0 comments on commit 86704c9

Please sign in to comment.