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

Tidy up various code (main, gps) #34

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

tormodvolden
Copy link
Contributor

@tormodvolden tormodvolden commented Jan 21, 2022

These changes should not affect the functionality at all, and are mostly "cosmetic" code cleanup. Only the debug output concerning GPS will have some visible changes. And there is a new debug feature: GPS raw data output with AT+LOGGPS=2.

tormodvolden and others added 29 commits March 18, 2022 13:49
This reverts commit 9e15412.

The commit had inadvertently reverted many previous changes and
also contains several independent changes, some of which are not
necessary.
This file doesn't need to be under revision control.
The current firmware is using the three flash pages at 0x08018F80,
0x08019000, and 0x08019080 for storing settings.

Lay out the firmware so that a hole at 0x08018800 - 0x0801A000 is
reserved for settings.

Signed-off-by: Tormod Volden <[email protected]>
Signed-off-by: Tormod Volden <[email protected]>
Improve variable scope and names, and use integer calculation. This
rework shouldn't change the resulting values.

Signed-off-by: Tormod Volden <[email protected]>
A constant or macro with a good name could be better.

Signed-off-by: Tormod Volden <[email protected]>
We don't need so many timestamps.

Signed-off-by: Tormod Volden <[email protected]>
The function was doing many things apart from debug printing, so rename it
and move some parts to the caller for better readability.

Signed-off-by: Tormod Volden <[email protected]>
And use AT_PRINTF consistently otherwise.

Signed-off-by: Tormod Volden <[email protected]>
Check if any buffers were updated, not only the last.

Only dump buffers if any of them were updated.

Allow LOGGPS levels higher than 1.

Signed-off-by: Tormod Volden <[email protected]>
Use the non-polling PRINTF which might lose data if it gets too busy,
but is also less prone to affect operation.

Signed-off-by: Tormod Volden <[email protected]>
Print UTC time instead of hard-coded +0800 local time.

Also print all timestamp elements with 2 digits, and
make latitude and longitude output consistent.

Signed-off-by: Tormod Volden <[email protected]>
Signed-off-by: Tormod Volden <[email protected]>
@tormodvolden
Copy link
Contributor Author

I have rebased this on top my other PR #35. It now also includes the remaining change from #11.

The most important location data on one line.

Signed-off-by: Tormod Volden <[email protected]>
This has currently higher risk of deadlocking but is also necessary
to not miss debug info.

Signed-off-by: Tormod Volden <[email protected]>
Each word is checked against NULL in GPS_parse() but if a field is
missing, split() would return a valid pointer to a zero-length
string. The subsequent parsing with sscanf() would yield random
coordinates calculated from uninitialized stack variables.

By returning NULL instead of an empty string, we'll match the logic
in gps_parse() and the exisiting checks will work correctly.

Fixes dragino#26

Signed-off-by: Tormod Volden <[email protected]>
Avoid using uninitialized values in coordinate calculation due to
incomplete data strings.

Signed-off-by: Tormod Volden <[email protected]>
The buffer overflow is guarded against already. This code was
randomly deleting sentences every 255 characters - about every
fourth sentence.

Signed-off-by: Tormod Volden <[email protected]>
This simplifies the check() function and further parsing.

Signed-off-by: Tormod Volden <[email protected]>
@tormodvolden
Copy link
Contributor Author

The newly added changes also fix serious bugs, such as #26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants