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

Various typos #2

Merged
merged 5 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
for dev, direction, string in protocol:
print("%s %s%s" % (dev, "> " if direction == "0" else " < ", repr(string)[1:-1]))

elif mode == "extract":
elif mode == "dump":
Copy link
Owner

Choose a reason for hiding this comment

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

We should leave the terminology at "dump / flash". It's a somewhat established standard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I figured.

The convert.py script has “usage” documentation for a mode called dump, but a part of your implementation in fact expects extract. Clearly a typo. This change fixes that in favour of dump.

(Not sure if perhaps convert.py is no longer necessary and should be removed entirely under #14.)

start_address = None
prev_address = None
for dev, direction, string in protocol:
Expand Down
10 changes: 5 additions & 5 deletions hx870dat.bt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// File: hx870dat.bt
// Authors: Christiane Ruetten
// E-Mail: [email protected]
// Version: 0.1a
// Version: 0.1.1a
// Purpose: Parsing Standard Horizon HX870 DAT files
// Category: HF Radio
// File Mask: *.dat
// ID Bytes: 03 67 01 00 00 00 00 00
// ID Bytes: 03 67
// History: Based on https://johannessen.github.io/hx870/
//------------------------------------------------

Expand All @@ -21,7 +21,7 @@ BigEndian();

// Magic Bytes -----------------------------------
FSeek(0x0000);
uint16 MagicPrefix <bgcolor=0xff00cc00>; // always 0x0361 (871)
uint16 MagicPrefix <bgcolor=0xff00cc00>; // always 0x0367 (871)


// 0002 Radio Status -----------------------------
Expand Down Expand Up @@ -56,7 +56,7 @@ enum <ubyte> _MultiWatch { MW_DUAL, MW_TRIPLE };
enum <ubyte> _ScanType { ST_MEMORY, ST_PRIORITY };
enum <ubyte> _EmergencyLED { EL_CONTINUOUS, EL_SOS, EL_BLINK1, EL_BLINK2, EL_BLINK3 };
enum <ubyte> _WaterHazardLED { WH_OFF, WH_ON, WH_ON_POWER_ON };
enum <ubyte> _Lamp { L_OFF, L_3S, L_5S, L_10S, L_20S, L_30S, L_CONTINUOUS };
enum <ubyte> _Lamp { L_OFF, L_3S, L_5S, L_10S, L_CONTINUOUS, L_20S, L_30S };
Copy link
Owner

Choose a reason for hiding this comment

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

I think this was one of the places where I found an error in your data, and I double checked in my device that the enum order is indeed L_CONTINUOUS last. Can you verify this?

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 know I double-checked this before making this change in your template. I’ve just checked again just to be safe, and my radio is currently set to 30 s, which is coded as 0x06.

So, in this particular case, the error does appear to be in your data. (I know I made errors in other fields, which your template helped me to correct.)

FWIW, I believe the first HX870 firmware versions didn’t offer the 20 s and 30 s settings. That’s why they’re at the end: They were added later than the “continuous” setting was. But I don’t seem to have a source to back this up, so it may just be conjecture on my part.

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for checking.

enum <ubyte> _AFPitchCONT { A_NORMAL, A_HIGH_LOW_CUT, A_HIGH_LOW_BOOST, A_LOW_BOOST, A_HIGH_BOOST };
enum <ubyte> _BatterySave { BS_OFF, BS_50, BS_70, BS_80, BS_90 };
enum <ubyte> _VOXDelayTime { V_0_5S, V_1S, V_1_5S, V_2S, V_3S };
Expand Down Expand Up @@ -94,9 +94,9 @@ struct _RadioConfiguration { // start: 0020
// Channels Setup continued
_OffOn VOX;
ubyte VOXLevel; // 0..4
ubyte _unknown0044 <format=hex, bgcolor=cBlack>; // always 00
_VOXDelayTime VOXDelayTime;
_OffOn NoiseCancelRx;
ubyte NoiseCancelRxLevel; // 0..3
_OffOn NoiseCancelTx;
ubyte _unknown0046 <format=hex, bgcolor=cBlack>; // always 00
ubyte _unused0047[3] <format=hex>; // always ff
Expand Down
12 changes: 6 additions & 6 deletions hxtool/cli/gpslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run(self):

stat = hx.comm.read_gps_log_status()
logger.info(f"Log size {stat['pages_used'] * 4}kB, "
f"{stat['slots_used']} waypoints, "
f"{stat['slots_used']} trackpoints, "
f"{stat['usage_percent']}% full")
if stat["full_stop"]:
logger.warning("Log is full. Logging is halted until erased")
Expand Down Expand Up @@ -116,14 +116,14 @@ def decode_gps_log(data: bytes) -> dict or None:
log = {
"header": hexlify(log_header).decode("ascii"),
"unknown": hexlify(unknown).decode("ascii"),
"waypoints": []
"trackpoints": []
}

offset = 0x40
while offset <= len(data) - 20:
if data[offset:offset+4] == b"\xff\xff\xff\xff":
break
log["waypoints"].append(unpack_log_line(data[offset:offset+20]))
log["trackpoints"].append(unpack_log_line(data[offset:offset+20]))
offset += 20

return log
Expand All @@ -146,7 +146,7 @@ def write_gpx(log_data: bytes, file_name: str) -> int:
gpx_track.segments.append(gpx_segment)

# Create points:
for point in log["waypoints"]:
for point in log["trackpoints"]:
p = gpxpy.gpx.GPXTrackPoint(
latitude=point["latitude"],
longitude=point["longitude"],
Expand All @@ -169,7 +169,7 @@ def write_json(log_data: bytes, file_name: str) -> int:
if log is None:
logger.warning("Log is blank. Not writing empty JSON log")
return 0
for w in log["waypoints"]:
for w in log["trackpoints"]:
w["utc_time"] = w["utc_time"].isoformat()
with open(file_name, "w") as f:
dump(log, f, indent=4)
Expand All @@ -195,7 +195,7 @@ def dump_log(log_data):
if log is None:
logger.info("Log is blank. Nothing to print")
return 0
for wp in log["waypoints"]:
for wp in log["trackpoints"]:
lat_deg, lat_min = to_hm(wp['latitude'])
lat_dir = 'N' if lat_deg >= 0 else 'S'
lon_deg, lon_min = to_hm(wp['longitude'])
Expand Down
2 changes: 1 addition & 1 deletion hxtool/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def enumerate_model(hx_device) -> list:

class HX870(object):
"""
Device object for Standard Horizon HX890 maritime radios
Device object for Standard Horizon HX870 maritime radios
"""
handle = "HX870"
brand = "Standard Horizon"
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
'hx890', 'hx890e', 'firmware', 'flashing', 'mmsi', 'atis'],
author='Christiane Ruetten',
author_email='[email protected]',
url='https://github.com/cr/pyhx870',
download_url='https://github.com/cr/pyhx870/archive/master.tar.gz',
url='https://github.com/cr/hx870',
download_url='https://github.com/cr/hx870/archive/master.tar.gz',
Copy link
Owner

Choose a reason for hiding this comment

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

Good catch! I have a latest tag in all my other projects and didn't notice that this link doesn't work without. I wonder where else this is broken...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That I can’t tell you. But I’m afraid your repository is called hx870, not pyhx870, so the links are still broken…

license='GPLv3',
packages=find_packages(exclude=["tests"]),
include_package_data=True, # See MANIFEST.in
Expand Down