LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problems with InstallComCallback

I am using CVI 5.5 and compiling under Visual C++. My application reads comms events from a Compumotor Stepper Motor RS-232 interface. Typically the events are several seconds appart. I have a seperate timer event that processes information based on the results of the Comm event. I can slow this down to once per second and I still miss comm events apparently regardless. The application requires 100mS timer events if possible as I will be sending velocity updates to the motor at that rate. The events are set up to look at one character LWRS_RECEIVE on 9600baud. I have no terminating character declared. Most of the time the characters are read ok sometimes it misses a complete message sometimes only part of a message. I have had an analyser on the line feeding the rs-232 Rx port and the messages are all present. I have read the buliten board and have noted that other processes could be squeezing out the Comm event. Can you help a novice?

void ReadRS232Interf(int portindex, int eventMask, void *data)
{
//disable generation of new position request messages till current message is serviced
timer_enabled_flag =0;
MessGenHoldOff = 1;
int i = 0;
read_data[0] = '\0';
bytes_read =0;
read_term = 0; //13 = c/r, 10 = l/f, 32 = sp
inqlen = GetInQLen (comport);/* RS-232 receive character length in the Q*/
//notifyCount = 1, EventChar = 0, eventMask = LWRS_RECEIVE;
bytes_read = ComRdTerm (comport, read_data, inqlen, read_term);
//Display the results
CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
SetCtrlVal (serial, SERIAL_TBOX_READ, tbox_read_data);
RS232Error = ReturnRS232Err ();
if (RS232Error)
{
DisplayRS232Error ();
}
//check the data out
if(Parse(bytes_read, read_data,
MessageCount2,
ErrorMessage,
GOflag,
DONEflag,
W1done,
PXdone,
ReadGOdata,
ReadDONEdata,
ReadW1data,
ReadPXdata))

{
//Do something
}
else
{
printf(ErrorMessage);
}
timer_enabled_flag =1;
MessGenHoldOff = 0;
}
0 Kudos
Message 1 of 3
(2,792 Views)
Using a windows PC for 100msec. resolution is a wrong choice, IMHO.

Anyways, looking at the code, when you call ComRdTerm, what's your
timeout? Default is 5 secs. I don't know how ComRdTerm behaves when you
pass a value of 0 as term_char like you are doing. I would use ComRd in
that case.

To debug this kind of problem, I would use another app on same PC or
different PC which sends out messages at programmed intervals (which you
can vary) to make sure you are catching all the events. Just use null
modem cabkle between 2 ports. To start with, don't process the events,
just do bare min to make sure you can catch them as they come. Then work
on processing them. You don't want to take too much time, processing
them, otherwise you miss them. Use threads if you have to.


vishi



Alastair Reynolds wrote:
> I am using CVI 5.5 and compiling under Visual C++. My application
> reads comms events from a Compumotor Stepper Motor RS-232 interface.
> Typically the events are several seconds appart. I have a seperate
> timer event that processes information based on the results of the
> Comm event. I can slow this down to once per second and I still miss
> comm events apparently regardless. The application requires 100mS
> timer events if possible as I will be sending velocity updates to the
> motor at that rate. The events are set up to look at one character
> LWRS_RECEIVE on 9600baud. I have no terminating character declared.
> Most of the time the characters are read ok sometimes it misses a
> complete message sometimes only part of a message. I have had an
> analyser on the line feeding the rs-232 Rx port and the messages are
> all present. I have read the buliten board and have noted that other
> processes could be squeezing out the Comm event. Can you help a
> novice?
>
> void ReadRS232Interf(int portindex, int eventMask, void *data)
> {
> //disable generation of new position request messages till
> current message is serviced
> timer_enabled_flag =0;
> MessGenHoldOff = 1;
> int i = 0;
> read_data[0] = '\0';
> bytes_read =0;
> read_term = 0; //13 = c/r, 10 = l/f, 32 = sp
> inqlen = GetInQLen (comport);/* RS-232 receive character
> length in the Q*/
> //notifyCount = 1, EventChar = 0, eventMask =
> LWRS_RECEIVE;
> bytes_read = ComRdTerm (comport, read_data, inqlen,
> read_term);
> //Display the results
> CopyString (tbox_read_data, 0, read_data, 0, bytes_read);
> SetCtrlVal (serial, SERIAL_TBOX_READ, tbox_read_data);
> RS232Error = ReturnRS232Err ();
> if (RS232Error)
> {
> DisplayRS232Error ();
> }
> //check the data out
> if(Parse(bytes_read, read_data,
> MessageCount2,
> ErrorMessage,
> GOflag,
> DONEflag,
> W1done,
> PXdone,
> ReadGOdata,
> ReadDONEdata,
> ReadW1data,
> ReadPXdata))
>
> {
> //Do something
> }
> else
> {
> printf(ErrorMessage);
> }
> timer_enabled_flag =1;
> MessGenHoldOff = 0;
> }
0 Kudos
Message 2 of 3
(2,791 Views)
Hi,
Thanks a lot for your prompt response. I am a newbe to this sort of thing. I am interested in your comment about not using a pc for an application with 100mS resolution. Can you tell me explicitally why not please?

I am on a very limited budget for this project (as I am funding it myself) I am also curious about the alternatives. Can I use a controller board and if so what sort of device am I looking for ? (so I can look at cost).

Kind regards from Scotland
0 Kudos
Message 3 of 3
(2,791 Views)