예제 #1
0
        /// <summary>
        /// Sends a request to addressed slave. Returns read and converted to string answer.
        /// </summary>
        /// <param name="messageFrame">A frame containing an address, a function code and a message to send.</param>
        /// <returns></returns>
        public MessageFrame SendRequest(MessageFrame messageFrame)
        {
            SendMessage(messageFrame);

            ushort[] rawResponse = _master.ReadHoldingRegisters((byte)messageFrame.TargetSlaveAddress,
                                                                (ushort)HoldingRegisterStartAddress, 123 * 2); //Read all available registers.

            var response = new MessageFrame();

            response.ReadMessageFromShorts(rawResponse);

            return(response);
        }