Beispiel #1
0
        public void InitializePort()
        {
            if (ActiveSerialPort != null)
            {
                if (!ActiveSerialPort.IsOpen)
                {
                    ActiveSerialPort.Open();
                }
            }

            activeSerialPort.DataReceived += ActiveSerialPort_DataReceived;

            ActiveSerialPort.Write("69");
        }
Beispiel #2
0
 public void SendMessage(SendTypes sendType, String message, int index)
 {
     if (ActiveSerialPort.IsOpen)
     {
         if (sendType == SendTypes.Clipboard && message.Length > 0)
         {
             message = message.Replace('\n', ' ').Replace('\r', ' ');
             ActiveSerialPort.Write("CPB:" + index + ":" + message.Substring(0, Math.Min(10, message.Length)));
             Console.WriteLine("CPB:" + index + ":" + message.Substring(0, Math.Min(10, message.Length)));
         }
         else if (sendType == SendTypes.ClipboardPush)
         {
             message = message.Replace('\n', ' ').Replace('\r', ' ');
             ActiveSerialPort.Write("CPBP:" + index + ":" + message.Substring(0, Math.Min(20, message.Length)));
             Console.WriteLine("CPB:" + index + ":" + message.Substring(0, Math.Min(10, message.Length)));
         }
     }
 }