Setting Input mode for serial communications.

  • Thread starter Thread starter Peter Krikelis
  • Start date Start date
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.
 
Peter:

The following is the compile error:

'AxMSCommLib.AxMSComm' does not contain a definition
for 'InputMode'

Weird. I just checked, and sure enugh, the InputMode property doesn't pop up
in Intellisense in C#, but it _is_ there when using the same control in
VB.Net! (I also tried in VB6 and of course it's there too)

I wonder why C# doesn't like that property?

Norvin
 
Hi Peter,

Do you refer to the Microsoft Communication Control, version 6.0?
I have refered this control and no error generated for InputMode
property. The intellisence for this property also will generate.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Peter Krikelis" <[email protected]>
| Sender: "Peter Krikelis" <[email protected]>
| Subject: Setting Input mode for serial communications.
| Date: Thu, 11 Sep 2003 09:16:14 -0700
| Lines: 93
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN4gAXviZTgT34ETUC920c2H2fSaw==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:184141
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| 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.
|
 
Hi Jeffrey,

Thank you for your help. I go to References of the
Solution Explorer. Then I check the properties of both
AxMSCommLib and MSCommLib (both libraries are added when
the Microsoft Comm Control is added to the form) and
scroll down to Version, both read version 1.0. Is this
version you speak of? If so, how do I upgrade?

Thank You
Peter
 
Hi Peter,

My component's version is 1.1.
Do you refer this component by adding reference or by adding items in tool
box?
It seems of that there are different usage of these 2 ways.

For adding reference, you can invoke inputmode property like this:
MSCommLib.MSCommClass obj=new MSCommLib.MSCommClass();
obj.InputMode=...;

For adding item in tool box, you can do like this:
AxMSCommLib.AxMSComm obj=new AxMSCommLib.AxMSComm();
obj.InputMode=...;

Hope this helps.
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Peter Krikelis" <[email protected]>
| Sender: "Peter Krikelis" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Setting Input mode for serial communications.
| Date: Fri, 12 Sep 2003 05:31:36 -0700
| Lines: 160
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN5Kc7U2PcBdk15SWuqSPwJoEZ85Q==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:184363
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi Jeffrey,
|
| Thank you for your help. I go to References of the
| Solution Explorer. Then I check the properties of both
| AxMSCommLib and MSCommLib (both libraries are added when
| the Microsoft Comm Control is added to the form) and
| scroll down to Version, both read version 1.0. Is this
| version you speak of? If so, how do I upgrade?
|
| Thank You
| Peter
|
|
|
| >-----Original Message-----
| >
| >Hi Peter,
| >
| >Do you refer to the Microsoft Communication Control,
| version 6.0?
| >I have refered this control and no error generated for
| InputMode
| >property. The intellisence for this property also will
| generate.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Peter Krikelis" <[email protected]>
| >| Sender: "Peter Krikelis" <[email protected]>
| >| Subject: Setting Input mode for serial communications.
| >| Date: Thu, 11 Sep 2003 09:16:14 -0700
| >| Lines: 93
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| Thread-Index: AcN4gAXviZTgT34ETUC920c2H2fSaw==
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:184141
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| 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.
| >|
| >
| >.
| >
|
 
Back
Top