LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Differences between ComWrt and ComWrtByte

What is the difference between these two codes?
1-"
unsigned char bytes[5];
bytes[0]=0xC5;
bytes[1]=0x55;
bytes[2]=0x0;
bytes[3]=0x0;
bytes[4]=0xD2;
for (i=0;i<5;i++)
ComWrtByte(1,bytes[i]);

"
2-"
unsigned char bytes[5];
bytes[0]=0xC5;
bytes[1]=0x55;
bytes[2]=0x0;
bytes[3]=0x0;
bytes[4]=0xD2;
ComWrt(1,bytes,5);

"
I asked this simple question because when I use these codes in my application, I've get different results from the COM port. When I look the TX channel when I use sample code#1 there are some delays (arbitrary length upto 20 ms) between bytes (arbitrary index). But when I use the 2nd sample code everything seems to be good..
I'm confused because I could not see inside these functions and yo
u know the answer. Could you please send me a detailed information of these functions? But not the definitions, you know that; I have already them inside the CVI help!
PS: CVI version 5.0
Thank you and waiting for your response,
Regards
Atakan Dura
0 Kudos
Message 1 of 2
(4,124 Views)
ComWrtByte will write a single byte at a time to the COM buffer, whereas ComWrt will transfer a larger chunk at a time. The buffer is then written to the COM port whenever available. In your case, it appears that the buffer is written faster than being filled by ComWrtByte, whereas ComWrt takes a large enough chunk that there is no delay. 20ms seems a bit long for a delay, but certainly the behavior is expected to be different with some delays. You would see the same behavior if you put ComWrt inside of a for loop, but the delays would be between groups of 5 characters, not each individual characters.

Allen P.
National Instruments
0 Kudos
Message 2 of 2
(4,124 Views)