[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

API communications: SetCommEventMask

Posted on 1998-06-25
2
Medium Priority
?
461 Views
Last Modified: 2008-02-01
I need my VB program to generate an event when a specific character is received in a comm port.  I've tried using MSComm control with InputLen=1 to analyze each character, but the data is received too fast for this method.  I've heard that by using the API I can generate an event when a specific character is received (ie. carriage return or linefeed). I'm not extremely familar with the API; can anyone provide a detailed example. I would like to be able to leave the received string in the buffer until a carriage return and linefeed are received, then read the string from the buffer.
0
Comment
Question by:MHaverty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Expert Comment

by:peterwest
ID: 1464328
Hi there,

You may want to check out the Knowledge Base Article Q75856.  This details how to use to Windows API to control the Comm port and also allows you to download a file which gives you the constants and API declarations.

If you need any further help then give me a shout!!

Pete

0
 
LVL 1

Accepted Solution

by:
khaledc earned 510 total points
ID: 1464329
Try using the OnComm Event in MSComm, help in VB gave the following description:

The OnComm event is generated whenever the value of the CommEvent property changes, indicating that either a communication event or an error occurred.

An example would be:

Private Sub MSComm_OnComm ()
      Select Case MSComm1.CommEvent
      ' Handle each event or error by placing
      ' code below each case statement

      ' Errors
            Case comEventBreak      ' A Break was received.
            Case comEventCDTO      ' CD (RLSD) Timeout.
            Case comEventCTSTO      ' CTS Timeout.
            Case comEventDSRTO      ' DSR Timeout.
            Case comEventFrame      ' Framing Error
            Case comEventOverrun      ' Data Lost.
            Case comEventRxOver      ' Receive buffer overflow.
            Case comEventRxParity      ' Parity Error.

Case comEventTxFull      ' Transmit buffer full.
            Case comEventDCB      ' Unexpected error retrieving DCB]

      ' Events
            Case comEvCD      ' Change in the CD line.
            Case comEvCTS      ' Change in the CTS line.
            Case comEvDSR      ' Change in the DSR line.
            Case comEvRing      ' Change in the Ring Indicator.
            Case comEvReceive      ' Received RThreshold # of chars
***************************      'Put your Code Here                  
            Case comEvSend      ' There are SThreshold number of ' characters in the transmit  buffer.
                                          
                                          

Case comEvEof      ' An EOF charater was found in                                                 ' the input stream
      End Select
End Sub


What you are after is to check when you receive data, therefore you are after the case when MSComm1.CommEvent=comEvReceive

Hope this may help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question