On 8/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello, am using win32::serial port for serial communication i can open
> the port and able to update the settings such as baud rate , parity
> etc.,but  i need to know how to transfer the data through it (read and
> write), can any give me sound examples
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

According to its documentation you can tie it to a file handle and the
read and write from it as if it were a normal file handle.  There are
also methods on the object to read and write (streamline and write).

from 
http://search.cpan.org/~bbirth/Win32-SerialPort-0.19/lib/Win32/SerialPort.pm#Methods_for_I/O_Processing
  $PortObj = tie (*FH, 'Win32::SerialPort', $Configuration_File_Name)
       || die "Can't tie: $^E\n";            ## TIEHANDLE ##

  print FH "text";                           ## PRINT     ##
  $char = getc FH;                           ## GETC      ##
  syswrite FH, $out, length($out), 0;        ## WRITE     ##
  $line = <FH>;                              ## READLINE  ##
  @lines = <FH>;                             ## READLINE  ##
  printf FH "received: %s", $line;           ## PRINTF    ##
  read (FH, $in, 5, 0) or die "$^E";         ## READ      ##
  sysread (FH, $in, 5, 0) or die "$^E";      ## READ      ##
  close FH || warn "close failed";           ## CLOSE     ##
  undef $PortObj;
  untie *FH;                                 ## DESTROY   ##

  $PortObj->linesize(10);               # with READLINE
  $PortObj->lastline("_GOT_ME_");       # with READLINE, list only

  $old_ors = $PortObj->output_record_separator("RECORD");       # with PRINT
  $old_ofs = $PortObj->output_field_separator("COMMA");         # with PRINT

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to