IOIO UART communication with uCamII

57 views
Skip to first unread message

Marouane M

unread,
Mar 26, 2015, 2:55:23 PM3/26/15
to ioio-...@googlegroups.com
Hi, 

I'm trying to get an image from ucamII using a ioio UART connection.


What I'm tying todo is Presented in section 7.4 page 16/22 of the pdf
but I want to Get a JPEG picture with 640*480

In the UARTController.java you have the code that i use like presented here after:

The problem is that I always have the message:
UART Read PICTACK OK
UART Read TimeoutException
UART Read Get Image Size FAILED

I do not know if i should read differently:
for exemple wait some bytes to start the read like I do in waitReference.
or should i set the baudrate and not use the automatic detection.

If you have a proposition I will try it.

THANKS IN Advance
==============================================

// this is just For Logging
   
class CamController extends UARTController {
       
@Override
       
public void log(String msg) {
           
final String theMsg = msg;
            runOnUiThread
(new Runnable() {
               
@Override
               
public void run() {
                    textLogger_
.append(theMsg);
                    scrollTextLogger_
.fullScroll(ScrollView.FOCUS_DOWN);
               
}
           
});
       
}
   
}


// at setup
            camIoioRxPIN30
= 30;
            camIoioTxPIN29
= 29;
           
Integer baud = 115200; // 115200; // after that try: ucamII autodetect 921600 or set 3686400;
           
CamController camCom = new CamController();
            camCom
.connect(ioio_, camIoioRxPIN30, camIoioTxPIN29, baud);
           
boolean syncOK = camCom.camSYNC();
           
if (syncOK) {
               
boolean initOK = camCom.camINITJPEG();
               
if (initOK) {
                   
boolean setPKGSizeOK = camCom.camSetPKGSize();
                   
if (setPKGSizeOK) {
                       
final byte[] data = camCom.camGetFrame();
                       
if (data.length != 0) {
                           
this.logOnUI("GET FRAME OK\n");
                            runOnUiThread
(new Runnable() {
                               
@Override
                               
public void run() {
                                   
// VideoView
                                   
//Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, dataSize);
                                   
//videoViewCam_.setImageBitmap(bitmap);
                                   
//textLogger_.append("bitmap.getByteCount() => " + bitmap.getByteCount() + "\n");
                                   
//textLogger_.append("bitmap.getHeight() => " + bitmap.getHeight() + "\n");
                                   
//textLogger_.append("bitmap.getWidth() => " + bitmap.getWidth() + "\n");
                                    textLogger_
.append("data.length => " + data.length + "\n");
                               
}
                           
});
                       
}


                   
}
               
}
           
}


UARTController.java

Ytai Ben-Tsvi

unread,
Mar 27, 2015, 10:19:35 PM3/27/15
to ioio-...@googlegroups.com
I would probe both UART channels with an independent source (either different UARTs on the IOIO on different threads, or logic analyzer or USB-serial cable, etc.) and verify that the protocol is correct.
Also, it is possible that some of your timeouts are overly aggressive, so at least until you get everything working and know what to expect I would make them very liberal.

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Marouane M

unread,
Apr 2, 2015, 1:09:00 PM4/2/15
to ioio-...@googlegroups.com
I worked a bit and I manage to communicate between ioio and uCamII because i managed to sync to get the image size.

I need a precision because a got an image of size 4800 so i need to get 4800 bytes from the uCamII and when i do uartIn.available() whatever the time i wait i never get more than 1024.


Ytai Ben-Tsvi

unread,
Apr 2, 2015, 2:10:26 PM4/2/15
to ioio-...@googlegroups.com
Is this a question?

On Thu, Apr 2, 2015 at 10:09 AM, Marouane M <marou...@gmail.com> wrote:
I worked a bit and I manage to communicate between ioio and uCamII because i managed to sync to get the image size.

I need a precision because a got an image of size 4800 so i need to get 4800 bytes from the uCamII and when i do uartIn.available() whatever the time i wait i never get more than 1024.


Marouane M

unread,
Apr 5, 2015, 7:42:49 AM4/5/15
to ioio-...@googlegroups.com
Yes,

I try to be clearer:
 First I ask the size of the image and I receive 4800.
 Then I need to read 4800 bytes so I though i wait that uartIn.available() return me 4800 and then I read those. but I wait I wait and i never get uartIn?available() == 4800 I only get 1024..

My question is: is there something like a buffer inside the ioio that limits to 1024?





Marouane M

unread,
Apr 5, 2015, 11:58:38 AM4/5/15
to ioio-...@googlegroups.com
Hi,
  using this code it worked:

int nbOfBytesRead = 0;
while (nbOfBytesRead < imageSize) {
              _uartIn
.read(bufferData, nbOfBytesRead, 1);
               nbOfBytesRead
++;
}

my previous question about a buffer in the ioio stands anyway .

Thanks For your Help Ytai and thank you for the fantastic ioio you built and support.

Ytai Ben-Tsvi

unread,
Apr 5, 2015, 12:12:39 PM4/5/15
to ioio-...@googlegroups.com

Yes, there are buffers on both ends of the channel. For efficiency, you should attempt to read more than one byte at a time and check for many bytes have actually been read by looking at the return value of read(). Finally, wrap this all in a method for cleanliness.

--
Reply all
Reply to author
Forward
0 new messages