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);
}