Hepta_Cam&GPS
Dependents: HEPTA2_assembly_0720 HEPTA2_ALL HEPTA2_ALL_ver0803_02
Fork of HeptaSerial by
Diff: HeptaSerial.cpp
- Revision:
- 5:50a03fcd9cc0
- Parent:
- 4:57c7f33a3621
- Child:
- 6:c11f48bbb567
--- a/HeptaSerial.cpp Mon Jul 24 05:51:24 2017 +0000 +++ b/HeptaSerial.cpp Wed Jul 26 06:22:13 2017 +0000 @@ -612,6 +612,7 @@ void HeptaSerial::Sync(void) { + serial.setTimeout(1); HeptaSerial::ErrorNumber err = HeptaSerial::NoError; serial._baud(14400); err = sync(); @@ -622,6 +623,33 @@ } else { printf("[FAIL] : Camera::sync (Error=%02X)\r\n", (int)err); } + /* + HeptaSerial::ErrorNumber err = HeptaSerial::NoError; + + err = sync(); + int count=0; + while(err) { + switch(count) { + case 0: + setmbedBaud(HeptaSerial::Baud14400); + break; + case 1: + setmbedBaud(HeptaSerial::Baud115200); + break; + case 2: + setmbedBaud(HeptaSerial::Baud57600); + break; + case 3: + setmbedBaud(HeptaSerial::Baud28800); + break; + default: + count=0; + } + count++; + err = sync(); + printf("init err1=%d\r\n", err); + + }*/ } void HeptaSerial::test_jpeg_snapshot_picture(int CAPTURE_FRAMES) @@ -629,7 +657,7 @@ HeptaSerial::ErrorNumber err = HeptaSerial::NoError; for (int i = 0; i < CAPTURE_FRAMES; i++) { char fname[64]; - snprintf(fname, sizeof(fname), "/fs/test%d.jpg", i); + snprintf(fname, sizeof(fname), "/fs/test.jpg"); fp_jpeg = fopen(fname, "w"); err = getJpegSnapshotPicture(); @@ -648,7 +676,7 @@ HeptaSerial::ErrorNumber err = HeptaSerial::NoError; for (int i = 0; i < CAPTURE_FRAMES; i++) { char fname[64]; - snprintf(fname, sizeof(fname), "/fs/test%d.txt", i); + snprintf(fname, sizeof(fname), "/fs/test.txt"); fp_jpeg = fopen(fname, "w"); err = getJpegSnapshotPicture_data(); @@ -665,10 +693,10 @@ void HeptaSerial::initialize(Baud baud,JpegResolution jr) { HeptaSerial::ErrorNumber err = HeptaSerial::NoError;//ErrorNumber define - setmbedBaud(baud); err = init(baud, jr);// if (HeptaSerial::NoError == err) { printf("[ OK ] : Camera::init\r\n"); + setmbedBaud(baud); } else { printf("[FAIL] : Camera::init (Error=%02X)\r\n", (int)err); } @@ -678,18 +706,21 @@ //*********************serial*********************// char HeptaSerial::getc() { + serial._baud(9600); serial.setTimeout(999); c = serial.getc(); return c; } int HeptaSerial::readable() { + serial._baud(9600); serial.setTimeout(999); i = serial.readable(); return i; } void HeptaSerial::flushSerialBuffer(void) { + serial._baud(9600); serial.setTimeout(999); ite = 0; while (serial.readable()) @@ -702,6 +733,7 @@ } void HeptaSerial::gga_sensing(float *time, float *latitude, char *ns, float *longitude, char *ew, int *quality, int *stnum, float *hacu, float *altitude, char *aunit, int *serial_check) { + serial._baud(9600); serial.setTimeout(999); int ite = 0; while(serial.getc()!='$'){ @@ -759,6 +791,7 @@ } void HeptaSerial::lat_log_sensing_u16(char *lat, char *log, int *dsize) { + serial._baud(9600); serial.setTimeout(999); char gph1[8]={0x00},gph2[8]={0x00},gph3[8]={0x00},gph4[8]={0x00},gpt1[8]={0x00},gpt2[8]={0x00},gpt3[8]={0x00},gpt4[8]={0x00}; int i=0,j=0;