Reputation: 11
When I send an underscore to the Serial Port (COM42), it acts as though I've send a backspace to the Serial Port. For example, if I send "Perl_Great", my Serial Port displays "PerGreat" I currently have the Serial Port configured this way. Is there a parameter to configure the Serial Port to a different encoding such that it won't treat an underscore as a backspace?
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
Upvotes: 1
Views: 124
Reputation: 128
The simple answer to you question is - "probably not" :-)
Your question "Is there a parameter to configure the Serial Port to a different encoding such that it won't treat an underscore as a backspace?", might be better phrased, as "what is causing the receiver of the string "Perl_Great" to drop two characters and only get "PerGreat"?
You ask about encoding, and mention UTF8, have you verified that your underscore in "Perl_Great" is eq "\x5f", and not some magic utf-8 string
Upvotes: 1