Пример #1
0
        internal byte[] ReadRequestResponse()
        {
            // read message frame, removing frame start ':'
            string frameHex = StreamResourceUtility.ReadLine(StreamResource).Substring(1);

            // convert hex to bytes
            byte[] frame = ModbusUtility.HexToBytes(frameHex);
            _logger.InfoFormat("RX: {0}", frame.Join(", "));

            if (frame.Length < 3)
            {
                throw new IOException("Premature end of stream, message truncated.");
            }

            return(frame);
        }
        internal byte[] ReadRequestResponse()
        {
            // read message frame, removing frame start ':'
            string frameHex = StreamResourceUtility.ReadLine(StreamResource).Substring(1);

            // convert hex to bytes
            byte[] frame = ModbusUtility.HexToBytes(frameHex);
#if ModBusDebug
            Debug.WriteLine($"RX: {string.Join(", ", frame)}");
#endif
            if (frame.Length < 3)
            {
                throw new IOException("Premature end of stream, message truncated.");
            }

            return(frame);
        }