Example #1
0
 private void OnDataRead(GodSerialPort port, byte[] data)
 {
     try
     {
         string code = Encoding.ASCII.GetString(data);
         if (code.Length > 10)
         {
             OnScanCoded?.Invoke(code);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex, "扫描枪接收数据时异常。");
     }
 }
Example #2
0
        private void OnDataRead(GodSerialPort port, byte[] data)
        {
            string code = Encoding.ASCII.GetString(data);

            if (code.Length > 10)
            {
                if (codeRegex.IsMatch(code))
                {
                    OnScanCoded?.Invoke(code, EnumCodeType.PartCode);
                }
                else
                {
                    OnScanCoded?.Invoke(code, EnumCodeType.EngineCode);
                }
                _logger.Info($"接收到扫描枪数据:{code}");
            }
        }