473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

the correct use of serial communication events

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
5 2399
KevinADC
4,059 Expert 2GB
I have no idea. Maybe someone else will.
Sep 30 '08 #2
Icecrack
174 Expert 100+
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
Arepi
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
174 Expert 100+
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
Arepi
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

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

Similar topics

1
by: Andreas Horneff | last post by:
Hi @ all, I've got a problem with serial communication in Borland C++ Builder. I've already found a lot of stuff about serial communication in the internet, but it dosen't work. What I want...
3
by: carmen | last post by:
I'm working in an aplication for a Smart Device that need to "talk" with a printer continuosly through the serial port. I'm trying to use the John Hint's sample code "Use P/Invoke to develop a .NET...
4
by: Vidya Bhagwath | last post by:
Hello Experts, I am porting the C++ code into the Visual C#.NET. My C++ code is mainly based on the serial communication. So I am using the windows structure such as DCB.. etc and the windows...
6
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in...
3
by: Manu | last post by:
Hi, i need to know how i can interface to RS232 with VC++.NET (MFC). In the old VC++ 6.0 there is the MSCOMM32 component, i read i can use it but there are some license problems. Is there some low...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
4
by: max_mont | last post by:
Hi all, I'm a newbie in .NET technology. I've already developed Serial communication applications in C++ (WIN32). And I wanted to migrate to .NET technology. There is a serial component in...
6
by: cnixuser | last post by:
Hello, I have a basic application written which is designed to data over a serial cable and then receive a response back. I am not getting any triggers to my data received event. I have tried...
2
by: Adrian Chen | last post by:
please help me! I come across a problem. Now I develop a finger print management system which is based on B/S.When users click a button in the web pages, a device connected to the COM1 serial port...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.