在 Perl 下,在 Linux 上打开 Serial::Device 作为文件会重置我的 Arduino,但我不希望它被重置。Arduino可以通过脉冲DTR复位,因此打开串口设备必须默认脉冲DTR。
我的问题是:如何防止我的 Arduino 被重置(DTR 被脉冲)?
这个最小的代码重置了我的 Arduino:
use Device::SerialPort;
use Symbol qw( gensym );
my $handle = gensym();
my $PortName = '/dev/ttyUSB1';
my $PortObj = tie( *$handle , "Device::SerialPort" , $PortName ) or die "Cannot open serial port: $!\n";
# At this point the Arduino is being reset.
我知道这只是通过使用PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile);
方法打开设备来完成,但我不能使用该方法,因为我无法检查串行缓冲区中是否有数据等待。在我的程序中,测试数据等待是一项硬性要求。