QUOTE(atomskaze @ 10 Jul, 2009 - 10:16 AM)

Hello.
I just wanted to know how should be the output of the communication.
Also, I am using this with an FPGA but when I open the port, and send data. the FPGA light goes lit but doesn't turn off. Also, when I want to close the port, it looks like the program is frozen. Is it that the code needs something else, or does it not support FPGA, or there could be fault in the programming of the FPGA?
I also want to know if part of the output of the program displays a message regarding that the object received data, or displays the data that was received.
I am bad at understanding things at first time, so please don't get mad if it was explained in the first post.
I just downloaded the code from the alternate link in a previous post. It seems that the click event was never created to close the port. It's an easy fix, here's what I added to make it work...
in CommunicationsManager.cs:
CODE
#region ClosePort
public bool ClosePort()
{
try
{
//first check if the port is already open
//if its open then close it
if (comPort.IsOpen == true) comPort.Close();
//display message
DisplayData(MessageType.Normal, "Port closed at " + DateTime.Now + "\n");
//return true if port is closed
if(comPort.IsOpen == false) return true;
DisplayData(MessageType.Normal, "Issue closing port\n");
return false;
}
catch (Exception ex)
{
DisplayData(MessageType.Error, ex.Message);
return false;
}
}
#endregion
NOTE: I added some basic error checking code to make sure the port closed before returning true, but I don't do anything with the false value at this point if there was a problem...
in frmMain.cs:
CODE
private void cmdClose_Click(object sender, EventArgs e)
{
comm.ClosePort();
cmdOpen.Enabled = true;
cmdClose.Enabled = false;
cmdSend.Enabled = false;
}
Hope that helps!
Tom