the correct use of serial communication events

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Arepi
    New Member
    • Sep 2008
    • 62

    the correct use of serial communication events

    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?

    Code:
    use Win32;    
    use Win32API::CommPort;
    use Win32API::File;
    
    
     $PortObj= new Win32API::CommPort ('com4')
           || die "Can't open PortName: $^E\n";  
    	   
    	  
    while(1)
    {
    	
    	
    	if ( ($PortObj->WaitCommEvent('com4', EV_RXCHAR ,  )) )  
    		 {
    			$count_in=$PortObj->read_bg( 1);
    			( $done,  $count_in, $string_in) = $PortObj->read_done(1);
    			print("$string_in\n");
    		}
    }
    Thanks!
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    I have no idea. Maybe someone else will.

    Comment

    • Icecrack
      Recognized Expert New Member
      • Sep 2008
      • 174

      #3
      first off use strict if you can,

      Code:
      use strict;
      second:

      try put this on one line,

      Code:
       $PortObj= new Win32API::CommPort ('com4')
             || die "Can't open PortName: $^E\n";
      try

      Code:
       if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, ERROR_IO_INCOMPLETE )) )  
               {
      don't forget to take out ' ' for your handle.

      or

      Code:
       if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, )) )  
               {
      usage for above:

      Code:
      WaitCommEvent($handle, $Event_Bitmask, $lpOverlapped);

      Comment

      • Arepi
        New Member
        • Sep 2008
        • 62

        #4
        Originally posted by Icecrack
        first off use strict if you can,

        Code:
        use strict;
        second:

        try put this on one line,

        Code:
         $PortObj= new Win32API::CommPort ('com4')
               || die "Can't open PortName: $^E\n";
        try

        Code:
         if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, ERROR_IO_INCOMPLETE )) )  
                 {
        don't forget to take out ' ' for your handle.

        or

        Code:
         if ( ($PortObj->WaitCommEvent(com4, EV_RXCHAR, )) )  
                 {
        usage for above:

        Code:
        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_INCOMP LETE.

        Itry this to:
        Code:
        if ( ($PortObj->WaitCommEvent('com4', 'EV_RXCHAR' ,  )) )
        its run but doesnt work like without strict.
        any other idea?

        Thanks!
        Last edited by Arepi; Oct 1 '08, 06:24 PM. Reason: not complete

        Comment

        • Icecrack
          Recognized Expert New Member
          • Sep 2008
          • 174

          #5
          Originally posted by Arepi
          Thanks for help!


          Itry this to:
          Code:
          if ( ($PortObj->WaitCommEvent('com4', 'EV_RXCHAR' ,  )) )
          !
          did you try:

          Code:
          if ( ($PortObj->WaitCommEvent(com4, 'EV_RXCHAR' ,  )) )
          if so please get back to me with all errors.

          thanks

          Comment

          • Arepi
            New Member
            • Sep 2008
            • 62

            #6
            Originally posted by Icecrack
            did you try:

            Code:
            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!
            Last edited by Arepi; Oct 2 '08, 12:30 AM. Reason: not complete

            Comment

            Working...