Ejemplo n.º 1
0
        private void btnSwitch_Click(object sender, EventArgs e)
        {
            List <string> lsDec   = txtOriginalData.Text.Split(' ').ToList();
            ushort        address = Convert.ToUInt16(lsDec[3]);

            //byte[] bytesaddress = BitConverter.GetBytes(address);
            if (address > 255)
            {
                lsDec[2] = ((byte)(address >> 8)).ToString();
                lsDec[3] = ((byte)(address)).ToString();
            }

            byte[] bytesCRC = BytesCheck.GetCRC16(TypeConvert.ByteStringToBytes(string.Join(" ", lsDec)), true);
            foreach (byte b in bytesCRC)
            {
                lsDec.Add(b.ToString());
            }

            txtSendData.Text = string.Join(" ", lsDec);
            Console.WriteLine(string.Join(" ", lsDec));
        }