public virtual bool SerialPortIsAvailable(string serialPortName, PrinterSettings settings) { try { return(FrostedSerialPort.GetPortNames().Any(portName => string.Compare(portName, serialPortName, true) == 0)); } catch { return(false); } }
public static string GetDefaultPortName() { string[] ports = FrostedSerialPort.GetPortNames(); if (ports.Length > 0) { return(ports[0]); } else { int p = (int)Environment.OSVersion.Platform; if (p == 4 || p == 128 || p == 6) { return("ttyS0"); // Default for Unix } else { return("COM1"); // Default for Windows } } }