Batch file to create your preferred DMR ID database

Post Reply
KD7MW
Posts: 41
Joined: Sun Feb 06, 2022 4:18 am

Batch file to create your preferred DMR ID database

Post by KD7MW » Fri Feb 25, 2022 7:32 am

As we all know, the GD-77 has limited memory for its DMR ID to callsign/name database. I've written MakeMyDmrDb.bat, a Windows batch file that filters the complete DMR ID database to the user's specifications. I've documented it both with a text file and extensive comments in the batch file itself. As supplied, it creates an output file with all DMR IDs from my home state (Washington) and the adjacent states and Canadian province. You can easily modify it to pass any set of states, provinces, or countries, or any DMR ID prefix or range of prefixes. I'm sharing MakeMyDmrDb.bat with the community here, with thanks for the wonderful OpenGD77 firmware.

Once you modify MakeMyDmrDb.bat to your needs, you can periodically update your user database by downloading the user.csv file from radioid.net, double clicking on MakeMyDmrDb.bat, and uploading the resulting file to your radio. Radioid.net offers similar features for a subscription fee, and OpenGD77 CPS filters by ID prefixes. But MakeMyDmrDb.bat can be set up once, then easily run periodically. It's free, it has no guarantees, it is "use at your own risk," and I hope you find it useful.

MakeMyDmrDb is attached to this message as a Zip file, which contains:
MakeMyDmrDb.bat The batch file
MakeMyDmrDbDocs.txt Documentation
MyCustomDmrIDs.csv A sample file for additional IDs that don't fit the BAT file's search criteria

73 to all,
--Peter, KD7MW
Attachments
MakeMyDmrDb.zip
(4.5 KiB) Downloaded 155 times

kt4lh
Posts: 272
Joined: Sun Jan 12, 2020 4:27 am

Re: Batch file to create your preferred DMR ID database

Post by kt4lh » Fri Feb 25, 2022 4:59 pm

And for Linux, this is what I've used for a long time:

https://gitlab.com/khaytsus/gd77-tools/ ... /csv2id.sh

Note that the script itself says what the radio needs to be set for; 16 chars, use voice memory, and remember to clear out the region in the CPS which seems to always have a default value and it'll filter out anything else.

I really wish there were a command line tool to write these in Linux, my Anytone 878 I have to use the Windows CPS but I can update the contacts in Linux. I've yet to see a way to do that for OpenGD77 which is odd. Maybe I've missed something.

KD7MW
Posts: 41
Joined: Sun Feb 06, 2022 4:18 am

Re: Batch file to create your preferred DMR ID database

Post by KD7MW » Mon Feb 28, 2022 4:57 am

That is a *very* nice shell script. It might be possible but very awkward to duplicate its function in CMD batch language, and it would probably require an external utility or two. I think it would be quite doable in Take Command (which is the successor to 4DOS and 4NT).

kt4lh
Posts: 272
Joined: Sun Jan 12, 2020 4:27 am

Re: Batch file to create your preferred DMR ID database

Post by kt4lh » Mon Feb 28, 2022 1:42 pm

KD7MW wrote:
Mon Feb 28, 2022 4:57 am
That is a *very* nice shell script. It might be possible but very awkward to duplicate its function in CMD batch language, and it would probably require an external utility or two. I think it would be quite doable in Take Command (which is the successor to 4DOS and 4NT).
The logic I wrote, some of the awk voodoo I think I found somewhere else ;) I'm a lazy man, if I gotta do something frequently I'm going to automate as much of it as I can. I have something similar for the Anytone 878, but I can create that data and write it directly in Linux which is super handy, GD77 I gotta fire up my Window VM, copy the file in, etc. Certainly not the end of the world.

K4ED
Posts: 16
Joined: Thu Jan 21, 2021 5:04 pm

Re: Batch file to create your preferred DMR ID database

Post by K4ED » Thu Mar 17, 2022 6:12 pm

Looks like the MacOS version will require small hacks:

dmr-filter.sh: line 56: [: -gt: unary operator expected

Have of data, getting 43000 more from world-wide
dmr-filter.sh: line 72: [: -gt: unary operator expected
dmr-filter.sh: line 76: 48000-: syntax error: operand expected (error token is "-")

If I get it working, I'll post it here.

kt4lh
Posts: 272
Joined: Sun Jan 12, 2020 4:27 am

Re: Batch file to create your preferred DMR ID database

Post by kt4lh » Fri Mar 18, 2022 11:57 am

K4ED wrote:
Thu Mar 17, 2022 6:12 pm
dmr-filter.sh: line 56: [: -gt: unary operator expected
First thing to try is changing the very top line to #!/bin/bash, I normally do this to make 100% sure bash is used, I had forgotten here. You might be running it on some older sh here, I've ran into that issue on some other distros where /bin/sh isn't just bash, bad assumption on my part.

If that doesn't help.... Not sure what "dmr-filter.sh" is, did you change the name from csv2id.sh I guess? Just look at the script and see which variable is empty on line 56, I'm guessing it's $lines, so go backwards from there. Check that curl is getting files, then check that the file referred to as $output is populated with data.

User avatar
F1RMB
Posts: 2627
Joined: Sat Nov 16, 2019 5:42 am
Location: Grenoble, France

Re: Batch file to create your preferred DMR ID database

Post by F1RMB » Fri Mar 18, 2022 12:42 pm

kt4lh wrote:
Fri Mar 18, 2022 11:57 am
K4ED wrote:
Thu Mar 17, 2022 6:12 pm
dmr-filter.sh: line 56: [: -gt: unary operator expected
First thing to try is changing the very top line to #!/bin/bash, I normally do this to make 100% sure bash is used, I had forgotten here. You might be running it on some older sh here, I've ran into that issue on some other distros where /bin/sh isn't just bash, bad assumption on my part.

If that doesn't help.... Not sure what "dmr-filter.sh" is, did you change the name from csv2id.sh I guess? Just look at the script and see which variable is empty on line 56, I'm guessing it's $lines, so go backwards from there. Check that curl is getting files, then check that the file referred to as $output is populated with data.
Quick looking at the script, it's always a bad idea to not surround variables with double quotes, as the variable could be empty at some point, hence condition testing will trigger a syntax error, e.g:

Code: Select all

if [ ${lines} -gt ${max} ]; then
vs

Code: Select all

if [ "${lines}" -gt "${max}" ]; then

About the first line, it's better to use:

Code: Select all

#!/usr/bin/env bash
than

Code: Select all

#!/bin/sh
as the shell could be installted on unusual location on some systems.

But yes, at least, it should be /bin/bash, as /bin/sh is a link on most system, but could be defaulted to tcsh or any non bash shell.
And this script is definitely using bash syntax.


Cheers.
---
Daniel

kt4lh
Posts: 272
Joined: Sun Jan 12, 2020 4:27 am

Re: Batch file to create your preferred DMR ID database

Post by kt4lh » Fri Mar 18, 2022 5:53 pm

F1RMB wrote:
Fri Mar 18, 2022 12:42 pm
Quick looking at the script, it's always a bad idea to not surround variables with double quotes, as the variable could be empty at some point, hence condition testing will trigger a syntax error, e.g:
Yes, I usually do that with strings but was thinking that numeric comparisons this would not work, but in a quick test it does seem to.

Either way it demonstrates an issue somewhere above the conditional; not the conditional itself. Either of these two values being empty is a failure somewhere.

Post Reply