示例#1
0
        public static byte[] generatepacket(DataMsg msg, MainForm.logoInstructionDef[] logoCmd)
        {
            byte[] packet = new byte[HEADER_SIZE + (LOGO_INST_SIZE * logoCmd.Length)];

            int i = 0;
            packet[i++] = (byte)msg.m_cmdtype;
            packet[i++] = msg.m_indexMission;
            packet[i++] = msg.m_indexCmd;
            packet[i++] = (byte)logoCmd.Length; // instructionCount

            for (int instIndex = 0; instIndex < logoCmd.Length; instIndex++)
            {
                packet[i++] = logoCmd[instIndex].cmd;
                packet[i++] = Convert.ToByte(logoCmd[instIndex].do_fly);
                packet[i++] = Convert.ToByte(logoCmd[instIndex].use_param);
                packet[i++] = logoCmd[instIndex].subcmd;
                packet[i++] = Convert.ToByte(logoCmd[instIndex].arg >> 8);
                packet[i++] = Convert.ToByte(logoCmd[instIndex].arg & 0xFF);
            }
            return packet;
        }
示例#2
0
        static public byte[] generatepacket(DataMsg msg, MainForm.logoInstructionDef[] logoCmd)
        {
            byte[] packet = new byte[HEADER_SIZE + (LOGO_INST_SIZE * logoCmd.Length)];

            int i = 0;

            packet[i++] = (byte)msg.m_cmdtype;
            packet[i++] = msg.m_indexMission;
            packet[i++] = msg.m_indexCmd;
            packet[i++] = (byte)logoCmd.Length; // instructionCount

            for (int instIndex = 0; instIndex < logoCmd.Length; instIndex++)
            {
                packet[i++] = logoCmd[instIndex].cmd;
                packet[i++] = Convert.ToByte(logoCmd[instIndex].do_fly);
                packet[i++] = Convert.ToByte(logoCmd[instIndex].use_param);
                packet[i++] = logoCmd[instIndex].subcmd;
                packet[i++] = Convert.ToByte(logoCmd[instIndex].arg >> 8);
                packet[i++] = Convert.ToByte(logoCmd[instIndex].arg & 0xFF);
            }
            return(packet);
        }
示例#3
0
        private byte[] generateDataMsgPacket()
        {
            // only 1 command is supported right now by this
            // app, but you can send up to logoInstructionDef[x]
            logoInstructionDef[] inst = new logoInstructionDef[1];

            inst[0] = new logoInstructionDef(CreateMsgData());

            DataMsg dataMsg = new DataMsg(DataMsgCmd_comboBox.SelectedIndex,
                (byte)DataMsgType_IndexMission_numericUpDown.Value,
                (byte)DataMsgType_IndexCmd_numericUpDown.Value);

            return DataMsg.generatepacket(dataMsg, inst);
        }