Serial connection behavior C#

  • Thread starter Daniel Passwater via DotNetMonster.com
  • 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
 
W

Willy Denoyette [MVP]

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.
 
D

Daniel Passwater via DotNetMonster.com

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.
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top