Skip Menu |

This queue is for tickets about the Win32-SerialPort CPAN distribution.

Report information
The Basics
Id: 120068
Status: new
Priority: 0/
Queue: Win32-SerialPort

People
Owner: Nobody in particular
Requestors: LSTEVENS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.22
Fixed in: (no value)



Subject: Fails to set baudrate on some USB Serial ports
Hi I'm the author of module Control::CLI which uses Win32::SerialPort for serial port connections. I have had reports from a user of one of my Perl applications that he was unable to use his USB Serial port because the application was failing to set the desired baudrate. His USB Serial port however works fine in other applications like TeraTerm. Yet if he sets the desired baudrate with TeraTerm, the Perl based application is then able to use his USB serial port at the desired baudrate. I believe this is exactly the same issue reported in bug id 25539, raised 10 years ago... so I prefer to open this new bug report! The problem is the following: USB Serial port Targus PA088, even with latest MCT driver 13.2.98, reports the following capabilities (on MSWin32): MODEMDEVCAPS: $MC_ActualSize= 0 $MC_ReqSize= 0 $MC_SpecOffset= 0 $MC_SpecSize= 0 $MC_ProvVersion= 0 $MC_ManfOffset= 0 $MC_ManfSize= 0 $MC_ModOffset= 0 $MC_ModSize= 0 $MC_VerOffset= 0 $MC_VerSize= 0 $MC_DialOpt= 0 $MC_CallFailTime= 0 $MC_IdleTime= 0 $MC_SpkrVol= 0 $MC_SpkrMode= 0 $MC_ModOpt= 0 $MC_MaxDTE= 0 $MC_MaxDCE= 0 $CP_Length= 64 $CP_Version= 2 $CP_ServiceMask= 1 $CP_Reserved1= 0 $CP_MaxTxQueue= 1000 $CP_MaxRxQueue= 1000 $CP_MaxBaud= 20000 $CP_ProvSubType= 6 $CP_ProvCapabilities= 1cb $CP_SettableParams= 7f $CP_SettableBaud= 67b70 $CP_SettableData= f $CP_SettableStopParity= 1f07 $CP_CurrentTxQueue= 0 $CP_CurrentRxQueue= 64 $CP_ProvSpec1= 0 $CP_ProvSpec2= 0 The problem stems from the value it reports for $CP_MaxBaud, which indicates that the maximum baud rate it supports is BAUD_115200 (0x00020000) = 115200 bps Win32API::CommPort version 0.21 incorrectly interprets this as the Serial Port being unable to support any other baud rate than 115200, and thus refuses to set a different baudrate when the is_baudrate() method is called. Most other Serial ports I have worked with report a $CP_MaxBaud set to BAUD_USER (0x10000000) = Programmable baud rate In which case Win32API::CommPort operates correctly. But this does not mean that the Serial port in question is behaving incorrectly by setting a MaxBaud of 115200. According to Microsoft documentation https://msdn.microsoft.com/en-us/library/windows/desktop/aa363189(v=vs.85).aspx dwMaxBaud : The maximum allowable baud rate, in bits per second (bps). Nowhere does it state that this should be the only baud rate supported by the device. Besides, the same USB serial port reports ($CP_SettableParams= 7f) which from the same Microsoft link is: dwSettableParams : A bitmask indicating the communications parameters that can be changed Which has the following bit set: SP_BAUD 0x0002 Furthermore we have $CP_SettableBaud= 67b70, which indicates that a number of different baudrates are supported. Ironically, if the Serial port is found to be already configured for a baudrate other than what specified in $CP_MaxBaud, then Win32API::CommPort authorizes this additional baudrate in line 1009: $self->{"_L_BAUD"}{$self->{BAUD}} = $self->{BAUD}; # actual must be ok This explains why using some other program (like TeraTerm) to set the desired baudrate then enables Win32::SerialPort to set the same baudrate. I believe CommPort.pm should be fixed with this change on line 838: 838c838 < if ($CP_MaxBaud & BAUD_USER) { --- Show quoted text
> if ($self->{"_C_BAUD"}) {
With this fix my user is now able to use my Perl based application on his USB serial cable. Thanks Best regards Ludovico Stevens