Beispiel #1
0
        //Send the configuration structure
        public bool setConfig(UInt32 CanID, Config_t config)
        {
            CAN.VCI_CAN_OBJ[] receive;

            byte[] txMsg = { (byte)CANCMD.CAN_CMD_SET_CONFIG };
            ctl.sendData(txMsg, CanID, false, true);

            ctl.sendData(StructTools.struct2byteArray <Config_t>(config), CanID, false, true);

            ctl.getCanFrames(out receive, 1);

            if (receive[0].Data[0] == (byte)CANCMD.CAN_CMD_SET_CONFIG)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        //Get the configuration structure from the master unit
        public Config_t getConfig(UInt32 CanID)
        {
            Config_t config = new Config_t();

            CAN.VCI_CAN_OBJ[] receive;

            byte[] txMsg = { (byte)CANCMD.CAN_CMD_GET_CONFIG };

            if (!ctl.sendData(txMsg, CanID, false, true))
            {
                return(config);
            }

            ctl.getCanFrames(out receive, (Marshal.SizeOf(typeof(Config_t)) - 1) / 8 + 1);

            byte[] buffer = new byte[Marshal.SizeOf(typeof(Config_t))];

            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] = receive[i / 8].Data[i % 8];
            }
            return(StructTools.byteArray2Struct <Config_t>(buffer));
        }
Beispiel #3
0
        public bool connect(UInt32 CanID)
        {
            config = getConfig(CanID);

            return(true);
        }