예제 #1
0
 public void ReadToBuffer()
 {
     ReadMemory.Clear();
     ReadMemory = ReadBuffer;
     ReadBuffer.Clear();
     string[] cleanedInput = Console.ReadLine().ToLower().Trim().Split(Delimiters, StringSplitOptions.RemoveEmptyEntries);
     foreach (string x in cleanedInput)
     {
         ReadBuffer.Add(x);
     }
 }
예제 #2
0
        /// <summary>
        /// Writes the sentence to client.
        /// </summary>
        /// <param name="sentence">The sentence.</param>
        protected void WriteSentenceToClient(NmeaSentence sentence)
        {
            // Get a byte array of the sentence
            byte[] sentenceBytes = sentence.ToByteArray();

            /* Some customers were found to make an emulator, but then not actually read from it.
             * To prevent huge buffers, we will only write a sentence if the buffer can handle it.
             * Otherwise, we'll ignore it completely.
             */
            if (ReadBuffer.Count + sentenceBytes.Length + 2 > ReadBuffer.Capacity)
            {
                return;
            }

            // Add the bytes
            ReadBuffer.AddRange(sentenceBytes);

            // Add a CrLf
            ReadBuffer.Add(13);
            ReadBuffer.Add(10);
        }