deepender singla

deepender singla

  • NA
  • 113
  • 76.6k

How to use value recieved in console application in other program

Jul 24 2011 6:42 AM
Hello Respected members

i am working on an application in which i got an input value from com4 in my console application code for which is this:
#region Namespace Inclusions
using System;
using System.IO.Ports;
using System.Windows.Forms;
#endregion


namespace SerialPortExample
{
    class SerialPortProgram
    {
        // Create the serial port with basic settings
        private SerialPort port = new SerialPort("COM4",
          9600, Parity.None, 8, StopBits.One);


        [STAThread]
        static void Main(string[] args)
        {
            // Instatiate this class
            new SerialPortProgram();
        }


        private SerialPortProgram()
        {
            //Console.WriteLine("Incoming Data:");


            // Attach a method to be called when there
            // is data waiting in the port's buffer
            port.DataReceived += new
              SerialDataReceivedEventHandler(port_DataReceived);


            // Begin communications
            port.Open();


            // Enter an application loop to keep this thread alive
            Application.Run();
        }


        private void port_DataReceived(object sender,
          SerialDataReceivedEventArgs e)
        {
            // Show all the incoming data in the port's buffer
            Console.WriteLine(port.ReadExisting());
            port.Close();


        }
    }
}  

now i want to send this value obtained to a new serial port com1 , how i can do that , in my view event hough i create another application i am sending data to com1 how i can use this console output as input to another application, plz help i will be very thankfull to you . i am struck on it badly.




Answers (18)