我想测试我的 Arduino 和我的 PC 之间的串行通信,我想这样做,因为当我将我的 arduino 连接到我的串行总线时,我没有收到一些数据。
我已经通过 rs232 将我的 PC 连接到我的 Arduino mega,并从 Arduino 连接回 PC。现在我想向 Arduino 发送一个 9 位字节并返回到 PC,当它工作时我知道我的串行总线是问题所在。
问题:
如何设置标记奇偶校验?
我测试“正常”字节(8 位)的代码是用 Visual C# 编写的,我希望我可以再次使用它们,并且只需要修复一点。
这里的代码:
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();
}
}
}
我希望有人能以友好的祝福帮助我 sniffi