CameraC328

Dependents:   CameraC328_TestProgram CameraC328_Thresholding Camera_TestProgram_2015 Camera_TestProgram_2015 ... more

Revision:
10:b04f3444b794
Parent:
7:d0d13822c37a
Child:
11:0c80f5829565
--- a/CameraC328.cpp	Thu Jul 01 10:39:59 2010 +0000
+++ b/CameraC328.cpp	Mon Aug 30 13:45:20 2010 +0000
@@ -1,5 +1,5 @@
 /**
- * C328-7640 device driver class (Version 0.0.2)
+ * C328-7640 device driver class (Version 0.0.3)
  * Reference documents: C328-7640 User Manual v3.0 2004.8.19
  *
  * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
@@ -227,14 +227,13 @@
         return en;
     }
 
-    WAITFUNC();
-
     char databuf[packageSize - 6];
     uint16_t pkg_total = length / (packageSize - 6);
     for (int i = 0; i <= (int)pkg_total; i++) {
         uint16_t checksum = 0;
         // ID.
         char idbuf[2];
+        WAITFUNC();
         if (!RECVFUNC(idbuf, sizeof(idbuf))) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -247,6 +246,7 @@
 
         // Size of the data.
         char dsbuf[2];
+        WAITFUNC();
         if (!RECVFUNC(dsbuf, sizeof(dsbuf))) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -255,6 +255,7 @@
         checksum += dsbuf[0];
         checksum += dsbuf[1];
         uint16_t ds = (dsbuf[1] << 8) | (dsbuf[0] << 0);
+        WAITFUNC();
         if (!RECVFUNC(&databuf[0], ds)) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -264,6 +265,7 @@
 
         // Verify code.
         char vcbuf[2];
+        WAITFUNC();
         if (!RECVFUNC(vcbuf, sizeof(vcbuf))) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -318,14 +320,13 @@
         return en;
     }
 
-    WAITFUNC();
-
     char databuf[packageSize - 6];
     uint16_t pkg_total = length / (packageSize - 6);
     for (int i = 0; i <= (int)pkg_total; i++) {
         uint16_t checksum = 0;
         // ID.
         char idbuf[2];
+        WAITFUNC();
         if (!RECVFUNC(idbuf, sizeof(idbuf))) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -338,6 +339,7 @@
 
         // Size of the data.
         char dsbuf[2];
+        WAITFUNC();
         if (!RECVFUNC(dsbuf, sizeof(dsbuf))) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -346,6 +348,7 @@
         checksum += dsbuf[0];
         checksum += dsbuf[1];
         uint16_t ds = (dsbuf[1] << 8) | (dsbuf[0] << 0);
+        WAITFUNC();
         if (!RECVFUNC(&databuf[0], ds)) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -355,6 +358,7 @@
 
         // Verify code.
         char vcbuf[2];
+        WAITFUNC();
         if (!RECVFUNC(vcbuf, sizeof(vcbuf))) {
             return (ErrorNumber)UnexpectedReply;
         }
@@ -645,4 +649,4 @@
     while (!serial.readable()) {
     }
     return true;
-}
\ No newline at end of file
+}