/// <summary> /// Constructor /// </summary> /// <param name="config">Configuration structure</param> public ModbusLinkRtu(ModbusConfiguration config) { // Init serial port driver PHY = new ModbusSerialPort(config); // Init link layer thread LinkThread = new Thread(ModbusRtuLinkTask); // Configure frame timing and set handler ConfigureTiming(config.BaudRate); FramingTimer.OnTimeout += FramingTimeoutHandler; }
/// <summary> /// Constructor /// </summary> /// <param name="config">Configuration structure</param> public ModbusLinkAscii(ModbusConfiguration config) { // Init serial port driver PHY = new ModbusSerialPort(config); // Init link layer thread LinkThread = new Thread(ModbusAsciiLinkTask) { Name = "Modbus Link Layer Thread", Priority = ThreadPriority.Normal }; // Configure timeout timer TimeoutCounter.Interval = 1000; TimeoutCounter.AutoReset = false; TimeoutCounter.Elapsed += TimeoutHandler; }