All pastes #188024 Raw Edit

Someone

public text v1 · immutable
·published 2006-10-01 18:21 UTC
rendered paste body
using System;
using System.IO;
using System.IO.Ports;

namespace testGPS
{
    class Program
    {
        
        static void Main(string[] args)
        {
            static byte[] buf = new byte[1024];
            SerialStream s = new SerialStream();
        
            try
            {
                s.Open("COM1");
                s.SetPortSettings(4800, SerialStream.FlowControl.None, SerialStream.Parity.None, 8, SerialStream.StopBits.One);
                
                int read = 0;
                while( (read = s.Read(buf, 0, buf.Length)) > 0)
                {
                    Console.Write(System.Text.ASCIIEncoding.ASCII.GetString(buf, 0, read));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error opening port:\r\n" + ex.ToString());
                Console.ReadLine();
            }
            finally
            {
                s.Close();
                s.Dispose();
            }
        }
    }
}