Exemplo n.º 1
0
        private byte getData <T>(T str, byte address)
        {
            byte[] buffer;

            buffer = StructTools.struct2byteArray <T>(str);
            return(buffer[address]);
        }
Exemplo n.º 2
0
        //Get the calibration structure from the master unit
        public bool setCalibration(UInt32 CanID, SlaveConfig sc)
        {
            UInt32 retval;

            CAN.VCI_CAN_OBJ[] send = ctl.allocateCanFrameBuffer(1 + Marshal.SizeOf(typeof(SlaveConfig)) / 8);
            CAN.VCI_CAN_OBJ[] receive;

            send[0].ID         = CanID;
            send[0].TimeFlag   = 0;
            send[0].SendType   = 0;
            send[0].RemoteFlag = 0;
            send[0].ExternFlag = 1;
            send[0].DataLen    = 1;

            send[0].Data[0] = (byte)CANCMD.CAN_CMD_WRITE_CAL;

            retval = CAN.VCI_Transmit(CAN.DEV_USBCAN2, 0, 0, send, 1);
            if (retval != CAN.STATUS_OK)
            {
                return(false);
            }

            ctl.sendData(StructTools.struct2byteArray <SlaveConfig>(sc), CanID, false, true);

            ctl.getCanFrames(out receive, 1);

            if (receive[0].Data[0] == (byte)CANCMD.CAN_CMD_WRITE_CAL)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
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);
            }
        }