Hepta_Cam&GPS
Dependents: HEPTA2_assembly_0720 HEPTA2_ALL HEPTA2_ALL_ver0803_02
Fork of HeptaSerial by
HeptaSerial.h
- Committer:
- hepta2ume
- Date:
- 2017-08-05
- Revision:
- 6:c11f48bbb567
- Parent:
- 4:57c7f33a3621
File content as of revision 6:c11f48bbb567:
#include "mbed.h" #include "SerialBuffered.h" #ifndef HEPTA_SERIAL_H #define HEPTA_SERIAL_H class HeptaSerial { public: enum JpegResolution { JpegResolution80x64 = 0x01, // unofficial JpegResolution160x128 = 0x03, // unofficial JpegResolution320x240 = 0x05, // QVGA JpegResolution640x480 = 0x07 // VGA }; enum ErrorNumber { NoError = 0x00, UnexpectedReply = 0x04, ParameterError = 0x0b, SendRegisterTimeout = 0x0c, CommandIdError = 0x0d, CommandHeaderError = 0xf0, SetTransferPackageSizeWrong = 0x11 }; enum Baud { Baud460800 = 0x02, Baud230400 = 0x03, Baud115200 = 0x04, Baud57600 = 0x05, Baud28800 = 0x06, Baud14400 = 0x07 // Default. }; enum ResetType { Nomal = 0x00, High = 0xff }; HeptaSerial(PinName tx, PinName rx); ~HeptaSerial(); ErrorNumber sync(); ErrorNumber init(Baud baud, JpegResolution jr); ErrorNumber getJpegSnapshotPicture(); ErrorNumber getJpegSnapshotPicture_data(); void setmbedBaud(Baud baud); void Sync(void); void initialize(Baud baud,JpegResolution jr); void test_jpeg_snapshot_picture(int CAPTURE_FRAMES); void test_jpeg_snapshot_data(int CAPTURE_FRAMES); void jpeg_callback(char *buf, size_t siz); void gps_setting(void); char getc(); int readable(); void flushSerialBuffer(void); void gga_sensing(float *time, float *latitude, char *ns, float *longitude, char *ew, int *quality, int *stnum, float *hacu, float *altitude, char *aunit, int *gps_check); void lat_log_sensing_u16(char *lat, char *log, char * height, int *dsize1, int *dsize2); private: SerialBuffered serial; static const int COMMAND_LENGTH = 6; static const int SYNCMAX = 60; static const int packageSize = 256; //static const int CAPTURE_FRAMES = 3; char msg[256],msgd[256]; int i,ite,rlock,stn; char c; char gps_data[7][1000]; char ns,ew,statas; float time,hokui,tokei,vel; float g_hokui,g_tokei; float d_hokui,m_hokui,d_tokei,m_tokei; int h_time,m_time,s_time; float height_1; int m_height,cm_height; ErrorNumber sendInitial(Baud band, JpegResolution jr); ErrorNumber sendGetPicture(void); ErrorNumber sendSnapshot(void); ErrorNumber sendSetPackageSize(uint16_t packageSize); ErrorNumber sendReset(ResetType specialReset); ErrorNumber recvData(uint32_t *length); ErrorNumber sendSync(); ErrorNumber recvSync(); ErrorNumber sendAck(uint8_t commandId, uint16_t packageId); ErrorNumber recvAckOrNck(); bool sendBytes(char *buf, size_t len, int timeout_us = 20000); bool recvBytes(char *buf, size_t len, int timeout_us = 20000); bool waitRecv(); bool waitIdle(); }; #endif