/// <summary> /// Initializes a new instance of the <see cref="ZWaveLib.ZWaveController"/> class. /// </summary> public ZWaveController() { serialPort = new SerialPortInput(); serialPort.MessageReceived += SerialPort_MessageReceived; serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; queuedMessages = new List<ZWaveMessage>(); queueManager = new Task(QueueManagerTask); queueManager.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="W800Rf32Lib.RfReceiver"/> class. /// </summary> public RfReceiver() { serialPort = new SerialPortInput(); serialPort.SetPort(portName, 4800); serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; serialPort.MessageReceived += SerialPort_MessageReceived; }
/// <summary> /// Initializes a new instance of the <see cref="ZWaveLib.ZWaveController"/> class. /// </summary> public ZWaveController() { // Setup Serial Port serialPort = new SerialPortInput(); serialPort.MessageReceived += SerialPort_MessageReceived; serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; // Setup Queue Manager Task queuedMessages = new List<ZWaveMessage>(); qmTokenSource = new CancellationTokenSource(); queueManager = Task.Factory.StartNew(() => QueueManagerTask(qmTokenSource.Token), qmTokenSource.Token); }
public ZWavePort() { serialPort = new SerialPortInput(); serialPort.Debug = true; serialPort.MessageReceived += ReceiveMessage; serialPort.ConnectedStateChanged += new SerialPortInput.ConnectedStateChangedEvent(serialport_ConnectedStateChanged); discoveryTimer = new Timer((object state) => { Discovery(); }); }
public ZWavePort() { serialPort = new SerialPortInput(); serialPort.MessageReceived += SerialPort_MessageReceived; serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; // TODO: discovery should be moved to Controller.cs discoveryTimer = new Timer((object state) => { Discovery(); }); }
public static void Main(string[] args) { // NOTE: To disable debug output uncomment the following two lines //LogManager.Configuration.LoggingRules.RemoveAt(0); //LogManager.Configuration.Reload(); serialPort = new SerialPortInput(); serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; serialPort.MessageReceived += SerialPort_MessageReceived; while (true) { Console.WriteLine("\nPlease enter serial to open (eg. \"COM7\" or \"/dev/ttyUSB0\" without double quotes),"); Console.WriteLine("or enter \"QUIT\" to exit.\n"); Console.Write("Port [{0}]: ", defaultPort); string port = Console.ReadLine(); if (String.IsNullOrWhiteSpace(port)) port = defaultPort; else defaultPort = port; // exit if the user enters "quit" if (port.Trim().ToLower().Equals("quit")) break; serialPort.SetPort(port, 115200); serialPort.Connect(); Console.WriteLine("Waiting for serial port connection on {0}.", port); while (!serialPort.IsConnected) { Console.Write("."); Thread.Sleep(1000); } // This is a test message (ZWave protocol message for getting the nodes stored in the Controller) var testMessage = new byte[] { 0x01, 0x03, 0x00, 0x02, 0xFE }; // Try sending some data if connected if (serialPort.IsConnected) { Console.WriteLine("\nConnected! Sending test message 5 times."); for (int s = 0; s < 5; s++) { Thread.Sleep(1000); Console.WriteLine("\nSEND [{0}]", (s + 1)); serialPort.SendMessage(testMessage); } } Console.WriteLine("\nTest sequence completed, now disconnecting."); serialPort.Disconnect(); } }
/// <summary> /// Initializes a new instance of the <see cref="ZWaveLib.ZWaveController"/> class. /// </summary> public ZWaveController() { string codeBase = GetType().Assembly.CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); configFolder = Path.GetDirectoryName(path); // Setup Serial Port serialPort = new SerialPortInput(); serialPort.MessageReceived += SerialPort_MessageReceived; serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; // Setup Queue Manager Task queuedMessages = new List<ZWaveMessage>(); qmTokenSource = new CancellationTokenSource(); queueManager = Task.Factory.StartNew(() => QueueManagerTask(qmTokenSource.Token), qmTokenSource.Token); }
/// <summary> /// Initializes a new instance of the <see cref="ZWaveLib.ZWaveController"/> class. /// </summary> public ZWaveController() { string codeBase = GetType().Assembly.CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); configFolder = Path.GetDirectoryName(path); // Setup Serial Port serialPort = new SerialPortInput(); serialPort.MessageReceived += SerialPort_MessageReceived; serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged; // Setup Queue Manager Task queuedMessages = new List<ZWaveMessage>(); queueManager = new Thread(QueueManagerTask); queueManager.Start(); }
public SerialPortHelper() { serialPort = new SerialPortInput(); }