private void SendCommandInternal(SlaveDevice device, byte command, byte[] data = null) { SendCommandInternal(new Message(device.ID, ID, command) { Data = data }); }
public SlaveDevice AddSlaveDevice(byte id) { var slave = new SlaveDevice(id, this); SlaveDevices.Add(slave); return(slave); }
/// <summary> /// Executes specified command by performing both operations send and receive which locked at one critical section /// </summary> /// <param name="device"></param> /// <param name="command"></param> /// <param name="timeout">Timeout for response (default: MasterDevice.DefaultTimeout)</param> /// <param name="data"></param> /// <returns></returns> /// <exception cref="ThreadInterruptedException"></exception> public Message ExecCommand(SlaveDevice device, byte command, int timeout = DefaultTimeout, byte[] data = null) { Message result; _logger.Trace("thread is ready to enter the critical section _locker"); lock (_locker) { _logger.Trace("thread entered the critical section _locker"); SendCommandInternal(device, command, data); _logger.Trace("command is sent, receiving _locker"); result = ReceiveMessageInternal(timeout); _logger.Trace("thread is ready to exit from the critical section _locker"); } _logger.Trace("thread exited from the critical section _locker"); return(result); }