Click here to Skip to main content
15,903,385 members
Home / Discussions / C#
   

C#

 
AnswerRe: Serial Port Class bug??? Pin
BobJanova3-Nov-11 6:02
BobJanova3-Nov-11 6:02 
GeneralRe: Serial Port Class bug??? Pin
glennPattonWork33-Nov-11 6:15
professionalglennPattonWork33-Nov-11 6:15 
AnswerRe: Serial Port Class bug??? Pin
Roger Wright3-Nov-11 7:01
professionalRoger Wright3-Nov-11 7:01 
GeneralRe: Serial Port Class bug??? Pin
glennPattonWork33-Nov-11 7:16
professionalglennPattonWork33-Nov-11 7:16 
AnswerRe: Serial Port Class bug??? Pin
Richard MacCutchan3-Nov-11 7:20
mveRichard MacCutchan3-Nov-11 7:20 
GeneralRe: Serial Port Class bug??? Pin
Luc Pattyn3-Nov-11 7:34
sitebuilderLuc Pattyn3-Nov-11 7:34 
GeneralRe: Serial Port Class bug??? Pin
Richard MacCutchan3-Nov-11 23:20
mveRichard MacCutchan3-Nov-11 23:20 
AnswerRe: Serial Port Class bug??? Pin
Luc Pattyn3-Nov-11 7:30
sitebuilderLuc Pattyn3-Nov-11 7:30 
I have been using serial ports quite a lot over the years, and I am unaware of any bug in Windows serial ports that could be relevant here.

Anyway, all your code snippets are doing is slow down the communication in different ways.

In my books, when a simple SerialPort.Write(byteArray, startIndex, length) doesn't work properly, then it is probably one of these two things:
- your serial bytes are bumping into each other due to a bit pattern format error (most common would be sending with just the one stop bit whereas the receiver may require 1.5 or 2)
- the receiver is badly designed and has a timing constraint, e.g. it needs more time to process a byte than it takes the byte to travel the serial line. Reducing the baud rate could solve this.

There are a lot of issues with serially receiving data, especially when data rates are high, and both throughput and latency are of high importance. Then Windows is tricky, as are many other systems. However, transmitting should never pose any problems.

Suggestion: try at lower baud rates first. I tend to develop comm protocols at 9600 Bd until they work perfectly, onlyu then turn up the baud rate.

Some random remarks:
- base-board serial ports tend to have good timing behavior; remote ports (such as USB serial cables, or Ethernet serial ports) tend to suffer delays and packetizing phenomena as they try not to send a whole package for each and every byte you want sent. So make sure to log the hardware aspects too when observing system behavior.
- make sure the GROUND signal in your serial cable is connected properly at both ends; a two-wire serial cable should not work, but it may occasionally work, be it intermittently.
- Windows knows how to buffer and dataflow the outgoing data, just like it does the incoming data; if you're unaware of this, it may continue for a while; and then stop sending data because the other side is "actively refusing to accept any more data". This depends on your handshake settings.
- make sure to setup and open the serial port once, then wait a while before exercising anything. Do not open and close all the time (a serial port is not a database!). That is recommended in general; and in particular in Windows where a fast close-open sequence is known to fail often (and that is a documented "feature").

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: Serial Port Class bug??? Pin
Roger Wright3-Nov-11 8:43
professionalRoger Wright3-Nov-11 8:43 
AnswerRe: Serial Port Class bug??? Pin
Luc Pattyn3-Nov-11 9:23
sitebuilderLuc Pattyn3-Nov-11 9:23 
GeneralRe: Serial Port Class bug??? Pin
Roger Wright3-Nov-11 10:48
professionalRoger Wright3-Nov-11 10:48 
GeneralRe: Serial Port Class bug??? Pin
Luc Pattyn3-Nov-11 11:03
sitebuilderLuc Pattyn3-Nov-11 11:03 
GeneralRe: Serial Port Class bug??? Pin
glennPattonWork33-Nov-11 23:02
professionalglennPattonWork33-Nov-11 23:02 
GeneralRe: Serial Port Class bug??? Pin
glennPattonWork33-Nov-11 23:22
professionalglennPattonWork33-Nov-11 23:22 
QuestionPassing array by reference from C# to c++/cli Pin
eyalbi0073-Nov-11 4:40
eyalbi0073-Nov-11 4:40 
AnswerRe: Passing array by reference from C# to c++/cli Pin
Mark Salsbery3-Nov-11 5:25
Mark Salsbery3-Nov-11 5:25 
GeneralRe: Passing array by reference from C# to c++/cli Pin
eyalbi0073-Nov-11 22:23
eyalbi0073-Nov-11 22:23 
GeneralRe: Passing array by reference from C# to c++/cli Pin
Nish Nishant4-Nov-11 4:32
sitebuilderNish Nishant4-Nov-11 4:32 
GeneralRe: Passing array by reference from C# to c++/cli Pin
Nish Nishant4-Nov-11 4:32
sitebuilderNish Nishant4-Nov-11 4:32 
AnswerRe: Passing array by reference from C# to c++/cli Pin
Luc Pattyn3-Nov-11 5:34
sitebuilderLuc Pattyn3-Nov-11 5:34 
QuestionDatagrid checkbox column update Pin
HarYur2-Nov-11 23:19
HarYur2-Nov-11 23:19 
AnswerRe: Datagrid checkbox column update Pin
Luc Pattyn2-Nov-11 23:39
sitebuilderLuc Pattyn2-Nov-11 23:39 
AnswerRe: Datagrid checkbox column update Pin
Bernhard Hiller3-Nov-11 22:14
Bernhard Hiller3-Nov-11 22:14 
QuestionHow to run an application action on clicking link Pin
Knightwalker2-Nov-11 11:12
Knightwalker2-Nov-11 11:12 
AnswerRe: How to run an application action on clicking link Pin
Abhinav S2-Nov-11 17:59
Abhinav S2-Nov-11 17:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.