using System; using System.IO; using System.Text; using SerialPorts; namespace MySerial { /// /// Summary description for Class1. /// class Class1 { /// /// The main entry point for the application. /// /// [STAThread] static void Main(string[] args) { WithEvents w = new WithEvents(); SerialPort p = new SerialPort(w); p.Cnfg.BaudRate = SerialPorts.LineSpeed.Baud_9600; p.Cnfg.DataBits = SerialPorts.ByteSize.Eight; p.Cnfg.StopBits = SerialPorts.StopBits.One; p.Cnfg.FlowCtrl = SerialPorts.Handshake.None; p.Cnfg.Parity = SerialPorts.Parity.None; p.Open(1); p.SendE(SerialPorts.ExtCodes.SetRTS); p.Send((byte)0x80); //send reset //Now read back while(true) { byte[] b = new byte[5]; uint n; n = p.Recv(b, 5); if(n > 0) { System.Console.WriteLine("X, Y = {0}, {1}", (b[2] << 7) + b[1] , (b[4] << 7) + b[3]); } } } } }