CODE
sector = Convert.ToInt32(j / 8192);
for (int i = 0; i <= sector + 1; i++)
//for (int i = 0; i <= 5; i++)
{
//if (!axMSComm1.PortOpen)
if (!axNETComm1.PortOpen)
{
//axMSComm1.PortOpen = true;
axNETComm1.PortOpen = true;
}
//axMSComm1.InBufferCount = 0;
axNETComm1.InBufferCount = 0;
strPmtk = "PMTK182,7," + i * 2000 + ",2000";
strChksum = getCheckSum(strPmtk);
pmtkstr2 = "$" + strPmtk + "*" + strChksum;
//axMSComm1.Output = pmtkstr2;
String Buffer = pmtkstr2 + "\r\n";
Object oBuffer = (object)Buffer;
//axNETComm1.set_Settings(ref oBuffer);
axNETComm1.set_Output(ref oBuffer);
//axMSComm1.Output = pmtkstr2 + "\r\n";
System.Threading.Thread.Sleep(1000);
string pmtk = "";
string Str = "";
//if (axMSComm1.InBufferCount > 0)
if (axNETComm1.InBufferCount > 0)
{
// Str = axMSComm1.Input.ToString();
Str = axNETComm1.InputData.ToString();
}
else
{
MessageBox.Show("null");
}
The loop goes in the else part and gives a "null" mesaage after it loops through 7 sectors. the mscomm1.output throws an exception System.Runtime.InteropServices.COMException