xrigau / androidthings-ws2801-driver

Android Things driver for the WS2801 RGB LED strip (includes demo app)
16 stars 3 forks source link

java.io.IOException: Unable to open SPI device in bus port SPI0.0 #6

Open kevindesai777 opened 7 years ago

kevindesai777 commented 7 years ago
java.io.IOException: Unable to open SPI device in bus port SPI0.0
01-01 00:01:05.685 1576-1576/com.app.lightsdemo W/System.err:     at com.xrigau.driver.ws2801.Ws2801.create(Ws2801.java:79)
01-01 00:01:05.686 1576-1576/com.app.lightsdemo W/System.err:     at com.app.lightsdemo.MainActivity.onCreate(MainActivity.java:46)
01-01 00:01:05.687 1576-1576/com.app.lightsdemo W/System.err:     at android.app.Activity.performCreate(Activity.java:6975)
01-01 00:01:05.688 1576-1576/com.app.lightsdemo W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
01-01 00:01:05.689 1576-1576/com.app.lightsdemo W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
01-01 00:01:05.689 1576-1576/com.app.lightsdemo W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
01-01 00:01:05.690 1576-1576/com.app.lightsdemo W/System.err:     at android.app.ActivityThread.-wrap11(Unknown Source:0)
01-01 00:01:05.691 1576-1576/com.app.lightsdemo W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
01-01 00:01:05.691 1576-1576/com.app.lightsdemo W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
01-01 00:01:05.692 1576-1576/com.app.lightsdemo W/System.err:     at android.os.Looper.loop(Looper.java:164)
01-01 00:01:05.693 1576-1576/com.app.lightsdemo W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6541)
01-01 00:01:05.693 1576-1576/com.app.lightsdemo W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
01-01 00:01:05.694 1576-1576/com.app.lightsdemo W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
01-01 00:01:05.694 1576-1576/com.app.lightsdemo W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
01-01 00:01:05.696 1576-1576/com.app.lightsdemo W/System.err: Caused by: com.google.android.things.pio.PioException: android.os.ServiceSpecificException: SPI0.0 driver failure (code 5)
01-01 00:01:05.698 1576-1576/com.app.lightsdemo W/System.err:     at com.google.android.things.pio.SpiDeviceImpl.<init>(SpiDeviceImpl.java:41)
01-01 00:01:05.699 1576-1576/com.app.lightsdemo W/System.err:     at com.google.android.things.pio.PeripheralManagerService.openSpiDevice(PeripheralManagerService.java:216)
01-01 00:01:05.700 1576-1576/com.app.lightsdemo W/System.err:     at com.xrigau.driver.ws2801.Ws2801.create(Ws2801.java:77)
01-01 00:01:05.700 1576-1576/com.app.lightsdemo W/System.err:   ... 13 more
01-01 00:01:05.702 1576-1576/com.app.lightsdemo W/System.err: Caused by: android.os.ServiceSpecificException: SPI0.0 driver failure (code 5)
01-01 00:01:05.703 1576-1576/com.app.lightsdemo W/System.err:     at android.os.Parcel.readException(Parcel.java:1956)
01-01 00:01:05.704 1576-1576/com.app.lightsdemo W/System.err:     at android.os.Parcel.readException(Parcel.java:1888)
01-01 00:01:05.705 1576-1576/com.app.lightsdemo W/System.err:     at com.google.android.things.pio.IPeripheralManagerClient$Stub$Proxy.OpenSpiDevice(IPeripheralManagerClient.java:1220)
01-01 00:01:05.706 1576-1576/com.app.lightsdemo W/System.err:     at com.google.android.things.pio.SpiDeviceImpl.<init>(SpiDeviceImpl.java:39)

I am using https://www.adafruit.com/product/738, I have reversed the direction since they denote opposite direction. (Tried it with normal direction also.) I have not connected external power, so may be that is the issue? I am running the latest dev preview, 5.1.

Edit: I updated to 0.4.1 and do not see the error anymore, however the lights still do not light up as I have configured them.

int[] colorArr = new int[5];
Arrays.fill(colorArr, Color.RED);
try{
mLedstrip = Ws2801.create(BoardDefaults.getSPIPort(), Ws2801.Mode.RGB, Ws2801.Direction.REVERSED);
mLedstrip.write(colorArr);
Log.d(TAG, "Think it works");
        }
        catch (IOException e){
            e.printStackTrace();
            Log.e("Error: ", e.toString());
        }

Can it be due to the limited power which the LED gets from the Board directly? I have another set of lights similar to these https://www.amazon.com/Addressable-Waterproof-Connectors-Included-Attached/dp/B008KEO540/ref=sr_1_9?ie=UTF8&qid=1509684148&sr=8-9&keywords=ws2801, and they work just fine.

xrigau commented 6 years ago

hey @kevindesai777 ! sorry I've been AFK for a few days

as you said it could be due to limited power, are you able to try it with an external power supply for the LEDs? if you don't, perhaps you could remove the last LED from the strand and plug the LED directly to the Android Things board, if it does work then it is most likely a problem with the power, otherwise it might be something else (wiring, slightly differences in the protocol, configuration issue, etc)