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

Refresh repo #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,25 @@ The tool supports reading and writing in the original binary format:
gd77xfer -p /dev/myradio read my-codeplug.g77
gd77xfer -p /dev/myradio write my-codeplug.g77

Reading-writing whole EEPROM:

gd77xfer -p /dev/myradio backup_eeprom my-eeprom.g77eeprom
gd77xfer -p /dev/myradio restore_eeprom my-eeprom.g77eeprom

The intention is to support import/export to yaml, but currently only export
is implemented

gd77xfer export my-codeplug.g77 my-codeplug.yml


## Contribution

python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python opengd77/xfer.py ....


## Copyright

This code was originally published on
Expand Down
Empty file added opengd77/__init__.py
Empty file.
28 changes: 14 additions & 14 deletions opengd77/xfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ def main():
else:
write_yaml(cp, args.file)

log.info(f"Read codeplug from {args.port} into {args.file}")
log.info(f"Read codeplug from {args.port} into {args.file.name}")

elif args.cmd == 'write':
log.info(f"Writing codeplug from {args.file} into {args.port}")
log.info(f"Writing codeplug from {args.file.name} into {args.port}")
cp = Codeplug.from_file(args.file)
radio = OpenGD77Radio(args.port)
radio.write_codeplug(cp)
log.info(f"Wrote {args.file} into {args.port}")
log.info(f"Wrote {args.file.name} into {args.port}")

elif args.cmd == 'export':
log.warning(f"export {args}")
Expand All @@ -156,31 +156,31 @@ def main():
cp = read_from_radio(args.port)

write_yaml(cp, args.output_file)
log.info(f"Exported data from {src} into {args.output_file}")
log.info(f"Exported data from {src} into {args.output_file.name}")

elif args.cmd == 'import':
# TODO: finish export logic
cp = Codeplug.from_file(args.output_file)
yaml = YAML()
with open(args.input_file, 'rb') as f:
yml = yaml.load(f.read())

elif args.cmd == 'backup_calib':
if not args.file.endswith('.g77calib'):
args.file = f"{args.file}.g77calib"
log.info(f"Storing calibration from {args.port} to {args.file}")
log.info(f"Storing calibration from {args.port} to {args.file.name}")
if not args.file.name.endswith('.g77calib'):
log.info("We strongly recommend to use .g77calib extension")
radio = OpenGD77Radio(args.port)
data = radio.read_calibration()
with open(args.file, 'wb') as f:
f.write(data)
args.file.write(data)


elif args.cmd == 'backup_eeprom':
if not args.file.endswith('.g77eeprom'):
args.file = f"{args.file}.g77eeprom"
log.info(f"Storing EEPROM from {args.port} to {args.file}")
log.info(f"Storing EEPROM from {args.port} to {args.file.name}")
if not args.file.name.endswith('.g77eeprom'):
log.info("We strongly recommend to use .g77eeprom extension")
radio = OpenGD77Radio(args.port)
data = radio.read_eeprom()
with open(args.file, 'wb') as f:
f.write(data)
args.file.write(data)

# elif args.cmd == 'restore_calib':
# elif args.cmd == 'restore_eeprom':
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pyserial==3.5
ruamel.yaml==0.18.2