473,409 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Setting Input mode for serial communications.

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
6 6943
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
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

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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andreas Horneff | last post by:
Hi @ all, I've got a problem with serial communication in Borland C++ Builder. I've already found a lot of stuff about serial communication in the internet, but it dosen't work. What I want...
4
by: Ben Zhu | last post by:
I have a small project, which need use both RS232 port and excel for data plot. I considering use excel VB macro for the entire project. Although I used serial port extensively in MFC, I am not...
3
by: Essam | last post by:
Hi All I have two programs ; both of them I need to give read/write access to the same Comm Port. How can I do so; using Code or third party tool/library
0
by: David | last post by:
I am having trouble with "ACCESS DENIED" error messages in a VB.NET 2003 application when attempting to open serial comms ports. The application has 2 ports that connect via serial cable to 2...
4
by: Gary Frank | last post by:
I'd like to write a program in VB.Net that handles serial communications to several devices. VB.Net 2003 does not have adequate built-in serial communications. I heard that 2005 will have that. ...
8
by: vicky | last post by:
Hello,I met a question when I wrote the program.I want the program can transmit the data frame continuosly through the RS232 when the communication has been interrupted.But I don't know how to...
5
by: Franklin M. Gauer III | last post by:
Hi All, I've written an ASP.NET application (webservice) that does simple serial communications via the .NET 2.0 SerialComm object. The application runs fine on my development machine. The...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
5
by: LongBow | last post by:
Hello, Is there a way, in .NET, to determine what are the avialable Serial (Communications) Ports on a Windows OS and is there a way to determine that port isn't being use other than attempting...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.