From ef861020f800840615911db372b2da45c2c69d0a Mon Sep 17 00:00:00 2001 From: Kevin Pope Date: Wed, 26 Feb 2014 09:22:42 -0800 Subject: [PATCH] Extensions to PrinterCommunication - added ComPort property and PulseRtsLow method --- PrinterCommunication.cs | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs index 4480a3874..ba9821d1c 100644 --- a/PrinterCommunication.cs +++ b/PrinterCommunication.cs @@ -1034,6 +1034,20 @@ namespace MatterHackers.MatterControl } } + public string ComPort + { + get + { + string comPort = null; + if (this.ActivePrinter != null) + { + comPort = this.ActivePrinter.ComPort; + + } + return comPort; + } + } + public int BaudRate { get @@ -1052,8 +1066,6 @@ namespace MatterHackers.MatterControl } return baudRate; } - - } private void ConnectToPrinter(Printer printerRecord) @@ -1469,6 +1481,36 @@ namespace MatterHackers.MatterControl } } + public void PulseRtsLow() + { + if (serialPort == null && this.ActivePrinter != null) + { + serialPort = new FrostedSerialPort(this.ActivePrinter.ComPort); + serialPort.BaudRate = this.BaudRate; + if (PrinterCommunication.Instance.DtrEnableOnConnect) + { + serialPort.DtrEnable = true; + } + + // Set the read/write timeouts + serialPort.ReadTimeout = 500; + serialPort.WriteTimeout = 500; + serialPort.Open(); + + serialPort.RtsEnable = true; + serialPort.RtsEnable = false; + try + { + Thread.Sleep(1); + } + catch + { + } + serialPort.RtsEnable = true; + serialPort.Close(); + } + } + public void Disable() { if (PrinterIsConnected)