Skip Menu |
 

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

Report information
The Basics
Id: 76881
Status: open
Priority: 0/
Queue: Device-SerialPort

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

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



Subject: Device::SerialPort spawning warnings
Date: Sun, 29 Apr 2012 12:41:57 +0200
To: bug-Device-SerialPort [...] rt.cpan.org
From: JPH <jph4dotcom [...] xs4all.nl>
I discussed this issue on stackoverflow.com ( http://stackoverflow.com/questions/10370724 ), where I was given a 
work around and was advised to register a bug with the author.

The warnings below occur while being attached to an Arduino sending data to my PC. Because the set up must be able 
to recover from a USB disconnect/reconnect, as a test I pull the cable from my Arduino, wait a few seconds, then 
reattach it. The interesting thing is that I can make my own script catch all warnings, except for two coming from
inside the Device::Serial module:

Use of uninitialized value $count_in in addition (+) at /usr/lib/perl5/Device/SerialPort.pm line 2214.
Use of uninitialized value $string_in in concatenation (.) or string at /usr/lib/perl5/Device/SerialPort.pm line 2232.

I am on Ubuntu 11.10  using libdevice-serialport-perl (1.04-2build1)

Hope this helps to improve the module. Don't hesitate to contact me if you require more details.

Kind regards, 

JP
Subject: Re: [rt.cpan.org #76881] AutoReply: Device::SerialPort spawning warnings
Date: Sun, 29 Apr 2012 13:50:55 +0200
To: bug-Device-SerialPort [...] rt.cpan.org
From: JPH <jph4dotcom [...] xs4all.nl>
Download (untitled) / with headers
text/plain 1.8k
Added a fix on mentioned URL. Hope this helps. On 04/29/2012 12:42 PM, Bugs in Device-SerialPort via RT wrote: Show quoted text
> Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "Device::SerialPort spawning warnings", > a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been > assigned an ID of [rt.cpan.org #76881]. Your ticket is accessible > on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=76881 > > Please include the string: > > [rt.cpan.org #76881] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > > Thank you, > bug-Device-SerialPort@rt.cpan.org > > ------------------------------------------------------------------------- > I discussed this issue on stackoverflow.com ( > > http://stackoverflow.com/questions/10370724 ), where I was given a > work around and was advised to register a bug with the author. > > The warnings below occur while being attached to an Arduino sending data to my PC. Because the set up must be able > to recover from a USB disconnect/reconnect, as a test I pull the cable from my Arduino, wait a few seconds, then > reattach it. The interesting thing is that I can make my own script catch all warnings, except for two coming from > inside the Device::Serial module: > > Use of uninitialized value $count_in in addition (+) at /usr/lib/perl5/Device/SerialPort.pm line 2214. > Use of uninitialized value $string_in in concatenation (.) or string at /usr/lib/perl5/Device/SerialPort.pm line 2232. > I am on Ubuntu 11.10 using libdevice-serialport-perl (1.04-2build1) > > Hope this helps to improve the module. Don't hesitate to contact me if you require more details. > > Kind regards, > > JP > >
Subject: Re: [rt.cpan.org #76881] AutoReply: Device::SerialPort spawning warnings
Date: Mon, 30 Apr 2012 23:26:41 -0400
To: bug-Device-SerialPort [...] rt.cpan.org
From: Bill Birthisel <bbirthisel [...] aol.com>
Download (untitled) / with headers
text/plain 4.3k
Hi JP, I'm no longer the primary maintainer. But I did write the relevant section of the code originally. So I'll offer an opinion. I don't consider this a bug. I agree that the warning message could be clearer. And that would be worthwhile to fix if something else was being done at the same time. But I never envisioned someone trying to disconnect/recover from within a tied-filehandle interface. It is possible, although not encouraged, using the lower-level methods (e.g. input) with the user responsible for checking errors and maintaining buffering. This code predates the widespread use of USB serial ports. On a hard-coded serial port, loss of connectivity carried with it a serious risk of lost or corrupted characters. I don't know if that risk still exists with a USB-based port. As I understand your posting, the code is working for you - but you get extra warnings on a hardware disconnect. I suspect many users, including me, would consider that a good thing. It may be that the use of the tied-filehandle interface, which does not expose much of the raw internal states, is causing some of the confusion. Here is the pipeline: 1. Your device 2. Serial to USB (with internal buffering) 3. USB Cable 4. linux USB Driver (with internal buffering and emulation to look like hardware serial device) 5. POSIX.pm (serial port interface including buffering) 6. Device::SerialPort 7. Tied-Filehandle interface 8. Your code The warning messages are coming from 7 (where the count and the buffer are seen as undefined). But that is not where the error originates. Item 7 calls 6 which in turn formats calls to 5. etc. When you break at item 3, about all that propagates up through the whole sequence is that at least one of the steps lost synchronization. It may be that your code uses checksums or something similar to detect lost data - but the inner items don't know anything about that. And while it is possible to explicitly check each data element for sanity (i.e. is it defined) in the low-level interface, the tie in perl does not have a convenient way to manage that. It looks to be quite a bit of work to make the tied-filehandle interface utterly airtight in the disconnect/recovery case. It might be nice to have. But I don't have time to do it and this is the first example I have heard reported in over ten years where that was a requirement. -bill On 04/29/2012 07:51 AM, JPH via RT wrote: Show quoted text
> Queue: Device-SerialPort > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=76881> > > Added a fix on mentioned URL. > > Hope this helps. > > On 04/29/2012 12:42 PM, Bugs in Device-SerialPort via RT wrote:
>> Greetings, >> >> This message has been automatically generated in response to the >> creation of a trouble ticket regarding: >> "Device::SerialPort spawning warnings", >> a summary of which appears below. >> >> There is no need to reply to this message right now. Your ticket has been >> assigned an ID of [rt.cpan.org #76881]. Your ticket is accessible >> on the web at: >> >> https://rt.cpan.org/Ticket/Display.html?id=76881 >> >> Please include the string: >> >> [rt.cpan.org #76881] >> >> in the subject line of all future correspondence about this issue. To do so, >> you may reply to this message. >> >> Thank you, >> bug-Device-SerialPort@rt.cpan.org >> >> ------------------------------------------------------------------------- >> I discussed this issue on stackoverflow.com ( >> >> http://stackoverflow.com/questions/10370724 ), where I was given a >> work around and was advised to register a bug with the author. >> >> The warnings below occur while being attached to an Arduino sending data to my PC. Because the set up must be able >> to recover from a USB disconnect/reconnect, as a test I pull the cable from my Arduino, wait a few seconds, then >> reattach it. The interesting thing is that I can make my own script catch all warnings, except for two coming from >> inside the Device::Serial module: >> >> Use of uninitialized value $count_in in addition (+) at /usr/lib/perl5/Device/SerialPort.pm line 2214. >> Use of uninitialized value $string_in in concatenation (.) or string at /usr/lib/perl5/Device/SerialPort.pm line 2232. >> I am on Ubuntu 11.10 using libdevice-serialport-perl (1.04-2build1) >> >> Hope this helps to improve the module. Don't hesitate to contact me if you require more details. >> >> Kind regards, >> >> JP >> >>
Subject: Re: [rt.cpan.org #76881] AutoReply: Device::SerialPort spawning warnings
Date: Tue, 01 May 2012 21:40:03 +0200
To: bug-Device-SerialPort [...] rt.cpan.org
From: JPH <jph4dotcom [...] xs4all.nl>
Download (untitled) / with headers
text/plain 1.4k
Thnx Bill for your comment, I'll have to study/think about your pipeline steps 1-8, maybe with this sum up I can figure out how to prevent DTS from pulsing when I open the filehandle (which is effectively resetting my Arduino). About the disconnect/recover, Sometimes the devices get disconnected due to EMI (eg. a 'tuned' motorbike passing the house), so I have to recover from that. I'm able to recover just fine, just don't like the two undefined variable warnings. Perl does throws proper errors too if I don't catch them myself. Anyways, My opinion is that it is a 'nice to have fixed'. I added (what I think is) a fix, but I know too little about the inner workings to be sure. For now I'm using my 'patched' version on my PC. What would be a proper way get in contact with people who have in depth knowledge on Device::SerialPort? My experience is that it is hard to find. Is there a forum/mailing list ... Thanks for your time. Enjoy! JP On 05/01/2012 05:27 AM, Bbirthisel@aol.com via RT wrote: Show quoted text
> But I never envisioned someone trying to > disconnect/recover from within a tied-filehandle interface.
Show quoted text
> Here is the pipeline: > 1. Your device > 2. Serial to USB (with internal buffering) > 3. USB Cable > 4. linux USB Driver (with internal buffering and emulation to look like > hardware serial device) > 5. POSIX.pm (serial port interface including buffering) > 6. Device::SerialPort > 7. Tied-Filehandle interface > 8. Your code
Subject: Re: [rt.cpan.org #76881] AutoReply: Device::SerialPort spawning warnings
Date: Tue, 01 May 2012 21:05:49 -0400
To: bug-Device-SerialPort [...] rt.cpan.org
From: Bill Birthisel <bbirthisel [...] aol.com>
Download (untitled) / with headers
text/plain 3.9k
Hi JP, You successfully reached at least one of the people with in depth knowledge. The other would be the current maintainer (see the README in the distribution). He took over in part because he had a more complete test environment including a Solaris machine. These days, I only have a couple of linux variants and several Windows versions. One of the tricky parts of changing/maintaining the SerialPort family of modules was that they run on a lot of different hardware - although not always identically :-( But we have tried to make the look identical If you want to try to detect and respond to momentary disconnects more reliably, I would tend to stay away from the tied filehandle interface and use either input or read directly. That way, you can test the return values for undef before trying to use them in other operations. So in your case, you were receiving these errors: Use of uninitialized value $count_in in addition (+) at /usr/lib/perl5/Device/SerialPort.pm line 2214. Use of uninitialized value $string_in in concatenation (.) or string at /usr/lib/perl5/Device/SerialPort.pm line 2232. Where the underlying code is (in part, [[line#]] and ###comments added): [[2206]] ($count_in, $string_in) = $self->read($size); ### ### This is the real problem. $self->read is returning undef ### perhaps from some logic in read itself or perhaps in the ### call to POSIX::read that happens further up the pipeline. ### ### It might be possible to do something like this ### unless (defined $count_in) { ### $count_in = 0; ### $string_in = ""; ### } ### ### I haven't tested it and I won't guarantee it would work in your case. $$buf = '' unless defined $$buf; my $buflen = length $$buf; my ($tail, $head) = ('',''); if($offset>= 0){ # positive offset [[2214]] if($buflen> $offset + $count_in){ $tail = substr($$buf, $offset + $count_in); } if($buflen< $offset){ $head = $$buf . ("\0" x ($offset - $buflen)); } else { $head = substr($$buf, 0, $offset); } } else { # negative offset $head = substr($$buf, 0, ($buflen + $offset)); if(-$offset> $count_in){ $tail = substr($$buf, $offset + $count_in); } } # remaining unhandled case: $offset< 0&& -$offset> $buflen [[2232]] $$buf = $head.$string_in.$tail; return $count_in; -bill On 05/01/2012 03:40 PM, JPH via RT wrote: Show quoted text
> Queue: Device-SerialPort > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=76881> > > Thnx Bill for your comment, I'll have to study/think about your pipeline steps 1-8, maybe with this sum up I can figure out how to prevent DTS from pulsing when I open the filehandle (which is > effectively resetting my Arduino). > > About the disconnect/recover, Sometimes the devices get disconnected due to EMI (eg. a 'tuned' motorbike passing the house), so I have to recover from that. I'm able to recover just fine, just don't > like the two undefined variable warnings. Perl does throws proper errors too if I don't catch them myself. > > Anyways, My opinion is that it is a 'nice to have fixed'. I added (what I think is) a fix, but I know too little about the inner workings to be sure. For now I'm using my 'patched' version on my PC. > > What would be a proper way get in contact with people who have in depth knowledge on Device::SerialPort? My experience is that it is hard to find. Is there a forum/mailing list ... > > Thanks for your time. > > Enjoy! > > JP > > On 05/01/2012 05:27 AM, Bbirthisel@aol.com via RT wrote:
>> But I never envisioned someone trying to >> disconnect/recover from within a tied-filehandle interface. >> Here is the pipeline: >> 1. Your device >> 2. Serial to USB (with internal buffering) >> 3. USB Cable >> 4. linux USB Driver (with internal buffering and emulation to look like >> hardware serial device) >> 5. POSIX.pm (serial port interface including buffering) >> 6. Device::SerialPort >> 7. Tied-Filehandle interface >> 8. Your code


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.