P
Peter Krikelis
Hi All,
I am having a problem setting up input mode for serial
communications.
(Sorry about the long code post).
The following code is what I use to set up my comm port.
// Constructor for Form with an AxMSCommLib control on it
named "com"
public SerialTerm()
{
// Initialize Form Components
InitializeComponent();
// Initialize the COM Port control
InitComPort();
}
private void InitComPort()
{
// Set the com port to be 1
com.CommPort = 1;
// This port is already open, close it to reset it.
if (com.PortOpen) com.PortOpen = false;
// Trigger the OnComm event whenever data is received
com.RThreshold = 1;
// Set the port to 9600 baud, no parity bit, 8 data
bits, 1 stop bit (all standard)
com.Settings = "9600,n,8,1";
// Force the DTR line high, used sometimes to hang up
modems
com.DTREnable = true;
// No handshaking is used
com.Handshaking = 0;
// Don't mess with byte arrays, only works with
simple data (characters A-Z and numbers)
com.InputMode =
MSCommLib.InputModeConstants.comInputModeBinary;
// Use this line instead for byte array input, best
for most communications
//com.InputMode =
MSCommLib.InputModeConstants.comInputModeText;
// Read the entire waiting data when com.Input is used
com.InputLen = 0;
// Don't discard nulls, 0x00 is a useful byte
com.NullDiscard = false;
// Attach the event handler
com.OnComm += new System.EventHandler(this.OnComm);
// Open the com port
com.PortOpen = true;
}
The following is the compile error:
'AxMSCommLib.AxMSComm' does not contain a definition
for 'InputMode'
I want to be able to use byte arrays with input data.
Therefore, I need to be able to change my inputmode to
binary.
Thank You
Pete.
I am having a problem setting up input mode for serial
communications.
(Sorry about the long code post).
The following code is what I use to set up my comm port.
// Constructor for Form with an AxMSCommLib control on it
named "com"
public SerialTerm()
{
// Initialize Form Components
InitializeComponent();
// Initialize the COM Port control
InitComPort();
}
private void InitComPort()
{
// Set the com port to be 1
com.CommPort = 1;
// This port is already open, close it to reset it.
if (com.PortOpen) com.PortOpen = false;
// Trigger the OnComm event whenever data is received
com.RThreshold = 1;
// Set the port to 9600 baud, no parity bit, 8 data
bits, 1 stop bit (all standard)
com.Settings = "9600,n,8,1";
// Force the DTR line high, used sometimes to hang up
modems
com.DTREnable = true;
// No handshaking is used
com.Handshaking = 0;
// Don't mess with byte arrays, only works with
simple data (characters A-Z and numbers)
com.InputMode =
MSCommLib.InputModeConstants.comInputModeBinary;
// Use this line instead for byte array input, best
for most communications
//com.InputMode =
MSCommLib.InputModeConstants.comInputModeText;
// Read the entire waiting data when com.Input is used
com.InputLen = 0;
// Don't discard nulls, 0x00 is a useful byte
com.NullDiscard = false;
// Attach the event handler
com.OnComm += new System.EventHandler(this.OnComm);
// Open the com port
com.PortOpen = true;
}
The following is the compile error:
'AxMSCommLib.AxMSComm' does not contain a definition
for 'InputMode'
I want to be able to use byte arrays with input data.
Therefore, I need to be able to change my inputmode to
binary.
Thank You
Pete.