Click here to get back home

help on win32::serialport

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
help on win32::serialport jis 06-04-2007
Posted by jis on June 4, 2007, 5:12 pm
Please log in for more thread options


Can anybody help with examples on reading a serial port.
Even after reading through the win32::serialport CPAN pod my attempt
to write a working code is gone futile.
I am trying to read a barcode with a scanner.

Please do help

regards,
jis


Posted by Sisyphus on June 5, 2007, 6:10 am
Please log in for more thread options



> Can anybody help with examples on reading a serial port.
> Even after reading through the win32::serialport CPAN pod my attempt
> to write a working code is gone futile.
> I am trying to read a barcode with a scanner.

I think your best chance of success would be to post to "Seekers of Perl
Wisdom" at perlmonks. Another option would be the 'perl-win32-users' mailing
list hosted by ActiveState, though it's really low volume these days. That's
not to say that there's no-one here who can help, but you've given us very
little to work with.

Wherever you post, it's better to provide a copy'n'paste of some code that
you've tried (along with a copy'n'paste of the error messages it generates).
That way, even if there's no-one around who can actually answer the
question, there might be someone lurking about who can see a fault in your
code and provide a correction.

Google might also be able to help out. I tried
http://www.google.com.au/search?hl=en&q=Win32%3A%3ASerialPort+barcode&btnG=Google+Search&meta=

I couldn't see anything there that stood out as a likely solution, but I
didn't actually follow any of the links.

Cheers,
Rob



Posted by jis on June 5, 2007, 11:29 am
Please log in for more thread options


>
>
> > Can anybody help with examples on reading a serial port.
> > Even after reading through the win32::serialport CPAN pod my attempt
> > to write a working code is gone futile.
> > I am trying to read a barcode with a scanner.
>
> I think your best chance of success would be to post to "Seekers of Perl
> Wisdom" at perlmonks. Another option would be the 'perl-win32-users' mailing
> list hosted by ActiveState, though it's really low volume these days. That's
> not to say that there's no-one here who can help, but you've given us very
> little to work with.
>
> Wherever you post, it's better to provide a copy'n'paste of some code that
> you've tried (along with a copy'n'paste of the error messages it generates).
> That way, even if there's no-one around who can actually answer the
> question, there might be someone lurking about who can see a fault in your
> code and provide a correction.
>
> Google might also be able to help out. I
triedhttp://www.google.com.au/search?hl=en&q=Win32%3A%3ASerialPort+barcode...
>
> I couldn't see anything there that stood out as a likely solution, but I
> didn't actually follow any of the links.
>
> Cheers,
> Rob

Atast i could figure out how it works.if anyobdy else searching for
the same here is the code.
This reads the barcode with the help of scanner.This is a basic
code.Ofcourse need to be modified for realtime use.

use strict;
use Win32::SerialPort;
sub openPort($);
sub closePort($);

my $bar;
my $DEVICE = "COM1";
my $data=0;
my $serial =openPort($DEVICE);
while(!($data=~/\r/))
{
$data=$serial->input;
$bar=$bar.$data;
}
print $bar;
closePort($serial);

sub openPort($)
{
my ($device) = @_;


my $serial = Win32::SerialPort->new ($device, 1);
die "Can't open serial port $serial: $^E\n" unless ($serial);

$serial->user_msg(1);
$serial->databits(8);
$serial->baudrate(9600);
$serial->parity("none");
$serial->stopbits(1);
return $serial;
}

sub closePort($)
{
my ($serial) = @_;
$serial->close();
}



Similar ThreadsPosted
Need help with Win32::SerialPort August 13, 2004, 5:43 am
Please help on win32::serialport July 13, 2007, 12:41 pm
problem in using win32::SerialPort September 7, 2007, 2:27 am
Win32::serialport and Windows NT 4 July 31, 2007, 6:08 pm
win32::SerialPort are_match just won't work February 15, 2006, 8:05 pm
No response from printer using Win32::SerialPort October 11, 2006, 11:36 am
hiding Win32::SerialPort->start( ... ) error messages April 19, 2005, 2:27 am
need help with "SerialPort" module April 25, 2006, 11:34 pm
SerialPort error July 7, 2007, 10:58 pm
SerialPort write question October 28, 2004, 11:52 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap