Ejemplo n.º 1
0
        private void Get_ComRecData()
        {
            int len = Read(tx_tmp);

            if (len <= 0)
            {
                return;
            }
            for (int i = 0; i < len; i++)
            {
                if (tx_tmp[i] != 0)
                {
                    tx_buf[tx_buf_index++] = tx_tmp[i];
                    if (tx_tmp[i] == (byte)'\n' || tx_buf_index >= tx_buf_limit)
                    {
                        int    dsp_len = tx_buf_index - 1;
                        byte[] dsp     = new byte[dsp_len];
                        for (int j = 0; j < dsp_len; j++)
                        {
                            dsp[j] = tx_buf[j];
                        }
                        string info = StrFormat.Ascii_ToString(dsp);
                        info = info.Trim();
                        list_com_str.Add(info);
                        tx_buf_index = 0;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void WriteString(string str)
 {
     if (port.IsOpen)
     {
         byte[] info = StrFormat.String_ToAscii(str);
         byte[] send = new byte[info.Length + 1];
         Array.Copy(info, send, info.Length);
         send[info.Length] = (byte)'\n';
         Write(send);
     }
 }
Ejemplo n.º 3
0
 public static System.DateTime GetSystemTime(string[] sArray, int index)
 {
     System.DateTime time = new DateTime(
         StrFormat.Ascii16to10(sArray[index + 3]) + 2000,
         StrFormat.Ascii16to10(sArray[index + 4]),
         StrFormat.Ascii16to10(sArray[index + 5]),
         StrFormat.Ascii16to10(sArray[index + 0]),
         StrFormat.Ascii16to10(sArray[index + 1]),
         StrFormat.Ascii16to10(sArray[index + 2]));
     return(time);
 }
Ejemplo n.º 4
0
 public static byte[] GetCanData(string[] arr, int len)
 {
     if (arr.Length >= 3 + len)
     {
         byte[] data = new byte[len];
         for (int i = 0; i < len; i++)
         {
             data[i] = (byte)StrFormat.AsciiHexToInt(arr[3 + i].Trim());
         }
         return(data);
     }
     return(null);
 }
Ejemplo n.º 5
0
        private Can_Data getRxData(string info)
        {
            Can_Data tmp = can_tmp;

            string[] arr = info.Split(',');
            tmp.id     = StrFormat.AsciiHexToInt(arr[0]);
            tmp.period = StrFormat.AsciiHexToULong(arr[1]);
            tmp.len    = StrFormat.AsciiHexToInt(arr[2]);
            for (int i = 0; i < tmp.len; i++)
            {
                tmp.data[i] = (byte)StrFormat.AsciiHexToInt(arr[3 + i]);
            }
            return(tmp);
        }