DevIo.pm: DevIo_writeBaudrate function from chri.jaes (Forum #139055)
git-svn-id: https://svn.fhem.de/fhem/trunk@29109 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -634,18 +634,36 @@ DevIo_OpenDev($$$;$)
|
|||||||
$selectlist{"$name.$dev"} = $hash;
|
$selectlist{"$name.$dev"} = $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($baudrate) {
|
DevIo_writeBaudrate($hash, $baudrate, $databits, $parity, $stopbits);
|
||||||
|
}
|
||||||
|
|
||||||
|
return &$doCb(&$doTailWork());
|
||||||
|
}
|
||||||
|
|
||||||
|
#139055
|
||||||
|
sub
|
||||||
|
DevIo_writeBaudrate($$;$$$)
|
||||||
|
{
|
||||||
|
my ($hash, $baudrate, $databits, $parity, $stopbits) = @_;
|
||||||
|
my $po = $hash->{USBDev};
|
||||||
|
my $name= $hash->{NAME};
|
||||||
|
|
||||||
|
if ($baudrate) {
|
||||||
$po->reset_error();
|
$po->reset_error();
|
||||||
|
if (defined($databits)) {
|
||||||
my $p = ($parity eq "none" ? "N" : ($parity eq "odd" ? "O" : "E"));
|
my $p = ($parity eq "none" ? "N" : ($parity eq "odd" ? "O" : "E"));
|
||||||
Log3 $name, 3, "Setting $name serial parameters to ".
|
Log3 $name, 3, "Setting $name serial parameters to ".
|
||||||
"$baudrate,$databits,$p,$stopbits" if(!$hash->{DevioText});
|
"$baudrate,$databits,$p,$stopbits" if(!$hash->{DevioText});
|
||||||
$po->baudrate($baudrate);
|
|
||||||
$po->databits($databits);
|
$po->databits($databits);
|
||||||
$po->parity($parity);
|
$po->parity($parity);
|
||||||
$po->stopbits($stopbits);
|
$po->stopbits($stopbits);
|
||||||
$po->handshake('none');
|
$po->handshake('none');
|
||||||
|
} else {
|
||||||
# This part is for some Linux kernel versions whih has strange default
|
Log3 $name, 3, "Setting $name serial baudrate to ".
|
||||||
|
"$baudrate" if(!$hash->{DevioText});
|
||||||
|
}
|
||||||
|
$po->baudrate($baudrate);
|
||||||
|
# This part is for some Linux kernel versions which has strange default
|
||||||
# settings. Device::SerialPort is nice: if the flag is not defined for
|
# settings. Device::SerialPort is nice: if the flag is not defined for
|
||||||
# your OS then it will be ignored.
|
# your OS then it will be ignored.
|
||||||
|
|
||||||
@@ -663,11 +681,7 @@ DevIo_OpenDev($$$;$)
|
|||||||
$po->stty_opost(0);
|
$po->stty_opost(0);
|
||||||
$po->stty_icrnl(0);
|
$po->stty_icrnl(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$po->write_settings;
|
$po->write_settings;
|
||||||
}
|
|
||||||
|
|
||||||
return &$doCb(&$doTailWork());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
|
|||||||
Reference in New Issue
Block a user