hi, I’ve a bare atmega chip on a breadboard and an panda II…both conected via serial with 2 cables, pin 0 on arduino to pin 1 on panda and pin 1 on arduino to pin 0 on panda.
what i want is to send for example a command from the arduino to the panda and get a response back. my problem is that most of the time i send something to the panda using the serial monitor from arduino IDE i get this error
Exception System.Exception - CLR_E_WRONG_TYPE (3)
#### Message:
#### System.Text.UTF8Encoding::GetChars [IP: 0000] ####
#### FEZ_Panda_II_Application1.Program::UART_DataReceived [IP: 002d] ####
#### System.IO.Ports.SerialPort::DataEventHandler [IP: 0012] ####
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
An unhandled exception of type ‘System.Exception’ occurred in mscorlib.dll
The code on the panda is very simple :
using System;
using System.Threading;
using System.IO.Ports;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Panda_II_Application1
{
public class Program
{
//Comunicacion
public static SerialPort UART = new SerialPort("COM1", 115200);
public static void Main()
{
// Blink board LED
Debug.EnableGCMessages(false);
bool ledState = false;
OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
//Inicia Comunicacion
UART.Open();
UART.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived);
while (true)
{
// Sleep for 500 milliseconds
Thread.Sleep(500);
// toggle LED state
ledState = !ledState;
led.Write(ledState);
}
}
static void UART_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (e.EventType == SerialData.Chars)
{
byte[] readbuffer = new byte[UART.BytesToRead];
UART.Read(readbuffer, 0,readbuffer.Length);
string RX_Data = new string(Encoding.UTF8.GetChars(readbuffer));
Debug.Print(RX_Data);
Debug.GC(true);
switch (RX_Data)
{
case "FE":
break;
case "T1":
break;
case "T2":
break;
}
}
}
}
}
what is wrong?