Read/write GD-77 codeplug in Linux in Python 3 (experimental)

larsks
Posts: 5
Joined: Mon Oct 26, 2020 12:22 pm

Re: Read/write GD-77 codeplug in Linux in Python 3 (experimental)

Post by larsks » Wed Oct 28, 2020 11:35 am

Hey folks,

I was starting down the same path (writing a Linux utility for interacting with the GD77), and it's great to find that other people have already done some development work!

I have a question about the serial port protocol. Looking at the source for the CPS, the sendCommand method (in Extras/OpenGD77/OpenGD77Form.cs) appears to validate commands by checking the response from the radio for:

Code: Select all

((readbuffer[0] == sendbuffer[0]) && (readbuffer[1] == sendbuffer[1]))
I see the same check in the GD77transfer.py script posted in this thread. However, even though the code in GD77transfer.py works (it displays text on the screen and downloads the codeplug), it looks like it only works because it ignores the return value of the sendCommand method. The radio always returns "-", so sendCommand always returns False.

The code in https://github.com/kzyapkov/opengd77xfer solves the problem by just explicitly checking for "-" as a response.

The radio must produce a valid response for CPS, because CPS includes this check:

Code: Select all

if (!sendCommand(0))
{
        displayMessage("Error connecting to the OpenGD77");
        dataObj.responseCode = 1;
        break;
}
...which would only succeed if that validation at the end of sendCommand returns true, but I can't produce this behavior working with the serial communication code in either GD77transfer.py or in https://github.com/kzyapkov/opengd77xfer.

What's going on here?

oh1fss
Posts: 31
Joined: Mon May 04, 2020 11:53 am

Re: Read/write GD-77 codeplug in Linux in Python 3 (experimental)

Post by oh1fss » Wed Nov 18, 2020 4:58 pm

I have extended the program to read/write codeplugs to OpenGD77 radios. Now you can backup the calibration, flash, EEPROM and MCU ROM using the program. I have tested the program in Linux (Fedora 33) using Python 3.9 with Baofeng DM 5R Plus running OpenRD5R.

The old functionality of the previous version (dated 24 May 2020) is intact. All old options work the same.

So to read codeplug from OpenGD77 radios:

./GD77transfer.py -r -f MyCodePlug.g77

and write it back to radio:

./GD77transfer.py -w -f MyCodePlug.g77

The memory segments can be backed up with the following commands:

./GD77transfer.py -o calibration -r -f calibration.bin
./GD77transfer.py -o flash -r -f flash.bin
./GD77transfer.py -o eeprom -r -f eeprom.bin
./GD77transfer.py -o mcurom -r -f mcurom.bin

To restore those files back to radio use the CPS. I have not tested that...

Also I fixed a bug in function initEmptyCodeplug(). The program worked correctly despite of the bug.
Attachments
GD77TRANSFER-201118.tgz
GD77TRANSFER-201118.tgz
(4.12 KiB) Downloaded 43 times

W9YA
Posts: 26
Joined: Sun Sep 06, 2020 4:16 am
Location: DM65pd38
Contact:

Re: Read/write GD-77 codeplug in Linux in Python 3 (experimental)

Post by W9YA » Thu Feb 11, 2021 8:48 pm

Great stuff OM...mny tnxs agn !!

es vy 73 de "baab" w9ya

VK3KYY
Posts: 3491
Joined: Sat Nov 16, 2019 3:25 am
Location: Melbourne, Australia
Contact:

Re: Read/write GD-77 codeplug in Linux in Python 3 (experimental)

Post by VK3KYY » Thu Feb 11, 2021 9:55 pm

oh1fss wrote:
Sun May 24, 2020 9:31 am
CPS (MainForm.cs, function openCodeplugFile()) checks the first 8 bytes of the codeplug file that it opens. Those 8 bytes must be FF or contain the current radio model. Otherwise you get error "Model does not match".

So I should set all gaps that are not read from the radio as FF - is that enough?

Those gaps are not written to the radio.
I don't know.

I reverse engineers the CPS from the official CPS Exe.

You'll need to do whatever makes your code compatible with whatever the CPS code currently does.

The firmware does not check the codeplug in any way.

ok3js
Posts: 9
Joined: Wed Apr 22, 2020 3:15 pm

Re: Read/write GD-77 codeplug in Linux in Python 3 (experimental)

Post by ok3js » Mon Mar 22, 2021 11:00 am

on openGD77 in DM1801 (openSuse Tumbeweeld) GD77TRANSFER-201118

ok3js@install:~/DMR> python3 GD77transfer.py -r -o mcurom -f test.gd77
- reading 0x80000 bytes: 100%
Traceback (most recent call last):
File "GD77transfer.py", line 476, in <module>
main()
File "GD77transfer.py", line 458, in main
getBackup(ser,filename,MODE_READ_MCUROM,0,512*1024,"MCU ROM")
File "GD77transfer.py", line 382, in getBackup
with open(filename,'wb') as f:
PermissionError: [Errno 13] Permission denied: 'test.gd77'


edit:
partially resolved, problem with rights, under root (su) it runs,

edit
error with me, I created a directory under root and the application did not have the right to save to this directory.

W9YA
Posts: 26
Joined: Sun Sep 06, 2020 4:16 am
Location: DM65pd38
Contact:

Re: Read/write GD-77 codeplug in Linux in Python 3 (experimental)

Post by W9YA » Mon Mar 22, 2021 12:45 pm

Um.....it's a bad idea to run as root user. Using sudo is preferred. I do not reqiire either to run GD77transfer.py ! ...... I use my stock archlinux machine for such chores. (Been using it since 2013, with updates to the latest software.)

Post Reply