Skip Menu |

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

Report information
The Basics
Id: 33559
Status: open
Priority: 0/
Queue: Win32-SerialPort

People
Owner: Nobody in particular
Requestors: wsvries [...] xs4all.nl
Cc:
AdminCc:

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



Subject: block length error
Date: Mon, 25 Feb 2008 10:54:29 +0100 (CET)
To: bug-Win32-SerialPort [...] rt.cpan.org
From: "Wim de Vries" <wsvries [...] xs4all.nl>
Hi, WinXP, SP2, Perl v5.8.8,Win32-serialport 0.19 (Have seen the same problem as I have raised once on mailing lists but there was no answer.) I try to get some bytes from an USB device (COM7). I got the following error: "invalid COMMPROP block length= 66 " so I changed the lines (line 661 in commport.pm). Original is 64 , I made it 66 if (($CP_Length > 66) and ($self->{"_TYPE"} == PST_RS232)) { carp "invalid COMMPROP block length= $CP_Length"; undef $self; return; Now it works, but sometimes WinXP goes completely down. Can that be caused by the change I made? Thanks, Wim de Vries
Subject: Re: [rt.cpan.org #33559] block length error
Date: Mon, 25 Feb 2008 19:06:10 EST
To: bug-Win32-SerialPort [...] rt.cpan.org
From: Bbirthisel [...] aol.com
Hi Wim, In a message dated 2/25/2008 4:55:46 AM Eastern Standard Time, bug-Win32-SerialPort@rt.cpan.org writes: Show quoted text
> Mon Feb 25 04:55:28 2008: Request 33559 was acted upon. > Transaction: Ticket created by wsvries@xs4all.nl > Queue: Win32-SerialPort > Subject: block length error > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: wsvries@xs4all.nl > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=33559 > > > > Hi, > WinXP, SP2, Perl v5.8.8,Win32-serialport 0.19 > (Have seen the same problem as I have raised once on mailing lists but > there was no answer.)
I don't recall seeing it. But it may have come at avery busy time. Show quoted text
> I try to get some bytes from an USB device (COM7). > I got the following error: > "invalid COMMPROP block length= 66 " > so I changed the lines (line 661 in commport.pm). > Original is 64 , I made it 66 > if (($CP_Length > 66) and ($self->{"_TYPE"} == PST_RS232)) { > carp "invalid COMMPROP block length= $CP_Length"; > undef $self; > return;
This is a leftover error message from the early days of Windows 95. I left the message even though I didn't expect to see it again after developers learned how to write drivers for the W95++ driver model. One of the factors in that driver setup was a device-specific length for the data structure passed to the API. Essentially, all "regular" RS-232 devices used a 64 byte long structure. Modems used a longer one (that varied with the feature set - but the perl module can interpret the proper length for that type by reading the API and extracting the length). Developers who had only used MS-DOS (or Windows 3.x) drivers had an initial learning curve for the much more complicated (but also more robust) serial drivers. So I saw several of these errors in the early days (and they were all flawed drivers or similar issues). I suspect that may me at work here as well if it only happens on COM7 (or other ports above 4). Are there any special features associated with this USB device?. If the COMMPROP structure is really 66 bytes, it is not a PST_RS232 no matter what it reports. Show quoted text
> Now it works, but sometimes WinXP goes completely down. Can that be caused > by the change I made? > Thanks, > Wim de Vries
One of the things that distinguishes Win32API::Commport from most other perl modules is its extensive use of (nearly) raw API calls and packed data structures (via the Win32::API module). Plus the fact it is talking to a real hardware driver using those calls. It is the latter factor that explains the crash. Since the serial driver handles hardware interrupts and device buffers, it runs with Operating System privileges rather than just User privileges. So issuing an API call with a different length than the OS expects can cause very odd results. Is there some way to test the devices with one of the "traditional" serial ports? Or is there something about the devices that prevents that sort of test? -bill ************** Ideas to please picky eaters. Watch video on AOL Living. (http://living.aol.com/video/how-to-please-your-picky-eater/rachel-campos-duffy/2050827?NCID=aolcmp00300000002598)
From: steve [...] affinitydevices.com
Sir, To follow up on the previous gentlemen's post, I am observing the same problem and it is with a Cygnal/SI Labs CP2102 device. It is a USB to Serial converter. Show quoted text
> Are there any special features associated with this USB device?. > If the COMMPROP structure is really 66bytes, it is not a PST_RS232 no > matter what it reports.
There are "some" special features to this device, but come in the way of software that allows you to set certain values for the device. (PID, VID, Serial#, Vendor String, Etc) But all in all, it is a USB to serial converter. I can use the software with other USB to Serial devices, such as the Keyspan USA-19HS, but not wit this CP2102. I modified the the check to 66, as the previous poster did, and it passed the startup sequence but would not pass communication. Show quoted text
> Is there some way to test the devices with one of the "traditional" > serial > ports? Or is there something about the devices that prevents that sort > of test? > > -bill
I would be more than willing to perform any tests to help solve this.
I have a couple of USB serial ports which don't exhibit this problem which are based on FDTI and Prolific chips. Can anyone confirm if this is still an issue?
We have also seen this issue with USB serial devices, both commercially available and proprietary to our customers. We just hack the module to have 66 instead of 64 in the test for this error. I happens on any assigned COM port number; I just bumped in to it again on COM4, for instance, so assigned numbers >= COM10 doesn't seem to be the cause. I recommend tweaking this check to 66 or skipping it on kernels after Win95/Win98. Many thanks for the great module.
Subject: Re: [rt.cpan.org #33559] block length error
Date: Fri, 07 May 2010 14:18:14 -0400
To: bug-Win32-SerialPort [...] rt.cpan.org
From: Bill Birthisel <bbirthisel [...] aol.com>
I'll consider what to do about it. I need to do a little research. I've never come across a device that returned 66. Both of the USB devices I have work normally. Originally, all serial devices returned a sizeof(COMMPROP) = 64 unless they included a modem and used a much larger structure (the 64 byte COMMPROP plus a bunch of modem properties appended to the end). In the early days of the module, the size check was recommended (by Microsoft) so that someone who allocated just enough memory would not get burned by an overrun. I always allocated extra to cover the maximum expected from a modem. However, the check did serve to identify some problems with badly coded drivers when people we learning how to write W95 and above drivers. However, I have not received a valid report of that sort for a long time. My first intuition is to skip the check unless debugging is active. I don't know if that is the best approach. Technically, this is a third-party-driver bug rather than a module bug. I just read a value passed to me and check it for sanity. Is there actually something encoded in the data structure in the extra bytes? Or is it just the count that is the problem? -bill On Fri, 2010-05-07 at 12:54 -0400, RBS via RT wrote: Show quoted text
> Queue: Win32-SerialPort > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=33559 > > > We have also seen this issue with USB serial devices, both commercially > available and proprietary to our customers. We just hack the module to > have 66 instead of 64 in the test for this error. > > I happens on any assigned COM port number; I just bumped in to it again on > COM4, for instance, so assigned numbers >= COM10 doesn't seem to be the > cause. > > I recommend tweaking this check to 66 or skipping it on kernels after > Win95/Win98. > > Many thanks for the great module.
On Fri May 07 14:18:32 2010, Bbirthisel@aol.com wrote: Show quoted text
> My first intuition is to skip the check unless debugging is active. I > don't know if that is the best approach. > > Technically, this is a third-party-driver bug rather than a module > bug.
I can't assume it's a driver bug because it seems like drivers with extra capabilities should be able to use a larger structure, but it could be. I'd have to dig in to this structure and its intended usage to decide either way, but since I can't get the driver modified, it's a moot point to me. Anyway, some combination of making this check debug only or loosening it to > 66 would address the few known failures caused by the check. Does your research show that this check is still necessary? - Barrie
Subject: Re: [rt.cpan.org #33559] block length error
Date: Wed, 30 Mar 2011 22:20:12 -0400
To: bug-Win32-SerialPort [...] rt.cpan.org
From: Bill Birthisel <bbirthisel [...] aol.com>
On Wed, 2011-03-30 at 12:08 -0400, RBS via RT wrote: Show quoted text
> Queue: Win32-SerialPort > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=33559 > > > On Fri May 07 14:18:32 2010, Bbirthisel@aol.com wrote:
> > My first intuition is to skip the check unless debugging is active. I > > don't know if that is the best approach. > > > > Technically, this is a third-party-driver bug rather than a module > > bug.
> > I can't assume it's a driver bug because it seems like drivers with > extra capabilities should be able to use a larger structure, but it > could be. I'd have to dig in to this structure and its intended usage to > decide either way, but since I can't get the driver modified, it's a > moot point to me.
Oh, I have no problem calling it a driver bug. The following MSDN posting was refreshed March 10, 2001: http://msdn.microsoft.com/en-us/library/aa363189%28v=vs.85% 29.aspx That is the same structure that SerialPort expects - and it is still 64 bytes long (for PST_RS232 devices). Show quoted text
> Anyway, some combination of making this check debug only or loosening it > to > 66 would address the few known failures caused by the check. Does > your research show that this check is still necessary?
I don't know what to propose as a workaround. Clearly there are a few devices with this problem - but I don't have any of them and I can't duplicate the problem. Some of the history suggests ignoring the check would be fine. But you also reported an occasional hard crash and I don't want to make those any easier. I did notice that Win CE seemed to use a slightly different COMMPROP structure. And even $MS has been known to introduce driver bugs (some of the parity settings were just plain flaky in NT4 with default drivers even though the same code worked fine with other OS versions). At this point, I don't have any other changes pending for the SerialPort modules. I think the risk of adverse side effects may outweigh a change that at best would benefit only a small number of devices. Since it is easy enough for you to disable the check if you are confident it works in your case - I'm inclined to leave the code alone at this time. -bill