summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Van Doorn <vandoorn.nick@gmail.com>2017-12-12 18:32:52 -0800
committerNick Van Doorn <vandoorn.nick@gmail.com>2017-12-12 18:32:52 -0800
commit977d9d2b812521a3d97aa0cadc911715d8077d1f (patch)
treebd808e27821d2d03fbb26e7f4b6a40bce29d4a42
parentbd0f01a8de05fcbf626edc973c237dc05395aff5 (diff)
Update API
-rw-r--r--README.md27
-rw-r--r--camera.h27
2 files changed, 40 insertions, 14 deletions
diff --git a/README.md b/README.md
index cb9ac44..e8f2918 100644
--- a/README.md
+++ b/README.md
@@ -27,13 +27,23 @@ The Legato serial API [`le_tty`](http://legato.io/legato-docs/latest/le__tty_8h.
## API
```c
-LE_SHARED le_result_t openCameraFd (const char *path, int *fd, tty_Speed_t baud, int nBytes, int timeout);
-LE_SHARED void sendCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs);
-LE_SHARED bool runCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen, bool flushFlag);
-LE_SHARED bool runCommandFlush (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen);
-LE_SHARED uint8_t readResponse (Camera *cam, uint8_t nBytes, uint8_t timeout);
+// File descriptor helpers
+LE_SHARED le_result_t fd_openCam (int *fd);
+LE_SHARED void fd_closeCam (int fd);
+LE_SHARED le_result_t fd_resetCamTty (int *fd);
+ssize_t fd_getByte (int fd, uint8_t *data);
+ssize_t fd_dataAvail (int fd, int *data);
+
+// Camera communication functions
+void sendCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs);
+bool runCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen, bool flushFlag);
+bool runCommandFlush (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen);
+uint8_t readResponse (Camera *cam, uint8_t nBytes, uint8_t timeout);
+bool verifyResponse (Camera *cam, uint8_t cmd);
+
+// High level commands to be called by
+// another component that requires this one
LE_SHARED void printBuffer (Camera *cam);
-LE_SHARED bool verifyResponse (Camera *cam, uint8_t cmd);
LE_SHARED bool cameraFrameBuffCtrl (Camera *cam, uint8_t cmd);
LE_SHARED bool takePicture (Camera *cam);
LE_SHARED bool reset (Camera *cam);
@@ -57,6 +67,11 @@ LE_SHARED uint8_t getCompression (Camera *cam);
LE_SHARED bool setCompression(Camera *cam, uint8_t c);
LE_SHARED bool getPTZ(Camera *cam, uint16_t *w, uint16_t *h, uint16_t *wz, uint16_t *hz, uint16_t *pan, uint16_t *tilt);
LE_SHARED bool setPTZ(Camera *cam, uint16_t wz, uint16_t hz, uint16_t pan, uint16_t tilt);
+
+// File stream functions for reading photos
+uint8_t getImageBlockSize (int jpgLen);
+bool readImageBlock (Camera *cam, FILE *filePtr);
+bool readImageToFile (Camera *cam, char *path);
LE_SHARED bool snapshotToFile (Camera *cam, char *path, uint8_t imgSize);
```
diff --git a/camera.h b/camera.h
index e8c02ab..b6831d3 100644
--- a/camera.h
+++ b/camera.h
@@ -2,7 +2,6 @@
#define CAMERA_H
#include "legato.h"
-#include "interfaces.h"
#define VC0706_RESP_PREFIX 0x76
#define VC0706_PREFIX 0x56
@@ -40,7 +39,7 @@
#define VC0706_SET_ZOOM 0x52
#define VC0706_GET_ZOOM 0x53
-#define CAM_BUFF_SIZE 200
+#define CAM_BUFF_SIZE 100
#define CAM_BLOCK_SIZE 32
#define CAM_DELAY 10
#define CAM_SERIAL 0
@@ -56,13 +55,23 @@ typedef struct {
uint16_t frameptr;
} Camera;
-LE_SHARED le_result_t openCameraFd (const char *path, int *fd, tty_Speed_t baud, int nBytes, int timeout);
-LE_SHARED void sendCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs);
-LE_SHARED bool runCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen, bool flushFlag);
-LE_SHARED bool runCommandFlush (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen);
-LE_SHARED uint8_t readResponse (Camera *cam, uint8_t nBytes, uint8_t timeout);
+// File descriptor helpers
+LE_SHARED le_result_t fd_openCam (int *fd);
+LE_SHARED void fd_closeCam (int fd);
+LE_SHARED le_result_t fd_resetCamTty (int *fd);
+ssize_t fd_getByte (int fd, uint8_t *data);
+ssize_t fd_dataAvail (int fd, int *data);
+
+// Camera communication functions
+void sendCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs);
+bool runCommand (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen, bool flushFlag);
+bool runCommandFlush (Camera *cam, uint8_t cmd, uint8_t args[], uint8_t nArgs, uint8_t respLen);
+uint8_t readResponse (Camera *cam, uint8_t nBytes, uint8_t timeout);
+bool verifyResponse (Camera *cam, uint8_t cmd);
+
+// High level commands to be called by
+// another component that requires this one
LE_SHARED void printBuffer (Camera *cam);
-LE_SHARED bool verifyResponse (Camera *cam, uint8_t cmd);
LE_SHARED bool cameraFrameBuffCtrl (Camera *cam, uint8_t cmd);
LE_SHARED bool takePicture (Camera *cam);
LE_SHARED bool reset (Camera *cam);
@@ -86,6 +95,8 @@ LE_SHARED uint8_t getCompression (Camera *cam);
LE_SHARED bool setCompression(Camera *cam, uint8_t c);
LE_SHARED bool getPTZ(Camera *cam, uint16_t *w, uint16_t *h, uint16_t *wz, uint16_t *hz, uint16_t *pan, uint16_t *tilt);
LE_SHARED bool setPTZ(Camera *cam, uint16_t wz, uint16_t hz, uint16_t pan, uint16_t tilt);
+
+// File stream functions for reading photos
uint8_t getImageBlockSize (int jpgLen);
bool readImageBlock (Camera *cam, FILE *filePtr);
bool readImageToFile (Camera *cam, char *path);