PORTS Forum

Ports and Interfaces => Serial Ports => Topic started by: GlennP on November 03, 2011, 12:27:00 pm

Title: Is there a bug in the Serial Port class ? (hope not!)
Post by: GlennP on November 03, 2011, 12:27:00 pm
Hi,
It's me again. Question the following bit of code:

for (int i = 0; i < Length; i++)
            {
                CommandSent = Command1.Substring(j, 1);
                myComPort.Write(CommandSent);
                //MessageBox.Show(CommandSent);
                richTextBox1.Text += CommandSent;
                j++;
            }
            myComPort.Write("\r\n");
 
works, while using the staight
myComPort.Write(Command1);
does not, is this due to a slight gap being introduced by the for loop? or am I wrong!
 
Title: Re: Is there a bug in the Serial Port class ? (hope not!)
Post by: Jan Axelson on November 03, 2011, 01:18:05 pm
Be sure you have a string in Command1. Try

myComPort.Write("test");

Jan
Title: Re: Is there a bug in the Serial Port class ? (hope not!)
Post by: GlennP on November 04, 2011, 05:11:44 am
Tried that long ago one of the boards that can register comms only see's one one character. The latest boards we are producing seem to not reply but with my cludgy method using the for loop they respond and act normally.  I am thinking that the buffer on the serial port is too small, if I had not seen this behavoir with more than one chip family (MSP430 & PIC16F) I would be thinking it is due to a manufactures issue but multiple chips, multiple families mean it is something else.  Someone (not me!) being a little stingy with buffer size ?

Glenn

Also I have had chat to the designer of the board he says the buffer is about 40 bytes which should be enough with for the messages.  The message is " L255:8:000 \n" if this is sent using the Write method does not work but sending it the 'for' loop above seems work.
 
Title: Re: Is there a bug in the Serial Port class ? (hope not!)
Post by: Jan Axelson on November 04, 2011, 10:36:12 am
If it works at a slower baud rate, it's likely an issue with how fast the firmware can remove the received data from the serial-port's buffer.

Jan
Title: Re: Is there a bug in the Serial Port class ? (hope not!)
Post by: GlennP on November 04, 2011, 01:11:16 pm
So, it's not my problem the board wont recieve at the speed its being sent at (!) That could well solve it, why does HyperTerm work though?

Glenn
TGIF
Title: Re: Is there a bug in the Serial Port class ? (hope not!)
Post by: Jan Axelson on November 04, 2011, 04:45:50 pm
If there is a buffering issue, use flow control.

The first step is to verify that the data is going out on the line to the board. Then investigate why the board isn't responding correctly.

Jan