Solved

Reading from a HyperTerminal in C#?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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:…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

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