mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-13 11:16:36 +00:00
FRM: switch to Log3
Merge branch 'frm_log3' git-svn-id: https://svn.fhem.de/fhem/trunk@4242 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8b09aea91c
commit
f298608b8f
@ -49,7 +49,7 @@ sub FRM_Initialize($) {
|
||||
$hash->{SetFn} = "FRM_Set";
|
||||
$hash->{AttrFn} = "FRM_Attr";
|
||||
|
||||
$hash->{AttrList} = "model:nano dummy:1,0 loglevel:0,1,2,3,4,5,6 sampling-interval i2c-config $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "model:nano dummy:1,0 sampling-interval i2c-config $main::readingFnAttributes";
|
||||
}
|
||||
|
||||
#####################################
|
||||
@ -78,7 +78,7 @@ sub FRM_Define($$) {
|
||||
DevIo_CloseDev($hash);
|
||||
|
||||
if ( $dev eq "none" ) {
|
||||
Log (GetLogLevel($hash->{NAME}), "FRM device is none, commands will be echoed only");
|
||||
Log3 $name,3,"device is none, commands will be echoed only";
|
||||
$main::attr{$name}{dummy} = 1;
|
||||
return undef;
|
||||
}
|
||||
@ -242,8 +242,7 @@ sub FRM_Attr(@) {
|
||||
if ($command eq "set") {
|
||||
$main::attr{$name}{$attribute}=$value;
|
||||
if ($attribute eq "sampling-interval"
|
||||
or $attribute eq "i2c-config"
|
||||
or $attribute eq "loglevel" ) {
|
||||
or $attribute eq "i2c-config") {
|
||||
FRM_apply_attribute($main::defs{$name},$attribute);
|
||||
}
|
||||
}
|
||||
@ -274,11 +273,7 @@ sub FRM_apply_attribute {
|
||||
} else {
|
||||
$err = "Error, arduino doesn't support I2C";
|
||||
}
|
||||
Log (GetLogLevel($hash->{NAME},2),$err) if ($err);
|
||||
}
|
||||
} elsif ($attribute eq "loglevel") {
|
||||
if (defined $firmata->{io}) {
|
||||
$firmata->{io}->{loglevel} = AttrVal($name,$attribute,5);
|
||||
Log3 $name,2,$err if ($err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -308,7 +303,7 @@ sub FRM_DoInit($) {
|
||||
$device->{protocol}->{protocol_version} = $device->{metadata}{firmware_version};
|
||||
$main::defs{$name}{firmware} = $device->{metadata}{firmware};
|
||||
$main::defs{$name}{firmware_version} = $device->{metadata}{firmware_version};
|
||||
Log (3, "Firmata Firmware Version: ".$device->{metadata}{firmware}." ".$device->{metadata}{firmware_version});
|
||||
Log3 $name,3,"Firmata Firmware Version: ".$device->{metadata}{firmware}." ".$device->{metadata}{firmware_version};
|
||||
$device->analog_mapping_query();
|
||||
$device->capability_query();
|
||||
do {
|
||||
@ -358,7 +353,7 @@ sub FRM_DoInit($) {
|
||||
} else {
|
||||
select (undef,undef,undef,0.01);
|
||||
if (time > $queryTicks) {
|
||||
Log (3, "querying Firmata Firmware Version");
|
||||
Log3 $name,3,"querying Firmata Firmware Version";
|
||||
$device->firmware_version_query();
|
||||
$queryTicks++;
|
||||
}
|
||||
@ -372,7 +367,7 @@ sub FRM_DoInit($) {
|
||||
FRM_forall_clients($shash,\&FRM_Init_Client,undef);
|
||||
return undef;
|
||||
}
|
||||
Log (3, "no response from Firmata, closing DevIO");
|
||||
Log3 $name,3,"no response from Firmata, closing DevIO";
|
||||
DevIo_Disconnected($hash);
|
||||
delete $hash->{FirmataDevice};
|
||||
return "FirmataDevice not responding";
|
||||
@ -399,9 +394,10 @@ FRM_Init_Client($@) {
|
||||
my @a = split("[ \t][ \t]*", $hash->{DEF});
|
||||
$args = \@a;
|
||||
}
|
||||
my $ret = CallFn($hash->{NAME},"InitFn",$hash,$args);
|
||||
my $name = $hash->{NAME};
|
||||
my $ret = CallFn($name,"InitFn",$hash,$args);
|
||||
if ($ret) {
|
||||
Log (GetLogLevel($hash->{NAME},2),"error initializing ".$hash->{NAME}.": ".$ret);
|
||||
Log3 $name,2,"error initializing ".$hash->{NAME}.": ".$ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,21 +503,22 @@ sub new {
|
||||
my ($class,$hash) = @_;
|
||||
return bless {
|
||||
hash => $hash,
|
||||
loglevel => main::GetLogLevel($hash->{NAME},5),
|
||||
}, $class;
|
||||
}
|
||||
|
||||
sub data_write {
|
||||
my ( $self, $buf ) = @_;
|
||||
main::Log ($self->{loglevel}, ">".join(",",map{sprintf"%02x",ord$_}split//,$buf));
|
||||
main::DevIo_SimpleWrite($self->{hash},$buf,undef);
|
||||
my $hash = $self->{hash};
|
||||
main::Log3 $hash->{NAME},5,">".join(",",map{sprintf"%02x",ord$_}split//,$buf);
|
||||
main::DevIo_SimpleWrite($hash,$buf,undef);
|
||||
}
|
||||
|
||||
sub data_read {
|
||||
my ( $self, $bytes ) = @_;
|
||||
my $string = main::DevIo_SimpleRead($self->{hash});
|
||||
my $hash = $self->{hash};
|
||||
my $string = main::DevIo_SimpleRead($hash);
|
||||
if (defined $string ) {
|
||||
main::Log ($self->{loglevel},"<".join(",",map{sprintf"%02x",ord$_}split//,$string));
|
||||
main::Log3 $hash->{NAME},5,"<".join(",",map{sprintf"%02x",ord$_}split//,$string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
@ -532,7 +529,7 @@ sub
|
||||
FRM_i2c_observer
|
||||
{
|
||||
my ($data,$hash) = @_;
|
||||
Log GetLogLevel($hash->{NAME},5),"onI2CMessage address: '".$data->{address}."', register: '".$data->{register}."' data: '".$data->{data}."'";
|
||||
Log3 $hash->{NAME},5,"onI2CMessage address: '".$data->{address}."', register: '".$data->{register}."' data: '".$data->{data}."'";
|
||||
FRM_forall_clients($hash,\&FRM_i2c_update_device,$data);
|
||||
}
|
||||
|
||||
@ -553,7 +550,7 @@ sub FRM_i2c_update_device
|
||||
sub FRM_string_observer
|
||||
{
|
||||
my ($string,$hash) = @_;
|
||||
Log (GetLogLevel($hash->{NAME},3), "received String_data: ".$string);
|
||||
Log3 $hash->{NAME},3,"received String_data: ".$string;
|
||||
readingsSingleUpdate($hash,"error",$string,1);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ FRM_AD_Initialize($)
|
||||
$hash->{DefFn} = "FRM_Client_Define";
|
||||
$hash->{InitFn} = "FRM_AD_Init";
|
||||
|
||||
$hash->{AttrList} = "IODev upper-threshold lower-threshold loglevel:0,1,2,3,4,5,6 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "IODev upper-threshold lower-threshold $main::readingFnAttributes";
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
||||
@ -62,10 +62,10 @@ sub
|
||||
FRM_AD_observer
|
||||
{
|
||||
my ($pin,$old,$new,$hash) = @_;
|
||||
main::Log(6,"onAnalogMessage for pin ".$pin.", old: ".(defined $old ? $old : "--").", new: ".(defined $new ? $new : "--"));
|
||||
my $name = $hash->{NAME};
|
||||
Log3 $name,6,"onAnalogMessage for pin ".$pin.", old: ".(defined $old ? $old : "--").", new: ".(defined $new ? $new : "--");
|
||||
main::readingsBeginUpdate($hash);
|
||||
main::readingsBulkUpdate($hash,"reading",$new,1);
|
||||
my $name = $hash->{NAME};
|
||||
my $upperthresholdalarm = ReadingsVal($name,"alarm-upper-threshold","off");
|
||||
if ( $new < AttrVal($name,"upper-threshold",1024) ) {
|
||||
if ( $upperthresholdalarm eq "on" ) {
|
||||
|
@ -26,7 +26,7 @@ FRM_I2C_Initialize($)
|
||||
$hash->{UndefFn} = "FRM_Client_Undef";
|
||||
$hash->{AttrFn} = "FRM_I2C_Attr";
|
||||
|
||||
$hash->{AttrList} = "IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "IODev $main::readingFnAttributes";
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ FRM_IN_Initialize($)
|
||||
$hash->{InitFn} = "FRM_IN_Init";
|
||||
$hash->{UndefFn} = "FRM_Client_Undef";
|
||||
|
||||
$hash->{AttrList} = "IODev count-mode:none,rising,falling,both count-threshold reset-on-threshold-reached:yes,no internal-pullup:on,off loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "IODev count-mode:none,rising,falling,both count-threshold reset-on-threshold-reached:yes,no internal-pullup:on,off $main::readingFnAttributes";
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ sub
|
||||
FRM_IN_observer
|
||||
{
|
||||
my ($pin,$old,$new,$hash) = @_;
|
||||
main::Log(6,"onDigitalMessage for pin ".$pin.", old: ".(defined $old ? $old : "--").", new: ".(defined $new ? $new : "--"));
|
||||
my $name = $hash->{NAME};
|
||||
my $name = $hash->{NAME};
|
||||
Log3 $name,5,"onDigitalMessage for pin ".$pin.", old: ".(defined $old ? $old : "--").", new: ".(defined $new ? $new : "--");
|
||||
my $changed = ((!(defined $old)) or ($old != $new));
|
||||
main::readingsBeginUpdate($hash);
|
||||
if ($changed) {
|
||||
|
@ -40,7 +40,8 @@ FRM_LCD_Initialize($)
|
||||
$hash->{AttrFn} = "FRM_LCD_Attr";
|
||||
$hash->{StateFn} = "FRM_LCD_State";
|
||||
|
||||
$hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev model backLight:on,off blink:on,off autoClear:on,off autoBreak:on,off loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev model"
|
||||
." backLight:on,off blink:on,off autoClear:on,off autoBreak:on,off $main::readingFnAttributes";
|
||||
# autoScroll:on,off direction:leftToRight,rightToLeft do not work reliably
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ FRM_OUT_Initialize($)
|
||||
$hash->{AttrFn} = "FRM_OUT_Attr";
|
||||
$hash->{StateFn} = "FRM_OUT_State";
|
||||
|
||||
$hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev $main::readingFnAttributes";
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ FRM_PWM_Initialize($)
|
||||
$hash->{AttrFn} = "FRM_PWM_Attr";
|
||||
$hash->{StateFn} = "FRM_PWM_State";
|
||||
|
||||
$hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "restoreOnReconnect:on,off restoreOnStartup:on,off IODev $main::readingFnAttributes";
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ FRM_SERVO_Initialize($)
|
||||
$hash->{UndefFn} = "FRM_Client_Undef";
|
||||
$hash->{AttrFn} = "FRM_SERVO_Attr";
|
||||
|
||||
$hash->{AttrList} = "min-pulse max-pulse IODev loglevel:0,1,2,3,4,5 $main::readingFnAttributes";
|
||||
$hash->{AttrList} = "min-pulse max-pulse IODev $main::readingFnAttributes";
|
||||
main::LoadModule("FRM");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user