IOException - SetFeature failed


#1

Hi, what does this error mean? Here is my code:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim BMP As New Drawing.Bitmap(1, 1)
        Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
        GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), New Drawing.Point(0, 0), BMP.Size)
        Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
        Dim device2 = BlinkStick.FindAll
        For Each device In device2
            device.SetMode(2)
            device.OpenDevice()
            For k = 0 To 7
                Dim j As Byte = k
                device.SetColor(0, j, RgbColor.FromRgb(Pixel.R, Pixel.G, Pixel.B))
            Next
        Next

    End Sub

Thanks


#2

You are sending the colors too fast. Add a delay of about 20ms after each SetColor function call.

Also, the correct way is to open the device first and then set the mode:

device.OpenDevice()
device.SetMode(2)

#3

I’m getting the same issue. I’ve put in the delay of 20ms but after some time the blink stick just crashes with this error.

I understand this might happen when debugging and stopping the program abnormally but in my case it is running outside debugger.

I’d like to use this in a production setting but I’m finding the stability a concern.


#4

Can you post your code sample for a quick review?


#5

Cool thanks. A second pair of eyes is helpful. Really want to go live with this :smile:

Here is where I’m getting crashes.

    private void Caution(bool firstTime)
    {
        using (new BlinkStickMutex(2000))
        {
            if (!firstTime)
            {
                if (WaitorQuit(20))
                {
                    return;
                }
                _device.Pulse("darkorange");
                if (WaitorQuit(20))
                {
                    return;
                }
                _device.Morph("darkorange");
                return;
            }

            if (WaitorQuit(20))
            {
                return;
            }

            _device.Morph("darkorange");

            if (WaitorQuit(20))
            {
                return;
            }

            for (int i = 0; i < Properties.Settings.Default.BlinkLoop; i++)
            {
                _device.Pulse("darkorange");
                if (WaitorQuit(20))
                {
                    return;
                }
            }

            _device.Morph("darkorange");

            WaitorQuit(20);                
        }
    }