Skip to content

Commit

Permalink
Merge pull request #11 from siriobalmelli-foss/develop
Browse files Browse the repository at this point in the history
minor linting and fixups
  • Loading branch information
MaJerle committed Mar 18, 2020
2 parents 2574e2d + 2197f18 commit cec679a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .lvimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
" tree-specific vimrc to comply with project coding style
" see https://github.com/MaJerle/c-code-style
if &ft == "c" || &ft == "cpp"
setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab autoindent cc=80 foldmethod=indent
endif
2 changes: 1 addition & 1 deletion examples/example_buff.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ main() {
uint8_t rx;

/* Init GPS */
gps_init(&hgps);
gps_init(&hgps);

/* Create buffer for received data */
ringbuff_init(&hgps_buff, hgps_buff_data, sizeof(hgps_buff_data));
Expand Down
34 changes: 17 additions & 17 deletions gps_nmea_parser/src/gps/gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@

/*
* Copyright (c) 2020 Tilen MAJERLE
*
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
Expand Down Expand Up @@ -111,7 +111,7 @@ parse_float_number(gps_t* gh, const char* t) {

/**
* \brief Parse latitude/longitude NMEA format to double
*
*
* NMEA output for latitude is ddmm.sss and longitude is dddmm.sss
* \param[in] gh: GPS handle
* \return Latitude/Longitude value in degrees
Expand All @@ -124,7 +124,7 @@ parse_lat_long(gps_t* gh) {
deg = FLT((int)((int)ll / 100)); /* Get absolute degrees value, interested in integer part only */
min = ll - (deg * FLT(100)); /* Get remaining part from full number, minutes */
ll = deg + (min / FLT(60.0)); /* Calculate latitude/longitude */

return ll;
}

Expand All @@ -139,17 +139,17 @@ parse_term(gps_t* gh) {
if (0) {
#if GPS_CFG_STATEMENT_GPGGA
} else if (!strncmp(gh->p.term_str, "$GPGGA", 6) || !strncmp(gh->p.term_str, "$GNGGA", 6)) {
gh->p.stat = STAT_GGA;
gh->p.stat = STAT_GGA;
#endif /* GPS_CFG_STATEMENT_GPGGA */
#if GPS_CFG_STATEMENT_GPGSA
#if GPS_CFG_STATEMENT_GPGSA
} else if (!strncmp(gh->p.term_str, "$GPGSA", 6) || !strncmp(gh->p.term_str, "$GNGSA", 6)) {
gh->p.stat = STAT_GSA;
gh->p.stat = STAT_GSA;
#endif /* GPS_CFG_STATEMENT_GPGSA */
#if GPS_CFG_STATEMENT_GPGSV
} else if (!strncmp(gh->p.term_str, "$GPGSV", 6) || !strncmp(gh->p.term_str, "$GNGSV", 6)) {
gh->p.stat = STAT_GSV;
gh->p.stat = STAT_GSV;
#endif /* GPS_CFG_STATEMENT_GPGSV */
#if GPS_CFG_STATEMENT_GPRMC
#if GPS_CFG_STATEMENT_GPRMC
} else if (!strncmp(gh->p.term_str, "$GPRMC", 6) || !strncmp(gh->p.term_str, "$GNRMC", 6)) {
gh->p.stat = STAT_RMC;
#endif /* GPS_CFG_STATEMENT_GPRMC */
Expand All @@ -158,7 +158,7 @@ parse_term(gps_t* gh) {
}
return 1;
}

/* Start parsing terms */
if (gh->p.stat == STAT_UNKNOWN) {
#if GPS_CFG_STATEMENT_GPGGA
Expand Down Expand Up @@ -237,7 +237,7 @@ parse_term(gps_t* gh) {
if (gh->p.term_num >= 4 && gh->p.term_num <= 19) { /* Check current term number */
uint8_t index, term_num = gh->p.term_num - 4; /* Normalize term number from 4-19 to 0-15 */
uint16_t value;

index = 4 * (gh->p.data.gsv.stat_num - 1) + term_num / 4; /* Get array index */
if (index < sizeof(gh->sats_in_view_desc) / sizeof(gh->sats_in_view_desc[0])) {
value = (uint16_t)parse_number(gh, NULL); /* Parse number as integer */
Expand Down Expand Up @@ -369,7 +369,7 @@ gps_process(gps_t* gh, const void* data, size_t len) {
while (len--) { /* Process all bytes */
if (*d == '$') { /* Check for beginning of NMEA line */
memset(&gh->p, 0x00, sizeof(gh->p));/* Reset private memory */
TERM_ADD(gh, *d); /* Add character to term */
TERM_ADD(gh, *d); /* Add character to term */
} else if (*d == ',') { /* Term separator character */
parse_term(gh); /* Parse term we have currently in memory */
CRC_ADD(gh, *d); /* Add character to CRC computation */
Expand Down Expand Up @@ -446,7 +446,7 @@ gps_distance_bearing(gps_float_t las, gps_float_t los, gps_float_t lae, gps_floa
* Result will tell us in which direction (according to north) we should move,
* to reach point 2.
*
* Example:
* Example:
* Bearing is 0 => move to north
* Bearing is 90 => move to east
* Bearing is 180 => move to south
Expand Down
28 changes: 14 additions & 14 deletions gps_nmea_parser/src/include/gps/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@

/*
* Copyright (c) 2020 Tilen MAJERLE
*
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
Expand All @@ -49,7 +49,7 @@ extern "C" {
*/

/**
* \brief Enables `1` or disables `0` `double precision` for floating point
* \brief Enables `1` or disables `0` `double precision` for floating point
* values such as latitude, longitude, altitude.
*
* `double` is used as variable type when enabled, `float` when disabled.
Expand Down Expand Up @@ -129,7 +129,7 @@ extern "C" {
* \brief GPS float definition, can be either `float` or `double`
* \note Check for \ref GPS_CFG_DOUBLE configuration
*/
#if GPS_CFG_DOUBLE || __DOXYGEN__
#if GPS_CFG_DOUBLE || __DOXYGEN__
typedef double gps_float_t;
#else
typedef float gps_float_t;
Expand Down Expand Up @@ -196,11 +196,11 @@ typedef struct {
char term_str[13]; /*!< Current term in string format */
uint8_t term_pos; /*!< Current index position in term */
uint8_t term_num; /*!< Current term number */

uint8_t star; /*!< Star detected flag */

uint8_t crc_calc; /*!< Calculated CRC string */

union {
uint8_t dummy; /*!< Dummy byte */
#if GPS_CFG_STATEMENT_GPGGA
Expand Down Expand Up @@ -234,9 +234,9 @@ typedef struct {
#if GPS_CFG_STATEMENT_GPRMC
struct {
uint8_t is_valid; /*!< Status whether GPS status is valid or not */
uint8_t date; /*!< Current UTF date */
uint8_t month; /*!< Current UTF month */
uint8_t year; /*!< Current UTF year */
uint8_t date; /*!< Current UTC date */
uint8_t month; /*!< Current UTC month */
uint8_t year; /*!< Current UTC year */
gps_float_t speed; /*!< Current spead over the ground in knots */
gps_float_t coarse; /*!< Current coarse made good */
gps_float_t variation; /*!< Current magnetic variation in degrees */
Expand Down

0 comments on commit cec679a

Please sign in to comment.