2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

10_FRM.pm: fix Device::Firmata check (forum #114552 msg #1112141)

- fix missing internal "DRIVER_VERSION"
- delete internal IODev_ERROR of FRM client if Device::Firmata check yields STATUS_INSTALLED
- reevaluate Device::Firmata check if last check did not yield STATUS_INSTALLED
- execute Device::Firmata check in FRM_Client_Define

git-svn-id: https://svn.fhem.de/fhem/trunk@23393 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jensb 2020-12-20 19:35:57 +00:00
parent 40c0ced777
commit 8af8e98c5d
2 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it. # Do not insert empty lines here, update check depends on it.
- bugfix: 10_FRM: Device::Firmata check (forum #114552 msg #1112141)
- bugfix: 55_DWD_OpenData: forecast rotation (forum #83097 msg #1108423) - bugfix: 55_DWD_OpenData: forecast rotation (forum #83097 msg #1108423)
- feature: 02_RSS: added readings to show filename and type of background - feature: 02_RSS: added readings to show filename and type of background
- bugfix: 57_SSCal: accept calendar names which are contain umlauts - bugfix: 57_SSCal: accept calendar names which are contain umlauts

View File

@ -43,7 +43,6 @@ use strict;
use warnings; use warnings;
use vars qw{%attr %defs}; use vars qw{%attr %defs};
use GPUtils qw(:all);
use DevIo; use DevIo;
#add FHEM/lib to @INC if it's not already included. Should rather be in fhem.pl than here though... #add FHEM/lib to @INC if it's not already included. Should rather be in fhem.pl than here though...
@ -180,14 +179,16 @@ sub FRM_Define {
} }
# check if Device::Firmata module is properly installed # check if Device::Firmata module is properly installed
$deviceFirmataStatus = FRM_Get_Device_Firmata_Status(); FRM_Get_Device_Firmata_Status();
given($deviceFirmataStatus) { given($deviceFirmataStatus) {
when(FRM_DEVICE_FIRMATA_STATUS_INSTALLED) { when(FRM_DEVICE_FIRMATA_STATUS_INSTALLED) {
delete $main::defs{$name}{DRIVER_STATUS}; delete $main::defs{$name}{DRIVER_STATUS};
$main::defs{$name}{DRIVER_VERSION} = $Device::Firmata::VERSION;
} }
when(FRM_DEVICE_FIRMATA_STATUS_NOT_INSTALLED) { when(FRM_DEVICE_FIRMATA_STATUS_NOT_INSTALLED) {
$main::defs{$name}{DRIVER_STATUS} = 'Perl module Device::Firmata not found, see Commandref for details how to fix'; $main::defs{$name}{DRIVER_STATUS} = 'Perl module Device::Firmata not found, see Commandref for details how to fix';
delete $main::defs{$name}{DRIVER_VERSION};
main::Log3 $name, 1, "$name ERROR: " . $main::defs{$name}{DRIVER_STATUS}; main::Log3 $name, 1, "$name ERROR: " . $main::defs{$name}{DRIVER_STATUS};
readingsSingleUpdate($hash, 'state', 'error', 1); readingsSingleUpdate($hash, 'state', 'error', 1);
return undef; return undef;
@ -195,8 +196,8 @@ sub FRM_Define {
when(FRM_DEVICE_FIRMATA_STATUS_WRONG_VERSION) { when(FRM_DEVICE_FIRMATA_STATUS_WRONG_VERSION) {
$main::defs{$name}{DRIVER_STATUS} = 'Perl module Device::Firmata version ' . FRM_MIN_DEVICE_FIRMATA_VERSION . ' or higher required, see Commandref for details how to fix'; $main::defs{$name}{DRIVER_STATUS} = 'Perl module Device::Firmata version ' . FRM_MIN_DEVICE_FIRMATA_VERSION . ' or higher required, see Commandref for details how to fix';
$main::defs{$name}{DRIVER_VERSION} = $Device::Firmata::VERSION;
main::Log3 $name, 2, "$name WARNING: " . $main::defs{$name}{DRIVER_STATUS}; main::Log3 $name, 2, "$name WARNING: " . $main::defs{$name}{DRIVER_STATUS};
$deviceFirmataStatus = FRM_DEVICE_FIRMATA_STATUS_INSTALLED; $deviceFirmataStatus = FRM_DEVICE_FIRMATA_STATUS_INSTALLED;
# @TODO readingsSingleUpdate($hash, 'state', 'error', 1); # @TODO readingsSingleUpdate($hash, 'state', 'error', 1);
# @TODO $deviceFirmataStatus = FRM_DEVICE_FIRMATA_STATUS_WRONG_VERSION; # @TODO $deviceFirmataStatus = FRM_DEVICE_FIRMATA_STATUS_WRONG_VERSION;
@ -204,7 +205,7 @@ sub FRM_Define {
} }
default { default {
main::Log3 $name, 1, "$name ERROR: Validation of Perl module Device::Firmata failed"; main::Log3 $name, 1, "$name ERROR: validation of Perl module Device::Firmata failed";
readingsSingleUpdate($hash, 'state', 'error', 1); readingsSingleUpdate($hash, 'state', 'error', 1);
return undef; return undef;
} }
@ -991,7 +992,7 @@ sub FRM_SetupDevice {
sub FRM_Get_Device_Firmata_Status { sub FRM_Get_Device_Firmata_Status {
# check if Device::Firmata module is properly installed # check if Device::Firmata module is properly installed
if ($deviceFirmataStatus == FRM_DEVICE_FIRMATA_STATUS_UNDEFINED) { if ($deviceFirmataStatus != FRM_DEVICE_FIRMATA_STATUS_INSTALLED) {
eval { eval {
require Device::Firmata; require Device::Firmata;
require Device::Firmata::Constants; require Device::Firmata::Constants;
@ -1119,11 +1120,13 @@ sub FRM_Client_Define {
my $cname = $chash->{NAME}; my $cname = $chash->{NAME};
# check if Device::Firmata module is properly installed # check if Device::Firmata module is properly installed
FRM_Get_Device_Firmata_Status();
if ($deviceFirmataStatus > 0) { if ($deviceFirmataStatus > 0) {
delete $main::defs{$cname}{IODev_ERROR};
readingsSingleUpdate($chash, 'state', 'defined', 1); readingsSingleUpdate($chash, 'state', 'defined', 1);
} else { } else {
$main::defs{$cname}{IODev_ERROR} = 1; $main::defs{$cname}{IODev_ERROR} = 1;
readingsSingleUpdate($chash, 'state', 'error: Perl module Device::Firmata not properly installed', 1); readingsSingleUpdate($chash, 'state', 'error: Perl module Device::Firmata not properly installed, check IODev for more details', 1);
} }
if ($main::init_done) { if ($main::init_done) {
@ -2262,6 +2265,12 @@ sub FRM_Serial_Close {
30.10.2020 jensb 30.10.2020 jensb
o "require DevIO" replaced with "use DevIO" (forum 110125) o "require DevIO" replaced with "use DevIO" (forum 110125)
23.11.2020 jensb
o fix missing internal "DRIVER_VERSION"
o delete internal IODev_ERROR of FRM client if Device::Firmata check yields STATUS_INSTALLED
o reevaluate Device::Firmata check if last check did not yield STATUS_INSTALLED
o execute Device::Firmata check in FRM_Client_Define
=cut =cut