2

I want test my serial communication between my Arduino and my PC, i want do that because when i connect my arduino to my serial bus i didn´t receive some data.

I have connected my PC over rs232 to my Arduino mega and from the Arduino back to the PC. Now i want send a 9-bit byte to the Arduino and back to the PC, when that works i know that my serial bus is the problem.

Question:

How can i set the mark parity?

My code to test a "normal" byte(8 bit) is written in Visual C# i hope i can use them again and must only fix a bit.

Here the code:

using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication5
{
  class Program
{
    static void Main(string[] args)
    {

        System.IO.Ports.SerialPort port = new SerialPort("COM5", 4800);
        try
        {
            port.Open();
            while (true)
            {
                //if (port.BytesToRead > 0)
                {
                    port.Write("A");
                }

            }
        }
        catch (Exception)  // Press CTRL-C to exit.
        {
            port.Close();
            Console.WriteLine("C");
        }
        port.Close();
    }
  }
}

I hope someone can help me with friendly wishes sniffi

sniffi
  • 125
  • 2
  • 15
  • 1
    port = new SerialPort("COM5", 4800, Parity.None, 8, StopBits.One); => you can change it there. if you need more than enum "Parity", I dont think its possible. –  Jul 11 '16 at 08:06
  • 1
    Only a device driver has a shot at doing this at an acceptable data rate, reprogramming the UART for every single byte is not something you can do reliably in a userland program unless you use long delays. 9-bit bus protocols are invented by companies that also want to sell you the hardware. Buy the hardware, resistance is futile. – Hans Passant Jul 11 '16 at 08:28
  • I´m a trainee at a companie and must try something the problem is my contact person is ill since i start the trainee. But thanks for the fast answers i test at the moment the comment from x... – sniffi Jul 11 '16 at 08:36

0 Answers0