public void Receive(object sender, SerialDataReceivedEventArgs e)
        {
            var dataReceived = _serialPort.ReadTo("\r");

            logger.Info($"{MessageCount}: {dataReceived}");

            var parsedLine = dataReceived.Split(' ');

            if (!_waitingForMemoryDump)
            {
                return;
            }

            if (parsedLine.Length == 7)
            {
                var timingValue = new TimingValue {
                    Time = parsedLine[3],
                    MeasurementNumber = int.Parse(parsedLine[1]),
                    InternalId        = _internalIdCounter++,
                };

                _memoryDump.Add(timingValue);
            }
            else if (dataReceived.Contains("ALGE-TIMING") || dataReceived.Contains("TIMY V 0974"))
            {
                _memoryDumpRecieved   = true;
                _waitingForMemoryDump = false;
            }
        }
Beispiel #2
0
        private void timyUsb_LineReceived(object sender, DataReceivedEventArgs e)
        {
            logger.Info($"Device {e.Device.Id} Bytes: {e.Data}");

            var parsedLine = e.Data.Split(' ');

            if (waitingForMemoryDump)
            {
                TimingValue timingValue;

                if (parsedLine[0].StartsWith("c"))
                {
                    timingValue = new TimingValue {
                        MeasurementNumber = TryParseMeasurementNumber(parsedLine[0]),
                        Time = parsedLine[2],
                    };
                }
                else
                {
                    timingValue = new TimingValue {
                        MeasurementNumber = TryParseMeasurementNumber(parsedLine[1]),
                        Time = parsedLine[3],
                    };
                }

                memoryDump.Add(timingValue);
            }
            else if (e.Data.Contains("ALGE-TIMING") || e.Data.Contains("TIMY V 0974"))
            {
                memoryDumpRecieved   = true;
                waitingForMemoryDump = false;
            }

            if (e.Data.StartsWith("PROG: "))
            {
                logger.Debug(e.Data);
            }
        }