Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
how to close a comport in perl?

Posted by vinzy1983 (vinzy1983), 24 January 2006
Hi,
Can anyone tell me how to close a comport in perl?
i tried using "undef $PortObj;" but it is not working properly.

i also made an unsuccessful attempt of using the following close funciton.
 $PortObj->close || warn "close failed";

Could anyone please help me out?

Thanks
-Vinay



Posted by admin (Graham Ellis), 24 January 2006
Good question ... but a bit of a different niche to the ones I'm most familiar with.    I'm guessing that your $PortObj variable is a reference to an object.   What type of object?  From a CPAN module or from a Windows distribution of Perl such as Activestate?

Also the term "not working properly" doesn't really tell us what's going wrong.   My understanding of a COM port is that you send characters over it from a program and at that low level there's really nothing to do when you don't want it any longer - just stop writing to it.    If you've got higher level drivers that buffer or lock the port then, yes, I can understand that there may be a bit more to closing the device.

Sorry to answer one question with another, but I need a bit more to have any chance of making any form of reasonable suggestion.

Posted by vinzy1983 (vinzy1983), 25 January 2006
Hi,
sorry for the insufficient description.

First of all, i use Activestate perl on windows platform.

Actually, i have a tool to run my perl scripts(which uses comport) under regression which runs for 2-3 days.
The problem i'm facing is the serial port gets locked up after sometime.
So for this i thought i should close the comport at the end of each of the scripts, which i could not accomplish.

I used a END block in the scripts as,
END {
      undef $comPort;
}

but this has not improved the situation.

And with $PortObj->close, i am facing syntax errors as i am not able to frame the close function properly using the comport object. I used the following combinations by referring the serialport.pm file in my activestate perl.
#################################
$comPort->{ALIAS} = "MYF";
$comPort=>'_port'->Win32::SerialPort::close || warn "close failed";
################################
$comPort=>'_port'->Win32::SerialPort::close(\$comPort=>{'_port'}) || warn "close failed";
Win32::SerialPort::close($comPort) || warn "close failed \n";
#################################

thanks
-Vinay




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho