// 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");
}
});
}
}
}
}
--
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.
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.
Hi,
int nbOfBytesRead = 0;
while (nbOfBytesRead < imageSize) {
_uartIn.read(bufferData, nbOfBytesRead, 1);
nbOfBytesRead++;
}
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.
--