Ports
May 24, 2013, 07:38:24 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: SMF - Just Installed!
 
   Home   Help Search Login Register  
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Pages: [1]
  Print  
Author Topic: Is there a bug in the Serial Port class ? (hope not!)  (Read 1260 times)
GlennP
Frequent Contributor
****
Posts: 126


« on: November 03, 2011, 11:27:00 am »

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!
 
Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1629


WWW
« Reply #1 on: November 03, 2011, 12:18:05 pm »

Be sure you have a string in Command1. Try

myComPort.Write("test");

Jan
Logged
GlennP
Frequent Contributor
****
Posts: 126


« Reply #2 on: November 04, 2011, 04: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.
 
« Last Edit: November 04, 2011, 12:05:36 pm by GlennP » Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1629


WWW
« Reply #3 on: November 04, 2011, 09: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
Logged
GlennP
Frequent Contributor
****
Posts: 126


« Reply #4 on: November 04, 2011, 12: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
Logged
Jan Axelson
Administrator
Frequent Contributor
*****
Posts: 1629


WWW
« Reply #5 on: November 04, 2011, 03: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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!