Solved

Reading from a HyperTerminal in C#?

Posted on 2007-03-22
2
3,460 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

23 Experts available now in Live!

Get 1:1 Help Now