Go Down

Topic: C# SerialPort and Native usb (Read 1 time) previous topic - next topic

heightball

Dec 29, 2014, 07:47 am Last Edit: Dec 29, 2014, 07:50 am by heightball
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
Code: [Select]
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

Code: [Select]
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. 

MorganS

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.
"The problem is in the code you didn't post."

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!
Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

heightball

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 !

Capitan_EO9

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

ieee488

you have to use the protocol Arduino if you want read in C# :)
Can you read?

This thread is 2.5 years old!

Go Up