Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8782303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:32:06+00:00 2026-06-13T20:32:06+00:00

I have to communicate in Mono with a device through FTDI RS485 connector (which

  • 0

I have to communicate in Mono with a device through FTDI RS485 connector (which has usual comport software interface) on 1000000 baud rate. OS – Linux (Ubuntu… Mint13 to be particular), mono 2.10.2.

First I run simple python test program on Linux:

 >> import serial
 >> ser = serial.Serial("/dev/ttyUSB0",1000000, timeout=0.5)
 >> ser.write(":DCS3FF8;")   # Some message to the device with crc
 >> ser.readall()
 ':CDS P0 M0 E0 L1 S07B3B;'  #This is the correct response from the device

 >> print ser
 Serial<id=0x2ce71d0, open=True>(port='/dev/ttyUSB0', baudrate=1000000, bytesize=8, parity='N', stopbits=1, timeout=0.5, xonxoff=False, rtscts=False, dsrdtr=False)

The device responds correctly. Everything works fine. This shows that everything is running fine on Linux.

Then I exit python and try to use Mono with code:

     var serialPort = new SerialPort();
     serialPort.PortName = "/dev/ttyUSB0";
     serialPort.BaudRate = 1000000;

     serialPort.Open();
     serialPort.Write(":DCS3FF8;");
     Thread.Sleep(150);
     Console.WriteLine("BytesToRead: '{0}'", serialPort.BytesToRead);
     Console.WriteLine("Existing   : '{0}'", serialPort.ReadExisting());

Compile and run it with command:

     dmcs serial_try.cs && mono serial_try.exe

And get TimeoutException, serialPort.BytesToRead is 0. At the same time I see that the connector is flashing with both lights (something is transferring).

When I run the same code on .NET on Windows, it successfully communicates with the device and receive the same message as with python.

So what is the catch with SerialPort on mono? Do I miss some setting or configuration?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:32:07+00:00Added an answer on June 13, 2026 at 8:32 pm

    The problem with reading FTDI device on mono was found to be caused by bug with baud rate.

    The idea of the bug: If one sets baud rate grater than 921600 the real baud rate is set to 9600.

    Funny to say (if you waste your time trying to figure out why you can’t communicate with SerialPort on mono), that this is related to an older bug. Where impossibility to set baud rate 921600 was stated. So it looks like the bug was fixed right up to 921600 and not a bit above.

    To workaround the bug, one can call stty after port is open to set the real baud rate. So add this function:

        private void ForceSetBaudRate(string portName, int baudRate)
        {
            if (Type.GetType ("Mono.Runtime") == null) return; //It is not mono === not linux! 
            string arg = String.Format("-F {0} speed {1}",portName , baudRate);
            var proc = new Process
                {
                    EnableRaisingEvents = false,
                    StartInfo = {FileName = @"stty", Arguments = arg}
                };
            proc.Start();
            proc.WaitForExit();
        }
    

    And call right after serial open:

        _serialPort.PortName = PortName;
        _serialPort.BaudRate = BaudRate;
        _serialPort.Open();
        ForceSetBaudRate(PortName, BaudRate);
    

    The hack is not beautiful, but finally FTDI Modem works on Mono + Linux and .Net + Windows.

    Other workarounds could be in implementing your own serial port wrapper and PInvoking it or in fixing mono bug as @skolima suggested.

    Update if the baud rate is non ASCII so one can’t use stty, python could be used as a solution. See comment below. Thanks to @Dorian Scholz.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to communicate with a device which listens on a port for all
I have on Service that must communicate with an Activity (MyActivity) through a BradcastReceiver.
I have a program with a Mono-based C# client and a Python server, which
I have a setup in which some applications communicate with each other via Tibco
I am developing an Android application in which I have to communicate to an
In the application I am designing, I have to communicate with a device and
hello friends i have created a UDP chatting program through which the clients can
Need to create a client server application, both have to communicate with Database. Which
I'm making some software which communicates with serial communication to some electronics through the
currently I'am developing an Android native app which have to communicate with a server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.