Solved

How to access serial port on Remote Machine

Posted on 2008-10-30
3
1,773 Views
Last Modified: 2013-12-17
Hi Experts,

I have written a small program that listens on a serial port (COM2). Upon DataReceived (event), I write the info to a DB for reporting. The program works well when installed locally. Is it possible to point the SerialPort class to a remote machine so I can run it from my desktop?

Thanks,

Matt
/*
 * File:        PhoneMonitor.cs
 * Author:      Matt Skelton
 * Date:        October 29, 2008    : Created
 *              October 30, 2008    : Updated
 * 
 * Description: The PhoneMonitor program listen to the COMx port (serial) 
 *              of a machine. On DataReceived (event), the info is written to DB.
 *              COMx can be changed to the desired serial port.
 */
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
 
namespace PhoneMonitor
{
    public partial class PhoneMonitor : Form
    {
        #region Attributes
 
        private SerialPort port = new SerialPort();
 
        #endregion
 
        #region Constructors
 
        public PhoneMonitor()
        {
            InitializeComponent();
 
            try
            {               
                if (port.IsOpen)
                {
                    port.Close();
                }
 
                port.PortName   = "COM2";
                port.BaudRate   = 19200;
                port.Parity     = Parity.None;
                port.DataBits   = 8;
                port.StopBits   = StopBits.One;
 
                if (port.IsOpen)
                {
                    port.Close();
                }
 
                port.Open();
                port.DtrEnable = true;
 
                port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
            
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
 
        #endregion
 
        #region Event Handlers
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {           
            textboxOutput.Text += port.ReadLine();
        }
 
        #endregion
    }
}

Open in new window

0
Comment
Question by:brodaseating
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 41

Accepted Solution

by:
graye earned 250 total points
ID: 22842738
I don't think you can run an application on your PC to monitor the serial port on a remote PC.
Having said that, you could create a classic "client server" application where a part of the app runs on your PC, and the part runs on the remote PC.   The two parts would use standard TCP/IP communication techniques to talk between the two.
Take a look at the following example:  http://www.codeproject.com/KB/IP/tcpclientserver.aspx
0
 
LVL 1

Author Closing Comment

by:brodaseating
ID: 31511686
Thanks, I thought that might be the case.
0
 
LVL 7

Expert Comment

by:HalfAsleep
ID: 24058412
You could also map a com port to another host, with the "net use" command.

net use com5 \\client\com1
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help with another query 10 54
Adjust the codes 3 63
How do you think this website does searches? 5 34
unable to isntall .net framework 3.5 19 35
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 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