B4A Library IOIO board library

kolbe

Active Member
Licensed User
Longtime User
Is it related to this bug fixed in 3.26?

I think the fix is in the Firmware and not the IOIOlib but I could be wrong. This is my only guess. I've used SPI but never TWI so I have nothing to test your code with.
 

headingwest

Member
Licensed User
Longtime User
More IOIO TWI issues

I got the IOIO talking I2C / TWI with my picaxe. When I put it into a loop to get continuous readings (5 per second) the application froze after a short while, maybe 4 or 5 seconds.

Resetting the Picaxe chip didn't fix the problem, so I suspected the IOIO.

I changed my function call from TWI.WriteRead to TWI.WriteReadAsync but now I get a strange error when I test the return value. I get "Java.Lang.NoSuchFieldException: ready_" on the line that reads if TWI.Status(0) = true.

See code:

B4X:
Sub ControlLoop_Tick
   NotificationTool
   
   If TWI.IsInitialized Then
      If  bTWIstatus = 1 Then
         If TWI.Status(0) = True Then      'HERE IS THE CRASH - Java.Lang.NoSuchFieldException: ready_
            If TWI.Status(1) = True Then
               lblLeft.Text = grd1(0) & " R " & grd1(1)
               lblright.Text = grd1(2) & " L " & grd1(3)
               GetDistanceAsync
            End If
         End If      
      Else
         GetDistanceAsync
      End If
   End If
End Sub

HELP!
 

kolbe

Active Member
Licensed User
Longtime User
I don't see anything obviously lacking in the library code. I suspect some kind of a race condition. Try less samples per second and see if the exception goes away. There is a wait involved with the twi.status call, it should wait for the writereadasync to finish. Because this is all running on the main thread maybe there are gui events that are keeping the twi code from completing. Are you updating things on the activity? You could also try writing the data to an array and periodically refreshing the screen, as apposed to updating the screen 5 times a second.

Could I get a traceback from the logs? Are you using firmware 3.26?


 

kolbe

Active Member
Licensed User
Longtime User
@headingwest

Another thought. With your TWI.WriteRead version, see how much time it takes on average to complete the call. Since it is a blocking call, get a time stamp before and after and subtract the difference. This will give you an idea of the max samples per second possible. It was probably freezing because one call wasn't done, blocked, meanwhile others are being scheduled, the app is then non responsive because all it is doing is dealing with all the backed up calls.

I checked this lag for a project I was doing and it averaged around 50ms for the simplest of calls, digitalout hardwired to a digitalin. With i2c I wouldn't be surprised if it was greater than the 200ms you are expecting.
 

kolbe

Active Member
Licensed User
Longtime User
Multiple IOIOs

I've done some testing with two IOIOs. It turns out that with the current library v1.7, you can already connect two, one by BT the other by USB. OK, so that isn't what you asked but its good news. Be sure to use the ioio.connect method to connect the IOIOs.

How can I connect the IOIO to a specific BlueTooth MAC address?

I have multiple IOIO's, and I can only connect to the last physically paired IOIO bluetooth dongle.
 

headingwest

Member
Licensed User
Longtime User
I2C crash

Hi Kolbe,

I was using a USB cable to connnect and had measured the response time from 8 to 15ms. So much faster than I expected.

This project is quite simple so no services and still testing basic stuff. So a crash with i2c at this stage makes me nervous.

I've ended up moving to UART which with the Async ability seems to use less of the Androids processing power as the data is waiting in the buffer. Also crash free so far!

Thanks again for your assistance. Btw I'm trying to keep the full source code available on my site.

Cheers,

JIm.
 

kolbe

Active Member
Licensed User
Longtime User
new IOIO library uploaded

I just uploaded the next version of the IOIO library.

Because most of the methods need to be threaded, many of the interfaces have changed.... most notably all the Open methods have changed. Remember that code modules cannot receive events.

The IOIO Workbench app pretty much shows you how to code everything.

Have fun.
 
Last edited:

headingwest

Member
Licensed User
Longtime User
Latest IOI

Thanks Kolbe!!!

Can't wait to get it installed and running. Can you confirm that this is for the IOIO V1 which uses 3.26 and not for IOIO-OTG which uses 3.3?

Thanks.
 

kolbe

Active Member
Licensed User
Longtime User
I only have a v1 at the moment so I can confirm v3.26. If I understand things correctly however, it should work with v2 as well.

I see we have a new application version now too, v4. I'll see about updating to that soon.
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
FYI, coslad in the Italian forum has reported that the IOIO library does indeed work with the IOIO-OTG.

I'm already working on v1.9 with CapSense. There is however a bug in Ytai's 4.00 library so I waiting for that to be fixed before releasing it.
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi ,
i didn't undestand witch library i have to use with ioio otg and bluetooth adpter .
Your library 1.8 is only for usb ?

Thanks
 

kolbe

Active Member
Licensed User
Longtime User
Perhaps I didn't understand. Did you get the IOIO-OTG to work with v1.8?

v1.8 should work with all IOIOs.

The only problem is that with Android 4.1 and above USB-ADB will not work. Google has now made this connection secured and Ytai doesn't plan on implementing a secured USB-ADB.

Bluetooth will work with all versions.

Unfortunately I haven't been able to get USB Open Accessory to work.

Hope this clears things up.


Hi ,
i didn't undestand witch library i have to use with ioio otg and bluetooth adpter .
Your library 1.8 is only for usb ?

Thanks
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi,
Excuse my English, now I try to explain me better.

I have seen that there was for b4a the ioio lib and the ioiobt lib, now , can I use only the 1.8 version to connect both USB and Bluetooth ( not in the same time together ) changing only the parameter to true in the connect function?
Or I need two library, one to USB and other to Bluetooth?

Wish I explained well, thanks

Inviato dal mio H9500 con Tapatalk 2
 

coslad

Well-Known Member
Licensed User
Longtime User
Hi ,
I answer to myself , i tried your library with Bt and IOIO-OTG and works fine.

I tested on a Galaxy s without problem , but on a ZP900 a MTK6577 based phone (homepage ZOPO ZP900 ),a strange thing happens , afer this commad :

If btadmin.IsEnabled Then YOYO.connect("io",True,1,0)

the event Sub io_connected(noerror As Boolean ) doesn't recalled (never) .

If i disconnect the the ioioboard in the bluetooth device list of the phone , obviously the connect function return false .

I tried even with different millisec in the connection function , but never the _connected sub is called .

If i connect with usb ( YOYO.connect("io",false,1,0) ) it works fine

Maybe can help to know that in the list of bluetooth connected device on the phone , the ioio appear as headphone icon .


PS: To Erel , please update the IOIO wiki .

Thanks
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
As you figured out there since v1.7 there is only one library and it works with both USB and BT.

If it doesn't connect but doesn't throw any exceptions then most likely there is a problem with BT pairing. Check the logcat from your device that works with the one that doesn't. The IOIO works well with some BT dongles and not with others. Try the workbench app that I included to see if the library detects a properly paired IOIO. Ytai's gethub page has a list of dongles that users report work correctly.

Sorry about the IOIO wiki I'll update it soon.

 

markon

New Member
Licensed User
Longtime User
I am willing to work with Kolbe on this


I am willing to work on this with Kolbe. Let me know.
I would like to do the following
1. Upgrade to the 3.30 release of the IOIOlib, IOIOAccesory, IOIOBT
2. Make to work with OpenAcc.

Let me know and we can start.

William Mark Esser.
 

kolbe

Active Member
Licensed User
Longtime User
If you could get OpenAcc to work that would be great. Check your PM, I sent you a reply.

I have a v1.9 built on 4.00 already. I guess I can release it as a beta. I know there is a bug in the capsense functionality that is why I haven't released it.

I am willing to work on this with Kolbe. Let me know.
I would like to do the following
1. Upgrade to the 3.30 release of the IOIOlib, IOIOAccesory, IOIOBT
2. Make to work with OpenAcc.

Let me know and we can start.

William Mark Esser.
 

bluedude

Well-Known Member
Licensed User
Longtime User
B4A with the IOIO mint board and shield

Koble,

What I mean is if you think the B4A library can run this IOIO mint.

Cheers,
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…