The recent Tytera MD-380, also known as Retevis RT-3, is very nice DMR portable UHF rig. However, one of its weak points is the programming software. While DMR for utility use often requires simple programming, when used for HAM radio, the big and evolving number of available repeaters, users and zones makes programming a big hassle.
The included programming software allows to do basic editing of the codeplug, but all the job has to be done manually. Inserting hundreds of records by hands is not what we expect to be doing in the computer era. Unfortunately the programming software does not have an export/import feature.
The specification of the binary format of the codeplug is available at this link.
The rdt2csv utility
This is why I studied the binary format of the codeplug, a file with extension .rdt that is saved and loaded by the Tytera/Retevis programming utility, and created rdt2csv, a command line utility that exports and imports the contents in CSV files.
CSV files are text files organized in lines, where each line is divided in fields, as specified by rfc4180. These files can be processed by Excel or OpenOffice Calc, editted with a simple text editor or processed by automatic utilities.
The rdt2csv utility exports the various tables in different CSV files. For example, it exports a file for the Channel Information table, adding one line for every defined channel. Same it does for the Zone Information, for the Scan List, the Digital RX Group List and so on.
Single entries, like General Settings, is exported as a CSV file containing a single line.
Note: from build 19020, rdt2csv detects and handles also the .bin/.img files generated by the md380-dfu command from the md380tools.
Cross tables references
The codeplug records contain references to each other. For example, inside a “Channel Information” the “Contact Name” field is a reference of a record in the “Digital Contacts” list. The codeplug stores this reference as the position in the target table: for example, if channel “ABC” has “Contact Name” internally set to 3, it means that it refers to the third entry of the “Digital Contacts” list. Maybe this is one of the reasons why the programming software does not allow to change the position of the records, who known.
The rdt2csv utility. instead of the number, uses the “Name” field of the referenced record. For example, if an exported channel has Contact Name referencing “John”, it will be exported as “John” and not using the internal number. In this way, the order of the records can be changed in the CSV files without loosing the right references.
Using the rdt2csv utility
rdt2csv is a command-line utility. This means that you will have to open an old “DOS” window and type in the command with parameters. I might later release a graphic version of this utility.
This is the command line help:
rdt2csv r.19000 - (c)2016 by Davide Achilli IZ2UUF - email@example.com USAGE: rdt2csv [-e|-u] <file.rdt> [-sc|-tab] <csv-files> -e export .rdt file to listed .csv files -u update .rdt file from listed .csv files -sc use semicolon (;) as CSV separator instead of comma -tab use tab as CSV separator instead of comma <csv-files>: -ch .csv filename for ChannelInformation -cont .csv filename for DigitalContact -rxgrp .csv filename for DigitalRxGroupList -gen .csv filename for GeneralSettings -scan .csv filename for ScanList -txt .csv filename for TextMessage -zone .csv filename for ZoneInformation This program can be freely redistributed.
Export from .rdt file
If the -e parameter is specified, the program will read the indicated .rdt file and it will export its contents in the listed .csv files.
rdt2csv -e myCodeplug.rdt -ch channels.csv -scan scan.csv
The example above reads the codeplug myCodeplug.rdt and exports its “Channel Information” table into a file called “channels.csv” and its “Scan List” in a file called “scan.csv”.
Update the rdt file
If the -u parameter is specified, the program will read the listed .csv files and merge their contents in the indicated .rdt file.
rdt2csv -u myCodeplug.rdt -ch channels.csv -scan scan.csv
The example above reads the files called “channels.csv” and “scan.csv” and merges them in the indicated codeplug myCodeplug.rdt. The word merging means that, in the example above, all the channels will be overwritten by “channels.csv”, all the scan lists will be overwrittend by “scan.csv”, but all the other information stored in the codeplug will not be touched.
The rfc4180 specification defines a CSV file to be separated by commas. After all, “CSV” is an acronym for “Comma Separated Values”. However, in many countries, including Italy, comma is used as decimal separator instead of the usual dot. For this reason, programs like Excel, when used in such countries, use a semicolon or a tab as separator. These separators can be used specifying the parameters -sc (semicolon) or -tab (tabulator).
Tables and fields
The CSV files are required to have headers. In other words, the first line is to be dedicated to give a name to each column. For example:
CallId,CallReceiveTone,CallType,Name 5057,on,private,"APRS Server" 2229192,on,group,"Wires-X" 1,off,group,"TG1 WW"
The names of the columns (i.e. “CallId”, “CallReceiveTone”, etc.) are specified in the description below. Also, some cells are required to assume one among some listed values. For example “CallType” can be one among group, private, all. Any other string will be refused.
The valid names and values for every available table are described in the tables below.
DISCLAIMER: use this utility at your own risk. I give no guarantee that the modified codeplugs will not brick your radio or cause other issues.
DISCLAIMER: this is a beta version, please help testing and report problems and suggestions! Thank you.
Download R.20974: rdt2csv.exe
Source code can be downloaded at macrocoding.tech.
Linux/MacOS/etc. users, hold on a little: I’m about to publish sources to allow building on any platform. The program is written in ANSI-C without any library call other than usual stdio/string/stdlib stuff: it can be built as-is on any platform.
05-June-2016 – Build 19004
– added support for field “Mode” in “General” (tnx IU2CIQ Emanuele)
– empty PC programming password now stored in CSV as empty string and not as ‘FF FF FF FF FF FF FF FF’
– PC programming password is converted to lowercase (as the programming program does)
07-June-2016 – Build 19010
– now DigitalContacts are referenced by CallId; contacts with dupe names are now handled correctly.
12-June-2016 – Build 19020
– rdt2csv now automatically detects and handles the .img/.bin files obtained by “md380-dfu read” command.
04-Sep-2016 – Build 19424
– fixed a bug: the tool was still considering in its checks the older records if their number was greater than the number of the new ones reporting false errors.
07-November-2017 – Build 20974
– Fixed crash on linux 64bit (thanks to Fabrizio IW2FDK)
– Changed detection of end of valid digital contacts (thanks to Dale Farnsworth)