I’m having data issues when I try to connect my FEZ Cobra to a PC via a serial port. Data that is sent in both directions gets corrupted. On the Cobra side, I get frame errors (code 4) when receiving data.
Here are some additional information:
- I’m using the latest GHI Premium firmware (4.2.10)
- I tried COM3 and COM4 with just RX and TD connected (plus ground).
- The setup is standard 9600, 8 data bits, no parity, 1 stop bit, no handshaking.
- It works fine connected to a FEZ Mini board.
- It works fine with a hardware loop back (RX connected to TD).
- The PC works fine with a hardware loop back.
- The PC app uses .Net.
- TeraTerm also receives corrupted data.
- I tried two USB/Serial adapters and a direct connect to the serial port of the PC with the same behavior.
Any suggestions would be most appreciated.
Thanks - Mark.
Here is the code I’m using to test this, it’s the same for the Cobra, Mini, and PC.
static SerialPort UART;
public static void TestUART()
{
UART = new SerialPort("COM3"); // COM23 for PC/USB, COM1 for PC/Serial Port
UART.BaudRate = 9600;
UART.Parity = Parity.None;
UART.StopBits = StopBits.One;
UART.DataBits = 8;
UART.Handshake = Handshake.None;
UART.Open();
UART.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived);
UART.ErrorReceived += new SerialErrorReceivedEventHandler(UART_ErrorReceived);
while (!UART.IsOpen)
Thread.Sleep(100);
Byte[] buffer = { 77 };
while (true)
{
UART.Write(buffer, 0, 1);
Thread.Sleep(1000);
}
}
private static void UART_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine("Data Received");
byte[] data = new byte[1];
UART.Read(data, 0, 1);
Console.WriteLine("Data Byte=" + data[0]);
}
private static void UART_ErrorReceived(object sender, SerialErrorReceivedEventArgs e)
{
Console.WriteLine("Error - " + e.EventType);
}