From 6f41fa91f9d1348773aaef408ff5e8ab595f81d5 Mon Sep 17 00:00:00 2001 From: Igor Date: Wed, 18 Apr 2018 18:41:47 +0300 Subject: [PATCH] fix library --- README.md | 4 ++- library.properties | 6 ++-- src/TroykaGPS.h | 2 +- src/utility/uartDevice.h | 65 +++++++++++++++++++--------------------- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 174d2c7..2f2ed79 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ GPS/GLONASS (Troyka-модуль) =========================== -Библиотека для Arduino, позволяющая считывать данные с [GPS/GLONASS](http://amperka.ru/product/troyka-gps-glonass) модуля. +Библиотека для Arduino, позволяющая считывать данные с GPS/GLONASS модулей: +* [GPS/GLONASS модуль со встроенной антенной.](http://amperka.ru/product/troyka-gps-glonass) +* [GPS/GLONASS модуль с выносной антенной.](http://amperka.ru/product/troyka-gps-glonass-extended-reciver) Установка библиотеки ==================== diff --git a/library.properties b/library.properties index 8fe9e71..b22be91 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=TroykaGPS -version=1.2 -author=Igor Dementiev, Amperka +version=1.0.0 +author=Igor Dementiev maintainer=Amperka sentence=Allows you to read data from the GPS/GLONASS sensor module. paragraph=The GPS/GLONASS sensor sends data to the control board in NMEA-message format. This library parses NMEA-messages and converts them into separate values. -category=Sensors +category=Communication url=https://github.com/amperka/TroykaGPS architectures=* diff --git a/src/TroykaGPS.h b/src/TroykaGPS.h index 790c376..3d1a970 100644 --- a/src/TroykaGPS.h +++ b/src/TroykaGPS.h @@ -43,7 +43,7 @@ class GPS : public GPSNAME::UARTDevice int8_t getMonth() const { return _month; } uint16_t getYear() const { return _year; } - private: +private: void setHeaderState(char c, int8_t* state, char* header); void parsingGNGGA(char* gpsBuffer, char* sat, char* altitude); void parsingGNRMC(char* gpsBuffer, char* connectSat, char* time, char* date, char* latitude, char* longitude, char* speed); diff --git a/src/utility/uartDevice.h b/src/utility/uartDevice.h index 089c912..9e55d6e 100644 --- a/src/utility/uartDevice.h +++ b/src/utility/uartDevice.h @@ -3,44 +3,41 @@ #include // miliseconds -#define DEFAULT_TIMEOUT 1000 +#define DEFAULT_TIMEOUT 1000 // miliseconds -#define DEFAULT_INTERCHAR_TIMEOUT 1000 +#define DEFAULT_INTERCHAR_TIMEOUT 1000 // using namespace for GPS namespace GPSNAME { - -enum dataType { - CMD = 0, - DATA = 1, -}; - -// abstract base class -class UARTDevice -{ -public: - UARTDevice(Stream* uartDevice); - virtual ~UARTDevice() = 0; - int uartDeviceAvailable(); - int uartDeviceAvailable(int waitTime); - void uartDeviceFlushSerial(); - int uartDeviceReadSerial(); - void uartDeviceReadBuffer(char* buffer, int count, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); - void uartDeviceCleanBuffer(char* buffer, int count); - void uartDeviceSendByte(uint8_t data); - void uartDeviceSendChar(const char c); - void uartDeviceSendCMD(const char* cmd); - void uartDeviceSendCMD(const __FlashStringHelper* cmd); - void uartDeviceSendCMDP(const char* cmd); - void uartDeviceSendAT(); - void uartDeviceSendEndMark(); - bool uartDeviceWaitForResp(const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); - bool uartDeviceCheckWithCMD(const char* cmd, const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); - bool uartDeviceCheckWithCMD(const __FlashStringHelper* cmd, const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); -private: - Stream* _uartDevice; -}; - + enum dataType { + CMD = 0, + DATA = 1, + }; + // abstract base class + class UARTDevice + { + public: + UARTDevice(Stream* uartDevice); + virtual ~UARTDevice() = 0; + int uartDeviceAvailable(); + int uartDeviceAvailable(int waitTime); + void uartDeviceFlushSerial(); + int uartDeviceReadSerial(); + void uartDeviceReadBuffer(char* buffer, int count, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); + void uartDeviceCleanBuffer(char* buffer, int count); + void uartDeviceSendByte(uint8_t data); + void uartDeviceSendChar(const char c); + void uartDeviceSendCMD(const char* cmd); + void uartDeviceSendCMD(const __FlashStringHelper* cmd); + void uartDeviceSendCMDP(const char* cmd); + void uartDeviceSendAT(); + void uartDeviceSendEndMark(); + bool uartDeviceWaitForResp(const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); + bool uartDeviceCheckWithCMD(const char* cmd, const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); + bool uartDeviceCheckWithCMD(const __FlashStringHelper* cmd, const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); + private: + Stream* _uartDevice; + }; } #endif