예제 #1
0
 //设置时间
 public static byte[] Set_time(byte address)
 {
     byte[] outByte = new byte[12];
     outByte[0] = 0x21;
     outByte[1] = 0x58;
     outByte[2] = 0x44;
     outByte[3] = address;
     outByte[4] = 0xb0;
     outByte[5] = 0x01;
     outByte[6] = 0x03;
     outByte[7] = DataInfo.bytetoBCD(Convert.ToByte(DateTime.Now.Second));
     outByte[8] = DataInfo.bytetoBCD(Convert.ToByte(DateTime.Now.Minute));
     outByte[9] = DataInfo.bytetoBCD(Convert.ToByte(DateTime.Now.Hour));
     return(DataInfo.CRC16(outByte));
 }
예제 #2
0
        //设置日期
        public static byte[] Set_date(byte address)
        {
            byte[] outByte = new byte[12];
            outByte[0] = 0x21;
            outByte[1] = 0x58;
            outByte[2] = 0x44;
            outByte[3] = address;
            outByte[4] = 0xb0;
            outByte[5] = 0x02;
            outByte[6] = 0x03;
            outByte[7] = DataInfo.bytetoBCD(Convert.ToByte(DateTime.Now.Day));
            outByte[8] = DataInfo.bytetoBCD(Convert.ToByte(DateTime.Now.Month));
            outByte[9] = DataInfo.bytetoBCD(Convert.ToByte(DateTime.Now.Year % 100));

            return(DataInfo.CRC16(outByte));
        }