Beispiel #1
0
        public static byte[] GetSendMulty(byte[] mac, byte[] box_number, byte command = 0x03)
        {
            byte[] byte_open = new byte[12] {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };
            int bytelength = box_number.Length > 12 ? 12 : box_number.Length;

            byte[] bs = BitConverter.GetBytes(0x1234);

            try { Console.WriteLine(bs[0].ToString("X2") + " " + bs[1].ToString("X2")); }
            catch (Exception) {; }

            for (int i = 0; i < bytelength; i++)
            {
                int boxNo = (int)box_number[i];
                if (boxNo > 0)
                {
                    byte_open[i] = 0x01;
                }
            }

            byte[] r_byte = new byte[50];
            try
            {
                Box_Date box_date     = new Box_Date();
                byte[]   date_control = new byte[51];
                date_control[0] = box_date.Date_flg[0];                    //
                Array.Copy(box_date.Date_start, 0, date_control, 1, 2);    //
                date_control[3] = box_date.Date_length[0];                 //
                Array.Copy(box_date.Date_datetime, 0, date_control, 4, 6); ////
                date_control[10] = command;                                //指令码
                Array.Copy(mac, 0, date_control, 11, 15);                  //
                Array.Copy(box_number, 0, date_control, 26, 12);
                byte[] rcr = new byte[46];
                Array.Copy(date_control, 3, rcr, 0, 46);
                string aa  = ByteToHexString(date_control);
                string aas = ByteToHexString(rcr);
                date_control[49] = Converts.GetCRCSUM(rcr)[0]; //old
                date_control[50] = Converts.GetCRCSUM(rcr)[1]; //old
                Array.Copy(date_control, 1, r_byte, 0, 50);
            }
            catch (Exception) {; }


            return(r_byte);
        }
Beispiel #2
0
        public static byte[] GetSendMulty(byte[] mac, byte[] box_number, byte[] order_no, byte command = 0x01)
        {
            byte[] byte_open = new byte[12] {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };
            int bytelength = box_number.Length > 12 ? 12 : box_number.Length;

            byte[] bs = BitConverter.GetBytes(0x1234);

            try { Console.WriteLine(bs[0].ToString("X2") + " " + bs[1].ToString("X2")); }
            catch (Exception) {; }

            for (int i = 0; i < bytelength; i++)
            {
                int boxNo = (int)box_number[i];
                if (boxNo > 0)
                {
                    byte_open[i] = 0x01;
                }
            }
            byte[] date_control = new byte[50];
            try
            {
                Client_Date box_date = new Client_Date();
                Array.Copy(box_date.Date_start, 0, date_control, 0, 2);                                  //EF03
                date_control[2] = 0x50;                                                                  //
                date_control[3] = command;                                                               //指令码
                Array.Copy(mac, 0, date_control, 4, 15);                                                 //
                Array.Copy(box_number, 0, date_control, 19, 12);
                Array.Copy(order_no, 0, date_control, 31, order_no.Count());                             ////
                Array.Copy(Encoding.UTF8.GetBytes(order_no.Count().ToString()), 0, date_control, 47, 1); ////
                byte[] rcr = new byte[46];
                Array.Copy(date_control, 2, rcr, 0, 46);
                date_control[48] = Converts.GetCRCSUM(rcr)[0]; //old
                date_control[49] = Converts.GetCRCSUM(rcr)[1]; //old
            }
            catch (Exception ex) {; }


            return(date_control);
        }