Hi how to send the messages to the serial port devices..?
Hi i have connected the rs232 cable with a device and my pc. I use the openconfig to open the comport and then i try to read from the comport. Now my problem is i wanted to get the data's from the serial port device based on my request. I have set a string which i can use it to fetch the data's from the device. How can i send that string and query the data..?
For example,
Rs_Status
I wanted to send this string and then fetch the Rs_Status infromation from the device.
#include <utility.h>
#include <rs232.h>
#include <cvirte.h>
#include <userint.h>
#include "comrdterm.h"
static int numbytesread;
static char inbuffer[100];
static int panelHandle;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "comrdterm.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
OpenComConfig (3, "dev1", 9600, 0, 7, 1, 512, 512);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
CloseCom (1);
CloseCom (2);
QuitUserInterface (0);
break;
}
return 0;
}
int CVICALLBACK Query (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
numbytesread = ComRdTerm (2, inbuffer, 100, 235);
Delay (.5);
FlushInQ (2);
SetCtrlVal (panelHandle, PANEL_TEXTBOX, inbuffer);
break;
}
return 0;
}