LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to USE ComCallback ?

Hi,

I need to get a SERIAL data when its available. But I don't know how to use and to init the COMCallBack.

Can you please write some sample code ?

thank you
0 Kudos
Message 1 of 4
(4,003 Views)
This excerpt is in the online CVI help and seems to be fairly clear...
EXAMPLE:
notifyCount = 50; /* Wait for at least 50 bytes in queue. */

eventChar = 13; /* Wait for LF. */
eventMask = LWRS_RXFLAG | LWRS_TXEMPTY | LWRS_RECEIVE;
InstallComCallback (comport, eventMask, notifyCount,
eventChar, ComCallback, NULL);
.
.
.
/* Callback Function */
void ComCallback(int portNo, int eventMask, void *data)
{

if (eventMask & LWRS_RXFLAG)

printf("Received specified character\n");

if (eventMask & LWRS_TXEMPTY)

printf("Transmit queue now empty\n");

if (eventMask & LWRS_RECEIVE)

printf("50 or more bytes in input queue\n");

}
0 Kudos
Message 2 of 4
(4,003 Views)
Hello,

You can use the InstallComCallback function, which allows you to install a synchronous callback function for a particular COM port. The callback function is called whenever any of the events specified in eventMask occur on the COM port and you allow the system to process events.

Example:
Using the RS232 Library InstallComCallback Function to Handle Events

I hope it helps.
0 Kudos
Message 3 of 4
(4,003 Views)

Hello

 

I am using the comcallback function and it works well until I call a  function that needs information to be updated from the serial port com. When excuting that one "XModemRcvRoutine " the programme doesn't interrupt to receive information!!!

(the code is below and there is a copy of the project inthe attached file)

I wonder if there is someone who can help me.

Thank you in advance to any one whmay be able to give me some solution to my problem. 

 

0 Kudos
Message 4 of 4
(3,007 Views)