How to pick date/time when serialport starts reading , and also when reading stops ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kayzee paracha
    New Member
    • Aug 2014
    • 2

    How to pick date/time when serialport starts reading , and also when reading stops ?

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.IO;
    using System.IO.Ports;
    using System.Timers;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            public static void Main(string[] args)
            {
                SerialPort SP = new SerialPort();
                SP.PortName = "COM16";
                SP.DataReceived += new SerialDataReceivedEventHandler(SP_DataReceived);
                SP.Open();
                Console.WriteLine("Press any key to continue...");
                Console.WriteLine();
                Console.ReadKey();
                SP.Close();
    
    
            }
    
            
           
    
            private static void SP_DataReceived(object sender, SerialDataReceivedEventArgs e)
            {
                SerialPort serialPort = (SerialPort)sender;
                string line = serialPort.ReadExisting();
                
              
                Console.Write(line);
            }
    
            private void StartReading()
            {
            }
    
    
        }
    }
    Last edited by Rabbit; Aug 18 '14, 03:49 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • kayzee paracha
    New Member
    • Aug 2014
    • 2

    #2
    am not asking about time of connection opening or closing .
    plz help if you can .
    thanks in advance .

    Comment

    • horace1
      Recognized Expert Top Contributor
      • Nov 2006
      • 1510

      #3
      GetSystemTime() will get up the current UTC time and date

      Comment

      Working...