ClientAPI - .Net
AdvancedSerialClient.cs
Go to the documentation of this file.
00001 using System;
00002 using System.IO.Ports;
00003 
00004 namespace ebl_arduino
00005 {
00009     public class AdvancedSerialClient : SerialProtocol
00010     {
00014         private SerialPort Port;
00015 
00019         public AdvancedSerialClient()
00020         {
00021 
00022         }
00023 
00028         public override bool IsConnected()
00029         {
00030             if (this.Port != null)
00031                 return this.Port.IsOpen;
00032             else
00033                 return false;
00034         }
00035 
00039         public override void Close()
00040         {
00041             this.ConnectionStream.Close();
00042             this.Port.Close();
00043         }
00044 
00050         public void Open(String Port, int BaudRate)
00051         {
00052             if (this.Port != null && this.Port.IsOpen)
00053                 this.Port.Close();
00054 
00055             this.Port = new SerialPort(Port);
00056             this.Port.BaudRate = BaudRate;
00057             this.Port.Open();
00058             this.ConnectionStream = this.Port.BaseStream;
00059             this.Receive();
00060 
00061             this.Flush();
00062 
00063             this.Send(MessageTypes.DISCOVERY_REQUEST);
00064         }
00065     }
00066 }
 All Classes Namespaces Files Functions Variables Enumerations Events