Esempio n. 1
0
        public static ParsingParameter ParsingContent(byte[] by)
        {
            ParsingParameter parameter = new ParsingParameter();

            parameter.FunctionAddress = by[1];
            parameter.DeviceAddress   = (byte)HexadecimalConversion.HexToInt(by[2], by[3]);
            parameter.Command         = (byte)HexadecimalConversion.HexToInt(by[4], by[5]);
            byte[] newby = new byte[by.Length - 9];
            if (newby.Length > 0)
            {
                Array.Copy(by, 6, newby, 0, newby.Length);
            }
            parameter.DataContent = newby;
            return(parameter);
        }
Esempio n. 2
0
 public static void SerialPortDataReceived(int port)
 {
     try
     {
         Thread.Sleep(10);
         byte[] by = sp.Read(sp.GetIqueue);
         if (by == null)
         {
             return;
         }
         List <byte[]> bylist = _dataValidation.Validation(by);
         foreach (byte[] item in bylist)
         {
             ParsingParameter param = DataParsing.ParsingContent(item);
             OnDataReceived(param);
         }
     }
     catch (Exception ex)
     {
         CustomExceptionHandler.GetExceptionMessage(ex);
         //MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 3
0
 private static void OnDataReceived(ParsingParameter param)
 {
     DataReceived?.Invoke(param);
 }