Serial connection behavior C#

  • Thread starter Thread starter Daniel Passwater via DotNetMonster.com
  • Start date Start date
D

Daniel Passwater via DotNetMonster.com

I have a serial connection in C# with a device running embedded C. My problem is that if the owner of the C code puts interupts in, I receive data. Without the interupts the transfer seems to be too fast. The interupts are an un acceptable solution. We are both connecting at 19200 baud. Does anyone have any suggestions?


Here's my incoming data handler:

This is located in the constructor:
// Create event handler for the serial input.
MainOperations.port.DataReceived += new Serial.Port.CommEvent(GetPR);


private void GetPR()
{

// Since RThreshold = 1, we get an event for every character.
byte[] inputData = new byte[1];

// Read the character.
inputData = MainOperations.port.Input;

// Store in an array.
ByteInput[InputCount] = inputData[0];

// Increment input buffer index.
InputCount++;

}

Thanks in advance for the help.
Daniel
 
Yes, you need to use some form of flow control on the RS232 interface,
software based XON/XOFF or hardware based RTS/CTS are a few to consider.

Willy.
 
I'm using a library that I got from the Microsoft .NET Framework SDK Code Samples called NetSerial. This is my first programming job, and writing a library for a serial connection was way over my head. There seems to be some flow control stuff in there, but I'm not sure that I'm using it. Also, the guy that's writing the embedded code is not using this library. I suspect that he just has a basic connection. Would flow control on my side still work if he's not using any? He does get what I'm sending.

Thanks for the help.
 
Flowcontrol is/can't be done at the user level (user library), it's the
driver's task, and you can enable/select it from the devices applet for your
COM ports.
Look for the device setting, and select "Hardware" flow control or
"XON/XOFF".
Hardware flow control requires a modem or a correctly wired cross cable,
XON/XOFF requires both 'ends' to support/enable it, no special cable wiring
needed here.

Willy.
 
Back
Top