By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,934 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,934 IT Pros & Developers. It's quick & easy.

the correct use of serial communication events

P: 62
Hi!

I read from emulated serial port (whit usb).It works correctly but with the condition of waitcommevent doesnt. How can use correct the serial events?

Expand|Select|Wrap|Line Numbers
  1. use Win32;    
  2. use Win32API::CommPort;
  3. use Win32API::File;
  4.  
  5.  
  6.  $PortObj= new Win32API::CommPort ('com4')
  7.        || die "Can't open PortName: $^E\n";  
  8.  
  9.  
  10. while(1)
  11. {
  12.  
  13.  
  14.     if ( ($PortObj->WaitCommEvent('com4', EV_RXCHAR ,  )) )  
  15.          {
  16.             $count_in=$PortObj->read_bg( 1);
  17.             ( $done,  $count_in, $string_in) = $PortObj->read_done(1);
  18.             print("$string_in\n");
  19.         }
  20. }
Thanks!
Sep 30 '08 #1
Share this Question
Share on Google+
5 Replies


KevinADC
Expert 2.5K+
P: 4,059
I have no idea. Maybe someone else will.
Sep 30 '08 #2

Icecrack
Expert 100+
P: 174
first off use strict if you can,

Expand|Select|Wrap|Line Numbers
  1. use strict;
second:

try put this on one line,

Expand|Select|Wrap|Line Numbers
  1.  $PortObj= new Win32API::CommPort ('com4')
  2.        || die "Can't open PortName: $^E\n";  
try

Expand|Select|Wrap|Line Numbers
  1.  if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, ERROR_IO_INCOMPLETE )) )  
  2.          {
don't forget to take out ' ' for your handle.

or

Expand|Select|Wrap|Line Numbers
  1.  if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, )) )  
  2.          {
usage for above:

Expand|Select|Wrap|Line Numbers
  1. WaitCommEvent($handle, $Event_Bitmask, $lpOverlapped);
Sep 30 '08 #3

P: 62
first off use strict if you can,

Expand|Select|Wrap|Line Numbers
  1. use strict;
second:

try put this on one line,

Expand|Select|Wrap|Line Numbers
  1.  $PortObj= new Win32API::CommPort ('com4')
  2.        || die "Can't open PortName: $^E\n";  
try

Expand|Select|Wrap|Line Numbers
  1.  if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, ERROR_IO_INCOMPLETE )) )  
  2.          {
don't forget to take out ' ' for your handle.

or

Expand|Select|Wrap|Line Numbers
  1.  if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, )) )  
  2.          {
usage for above:

Expand|Select|Wrap|Line Numbers
  1. WaitCommEvent($handle, $Event_Bitmask, $lpOverlapped);
Thanks for help!

I try the code whit use strict but the following message come in promt shell: Bareword "EV_RXCHAR" not allowed while "stricts sub" in use
and same for com4 and ERROR_IO_INCOMPLETE.

Itry this to:
Expand|Select|Wrap|Line Numbers
  1. if ( ($PortObj->WaitCommEvent('com4', 'EV_RXCHAR' ,  )) ) 
its run but doesnt work like without strict.
any other idea?

Thanks!
Oct 1 '08 #4

Icecrack
Expert 100+
P: 174
Thanks for help!


Itry this to:
Expand|Select|Wrap|Line Numbers
  1. if ( ($PortObj->WaitCommEvent('com4', 'EV_RXCHAR' ,  )) ) 
!
did you try:

Expand|Select|Wrap|Line Numbers
  1. if ( ($PortObj->WaitCommEvent(com4, 'EV_RXCHAR' ,  )) ) 
if so please get back to me with all errors.

thanks
Oct 1 '08 #5

P: 62
did you try:

Expand|Select|Wrap|Line Numbers
  1. if ( ($PortObj->WaitCommEvent(com4, 'EV_RXCHAR' ,  )) ) 
if so please get back to me with all errors.

thanks
yes I try all variations : whit srtict and whitout ' ', combackwhit errror:not allowed while "stricts sub" in use
when i use ' ' its run but doesnt use event

Thank you!
Oct 2 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.