Solved

Reading from a HyperTerminal in C#?

Posted on 2007-03-22
2
3,475 Views
Last Modified: 2013-12-17
I'm having a problem with a C# program, I've connected a cross-over cable into my COM1 and COM2 ports so that I can open two HyperTerminal windows and have them communicate with each other, is it at all possible to write a program in C# that will be able to read the information that is sent to the HyperTerminal and store the information in a file or in some other way?
0
Comment
Question by:Richardsc
2 Comments
 
LVL 2

Accepted Solution

by:
_Eyeball_ earned 125 total points
ID: 18770882
Yes and no.

If you want to listen what the hyperterminals are talking no. That's because the hyperterminal blocks the port and you cant use it anymore

If you only want to listen to what the hyperterminal sends it's pretty easy...

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        private static System.IO.Ports.SerialPort m_Listener;

        static void Main(string[] args)
        {
            m_Listener = new System.IO.Ports.SerialPort();


            m_Listener.PortName = "COM1";
           
            // ... set all Informations you need

            // Register Event
            m_Listener.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(OnDataReceived);


            try
            {
                m_Listener.Open();
                Console.WriteLine("Successful opened");
            }
            catch
            {
                Console.WriteLine("Error while opening");
            }
            finally
            {
                Console.ReadLine(); // Waiting till user press Enter
                m_Listener.Close();              
            }
        }

        private static void OnDataReceived(
            object sender, System.IO.Ports.SerialDataReceivedEventArgs args)
        {
            // Create Filestream here and write bytes to file
        }
    }
}
0
 

Author Comment

by:Richardsc
ID: 18771093
I was hoping there would be some way around HyperTerminal blocking the port. Oh well. What you've given me here is a great help.

Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now