Skip to content

GPS Bug 63 + Developer Tutorial Clean#76

Merged
kb1lqd merged 38 commits intomasterfrom
Developer_Tutorial_Clean_Lastcommit
Feb 18, 2017
Merged

GPS Bug 63 + Developer Tutorial Clean#76
kb1lqd merged 38 commits intomasterfrom
Developer_Tutorial_Clean_Lastcommit

Conversation

@kb1lqd
Copy link
Contributor

@kb1lqd kb1lqd commented Feb 17, 2017

Combining Pull request #68 and a developer tutorial cleanup. Accidentally edited both into a single branch and it's easier to just push them both through.

GPS Bug

Fixed #63 and updated other similar items.

  • Added length test status and check for global failure to deviceconfig.py so that data too long errors (could update to truncation later if wanted) and displays on deviceconfiguration.py script command prompt
  • Added other generic length checks for good practice to key fields in device configuration
  • Added custom leading/trailing padding packet creation functions in commandmodule.py to pad data with specific bytes
  • Force all Lat, Lon, Alt to match NMEA standards for formatting exept that it allows both leading/trailing padding '0' for Lat/Lon
  • Lat/Lon/Alt check for incorrect formatting and auto-correct where possible but otherwise error to avoid mis-configuration
  • Updates disallow negative altitude for now (issues handling the negative) for default programmed GPS configuration location

Device Configuration (General)

  • Added non-inline INI file comments for format descriptions

#Developer Tutorial Cleaning

  • Deleted a number of old tutorial files/directories leaving only the intended ..\Faraday-Software\Tutorials\Python_Developer_Tutorials
  • Fixed basic formatting (minor) and typo's in tutorials 1-Basic_Proxy_Interactions_And_Programming tutorials 0 through 3
    • Updated to generic callsign and ID "REPLACEME"

Brenton Salmi added 30 commits February 11, 2017 11:20
Added global failure that prevents programming from occuring if a length
is too long.,
Force all GPS lat/lon/alt to float and also create packet with ASCII
padding (0x30 for 0's) just like NMEA ASCII uses.
Update fields to generic configurations.
Working com port variable for scripter.
Test.py is programming from command line!
Single BAT file for running working. Not as cleanly modular as I'd like
to much better than before.
Finished the example and tutorial first pass.
Fixed absolute links that were broken to relative for GitHub.
Deleted and renamed folders to better organize.
Changed to REPLACEME's

local_device_callsign = 'REPLACEME'  # Should match the connected
Faraday unit as assigned in Proxy configuration
local_device_node_id = REPLACEME  # Should match the connected Faraday
unit as assigned in Proxy configuration
Proxy config
Just inserted a few newlines to clean up output.
#68 (review)

* Prepend instead of append Zero's
* Do not convert to float, all Lat, Lon, Alt remains ASCII string
* Fixed bug in the submitted deviceconfig.py that padded ALTITUDE with
the ALTITUDE_UNIT length (1 instead of 8 bytes)
Removed some engineering data prints.
Brenton Salmi added 4 commits February 15, 2017 00:42
Cleaned up debug code in device config.
Moved inline INI comments to non-inline.
@kb1lqd kb1lqd mentioned this pull request Feb 17, 2017
@kb1lqd kb1lqd requested a review from kb1lqc February 17, 2017 09:12
@kb1lqd kb1lqd added this to the Initial Code Release milestone Feb 17, 2017
units=1
unit0call=REPLACEME
unit0id=REPLACEME No newline at end of file
unit0call= REPLACEME
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: do you have a style reference for your .ini files? Do you want a space between = and REPLACEME

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am open to suggestions @hdkmike , I like the idea of sticking towards what originally seems to be the case of no spaces. Example wikipedia

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought as well. I vote for sticking with that.

padded_data = pad + data
return padded_data


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: How many newlines do you put between top level defs? For me, it's usually 2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're trying to move towards PEP8 or at least very close to it. I believe it's 2 in there as well. We've been scrambling to get functionality and tutorials updated so lots missed in the last few days and in general. Thanks for pointing out! You;re welcome to clone this branch and fix up some styling towards PEP8. That would be super helpful!

self.rf_default_boot_freq = [freq_list[2], freq_list[1], freq_list[0]]
self.rf_PATable = patable_byte
return True

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: Method definitions inside a class are surrounded by a single blank line.

altitude_str = commandmodule.create_fixed_length_packet_leading_padding(str(float(altitude_str)),
self.MAX_ALTITUDE_LEN, 0x30)


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: Too many blank lines between statements

gps = pkt_struct_gps.pack(self.gps_latitude, self.gps_latitude_dir, self.gps_longitude, self.gps_longitude_dir,
self.gps_altitude, self.gps_altitude_units, self.gps_boot_bitmask)


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: too many blank lines between statements

units=1
unit0call=REPLACEME
unit0id=REPLACEME No newline at end of file
unit0call= REPLACEME
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought as well. I vote for sticking with that.

@kb1lqc
Copy link
Member

kb1lqc commented Feb 18, 2017

Checked simply programming a unit with bogus but valid data. Latitude, Longitude and altitude appeared to have updated nominally:
image

image

Moving to 9999.99 meters altitude and South/East coordinate direction also appeared nominal:
image

kb1lqc
kb1lqc previously requested changes Feb 18, 2017
Copy link
Member

@kb1lqc kb1lqc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left lots of comments. Overall I agree with @hdkmike that we should improve formatting more towards PEP8 but I think we should let it pass on this commit. Let's get good functionality and then in a new pull request attack code style.

Overall the update appears to work but I did not physically test bootstrap loading. You need to sanitize input better per my comments and possibly some I missed.

I am not sure why you are moving the Tutorials folder?

"""
pad_len = fixed_legth - len(data)
pad = chr(padding_byte) * pad_len
pad = pad
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pad = pad?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, pretty much does what it says.

Removed on all 3 padding functions.

:Example:

>>> pack_data("Test data message", 20, 0x30)
'Test data message\x00\x00\x00'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're example differs from the example code output. When I chr(0x30) I get "000" which is not "\x00\x00\x00"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to show a better example for all 3 padding functions:

image

image

image

"""
pad_len = fixed_legth - len(data)
pad = chr(padding_byte) * pad_len
pad = pad
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again why pad=pad?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed as stated above.

:Example:

>>> pack_data("Test data message", 20, 0x30)
'\x00\x00\x00Test data message'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again your example differs from the input 0x30 padding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #76 (comment)

Fixed.

return padded_data


def create_fixed_length_packet_padding(data, fixed_legth, padding_byte):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be less brute force by doing something similar to what I did in my aprs.py formatting:

https://github.com/FaradayRF/Faraday-Software/blob/master/Applications/APRS/aprs.py#L137
For example I performed
latDec = str("%.2f" % latDec).zfill(5)

This rounded an input float to two decimal places followed by string conversion. Then ensured the entire string was five characters long, including the decimal point, appending zeros (strings) to the end to fill up.

To do leading Zeros you could split() the string at the decimal point and take the int to the left of the decimal and then use string formatting with something like ("%02d" % int(a)).zfill(5) which would fill up to five characters with leading zeros. Then join*() the strings back together. This uses built in functions in a pretty straightforward way to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point for Zfill on the leading zeros but what about trailing? I can use Zfill and remove trailing zero support completely but how would I ensure the size 4 bytes on righthand decimal side?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing zeros is exactly what the "%.2f" above does. Notice the two different formatting statements.

import array
import sys

#filename = sys.argv[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Committing a bunch of commented out code?

self.CreateOutputFile()
self.CreateBslScript()

# ParseTiTxtHexFile(file_program_hex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code?


def CreateBslScript(self):
#global device_com_port
#com_string = 'MODE 6xx UART 9600 COM%d PARITY' % device_com_port
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old string?

@@ -55,7 +55,7 @@ To run the code example we've placed hello-world.py in the start folder
Ensure that Proxy is running in the background!

### Linux (Debian-based)
* Navigate in terminal to `/git/faraday-software/Tutorials/start` and run `sudo python hello-world.py`
* Navigate in terminal to `/git/faraday-software/Python_Developer_Tutorials/start` and run `sudo python hello-world.py`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing this? I direct faradayrf.com/start to the readme in Tutorials/start, we need to coordinate this.

@@ -19,7 +19,7 @@
import os
import sys
sys.path.insert(0, os.path.abspath('../Faraday_Proxy_Tools/FaradayIO')) #FaradayIO toolset
sys.path.insert(0, os.path.abspath('../Tutorials/FaradayIO/Tutorial_0')) #FaradayIO toolset
sys.path.insert(0, os.path.abspath('../Python_Developer_Tutorials/FaradayIO/Tutorial_0')) #FaradayIO toolset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why changing? Needs coordination.

Brenton Salmi added 4 commits February 17, 2017 23:46
Fixed padding function examples to have more accurate examples.
For callsign, callsign id, and GPIO defaults.
Min and Max allowable frequency.
@kb1lqd
Copy link
Contributor Author

kb1lqd commented Feb 18, 2017

@kb1lqc This pull request has changed from fixing the noted issue for GPS into a "implement complete configuration file checking"

@kb1lqd kb1lqd dismissed kb1lqc’s stale review February 18, 2017 09:17

Updated a few relavent ones but this is just crazy out of scope for this puyll request. Will make future issue enhancement. All intended updates are shown working, optimized or not.

@kb1lqd
Copy link
Contributor Author

kb1lqd commented Feb 18, 2017

#80

Copy link
Member

@kb1lqc kb1lqc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made my comments and overall we just need the fixes this offers. We'e created issue tickets for relevant fixes we know need to be made to these files. Time to move on.


>>> pack_data("Test data message", 20)
>>> testdata = create_fixed_length_packet("Test data message", 20)
>>> print repr(testdata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should eventually remove test print cases

>>> pack_data("Test data message", 20, 0x30)
'Test data message\x00\x00\x00'
>>> testdata = create_fixed_length_packet_padding("Test data message", 20, 0x7E)
>>> print testdata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should eventually remove

>>> pack_data("Test data message", 20, 0x30)
'\x00\x00\x00Test data message'
>>> testdata = create_fixed_length_packet_leading_padding("Test data message", 20, 0x7E)
>>> print testdata
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should eventually remove

Copy link
Member

@kb1lqc kb1lqc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've made necessary fixes and created relevant issue tickets for more thorough checks and formatting. Let's move on.

@kb1lqd kb1lqd merged commit 8e9b19c into master Feb 18, 2017
@kb1lqc kb1lqc deleted the Developer_Tutorial_Clean_Lastcommit branch March 4, 2017 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants