C# SerialPort and Native usb

Trying to read the SerialUSB with C# getting no data.

Serial.println() work fine but SerialUSB.println() is not in C#. :o

SerialUSB work with c++ and python but for unknown reason c# since not been able to read the native usb.

I really need the speed of native port and don't want to transfer all the project in c++(at lease i am hopping)

Skecth Println a test string in both Serial

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(9600);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  SerialUSB.println("Test");
  Serial.println("Test");
  delay(1000);

}

c# code is only a for loop to read the serial inputbuffer. Working with the programming port, but not the native one

using System;
using System.IO.Ports;

namespace test
{
    class Program
    {

        static void Main(string[] args)
        {
            //Switch com port to your. Mine is COM3 for prog and COM4 for native
            SerialPort port = new SerialPort("COM3", 9600);
            port.Open();
            for(int i =0;i <10;i++)
            {   
                    Console.WriteLine(port.ReadLine());
            }
            port.Close();

        }

    }
}

On Windows 8.1
Did try arduino IDE 1.5.8 and 1.6.0

tank you all.

Does the Arduino serial monitor read the native port data?

You know those two ports generally appear as different COM ports when you plug them in so you need to change your C# code.

I had the same problem when I tried using the arduino due and C#. It turns out, that you need to set DtrEnable to true. Then it all works well!

Gericom:
I had the same problem when I tried using the arduino due and C#. It turns out, that you need to set DtrEnable to true. Then it all works well!

Ty that was the solution!! You are a life saver !

you have to use the protocol Arduino if you want read in C# :slight_smile:

Capitan_EO9:
you have to use the protocol Arduino if you want read in C# :slight_smile:

Can you read?

This thread is 2.5 years old!