Exemple #1
0
        /// <summary>
        /// Writes a modbus request to a transport.
        /// </summary>
        /// <param name="request">An instance of a modbus request to write</param>
        protected override void WriteRequest(IModbusClientRequest request)
        {
            var tcpModbusRequest = (TcpModbusClientRequest)request;

            tcpModbusRequest.TransactionId = this.GetNewTransactionId();

            var frameToWrite = request.BuildRequestFrame();

            this._transport.Write(frameToWrite, 0, frameToWrite.Length);
        }
Exemple #2
0
        private IEnumerable <Task> OnWriteRequestAsync(IModbusClientRequest request)
        {
            var tcpModbusRequest = (TcpModbusClientRequest)request;

            tcpModbusRequest.TransactionId = this.GetNewTransactionId();
            var frameToWrite = request.BuildRequestFrame();
            var writeTask    = this._transport.WriteAsync(frameToWrite, 0, frameToWrite.Length);

            yield return(writeTask);
        }