mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-07 19:04:20 +00:00
factor out sub FRM_poll
git-svn-id: https://svn.fhem.de/fhem/trunk@2591 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5dfde9ffab
commit
bc543cf378
@ -183,12 +183,7 @@ sub FRM_DoInit($) {
|
|||||||
$device->system_reset();
|
$device->system_reset();
|
||||||
$device->firmware_version_query();
|
$device->firmware_version_query();
|
||||||
for (my $i=0;$i<50;$i++) {
|
for (my $i=0;$i<50;$i++) {
|
||||||
my ($rout, $rin) = ('', '');
|
if (FRM_poll($hash)) {
|
||||||
vec($rin, $hash->{FD}, 1) = 1;
|
|
||||||
my $nfound = select($rout=$rin, undef, undef, 0.1);
|
|
||||||
my $mfound = vec($rout, $hash->{FD}, 1);
|
|
||||||
if($mfound) {
|
|
||||||
$device->poll();
|
|
||||||
if ($device->{metadata}{firmware} && $device->{metadata}{firmware_version}){
|
if ($device->{metadata}{firmware} && $device->{metadata}{firmware_version}){
|
||||||
$device->{protocol}->{protocol_version} = $device->{metadata}{firmware_version};
|
$device->{protocol}->{protocol_version} = $device->{metadata}{firmware_version};
|
||||||
$main::defs{$name}{firmware} = $device->{metadata}{firmware};
|
$main::defs{$name}{firmware} = $device->{metadata}{firmware};
|
||||||
@ -196,12 +191,7 @@ sub FRM_DoInit($) {
|
|||||||
$device->analog_mapping_query();
|
$device->analog_mapping_query();
|
||||||
$device->capability_query();
|
$device->capability_query();
|
||||||
for (my $j=0;$j<100;$j++) {
|
for (my $j=0;$j<100;$j++) {
|
||||||
my ($rout, $rin) = ('', '');
|
if (FRM_poll($hash)) {
|
||||||
vec($rin, $hash->{FD}, 1) = 1;
|
|
||||||
my $nfound = select($rout=$rin, undef, undef, 0.1);
|
|
||||||
my $mfound = vec($rout, $hash->{FD}, 1);
|
|
||||||
if ($mfound) {
|
|
||||||
$device->poll();
|
|
||||||
if (($device->{metadata}{analog_mappings}) and ($device->{metadata}{capabilities})) {
|
if (($device->{metadata}{analog_mappings}) and ($device->{metadata}{capabilities})) {
|
||||||
my $inputpins = $device->{metadata}{input_pins};
|
my $inputpins = $device->{metadata}{input_pins};
|
||||||
$main::defs{$name}{input_pins} = join(",", sort{$a<=>$b}(@$inputpins));
|
$main::defs{$name}{input_pins} = join(",", sort{$a<=>$b}(@$inputpins));
|
||||||
@ -347,6 +337,19 @@ sub FRM_string_observer
|
|||||||
main::readingsSingleUpdate($hash,"error",$string,1);
|
main::readingsSingleUpdate($hash,"error",$string,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub FRM_poll
|
||||||
|
{
|
||||||
|
my ($hash) = @_;
|
||||||
|
my ($rout, $rin) = ('', '');
|
||||||
|
vec($rin, $hash->{FD}, 1) = 1;
|
||||||
|
my $nfound = select($rout=$rin, undef, undef, 0.1);
|
||||||
|
my $mfound = vec($rout, $hash->{FD}, 1);
|
||||||
|
if($mfound) {
|
||||||
|
$hash->{FirmataDevice}->poll();
|
||||||
|
}
|
||||||
|
return $mfound;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user