private async void deviceEventsGet_Click_1(object sender, RoutedEventArgs e)
        {
            CustomDevice fx2Device = DeviceList.Current.GetSelectedDevice();

            bool[] switchStateArray = new bool[8];

            if (fx2Device == null)
            {
                rootPage.NotifyUser("Fx2 device not connected or accessible", NotifyType.ErrorMessage);
                return;
            }

            try
            {
                var output = new byte[1];

                await fx2Device.SendIOControlAsync(Fx2Driver.ReadSwitches,
                                                   null,
                                                   output.AsBuffer());

                switchStateArray = CreateSwitchStateArray(output);
            }
            catch (Exception exception)
            {
                rootPage.NotifyUser(exception.ToString(), NotifyType.ErrorMessage);
                return;
            }

            UpdateSwitchStateTable(switchStateArray);
        }
示例#2
0
        private async System.Threading.Tasks.Task <bool> FillInternalStream(ulong index)
        {
            bool result = false;
            //  ulong startIndexInCD = ((ulong)StartSector * CD_SECTOR_SIZE) + internalStream.Size - GetWAVHeaderBufferLen();
            //  ulong endIndexInCD = ((ulong)StartSector * CD_SECTOR_SIZE) + index - GetWAVHeaderBufferLen();
//            ulong startReadSector = startIndexInCD / CD_SECTOR_SIZE;
//            ulong endReadSector = (endIndexInCD / CD_SECTOR_SIZE) + 1;
            ulong startReadSector = (ulong)StartSector + ((internalStream.Size - GetWAVHeaderBufferLen()) / CD_RAW_SECTOR_SIZE);
            ulong endReadSector   = (ulong)StartSector + ((index - GetWAVHeaderBufferLen()) / CD_RAW_SECTOR_SIZE) + 1;

            if (endReadSector > (ulong)EndSector)
            {
                endReadSector = (ulong)EndSector;
            }
            if ((StartSector < EndSector) &&
                (startReadSector < endReadSector))
            {
                int   numberSector = 20;
                var   inputBuffer  = new byte[8 + 4 + 4];
                var   outputBuffer = new byte[CD_RAW_SECTOR_SIZE * numberSector];
                ulong k            = startReadSector;
                while (k < endReadSector)
                {
                    numberSector = (int)((((ulong)(k + (ulong)numberSector)) < endReadSector) ? 20 :endReadSector - k);
                    ulong  firstSector = k * CD_SECTOR_SIZE;
                    byte[] array       = BitConverter.GetBytes(firstSector);
                    for (int i = 0; i < array.Length; i++)
                    {
                        inputBuffer[i] = array[i];
                    }
                    byte[] intarray = BitConverter.GetBytes(numberSector);
                    for (int i = 0; i < intarray.Length; i++)
                    {
                        inputBuffer[8 + i] = intarray[i];
                    }
                    intarray = BitConverter.GetBytes((int)2);
                    for (int i = 0; i < intarray.Length; i++)
                    {
                        inputBuffer[12 + i] = intarray[i];
                    }
                    uint r = 0;;
                    r = await CDReaderDevice.SendIOControlAsync(
                        readRaw, inputBuffer.AsBuffer(), outputBuffer.AsBuffer());

                    if (r > 0)
                    {
                        uint len = await this.WriteAsync(outputBuffer.AsBuffer(0, (int)r));

                        if (len == r)
                        {
                            result = true;
                        }
                    }
                    k += (ulong)numberSector;
                }
            }
            return(result);
        }
示例#3
0
        private async void deviceEventsGet_Click(object sender, RoutedEventArgs e)
        {
            CustomDevice fx2Device = DeviceList.Current.GetSelectedDevice();

            bool[] switchStateArray = new bool[8];

            if (fx2Device == null)
            {
                rootPage.NotifyUser("Fx2 device not connected or accessible", NotifyType.ErrorMessage);
                return;
            }

            var button = (Button)sender;

            button.IsEnabled = false;

            var output = new byte[1];

            try
            {
                uint bytesRead = await fx2Device.SendIOControlAsync(Fx2Driver.ReadSwitches, null, output.AsBuffer());

                if (bytesRead == 0)
                {
                    rootPage.NotifyUser("Fx2 device returned 0 byte interrupt message.  Stopping", NotifyType.ErrorMessage);
                }
                else
                {
                    switchStateArray = CreateSwitchStateArray(output);
                    UpdateSwitchStateTable(switchStateArray);
                }
            }
            catch (Exception exception)
            {
                rootPage.NotifyUser(exception.ToString(), NotifyType.ErrorMessage);
            }
            button.IsEnabled = true;
        }
示例#4
0
        public async Task <int> GetRegisterAppCountAsync()
        {
            byte[] outputBuffer = new byte[2 * sizeof(int)];
            try
            {
                await _shadowDevice.SendIOControlAsync(IOCTLs.IOCTLShadowDriverGetRegisterdAppCount, null, outputBuffer.AsBuffer());
            }
            catch (NullReferenceException)
            {
                throw new ShadowFilterException(0xC0090040);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            var status = BitConverter.ToUInt32(outputBuffer, 0);

            if (status != 0)
            {
                HandleError(status);
            }

            var count = BitConverter.ToInt32(outputBuffer, sizeof(int));

            return(count);
        }