LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TCP server program passing chars problem

I wrote a server program using LW/CVI...my prog won't receive more then one char at a time..if i type fast or press enter i receive a bunch of garbage....It passes chars the way it's meant to but it won't receive...I place the chars in a buffer then display them...has anyone else had this problem??????????
0 Kudos
Message 1 of 6
(3,330 Views)
I've had no problems with this functionality.

Try looking at the examples, or if you can, post your Tx, or Rx functions here. I'd say it may be your Rx function.

Chris
0 Kudos
Message 2 of 6
(3,330 Views)
I've attached my server program with this....does this help anyone answer my question????
0 Kudos
Message 3 of 6
(3,330 Views)
I've noticed that you send (upto) 500 chars, and you append a '\n' to the end of your string. But there is no terminating ASCII NULL.

When you receive your characters, you are (providing no error), sending the contents of the buffer (buf) to your UIR Panel. Since there is no ASCII_NULL it might print garbage.
If you initialise the TX buffer with all ASCII_NULLS, and then append one to each string before sending, see what effect that has.

Since you are Tx'ing 500 characters (unless there is an ASCII NULL in there somewhere), your receive function will Rx all 500 and the function continues, but, assuming your only transmitt 400 because, your RX function will wait for the timeout period (1000 in your case) until proceding. Since you are acting on TCP_DataReady,
you could lower this value down to 100 or less, and it will respond to as many characters as you send it.

When you calculate the string length of your buffer to send, it does not, or might not find the terminating ASCII_NULL, so the number of characters actually transmitted may be differnent to the number in your buffer.

Other than that, its basically the same as I have.
0 Kudos
Message 4 of 6
(3,330 Views)
Thanks......I used a for loop to null the buffer.....for (i=0; i<...etc...
buf[i] ='\0';

This worked without any problems
0 Kudos
Message 5 of 6
(3,330 Views)
You could use FillBytes as well.

You should only need to do this once when you define (or initialise your TX buffer). Then providing you append an ASCII NULL to the end of the string to be TX'ed, strlen will pick this up as the end of the string, and only TX that amount of characters. (Since you add the +1, it should also TX the ASCII_NULL)
0 Kudos
Message 6 of 6
(3,330 Views)