LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring a remote P.C. serial communication response time.

Hi all...


I'm trying to measure the time it takes for a remote station to receive
one (1) char and to respond with one char through the com port.

The port is initialized to 600bps 8 data bits even parity and 2 stop
bits.
The operating system is winnt4.0 sp5.

The expected time to be measured (as I see it...) is the transmitted
char(==10 bits) transmitting time, + some remote station internal
processing time, + the received char transmitting time.

16.6mSec +~3mSec + 16.6mSec = ~35mSec.

What I get is ~250mSec!

I don't understand why...

Attached here is the code I run on the remote P.C. that does only a
simple task: waiting for any char to get to the Rx Queue, and when it
gets, if sends a one ch
ar response.

That's it!

Can anyone help or explain to me what is happening here???


Thanks you


#include
#include
#include
#include



int ret, qq, loop;
char buffer[100];
double passed_time;



SendOneByte(int buff)
{
int byte_send;

byte_send = ComWrtByte (1, buff);

return byte_send;
}



void main(void)
{
ret = OpenComConfig (1, "COM1", 9600, 2, 8, 2, 512, 512);

while (1)
{
while(!(qq = GetInQLen (1)));

// passed_time = Timer();
SendOneByte(65);

ComRd (1, buffer, qq);

// printf("%f\n", Timer()-passed_time);

}


CloseCom (1);

}
0 Kudos
Message 1 of 5
(3,951 Views)
I am experienced a similar problem in an application with a heavy traffic on RS232 port; It seems that a great time is lost in passing characters from my program to the operating system and from this one to the COM driver, time added to the pure tx/rx time.
I solved my problem using low level functions to write to the port and it does work fine.
Here some code for transmission on COM1 port:

short IOind = 0x3F8; // Address of serial port
int i, x;
char message[20];

strcpy (message, "Testing...");
FlushInQ (com); // Empty buffer
for (i = 0; i < strlen (message); i++) { // Send one byte at a time
outp (IOind, *(message + i));
// A little while to pace characters
for (x = 0; x < 10; x++);
}
Delay (0.007); // Fixed pause for my device to receive message and respond
....

I hope this will help
Roberto
Alon Keisar ha scritto nel messaggio <38A80ACE.8CB1CA9D@tact.co.il>...
Hi all...

I'm trying to measure the time it takes for a remote station to receive one (1) char and to respond with one char through the com port.

The port is initialized to 600bps 8 data bits even parity and 2 stop bits.
The operating system is winnt4.0 sp5.

The expected time to be measured (as I see it...) is the transmitted char(==10 bits) transmitting time, + some remote station internal processing time, + the received char transmitting time.

16.6mSec +~3mSec + 16.6mSec = ~35mSec.

What I get is ~250mSec!

I don't understand why...


Attached here is the code I run on the remote P.C. that does only a simple task: waiting for any char to get to the Rx Queue, and when it gets, if sends a one char response.

That's it!

Can anyone help or explain to me what is happening here???


Thanks you


#include
#include
#include
#include



int ret, qq, loop;
char buffer[100];
double passed_time;



SendOneByte(int buff)
{
int byte_send;

byte_send = ComWrtByte (1, buff);

return byte_send;
}



void main(void)
{
ret = OpenComConfig (1, "COM1", 9600, 2, 8, 2, 512, 512);

while (1)
{
while(!(qq = GetInQLen (1)));

// passed_time = Timer();
SendOneByte(65);

ComRd (1, buffer, qq);

// printf("%f\n", Timer()-passed_time);

}


CloseCom (1);

}
0 Kudos
Message 2 of 5
(3,951 Views)
hi
this is very interesting.
i have a similar problem with LabWindows/CVI 5.0 on NT4.0(SP5).

i have two applications: one runs on the pc, the other one on a target. the
communication runs with 115k baud.

i have analysed the serial port communication with an oscilloscope and found
following:

PC: ___|||||||||||______________||||||||||
T : _______________||_____________________

as you can see the pc waits quite a long time after retrieving the targets
acknowledge. this time is 150ms !! in this time my program does nothing.

it looks like the time is lost somewhere between NT my Program and the serial
port.

150 ms is not much if you have only one message. if you want to send 1000
messages the total delay is more than 2.5 min !!

is there any workaround for NT? is it p
ossible to use a different serial
driver ?


any help is appreciated

many thanks

alain
0 Kudos
Message 3 of 5
(3,951 Views)
Sorry I can't be of any help; I'm trying to solve the same problem. In
MS Visual C++ I can use a different I/O library (DLPortIO, a shareware
driver which is quite fast and works on NT) but this is not possible in
LabWindows/CVI. It seems the CVI serial port driver is always loaded
and there's no way to unload it that I know of. Maybe someone at NI
knows? I'm going to e-mail them.

Tom


In article <38fb4000@newsgroups.ni.com>,
"Alain" wrote:
>
> hi
> this is very interesting.
> i have a similar problem with LabWindows/CVI 5.0 on NT4.0(SP5).
>
> i have two applications: one runs on the pc, the other one on a
target. the
> communication runs with 115k baud.
>
> i have analysed the serial port communication with an oscilloscope and
f
ound
> following:
>
> PC: ___|||||||||||______________||||||||||
> T : _______________||_____________________
>
> as you can see the pc waits quite a long time after retrieving the
targets
> acknowledge. this time is 150ms !! in this time my program does
nothing.
>
> it looks like the time is lost somewhere between NT my Program and the
serial
> port.
>
> 150 ms is not much if you have only one message. if you want to send
1000
> messages the total delay is more than 2.5 min !!
>
> is there any workaround for NT? is it possible to use a different
serial
> driver ?
>
> any help is appreciated
>
> many thanks
>
> alain
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 4 of 5
(3,951 Views)
hi there

i have solved the problem now. first of all. the labwin serial driver is
very stable but it is slow. the reason is that windows is message based.
so when you want to receive a character over the serial port you deliver
a message. once in a while those messages are handled.

so if you want to be really fast it is best
to receive all bytes in one call.if you use something like
for(i=0; i<10; i++)
{
ReadByte(...);
}
you are really slow.

the next step is to stop labwin from updating the screen all the time. this
takes
about 60 ms. so it is not a smart idea to count all the packages and give
the user feedback.

so leave away all fancy stuff. do exactly what you want, nothing more, and
you should be fast

regards

alain
0 Kudos
Message 5 of 5
(3,951 Views)