Exemple #1
0
        private void WritePortCommand(byte code, byte[] data)
        {
            _lastCommandStatus = EltraCommandStatus.Unknown;
            _lastErrorCode     = EltraErrorCodes.None;
            _lastData          = null;

            List <byte> command = new List <byte> {
                0x12, //WUP
                0x02, //STX
                0x42, //DEST
                code  //CMD
            };

            if (data != null)
            {
                command.AddRange(data); //DATA
            }
            command.Add(0x03);          //ETX

            Lrc8 lrc = Lrc8.GetEltra();

            lrc.Append(command.ToArray());
            command.AddRange(lrc.DigestAsAscii30); //LRC

            command.Add(0x04);                     //EOT

            _serial.Write(command.ToArray(), 0, command.Count);
        }
Exemple #2
0
        public void Lrc8_Eltra()
        {
            string expected  = "1A";
            Lrc8   actualCrc = Lrc8.GetEltra();

            actualCrc.Append("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", true);
            string actual = actualCrc.Digest.ToString("X2");

            Assert.AreEqual(expected, actual);
        }