Solved

Reading from a HyperTerminal in C#?

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show/Hide ASP.NET controls with JQuery best practices 3 49
Store results in vb.net 3 20
Footer for each row on Gridview 2 21
.NET 2008 VB and C# 6 28
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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