perl - 在 Perl 中向串口发送下划线
问题描述
当我向串行端口 (COM42) 发送下划线时,就好像我向串行端口发送了一个退格键。例如,如果我发送“Perl_Great”,我的串行端口会显示“PerGreat” 我目前以这种方式配置了串行端口。是否有一个参数可以将串行端口配置为不同的编码,这样它就不会将下划线视为退格?
use Win32::SerialPort;
my $port = new Win32::SerialPort( "\\\\.\\" . $self->{Port} )
or $self->__Error( "Could not open com port $self->{Port}\n\t$^E\n", 'FATAL' );
$port->baudrate($self->{BaudRate});
$port->parity($self->{Parity});
$port->databits($self->{DataBits});
$port->stopbits($self->{StopBits});
$port->handshake( "none" );
$port->are_match( "\r" ); # the symbol that "lookfor" will be looking for in a blocking call
$port->read_const_time(2000); #timeout for blocking read (ms)
$port->lookclear;
$port->write_settings();
my $command = "Perl_Great";
$port->write($command); # where $command is previously loaded with "Perl_Great". I checked with a Win32::MsgBox That the string is intact at this point
解决方案
您的问题的简单答案是-“可能不是”:-)
您的问题“是否有一个参数可以将串行端口配置为不同的编码,以便它不会将下划线视为退格?”,可能会更好地表述为“是什么导致字符串“Perl_Great”的接收者去掉两个字符,只得到“PerGreat”?
您询问编码,并提到 UTF8,您是否验证过“Perl_Great”中的下划线是 eq “\x5f”,而不是一些神奇的 utf-8 字符串
推荐阅读
- python - 没有名为“tensorflow”的模块 jupyter notebook
- javascript - 如何在对象的函数中提取变量?
- mysql - 在 JOIN MAX(date) MYSQL 之后使用 MIN 值
- react-native - React Native TTS 错误 TextToSpeech 未定义
- python - 搜索严格格式的字符串
- angular - 如何将rest api容器的url配置到另一个具有Angular cli代理的容器中
- deep-learning - 使用 Facebook Prophet 进行空预测
- sql - sql 内连接 - 多列
- java - 服务器为 Java 中的 POST 请求返回 400 错误代码
- file - Perl:给定一个文本文件,我必须将包含某个单词的文本行保存在矩阵中