By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,234 Members | 2,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,234 IT Pros & Developers. It's quick & easy.

Setting Input mode for serial communications.

P: n/a
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.
Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I recommend going with a RS232 library written in C# instead of using
interop. There's some good code at this article:

http://msdn.microsoft.com/msdnmag/is...m/default.aspx

Chris

"Peter Krikelis" <pk*******@hotmail.com> wrote in message
news:07****************************@phx.gbl...
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.

Nov 15 '05 #2

P: n/a
Peter:

<snip>
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
Nov 15 '05 #3

P: n/a

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" <pk*******@hotmail.com>
| Sender: "Peter Krikelis" <pk*******@hotmail.com>
| Subject: Setting Input mode for serial communications.
| Date: Thu, 11 Sep 2003 09:16:14 -0700
| Lines: 93
| Message-ID: <07****************************@phx.gbl>
| 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.
|

Nov 15 '05 #4

P: n/a
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 InputModeproperty. 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" <pk*******@hotmail.com>
| Sender: "Peter Krikelis" <pk*******@hotmail.com>
| Subject: Setting Input mode for serial communications.
| Date: Thu, 11 Sep 2003 09:16:14 -0700
| Lines: 93
| Message-ID: <07****************************@phx.gbl>
| 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.
|

.

Nov 15 '05 #5

P: n/a

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" <pk*******@hotmail.com>
| Sender: "Peter Krikelis" <pk*******@hotmail.com>
| References: <07****************************@phx.gbl>
<MK**************@cpmsftngxa06.phx.gbl>
| Subject: RE: Setting Input mode for serial communications.
| Date: Fri, 12 Sep 2003 05:31:36 -0700
| Lines: 160
| Message-ID: <24****************************@phx.gbl>
| 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" <pk*******@hotmail.com>
| >| Sender: "Peter Krikelis" <pk*******@hotmail.com>
| >| Subject: Setting Input mode for serial communications.
| >| Date: Thu, 11 Sep 2003 09:16:14 -0700
| >| Lines: 93
| >| Message-ID: <07****************************@phx.gbl>
| >| 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.
| >|
| >
| >.
| >
|

Nov 15 '05 #6

P: n/a
Here is a nice article on DOTNET Serial Communication
http://msdn.microsoft.com/msdnmag/is...m/default.aspx

"Chris Capel" <ch***@ibanktech.net> wrote in message news:<#z**************@TK2MSFTNGP10.phx.gbl>...
I recommend going with a RS232 library written in C# instead of using
interop. There's some good code at this article:

http://msdn.microsoft.com/msdnmag/is...m/default.aspx

Chris

"Peter Krikelis" <pk*******@hotmail.com> wrote in message
news:07****************************@phx.gbl...
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.

Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.