LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to use same files and functions for 2 set of hardware (Same hardware)

I have 1 set of files. library.c and library.h.
This files have code to communicate to a device via serial port. This code works fine if I have 1 device attached to my serial port.
library.c file has mutithreading functions and can communicate to only 1 device at a time.
 
I need to communicate to 2 of these devices simultenously using 2 serial ports. My problem is I have to use same function to communicate with different devices and I don't have mechanism to identify them.
For example:
I have function like send_message. How do I use this function to communicate to 2 different devices? Can I create dll from my code and use 1 set as dll and other set as .c and .h?
 
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 1 of 2
(3,047 Views)

The usual approach in these situations is to include an extra parameter which identifies the correct hardware. So for example instead of:

    send_message ("A message for the serial port\n");

you could use:

    send_message (port_1, "A message for serial port 1 only\n");

where port_1 is used to select which hardware the function talks to. The CVI RS232 routines need this information anyway, so you just need to use a local variable instead of the port number being fixed.

JR

0 Kudos
Message 2 of 2
(3,039 Views)