Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS: Parsers and Unit Tests #176

Open
wants to merge 206 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
ed2ad8c
Added a UART buffer in the uart handler, need to test this when I cre…
christopherkinyua Aug 7, 2024
93f264d
Created rtos task that runs every 200ms
christopherkinyua Aug 7, 2024
9768f58
Updated uart_handler.h, Added some psuedo code for the rtos
christopherkinyua Aug 7, 2024
96b440a
Fixed Instance in uart_handler for the gps port
christopherkinyua Aug 13, 2024
58a2df8
WIP
christopherkinyua Aug 13, 2024
ea1a809
Created gps header file. Will need to add necessary functions
christopherkinyua Aug 14, 2024
b01d829
Used docstring to describe functions obtained from the docs
christopherkinyua Aug 14, 2024
1c253ad
Some pseudo code written
christopherkinyua Aug 14, 2024
1a8fae5
Changed variable names to match naming conventions
christopherkinyua Aug 15, 2024
daf65c4
Code Clean Up and using LOG_message
christopherkinyua Aug 16, 2024
2ab0f70
Started Creating the struct for the GNSS Response
christopherkinyua Aug 16, 2024
1f662eb
Change function name and add some pseudo code comments for coding dir…
christopherkinyua Aug 16, 2024
ba368ec
WIP: writing structs for the gps parser
christopherkinyua Aug 16, 2024
c0873cc
Created rtos task that runs every 200ms
christopherkinyua Aug 7, 2024
24fa2a0
Updated uart_handler.h, Added some psuedo code for the rtos
christopherkinyua Aug 7, 2024
e22118a
WIP
christopherkinyua Aug 13, 2024
8f030e9
WIP: Fixing docStrings and working on struct
christopherkinyua Aug 16, 2024
4fdc013
Made bestxyza struct
christopherkinyua Aug 16, 2024
6e6b6e5
Created Response Header unit test
christopherkinyua Aug 17, 2024
834cd42
Added unit test for bestxyza
christopherkinyua Aug 17, 2024
e12b261
Added code to the rtos task. Updated the headers in gps.h. Increased …
christopherkinyua Aug 17, 2024
3aaf018
WIP
christopherkinyua Aug 17, 2024
12d81c5
Fixing build issues
christopherkinyua Aug 17, 2024
a205401
WIP:Trying to figure out the parsing
christopherkinyua Aug 17, 2024
377e55c
Added a UART buffer in the uart handler, need to test this when I cre…
christopherkinyua Aug 7, 2024
e12a38b
Created rtos task that runs every 200ms
christopherkinyua Aug 7, 2024
0e91ecf
Updated uart_handler.h, Added some psuedo code for the rtos
christopherkinyua Aug 7, 2024
af28e7f
Fixed Instance in uart_handler for the gps port
christopherkinyua Aug 13, 2024
7022436
WIP
christopherkinyua Aug 13, 2024
c7a4d85
Used docstring to describe functions obtained from the docs
christopherkinyua Aug 14, 2024
c31f3e4
Some pseudo code written
christopherkinyua Aug 14, 2024
9d79919
Changed variable names to match naming conventions
christopherkinyua Aug 15, 2024
dee2a27
Code Clean Up and using LOG_message
christopherkinyua Aug 16, 2024
117db00
Started Creating the struct for the GNSS Response
christopherkinyua Aug 16, 2024
1a4cf07
Change function name and add some pseudo code comments for coding dir…
christopherkinyua Aug 16, 2024
6129293
WIP: writing structs for the gps parser
christopherkinyua Aug 16, 2024
68f3ed7
WIP: Fixing docStrings and working on struct
christopherkinyua Aug 16, 2024
a6dd9e5
Made bestxyza struct
christopherkinyua Aug 16, 2024
1e13763
Created Response Header unit test
christopherkinyua Aug 17, 2024
f58d283
Added unit test for bestxyza
christopherkinyua Aug 17, 2024
c7e0ccd
Added code to the rtos task. Updated the headers in gps.h. Increased …
christopherkinyua Aug 17, 2024
a805afa
WIP
christopherkinyua Aug 17, 2024
4dc28a7
Fixing build issues
christopherkinyua Aug 17, 2024
c62c60c
WIP:Trying to figure out the parsing
christopherkinyua Aug 17, 2024
22cff1a
Changed my types to enums instead
christopherkinyua Aug 23, 2024
8d96223
Using TCM_extract_string_arg to parse the input string. Updated unit …
christopherkinyua Aug 24, 2024
a89a77c
Trying to fix build issue
christopherkinyua Aug 24, 2024
aa3d29f
Cleaned up and made progress to bestxyza parser
christopherkinyua Aug 24, 2024
4560c85
GPS Header Parser Passed Unit Test V1. Will test with different heade…
christopherkinyua Aug 27, 2024
e9c4bf1
WIP: almost done with bestxyza parser besides the crc. Testing the ot…
christopherkinyua Aug 27, 2024
1710f85
WIP: Need to address changes as per updated ticket
christopherkinyua Aug 30, 2024
d866eab
WIP: Modified the gps types structs to have relevant information. Mod…
christopherkinyua Aug 30, 2024
32e32cd
Added data structs, parse function and unit test for TIMEA function. …
christopherkinyua Aug 31, 2024
5e4aaa4
WIP: Handling multiple responses in a single string
christopherkinyua Sep 1, 2024
4849714
Completed GPS Parse Header Unit Tests
christopherkinyua Sep 4, 2024
26af038
Added unit tests for functions used within the Parsers
christopherkinyua Sep 4, 2024
65e48f2
Added more tests in gps unit test
christopherkinyua Sep 6, 2024
abcebdb
WIP: Adding and fixing unit tests
christopherkinyua Sep 9, 2024
269c90b
Completed Unit testing, need to update code to use already made funct…
christopherkinyua Sep 11, 2024
20ff3e7
Using INT64 and INT32 defs instead of const variables
christopherkinyua Sep 11, 2024
ab35156
WIP: Trying to use TCMD_ascii_to_int64 function
christopherkinyua Sep 11, 2024
ba2415a
WIP
christopherkinyua Sep 12, 2024
b00cd23
Cahnges
christopherkinyua Sep 12, 2024
504e60a
WIP
christopherkinyua Sep 13, 2024
8e2a9d5
WIP
christopherkinyua Sep 13, 2024
0418d4e
WIP
christopherkinyua Sep 14, 2024
5b9247c
Added int64_t to string function, modified log message to handle a la…
christopherkinyua Sep 14, 2024
14d0c4d
Fixing rebase
christopherkinyua Sep 14, 2024
88bbbf0
Further rebase fixes
christopherkinyua Sep 14, 2024
36200a7
WIP: Addressing PR comments
christopherkinyua Sep 17, 2024
6056b93
WIP: Addressing PR comments
christopherkinyua Sep 18, 2024
93895fb
Fixing build error
christopherkinyua Sep 18, 2024
1001a08
WIP: PR comments
christopherkinyua Sep 18, 2024
b2107e6
WIP: PR changes, enum naming changes
christopherkinyua Sep 18, 2024
d0b44e5
Addressing Pr comments: Adding prefix GPS to every function
christopherkinyua Sep 18, 2024
3a4a86f
WIP
christopherkinyua Sep 18, 2024
274bf1f
Addressing PR Comments: Created new files to separate code. Resolved …
christopherkinyua Sep 18, 2024
aac359a
UART handler changes: Toggle function for ISR For GPS for the spammin…
christopherkinyua Sep 19, 2024
9735407
Build Fix
christopherkinyua Sep 19, 2024
8fd5afa
Small fixes during discussion - `GPS_set_uart_interrupt_state`, forma…
DeflateAwning Sep 20, 2024
bc1130a
Fixes from Rebase
christopherkinyua Sep 20, 2024
b7485d1
Added thread within main
christopherkinyua Sep 20, 2024
a16b422
rtos_task fixes: replaces return with continue and corrected timeout …
christopherkinyua Sep 20, 2024
cec6a3a
WIP:Created telecommand functions for setting up the gps
christopherkinyua Sep 20, 2024
e5a7a7d
Addressed PR changes
christopherkinyua Sep 21, 2024
3eb570e
Fixed Parsing Error for eps_args_str
christopherkinyua Sep 21, 2024
9b27bbc
Adding error fix during testing
christopherkinyua Oct 2, 2024
6339ace
Updated gps unit test test_file param
christopherkinyua Oct 3, 2024
8430ed0
Added a UART buffer in the uart handler, need to test this when I cre…
christopherkinyua Aug 7, 2024
6673845
Created rtos task that runs every 200ms
christopherkinyua Aug 7, 2024
453be79
Updated uart_handler.h, Added some psuedo code for the rtos
christopherkinyua Aug 7, 2024
fd2a525
Fixed Instance in uart_handler for the gps port
christopherkinyua Aug 13, 2024
6801264
WIP
christopherkinyua Aug 13, 2024
4030e57
Created gps header file. Will need to add necessary functions
christopherkinyua Aug 14, 2024
127ff87
Used docstring to describe functions obtained from the docs
christopherkinyua Aug 14, 2024
8703492
Some pseudo code written
christopherkinyua Aug 14, 2024
da38dee
Changed variable names to match naming conventions
christopherkinyua Aug 15, 2024
caa7d52
Code Clean Up and using LOG_message
christopherkinyua Aug 16, 2024
bc271c5
Started Creating the struct for the GNSS Response
christopherkinyua Aug 16, 2024
5938686
Change function name and add some pseudo code comments for coding dir…
christopherkinyua Aug 16, 2024
30f4968
WIP: writing structs for the gps parser
christopherkinyua Aug 16, 2024
2d24c01
Created rtos task that runs every 200ms
christopherkinyua Aug 7, 2024
86e0e90
Updated uart_handler.h, Added some psuedo code for the rtos
christopherkinyua Aug 7, 2024
eb0b3de
WIP
christopherkinyua Aug 13, 2024
ddc4abc
WIP: Fixing docStrings and working on struct
christopherkinyua Aug 16, 2024
036e141
Made bestxyza struct
christopherkinyua Aug 16, 2024
c56f70b
Created Response Header unit test
christopherkinyua Aug 17, 2024
311acea
Added unit test for bestxyza
christopherkinyua Aug 17, 2024
977977e
Added code to the rtos task. Updated the headers in gps.h. Increased …
christopherkinyua Aug 17, 2024
5073832
WIP
christopherkinyua Aug 17, 2024
db844ec
Fixing build issues
christopherkinyua Aug 17, 2024
ec92ddf
WIP:Trying to figure out the parsing
christopherkinyua Aug 17, 2024
ef9df0c
Added a UART buffer in the uart handler, need to test this when I cre…
christopherkinyua Aug 7, 2024
80f4530
Created rtos task that runs every 200ms
christopherkinyua Aug 7, 2024
abd8b41
Updated uart_handler.h, Added some psuedo code for the rtos
christopherkinyua Aug 7, 2024
b8674ea
Fixed Instance in uart_handler for the gps port
christopherkinyua Aug 13, 2024
2d2e907
WIP
christopherkinyua Aug 13, 2024
6720092
Used docstring to describe functions obtained from the docs
christopherkinyua Aug 14, 2024
9884a69
Some pseudo code written
christopherkinyua Aug 14, 2024
3e2d608
Changed variable names to match naming conventions
christopherkinyua Aug 15, 2024
91bd69b
Code Clean Up and using LOG_message
christopherkinyua Aug 16, 2024
25cb888
Started Creating the struct for the GNSS Response
christopherkinyua Aug 16, 2024
93af9fa
Change function name and add some pseudo code comments for coding dir…
christopherkinyua Aug 16, 2024
33595db
WIP: writing structs for the gps parser
christopherkinyua Aug 16, 2024
fc0f2d5
WIP: Fixing docStrings and working on struct
christopherkinyua Aug 16, 2024
a542c72
Made bestxyza struct
christopherkinyua Aug 16, 2024
8aa2574
Created Response Header unit test
christopherkinyua Aug 17, 2024
9ef843f
Added unit test for bestxyza
christopherkinyua Aug 17, 2024
94389bd
Added code to the rtos task. Updated the headers in gps.h. Increased …
christopherkinyua Aug 17, 2024
e4fa4e2
WIP
christopherkinyua Aug 17, 2024
1b1c5de
Fixing build issues
christopherkinyua Aug 17, 2024
9b990cb
WIP:Trying to figure out the parsing
christopherkinyua Aug 17, 2024
4d66b03
Changed my types to enums instead
christopherkinyua Aug 23, 2024
e698fe9
Using TCM_extract_string_arg to parse the input string. Updated unit …
christopherkinyua Aug 24, 2024
c128abb
Trying to fix build issue
christopherkinyua Aug 24, 2024
480b580
Cleaned up and made progress to bestxyza parser
christopherkinyua Aug 24, 2024
d2957e0
GPS Header Parser Passed Unit Test V1. Will test with different heade…
christopherkinyua Aug 27, 2024
21a6b56
WIP: almost done with bestxyza parser besides the crc. Testing the ot…
christopherkinyua Aug 27, 2024
fc1afcc
WIP: Need to address changes as per updated ticket
christopherkinyua Aug 30, 2024
2117a70
WIP: Modified the gps types structs to have relevant information. Mod…
christopherkinyua Aug 30, 2024
39a4731
Added data structs, parse function and unit test for TIMEA function. …
christopherkinyua Aug 31, 2024
135627a
WIP: Handling multiple responses in a single string
christopherkinyua Sep 1, 2024
db0bf1c
Completed GPS Parse Header Unit Tests
christopherkinyua Sep 4, 2024
a85c1f9
Added unit tests for functions used within the Parsers
christopherkinyua Sep 4, 2024
0bfd33c
Added more tests in gps unit test
christopherkinyua Sep 6, 2024
eefb5d7
WIP: Adding and fixing unit tests
christopherkinyua Sep 9, 2024
8c3e565
Completed Unit testing, need to update code to use already made funct…
christopherkinyua Sep 11, 2024
1d0fb1c
Using INT64 and INT32 defs instead of const variables
christopherkinyua Sep 11, 2024
b0bd6e0
WIP: Trying to use TCMD_ascii_to_int64 function
christopherkinyua Sep 11, 2024
8c9d95a
WIP
christopherkinyua Sep 12, 2024
c561367
Cahnges
christopherkinyua Sep 12, 2024
78a3a8d
WIP
christopherkinyua Sep 13, 2024
04a299d
WIP
christopherkinyua Sep 13, 2024
6b6bf12
WIP
christopherkinyua Sep 14, 2024
e2cf604
Added int64_t to string function, modified log message to handle a la…
christopherkinyua Sep 14, 2024
2b741d5
Fixing rebase
christopherkinyua Sep 14, 2024
9ec047b
Further rebase fixes
christopherkinyua Sep 14, 2024
571be27
WIP: Addressing PR comments
christopherkinyua Sep 17, 2024
4fc3cb1
WIP: Addressing PR comments
christopherkinyua Sep 18, 2024
1621457
Fixing build error
christopherkinyua Sep 18, 2024
ca19b0c
WIP: PR comments
christopherkinyua Sep 18, 2024
875cef4
WIP: PR changes, enum naming changes
christopherkinyua Sep 18, 2024
e790d8f
Addressing Pr comments: Adding prefix GPS to every function
christopherkinyua Sep 18, 2024
08d81de
WIP
christopherkinyua Sep 18, 2024
0d96860
Addressing PR Comments: Created new files to separate code. Resolved …
christopherkinyua Sep 18, 2024
b039241
UART handler changes: Toggle function for ISR For GPS for the spammin…
christopherkinyua Sep 19, 2024
03faf0e
Build Fix
christopherkinyua Sep 19, 2024
5502af0
Small fixes during discussion - `GPS_set_uart_interrupt_state`, forma…
DeflateAwning Sep 20, 2024
3c951b8
Fixes from Rebase
christopherkinyua Sep 20, 2024
66b5d7d
Added thread within main
christopherkinyua Sep 20, 2024
ccde921
rtos_task fixes: replaces return with continue and corrected timeout …
christopherkinyua Sep 20, 2024
0f7c9b4
WIP:Created telecommand functions for setting up the gps
christopherkinyua Sep 20, 2024
49f0269
Addressed PR changes
christopherkinyua Sep 21, 2024
e09013e
Fixed Parsing Error for eps_args_str
christopherkinyua Sep 21, 2024
9c12a47
Adding error fix during testing
christopherkinyua Oct 2, 2024
f4c0a68
Updated gps unit test test_file param
christopherkinyua Oct 3, 2024
d8fd978
Fixing build issues
christopherkinyua Oct 4, 2024
c97f861
Added code to the rtos task. Updated the headers in gps.h. Increased …
christopherkinyua Aug 17, 2024
a6b4271
Further rebase fixes
christopherkinyua Sep 14, 2024
77eca55
Merge Conflixes Resolved
christopherkinyua Oct 4, 2024
25bdb33
Testing: Log messages and updared setup commands that received a resp…
christopherkinyua Oct 10, 2024
33e91a8
Testing: Added a delay between each setup command, cleared up some lo…
christopherkinyua Oct 11, 2024
c6c7c2d
Testing: Fixed loop logic
christopherkinyua Oct 18, 2024
a4a5ca4
Variable Rename and added TODOs
christopherkinyua Oct 30, 2024
377d4bb
Var Rename and TODOs
christopherkinyua Oct 30, 2024
ed21ed2
WIP: Added gps args helpers and sample code from eps
christopherkinyua Nov 6, 2024
bbb5c1a
WIP
christopherkinyua Nov 8, 2024
8ac54b2
WIP:Added gps_send_command to telecommand defs
christopherkinyua Nov 15, 2024
ad0c95e
WIP:Added gps_send_command to telecommand defs
christopherkinyua Nov 15, 2024
59e43d8
WIP
christopherkinyua Nov 15, 2024
54e8b67
Testing Code using new method
christopherkinyua Nov 19, 2024
f0645f5
Clean up
christopherkinyua Nov 19, 2024
3fd07de
func rename
christopherkinyua Nov 19, 2024
f2766ff
Build Fix
christopherkinyua Nov 19, 2024
f500cd7
Created log command verification function. Yet to implement
christopherkinyua Nov 20, 2024
1a1e4a3
Added todos and updated comments in the code
christopherkinyua Nov 20, 2024
4de6707
Moved gps rtos task to separate file and addressed tabs to space comment
christopherkinyua Nov 21, 2024
bdb3da0
Merge branch 'main' into chris&kale/log-gps-position-to-filesystem-i16
christopherkinyua Nov 21, 2024
d6e963b
Build Fix
christopherkinyua Nov 21, 2024
7bb305e
Build Fix
christopherkinyua Nov 21, 2024
035d091
Fixed autoformatting comment
christopherkinyua Nov 21, 2024
26d86b1
Testing: Fixed the uart handler to be pointing to the gps
christopherkinyua Nov 22, 2024
a33ed1b
WIP: Modified code logic
christopherkinyua Nov 22, 2024
f4abf8e
Successful testing changes with python script
christopherkinyua Nov 25, 2024
ac6fb38
added gps test python script
christopherkinyua Nov 25, 2024
9726cc1
Testing Successful
christopherkinyua Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions firmware/Core/Inc/gps/gps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef __INCLUDE_GUARD__GPS_H__
#define __INCLUDE_GUARD__GPS_H__

#include <stdint.h>

uint32_t GPS_crc32_value(uint8_t i);
uint32_t GPS_calculate_block_crc32( uint32_t ulCount, uint8_t *ucBuffer );

#endif // __INCLUDE_GUARD__GPS_H__
8 changes: 8 additions & 0 deletions firmware/Core/Inc/gps/gps_args_helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __INCLUDE_GUARD__GPS_ARGS_HELPERS_H__
#define __INCLUDE_GUARD__GPS_ARGS_HELPERS_H__

#include <stdint.h>

uint8_t GPS_check_starts_with_log_prefix(const char *str);

#endif // __INCLUDE_GUARD__GPS_ARGS_HELPERS_H__
10 changes: 10 additions & 0 deletions firmware/Core/Inc/gps/gps_ascii_parsers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __INCLUDE_GUARD__GPS_ASCII_PARSERS_H__
#define __INCLUDE_GUARD__GPS_ASCII_PARSERS_H__

#include "gps/gps_types.h"

uint8_t GPS_header_response_parser(const char* data_received, GPS_header_response_t *result);
uint8_t GPS_bestxyza_data_parser(const char* data_received, GPS_bestxyza_response_t *result);
uint8_t GPS_timea_data_parser(const char* data_received, GPS_timea_response_t *result);

#endif // __INCLUDE_GUARD__GPS_ASCII_PARSERS_H__
12 changes: 12 additions & 0 deletions firmware/Core/Inc/gps/gps_internal_drivers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#ifndef INCLUDE_GUARD__GPS_INTERNAL_DRIVERS_H__
#define INCLUDE_GUARD__GPS_INTERNAL_DRIVERS_H__

#include <stdint.h>

uint8_t GPS_send_cmd_get_response(const char *cmd_buf, uint8_t cmd_buf_len, uint8_t rx_buf[],
uint16_t rx_buf_len, const uint16_t rx_buf_max_size);

uint8_t GPS_validate_log_response(const char *gps_response_buf);

#endif /* INCLUDE_GUARD__GPS_INTERNAL_DRIVERS_H__ */
188 changes: 188 additions & 0 deletions firmware/Core/Inc/gps/gps_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
#ifndef INCLUDE_GUARD__GPS_TYPES_H
#define INCLUDE_GUARD__GPS_TYPES_H

#include <stdint.h>

// ****************** SECTION: GPS_header_structs ******************

/// @brief This refers to the status that indicates how well a time is known
/// All reported receiver times are subject to a qualifying time status
/// Refer to page 51-53 of the OEM7 Commands and Logs Reference Manual
typedef enum {
GPS_REF_TIME_UNKNOWN = 20,
GPS_REF_TIME_APPROXIMATE = 60,
GPS_REF_TIME_COARSEADJUSTING = 80,
GPS_REF_TIME_COARSE = 100,
GPS_REF_TIME_COARSESTEERING = 120,
GPS_REF_TIME_FREEWHEELING = 130,
GPS_REF_TIME_FINEADJUSTING = 140,
GPS_REF_TIME_FINE = 160,
GPS_REF_TIME_FINEBACKUPSTEERING = 170,
GPS_REF_TIME_FINESTEERING = 180,
GPS_REF_TIME_SATTIME = 200
} GPS_reference_time_status_t;


/// @brief This is the first part of the response that every command response from the GNSS receiver has.
/// Refer to page 34-35 of the OEM7 Commands and Logs Reference Manual
typedef struct {
/// @brief The ASCII name of the log or command e.g., "BESTXYZA" or "TIMEA"
char log_name[128];

/// @brief Indicates the quality of the GPS reference time
GPS_reference_time_status_t time_status;

} GPS_header_response_t;

// ****************** END SECTION: GPS_header_structs ******************


// ****************** SECTION: GPS_data_structs ******************

/// @brief This refers to the solution status
/// Refer to table 90 page 500-501 of the OEM7 Commands and Logs Reference Manual
typedef enum {
GPS_SOL_STATUS_SOL_COMPUTED = 0,
GPS_SOL_STATUS_INSUFFICIENT_OBS = 1,
GPS_SOL_STATUS_NO_CONVERGENCE = 2,
GPS_SOL_STATUS_SINGULARITY = 3,
GPS_SOL_STATUS_COV_TRACE = 4,
GPS_SOL_STATUS_TEST_DIST = 5,
GPS_SOL_STATUS_COLD_START = 6,
GPS_SOL_STATUS_V_H_LIMIT = 7,
GPS_SOL_STATUS_VARIANCE = 8,
GPS_SOL_STATUS_RESIDUALS = 9,
GPS_SOL_STATUS_RESERVED_10_12 = 10, // Since 10-12 are reserved
GPS_SOL_STATUS_INTEGRITY_WARNING = 13
// 14-17 are reserved
} GPS_solution_status_enum_t;


/// @brief This refers to the position or velocity type
/// Refer to table 91 page 501-503 of the OEM7 Commands and Logs Reference Manual
typedef enum {
GPS_TYPE_NONE = 0,
GPS_TYPE_FIXEDPOS = 1,
GPS_TYPE_FIXEDHEIGHT = 2,
GPS_TYPE_RESERVED_3_7 = 3, // Values from 3 to 7 are reserved
GPS_TYPE_DOPPLER_VELOCITY = 8,
GPS_TYPE_RESERVED_9_15 = 9, // Values from 9 to 15 are reserved
GPS_TYPE_SINGLE = 16,
GPS_TYPE_PSDIFF = 17,
GPS_TYPE_WAAS = 18,
GPS_TYPE_PROPAGATED = 19,
GPS_TYPE_RESERVED_20_31 = 20, // Values from 20 to 31 are reserved
GPS_TYPE_L1_FLOAT = 32,
GPS_TYPE_RESERVED_33 = 33,
GPS_TYPE_NARROW_FLOAT = 34,
GPS_TYPE_RESERVED_35_47 = 35, // Values from 35 to 47 are reserved
GPS_TYPE_L1_INT = 48,
GPS_TYPE_WIDE_INT = 49,
GPS_TYPE_NARROW_INT = 50,
GPS_TYPE_RTK_DIRECT_INS = 51,
GPS_TYPE_INS_SBAS = 52,
GPS_TYPE_INS_PSRSP = 53,
GPS_TYPE_INS_PSRDIFF = 54,
GPS_TYPE_INS_RTKFLOAT = 55,
GPS_TYPE_INS_RTKFIXED = 56,
GPS_TYPE_RESERVED_57_67 = 57, // Values from 57 to 67 are reserved
GPS_TYPE_PPP_CONVERGING = 68,
GPS_TYPE_PPP = 69,
GPS_TYPE_OPERATIONAL = 70,
GPS_TYPE_WARNING = 71,
GPS_TYPE_OUT_OF_BOUNDS = 72,
GPS_TYPE_INS_PPP_CONVERGING = 73,
GPS_TYPE_INS_PPP = 74,
GPS_TYPE_PPP_BASIC_CONVERGING = 77,
GPS_TYPE_PPP_BASIC = 78,
GPS_TYPE_INS_PPP_BASIC_CONVERGING = 79,
GPS_TYPE_INS_PPP_BASIC = 80
} GPS_position_type_enum_t;


/// @brief This is the struct for the BESTXYZA Command response.
/// Refer to page 515-517 of the OEM7 Commands and Logs Reference Manual
typedef struct {
/// @brief Position solution status
GPS_solution_status_enum_t position_solution_status;

/// @brief Position type.
GPS_position_type_enum_t position_type;

/// @brief Documentation says the point coordinates come as a double.
/// We store as an int64 because the earth's radius(6.10^6 m) and we are storing the values as millimeters which fits within an int64.
/// Position coordinates in millimeters
int64_t position_x_mm;
int64_t position_y_mm;
int64_t position_z_mm;

/// @brief Documentation says the standard deviation of the position coordinates come as a float.
/// The standard deviation of the position coordinates in millimeters
uint32_t position_x_std_mm;
uint32_t position_y_std_mm;
uint32_t position_z_std_mm;

/// @brief Differential age in seconds. Storing as a uint64 so as to capture the millisecond accuracy
uint64_t differential_age_ms;

/// @brief Solution age in seconds. Storing as a uint64 so as to capture the millisecond accuracy
uint64_t solution_age_ms;

/// @brief 32 bit CRC (ASCII and Binary only).
uint32_t crc;

} GPS_bestxyza_response_t;


/// @brief This refers to the Clock Model Status
/// Refer to table 105 page 526 of the OEM7 Commands and Logs Reference Manual
typedef enum {
GPS_CLOCK_VALID = 0,
GPS_CLOCK_CONVERGING = 1,
GPS_CLOCK_ITERATING = 2,
GPS_CLOCK_INVALID = 3,
} GPS_clock_model_status_enum_t;

typedef enum {
GPS_UTC_INVALID = 0,
GPS_UTC_VALID = 1,
GPS_UTC_WARNING = 2
} GPS_utc_status_enum_t;

/// @brief This is the struct for the TIMEA Command response.
/// Refer to page 941-943 of the OEM7 Commands and Logs Reference Manual
typedef struct {
/// @brief Clock model status
GPS_clock_model_status_enum_t clock_status;

/// @brief /// The offset of GPS system time from UTC time
/// Documentation says the utc offset comes as a double.
int64_t utc_offset;

/// @brief UTC status
/// Refer to page 943 of the OEM7 Commands and Logs Reference Manual
GPS_utc_status_enum_t utc_status;

/// @brief 32 bit CRC (ASCII and Binary only).
uint32_t crc;

} GPS_timea_response_t;

// ****************** END SECTION: GPS_data_structs ******************

// ****************** SECTION: GPS helper functions ******************

uint8_t GPS_reference_time_status_str_to_enum(const char *status_str, GPS_reference_time_status_t *status);
const char* GPS_reference_time_status_enum_to_str(GPS_reference_time_status_t status);
uint8_t GPS_solution_status_str_to_enum(const char *status_str, GPS_solution_status_enum_t *status);
uint8_t GPS_position_type_str_to_enum(const char *type_str, GPS_position_type_enum_t *type);
const char* GPS_position_type_enum_to_str(GPS_solution_status_enum_t status);
const char* GPS_position_type_enum_to_string(GPS_position_type_enum_t type);
uint8_t GPS_clock_model_status_str_to_enum(const char *status_str, GPS_clock_model_status_enum_t *status);
uint8_t GPS_utc_status_str_to_enum(const char *status_str, GPS_utc_status_enum_t *status);
const char* GPS_clock_model_status_enum_to_string(GPS_clock_model_status_enum_t status);
const char* GPS_utc_status_enum_to_string(GPS_utc_status_enum_t status);

// ****************** END SECTION: GPS_header_structs ******************

#endif // INCLUDE_GUARD__GPS_TYPES_H
9 changes: 9 additions & 0 deletions firmware/Core/Inc/rtos_tasks/gps_rtos_tasks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#ifndef __INCLUDE_GUARD__GPS_RTOS_TASKS_H__
#define __INCLUDE_GUARD__GPS_RTOS_TASKS_H__

#include "main.h"

void TASK_receive_gps_info(void *argument);

#endif // __INCLUDE_GUARD__GPS_RTOS_TASKS_H__
14 changes: 14 additions & 0 deletions firmware/Core/Inc/telecommands/gps_telecommand_defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef __INCLUDE_GUARD__GPS_TELECOMMAND_DEFS_H
#define __INCLUDE_GUARD__GPS_TELECOMMAND_DEFS_H

#include "telecommands/telecommand_types.h"

#include <stdint.h>

uint8_t TCMDEXEC_gps_set_enabled(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel,
char *response_output_buf, uint16_t response_output_buf_len);

uint8_t TCMDEXEC_gps_send_log_cmd(const char *args_str, TCMD_TelecommandChannel_enum_t tcmd_channel,
char *response_output_buf, uint16_t response_output_buf_len);

#endif // __INCLUDE_GUARD__GPS_TELECOMMAND_DEFS_H
1 change: 1 addition & 0 deletions firmware/Core/Inc/transforms/arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int16_t GEN_get_index_of_substring_in_array(const char *haystack_arr, int16_t ha

void GEN_uint64_to_str(uint64_t value, char *buffer);
void GEN_uint64_to_padded_str(uint64_t value, uint8_t padding_len, char *buffer);
void GEN_int64_to_str(int64_t value, char *buffer);

uint8_t GEN_hex_str_to_byte_array(const char *hex_str, uint8_t output_byte_array[],
uint16_t output_byte_array_size, uint16_t *output_byte_array_len);
Expand Down
9 changes: 9 additions & 0 deletions firmware/Core/Inc/uart_handler/uart_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ extern volatile uint8_t UART_mpi_rx_last_byte; // Last received byte from the MP
extern volatile uint32_t UART_mpi_rx_last_byte_write_time_ms; // Last write time in milliseconds for MPI response
extern volatile uint16_t UART_mpi_rx_buffer_write_idx; // Write index for MPI response buffer

extern const uint16_t UART_gps_buffer_len; // Length of the UART telecommand buffer
extern volatile uint8_t UART_gps_buffer[]; // Buffer for UART telecommands
extern volatile uint16_t UART_gps_buffer_write_idx; // Write index for UART telecommand buffer
extern volatile uint32_t UART_gps_last_write_time_ms; // Last write time in milliseconds for UART telecommand
extern volatile uint8_t UART_gps_buffer_last_rx_byte; // Last received byte for UART telecommand
extern volatile uint8_t UART_gps_uart_interrupt_enabled; // Set to 1 when a command is sent, and we're awaiting a response


void UART_init_uart_handlers(void);
void GPS_set_uart_interrupt_state(uint8_t toggle_status);


#endif // __INCLUDE_GUARD__UART_HANDLER_H__
14 changes: 14 additions & 0 deletions firmware/Core/Inc/unit_tests/unit_test_gps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef __INCLUDE_GUARD__UNIT_TEST_GPS_H__
#define __INCLUDE_GUARD__UNIT_TEST_GPS_H__

#include <stdint.h>

uint8_t TEST_EXEC__GPS_reference_time_status_str_to_enum();
uint8_t TEST_EXEC__GPS_solution_status_str_to_enum();
uint8_t TEST_EXEC__GPS_position_type_str_to_enum();

uint8_t TEST_EXEC__GPS_header_response_parser();
uint8_t TEST_EXEC__GPS_bestxyza_data_parser();
uint8_t TEST_EXEC__GPS_timea_data_parser();

#endif // __INCLUDE_GUARD__UNIT_TEST_GPS_H__
43 changes: 43 additions & 0 deletions firmware/Core/Src/gps/gps.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "gps/gps.h"
#include <stdint.h>

#define BUFFER_SIZE 256
#define CRC32_POLYNOMIAL 0xEDB88320L

// TODO: Utilize the CRC functions below from the documentation to perform error checking on GPS response
// Refer to Page 56 of the OEM7 Commands and Logs Reference Manual

/// @brief Calculate a CRC value to be used by CRC calculation functions.
/// @param i
/// - Arg 0: variable name
/// @return 32 bit CRC Value
uint32_t GPS_crc32_value(uint8_t i) {
int j;
uint32_t crc;
crc = i;

for ( j = 8 ; j > 0; j-- ) {
if ( crc & 1 )
crc = ( crc >> 1 ) ^ CRC32_POLYNOMIAL;
else
crc >>= 1;
}
return crc;
}

/// @brief Calculates the CRC-32 of a block of data all at once
/// @param ulCount - Number of bytes in the data block
/// @param ucBuffer - Data block
/// @return 32 bit CRC Value
uint32_t GPS_calculate_block_crc32( uint32_t ulCount, uint8_t *ucBuffer ) {
uint32_t temp1;
uint32_t temp2;
uint32_t crc = 0;
while ( ulCount-- != 0 ) {
temp1 = ( crc >> 8 ) & 0x00FFFFFFL;
temp2 = GPS_crc32_value( ((int) crc ^ *ucBuffer++ ) & 0xFF );
crc = temp1 ^ temp2;
}

return( crc );
}
30 changes: 30 additions & 0 deletions firmware/Core/Src/gps/gps_args_helpers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "gps/gps_args_helpers.h"

#include <stdio.h>
#include <stdint.h>
#include <string.h>

/// @brief Checks if the passed string starts with the valid log prefix (LOG, UNLOG and UNLOGALL)
/// @param str The gps log command string to check.
/// @return 0 if str starts with valid log prefix, 1 otherwise.
uint8_t GPS_check_starts_with_log_prefix(const char *str) {

// Copying the passed gps log command into a buffer for parsing
char buffer[100];
strncpy(buffer,str,sizeof(buffer));
buffer[sizeof(buffer) - 1] = '\0';

// Extracting the log prefix from the gps log command
char* token = strtok(buffer, " \t\n");

if (token == NULL) {
return 1;
}

if (strncmp(token, "log", 3) == 0 || strncmp(token, "unlog", 5) == 0 || strncmp(token, "unlogall", 8) == 0) {
return 0;
}

// Error: Token does not start with the log prefix
return 1;
}
Loading