MagTek 99875125 User Manual
Page 63
Section 5. Example Applications
axMSComm1.PortOpen = true;
if(!axMSComm1.PortOpen)
{
txtOpenResults.Text="Port failed to open";
return;
}
else
{
txtOpenResults.Text="Port opened " + axMSComm1.CommPort;
}
btnSend.Enabled=true;
btnOpen.Enabled=false;
btnClose.Enabled=true;
}
//
// Close the comm (MTD) port
//
private void btnClose_Click(object sender, System.EventArgs e)
{
if(axMSComm1.PortOpen)
{
axMSComm1.PortOpen = false;
}
txtOpenResults.Text="Port closed";
btnClose.Enabled = false;
btnSend.Enabled = false;
btnOpen.Enabled = true;
}
//
// Send current command
//
private void btnSend_Click(object sender, System.EventArgs e)
{
txtResponse.Text = "";
if(axMSComm1.PortOpen)
{
axMSComm1.Output = txtCommand.Text + "\n";
}
}
//
// Capture the data from the MTD driver
//
private void axMSComm1_OnComm(object sender, System.EventArgs e)
{
switch(axMSComm1.CommEvent)
{
// event #2 is the receive event
case 2:
{
txtResponse.Text += axMSComm1.Input.ToString();
break;
}
}
}
}
}
55