Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 3daf572bcae1 Team Team01_HEPTA_Trainig
Fork of HeptaCamera_GPS by
Diff: HeptaCamera_GPS.cpp
- Revision:
- 17:a30fa71eddb7
- Parent:
- 16:acef3a7f9597
- Child:
- 18:da116273b461
--- a/HeptaCamera_GPS.cpp Fri Sep 08 08:16:45 2017 +0000
+++ b/HeptaCamera_GPS.cpp Thu Oct 26 11:27:12 2017 +0000
@@ -225,6 +225,121 @@
return (ErrorNumber)NoError;
}
+/**
+ * Get JPEG snapshot picture into a file.
+ *
+ * @param func A pointer to a callback function.
+ * You can block this function until saving the image datas.
+ * @return Status of the error.
+ */
+HeptaCamera_GPS::ErrorNumber HeptaCamera_GPS::getJpegSnapshotPicture(FILE *fp)
+{
+ WAITIDLE();
+ ErrorNumber en;
+
+
+ en = sendSnapshot();
+ if (NoError != en) {
+ return en;
+ }
+ WAITFUNC();
+ en = recvAckOrNck();
+ if (NoError != en) {
+ return en;
+ }
+
+ en = sendGetPicture();
+ if (NoError != en) {
+ return en;
+ }
+ WAITFUNC();
+ en = recvAckOrNck();
+ if (NoError != en) {
+ return en;
+ }
+
+ /*
+ * Data : snapshot picture
+ */
+ uint32_t length = 0;
+ WAITFUNC();
+ en = recvData(&length);
+ if (NoError != en) {
+ return en;
+ }
+ en = sendAck(0x00, 0);
+ if (NoError != en) {
+ return en;
+ }
+
+ 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;
+ }
+ checksum += idbuf[0];
+ checksum += idbuf[1];
+ uint16_t id = (idbuf[1] << 8) | (idbuf[0] << 0);
+ if (id != i) {
+ return (ErrorNumber)UnexpectedReply;
+ }
+
+ // Size of the data.
+ char dsbuf[2];
+ WAITFUNC();
+ if (!RECVFUNC(dsbuf, sizeof(dsbuf))) {
+ return (ErrorNumber)UnexpectedReply;
+ }
+
+ // Received the data.
+ checksum += dsbuf[0];
+ checksum += dsbuf[1];
+ uint16_t ds = (dsbuf[1] << 8) | (dsbuf[0] << 0);
+ WAITFUNC();
+ if (!RECVFUNC(&databuf[0], ds)) {
+ return (ErrorNumber)UnexpectedReply;
+ }
+ for (int j = 0; j < ds; j++) {
+ checksum += databuf[j];
+ }
+
+ // Verify code.
+ char vcbuf[2];
+ WAITFUNC();
+ if (!RECVFUNC(vcbuf, sizeof(vcbuf))) {
+ return (ErrorNumber)UnexpectedReply;
+ }
+ uint16_t vc = (vcbuf[1] << 8) | (vcbuf[0] << 0);
+ if (vc != (checksum & 0xff)) {
+ return (ErrorNumber)UnexpectedReply;
+ }
+
+ /*
+ * Call a call back function.
+ * You can block this function while working.
+ */
+ size_t siz = ds;
+ for (int ii = 0; ii < (int)siz; ii++) {
+ fprintf(fp, "%c", databuf[ii]);
+ }
+ /*
+ * We should wait for camera working before reply a ACK.
+ */
+ wait_ms(100);
+ en = sendAck(0x00, 1 + i);
+ if (NoError != en) {
+ return en;
+ }
+ }
+
+ return (ErrorNumber)NoError;
+}
+
HeptaCamera_GPS::ErrorNumber HeptaCamera_GPS::getJpegSnapshotPicture_data()
{
WAITIDLE();
@@ -334,6 +449,8 @@
return (ErrorNumber)NoError;
}
+
+
HeptaCamera_GPS::ErrorNumber HeptaCamera_GPS::sendInitial(Baud baud, JpegResolution jr)
{
char send[COMMAND_LENGTH];
