Exemple #1
0
        public void SetInterface(CANInterface can)
        {
            if (can == null)
            {
                return;
            }
            byte *address = stackalloc byte[can.NativeId.Length + 1];

            Encoding.ASCII.GetBytes(can.NativeId, new Span <byte>(address, can.NativeId.Length + 1));
            address[can.NativeId.Length] = 0;
            FRC_CAN_Reader_Native_SetDevice(handle, address);
        }
Exemple #2
0
        public CANInterface[] GetInterfaces()
        {
            int length  = 0;
            var devices = FRC_CAN_Reader_Native_EnumerateDevices(&length);

            var ret = new CANInterface[length];

            for (int i = 0; i < length; i++)
            {
                ret[i] = new CANInterface
                {
                    Name     = Marshal.PtrToStringAnsi((IntPtr)devices[i].name),
                    NativeId = Marshal.PtrToStringAnsi((IntPtr)devices[i].deviceId)
                };
            }

            FRC_CAN_Reader_Native_FreeDevices(devices, length);

            return(ret);
        }