Пример #1
0
 /// <summary>
 /// Gets the field.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="starting">The starting.</param>
 /// <param name="ending">The ending.</param>
 /// <param name="index">The index.</param>
 /// <param name="count">The count.</param>
 /// <returns></returns>
 public static string GetField(List<byte> list, string starting, string ending, int index, int count)
 {
     Encode enc = new Encode();
     enc.ToBinary(starting);
     int start = IndexOfBytes(list.ToArray(), enc.Encoded, index, count);
     if (start == -1)
     {
         return null;
     }
     start = start + enc.Encoded.Length;
     int end = -1;
     enc.ToBinary(ending);
     end = IndexOfBytes(list.ToArray(), enc.Encoded, start + 1, list.Count - start);
     if (end == -1)
     {
         return null;
     }
     List<byte> field = new List<byte>();
     for (int idx = start; idx < end; idx++)
     {
         field.Add(list[idx]);
     }
     Decode dec = new Decode();
     dec.ToReadable(field.ToArray());
     return dec.Decoded;
 }
Пример #2
0
 /// <summary>
 /// To compute checksum.
 /// </summary>
 /// <param name="byteArray">The byte array.</param>
 public static void ToCompute(byte[] byteArray)
 {
     if (_table == null)
     {
         Initialize();
     }
     ushort crc = ComputeChecksum(byteArray, 0, byteArray.Length);
     _binaryValue = ConvertCRC16ToFourBytes(crc);
     Decode trn = new Decode();
     trn.ToReadable(BinaryValue);
     _readableValue = trn.Decoded;
 }
Пример #3
0
 private void Omaha()
 {
     StringBuilder sb = new StringBuilder();
     int index = -1;
     bool found = false;
     List<byte> badStart = new List<byte>();
     foreach (byte theByte in _inputs.ByteList)
     {
         index++;
         badStart.Add(theByte);
         if (theByte == _firstGood && index > 0)
         {
             badStart.RemoveAt(index);
             found = true;
             break;
         }
     }
     if (found)
     {
         Decode dec = new Decode();
         dec.ToReadable(badStart.ToArray());
         sb.Length = 0;
         sb.AppendFormat("[{0}] *** Warning *** Bad Staring characters, size = {1}, [{2}]", _inputs.Swarm, index, dec.Decoded);
         Events.DoLog(this, sb.ToString());
         _inputs.ByteList.RemoveRange(0, index);
     }
 }
Пример #4
0
 private void Hike()
 {
     StringBuilder sb = new StringBuilder();
     int start1 = Search.GetIndex(_panelLibrary.RawStream, "<sy>", "<et>"); // look for standard start
     int start2 = Search.GetIndex(_panelLibrary.RawStream, "<sh>", "<cr>"); // look for kermit start
     int length = Search.GetLength(_panelLibrary.RawStream, "<sh>", "<cr>");
     if (length != 2)
     {
         start2 = 0;
     }
     if (start1 == 0 && start2 == 0)
     {
         return;
     }
     else
     {
         int lowest = 0;
         if (start1 > 0)
         {
             lowest = start1;
         }
         if (start2 < start1 && start2 > 0)
         {
             lowest = start2;
         }
         if (lowest > 0)
         {
             Decode dec = new Decode();
             dec.ToReadable(_panelLibrary.RawStream.ToArray(), 0, lowest);
             sb.Length = 0;
             sb.AppendFormat("[{0}] *** Warning *** Bad Staring character(s), size = {1}, [{2}]", _panelLibrary.Snap, lowest, dec.Decoded);
             Events.LoadLog(lowest, sb.ToString());
             _panelLibrary.RawStream.RemoveRange(0, lowest);
         }
     }
 }
Пример #5
0
 /// <summary>
 /// To compute checksum.
 /// </summary>
 /// <param name="packet">The packet.</param>
 public static void ToCompute(string packet)
 {
     if (_table == null)
     {
         Initialize();
     }
     Encode enc = new Encode();
     enc.ToBinary(packet);
     ushort crc = ComputeChecksum(enc.Encoded, 0, enc.Encoded.Length);
     _binaryValue = ConvertCRC16ToFourBytes(crc);
     Decode trn = new Decode();
     trn.ToReadable(BinaryValue);
     _readableValue = trn.Decoded;
 }
Пример #6
0
 private void Hike()
 {
     StringBuilder sb = new StringBuilder();
     int start = Search.GetIndex(_inputs.RawStream, "<sy>", "<et>");
     if (start > 0)
     {
         Decode dec = new Decode();
         dec.ToReadable(_inputs.RawStream.ToArray(), 0, start);
         sb.Length = 0;
         sb.AppendFormat("[{0}] *** Warning *** Bad Staring character(s), size = {1}, [{2}]", _inputs.Snap, start, dec.Decoded);
         Events.LoadLog(start, sb.ToString());
         _inputs.RawStream.RemoveRange(0, start);
     }
 }