Mono C# SerialPort Connection

I purchased a Macbook2,1 recently, running Snow Leopard (10.6.8) and I've run into difficulties running code to connect via SerialPort to an Arduino UNO. I know the Arduino is not at fault, as I can connect to it via CoolTerm and get desired output. That means that my SerialPort connection code must be faulty. In researching this issue, I have ensured that RTS and DTS are both enabled, and that handshaking is enabled (RTS). Alas, the code does not work completely correctly; no data is received. However, the port is open, because the "Port open" line does print.
Attached is both the C# code I'm using to connect serially and the CoolTerm parameters I'm using to connect manually. Do you see any flaws in what I'm doing?

See my third post for the real question; this one is irrelevant.

Why re-invent the wheel? Arduino Playground - Csharp

That would be the smart idea... :slight_smile: I'm looking into it and I'll see if it works out.

Thanks for the movement to the right forum. I'm sorry about putting this in the wrong place; I realized it after the fact, hoping it would find the right home.

I've been working with the SendAndReceive example in CmdMessenger (v3.6). Both ends, the Macbook and the Arduino, seem to cooperate during compilation. When running the C# code, the Arduino receives a message from the Macbook, the Arduino sends a message back, but the Macbook (C#) does not acknowledge the request.

The code for Arduino and the MacBook C# is essentially the same as the SendAndReceive example. Is this a fault with me, the library, or neither?

Attached is a copy of the SerialMonitor output.

SerialMonitor.png

ZachTheRiah:
but the Macbook (C#) does not acknowledge the request.

Makes no sense.

Anonymous printing sucks. Identify what is being printed. I have no interest in guessing.

Did I miss the part in your C# code where you actually write to the serial port?

ZachTheRiah:
When running the C# code, the Arduino receives a message from the Macbook, the Arduino sends a message back, but the Macbook (C#) does not acknowledge the request.

ieee488:
Makes no sense.

What I meant by this is that the C# code does not acknowledge messages from the Arduino, even though the Arduino SerialMonitor says messages have been sent to the C# code through the Serial Port.

PaulS:
Anonymous printing sucks. Identify what is being printed. I have no interest in guessing.

Did I miss the part in your C# code where you actually write to the serial port?

I've stopped looking into that; I've edited the original post. (Thanks for reminding me to update the main post!)

There is nothing special about communicating with the Arduino over serial port.

I don't recall having to do

mySerialPort.Handshake = Handshake.RequestToSend;
mySerialPort.RtsEnable = true;
mySerialPort.DtrEnable = true;

I also read a byte at a time.

You'll want to read about how buggy serial port can be with .NET
I read the serial port in bytes.

I've stopped looking into that; I've edited the original post. (Thanks for reminding me to update the main post!)

That makes everyone that commented on the original code look like an idiot. Personally, I do not like being made to look like an idiot. Do not do that again.

Post any changes to the code in a new reply.

Why did you stop looking into the most obvious oversight?

I don't recall having to do

The DtrEnable call is needed if you want to talk to a Leonardo (or Micro).

You'll want to read about how buggy serial port can be with .NET

I've never had a problem. Must be lucky (or good).

PaulS:
The DtrEnable call is needed if you want to talk to a Leonardo (or Micro).

Yes, but he has a Uno, as did I.

Thank you PaulS and ieee488 for responding to my question. Particularly ieee488's response lead me to do some further digging on the "bugginess" of .NET implementations. On further research, the only reason I can see that my code fails is not actually from me, but from the implementation of Mono C#'s SerialPort that I am using. I'm looking into other languages to try implementing what I am looking for. Thank you! :slight_smile:

At the time I was working on a Windows 7 Pro 64-bit PC and using VB.NET 2010 Express.