I am experiencing a weird problem, with Fez Hydra and GHI RS-232 module. I am trying to send some data from PC to the board, just to test the serial connection. I have checked all serial parameters to be the same on both ends. But, had no luck to fire DataReceived event of serial port on the board. I put a check point at the first line of the method to catch if the method runs, but it never happened. I used a sniffer cable between the PC and the boards, to make sure that the PC sends data properly to the port. What made me confused is when the cable is disconnected from RS-232 Module, the sniffer application shows data transmission from PC out. As soon as I connect the cable to the RS-232 module it stops sending, unless I unplug the cable again from the module. Here is my code:
void ProgramStarted()
{
RunProgram();
// Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
Debug.Print("Program Started");
}
void RunProgram()
{
rs232.Initialize(19200, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8, GT.Interfaces.Serial.HardwareFlowControl.NotRequired);
rs232.serialPort.Open();
rs232.serialPort.DataReceived += new GT.Interfaces.Serial.DataReceivedEventHandler(sp_DataReceived);
}
DateTime dateTimeStart;
public void sp_DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData data)
{
dateTimeStart = DateTime.Now;
if (rs232.serialPort.BytesToRead > 0)
{
byte[] byteRxBuffer = new byte[rs232.serialPort.BytesToRead];
rs232.serialPort.Read(byteRxBuffer, 0, byteRxBuffer.Length);
}
}
I have attached a picture of my setup as well, if it helps. Any ideas or suggestions about what is happening here? Thanks.