QC Control software

Dependencies:   mbed

Fork of dgps by Colin Stearns

Revision:
13:a6d3cf2b018e
Parent:
12:e42985e3ea64
Child:
14:6be57da62283
--- a/handle/handleCamera.cpp	Sat Apr 05 22:27:18 2014 +0000
+++ b/handle/handleCamera.cpp	Mon Apr 07 01:30:04 2014 +0000
@@ -3,7 +3,9 @@
 void ImageHandle::setup(){
     char* version = cam.getVersion();
     outputDevice.printf("Version %s\n",version);
-    uint8_t targetSize=VC0706_160x120;//VC0706_640x480;//VC0706_160x120;
+    uint8_t targetSize=VC0706_640x480;
+    // 320x240
+    //VC0706_640x480;//VC0706_160x120;
     cam.setImageSize(targetSize);
     uint8_t realSize=cam.getImageSize();
 }
@@ -16,17 +18,27 @@
     unsigned int sID=getPS().getSuperID();
     getPS().sendPacket(sID,NULL,0,PT_IMAGE);
     int size=cam.frameLength();
-    outputDevice.printf("Image Start\n",size);
+    outputDevice.printf("Image Start %d\n",size);
     int i;
+    char backBuffer[PACKETSIZE];
+    int bloc=0;
     for(i=0;i<size;){
         // read 32 bytes at a time;
         uint8_t bytesToRead = std::min(64, size-i); // change 32 to 64 for a speedup but may not work with all setups!
         uint8_t bytesRead=0;
         char* buffer = (char*)cam.readPicture(bytesToRead,&bytesRead);
-        getPS().sendPacket(sID,buffer,bytesRead);
+        for(int a=0;a<bytesRead;a++){
+            if(bloc==PACKETSIZE){
+                getPS().sendPacket(sID,backBuffer,bloc);
+                bloc=0;
+            }
+            backBuffer[bloc++]=buffer[a];
+        }
+        //getPS().sendPacket(sID,buffer,bytesRead);
         //for(int a=0;a<bytesRead;a++){outputDevice.putc(buffer[a]);}
         i+=bytesRead;
     }
+    getPS().sendPacket(sID,backBuffer,bloc);
     outputDevice.printf("Image End\n",size);
     getPS().sendPacket(sID,NULL,0,PT_END);
 }