For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2007 > win32 serial port









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author win32 serial port
Saran j jegan

2007-09-26, 10:00 pm

Hello , am using win32::serialport module to communicate with my
serial port device, this is my code

use Win32::SerialPort;
my $serial_port;
my $return;
my $quiet = 1;

$serial_port = Win32::SerialPort->new ($port,1) die "Can't open serial
port $port: $^E\n" unless ($serial_port);
my $configFile= 'ER400TRS.conf';
print LOG "configuration file: $configFile\n";
print "$configFile";
my $baud = $serial_port->baudrate(4800);
my $par = $serial_port->parity("even");
my $rint=$serial_port->read_interval;
my $data=$serial_port->databits(7);
my $stop=$serial_port->stopbits(1);
my $hshake=$serial_port->handshake;
my $rconst=$serial_port->read_const_time(100);
my $rchar=$serial_port->read_char_time(5);
my $wconst=$serial_port->write_const_time(100);
my $wchar=$serial_port->write_char_time(5);
my ($rbuf, $wbuf)= $serial_port->buffers;

$serial_port = tie (*FOO, 'Win32::SerialPort', $configFile)
|| die "Can't tie: $^E\n"; ## TIEHANDLE ##



$serial_port->close || die "\n close problem with $port\n";

undef $serial_port;



the code works fine i can write my data to the buffer but when am try
to use file handle to tie with config file
am getting the error access denied can't tie....can any suggest me ?

Dr.Ruud

2007-09-26, 10:00 pm

Saran.j.jegan@gmail.com schreef:

> Hello , am using win32::serialport module


ITYM "Win32::SerialPort". Casing matters.

--
Affijn, Ruud

"Gewoon is een tijger."
Matthew Whipple

2007-09-26, 10:00 pm

You are using 2 constructors that may be stepping on each others toes.
Opening the port with new may lock the port from being tied later. What
is in the $configfile, since it appears as though most of the
configuration is done in the script (although that configuration would
probably be undone by the loading of the file)? I'd say drop the tie
constructor for now and use write_method to ensure that you have proper
access to the port.

Saran.j.jegan@gmail.com wrote:
> Hello , am using win32::serialport module to communicate with my
> serial port device, this is my code
>
> use Win32::SerialPort;
> my $serial_port;
> my $return;
> my $quiet = 1;
>
> $serial_port = Win32::SerialPort->new ($port,1) die "Can't open serial
> port $port: $^E\n" unless ($serial_port);
> my $configFile= 'ER400TRS.conf';
> print LOG "configuration file: $configFile\n";
> print "$configFile";
> my $baud = $serial_port->baudrate(4800);
> my $par = $serial_port->parity("even");
> my $rint=$serial_port->read_interval;
> my $data=$serial_port->databits(7);
> my $stop=$serial_port->stopbits(1);
> my $hshake=$serial_port->handshake;
> my $rconst=$serial_port->read_const_time(100);
> my $rchar=$serial_port->read_char_time(5);
> my $wconst=$serial_port->write_const_time(100);
> my $wchar=$serial_port->write_char_time(5);
> my ($rbuf, $wbuf)= $serial_port->buffers;
>
> $serial_port = tie (*FOO, 'Win32::SerialPort', $configFile)
> || die "Can't tie: $^E\n"; ## TIEHANDLE ##
>
>
>
> $serial_port->close || die "\n close problem with $port\n";
>
> undef $serial_port;
>
>
>
> the code works fine i can write my data to the buffer but when am try
> to use file handle to tie with config file
> am getting the error access denied can't tie....can any suggest me ?
>
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com