Beispiel #1
0
        private async Task <byte[]> SendInitRequestAsync()
        {
            var msg = MessageGenerator.GenerateRequestMessage();

            _logger.Info($"Sending request message: {msg}");
            await _transport.WriteBytesAsync(msg);

            return(msg);
        }
        public async Task <bool> ReadAndParseAsync()
        {
            InitializeFields();

            if (_initialSync)
            {
                await SynchronizeAsync();
            }
            _hexDump.DumpBytes(HexDumpMode.BytesOut, Constants.SignOnMessage);
            await _reader.WriteBytesAsync(Constants.SignOnMessage);

            await ReadSignOnMessageAsync();

            var result = await ReadVendorMessageAsync();

            if (result)
            {
                if (UseShortReactionTime)
                {
                    Thread.Sleep(20);
                }
                else
                {
                    Thread.Sleep(200);
                }
                _hexDump.DumpBytes(HexDumpMode.BytesOut, Constants.AckMessage);
                await _reader.WriteBytesAsync(Constants.AckMessage);

                var ok = await ReadAckResponseMessageAsync();

                var result1 = await ReadObisMessageAsync();

                return(result1);
            }
            return(false);
        }