summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Berg <christoph.berg@credativ.de>2022-11-08 11:40:45 +0100
committerChristoph Berg <christoph.berg@credativ.de>2022-11-08 11:40:45 +0100
commit42b1373eff59af2aebb218ded3d2d55cc96dc630 (patch)
treed6e7e435fa41c65fff7a73dd7dc99bb4a12da5c8
parent176c8e29d64892072697c5d30513204773545a9b (diff)
parent6f19923a918f7fb63a444b0c99950fdbe9d2f74c (diff)
Update upstream source from tag 'upstream/20221106+py3'
Update to upstream version '20221106+py3' with Debian dir b54298e303932808cc08745c5f5133ad7b12628e
-rw-r--r--.github/actions/py2-tox/action.yaml29
-rw-r--r--.github/actions/py3-tox/action.yaml20
-rw-r--r--.github/workflows/py2-test.yaml57
-rw-r--r--.github/workflows/py3-pr.yaml51
-rw-r--r--.github/workflows/py3-test.yaml74
-rw-r--r--.github/workflows/test-py3-merge.yaml35
-rw-r--r--.hgignore21
-rw-r--r--.hgtags17
-rw-r--r--.pylintrc308
-rw-r--r--README.chirpc2
-rw-r--r--README.md12
-rw-r--r--chirp/bandplan.py69
-rw-r--r--chirp/bitwise.py4
-rw-r--r--chirp/chirp_common.py12
-rw-r--r--chirp/directory.py28
-rw-r--r--chirp/drivers/alinco.py43
-rw-r--r--chirp/drivers/anytone.py250
-rw-r--r--chirp/drivers/anytone778uv.py1792
-rw-r--r--chirp/drivers/anytone_ht.py83
-rw-r--r--chirp/drivers/anytone_iii.py2039
-rw-r--r--chirp/drivers/baofeng_common.py58
-rw-r--r--chirp/drivers/baofeng_uv3r.py14
-rw-r--r--chirp/drivers/baofeng_wp970i.py53
-rw-r--r--chirp/drivers/bf-t1.py14
-rw-r--r--chirp/drivers/bf-t8.py1024
-rw-r--r--chirp/drivers/bj9900.py4
-rw-r--r--chirp/drivers/bjuv55.py4
-rw-r--r--chirp/drivers/boblov_x3plus.py4
-rw-r--r--chirp/drivers/btech.py2195
-rw-r--r--chirp/drivers/fake.py100
-rw-r--r--chirp/drivers/fd268.py34
-rw-r--r--chirp/drivers/ft1500m.py2
-rw-r--r--chirp/drivers/ft1802.py2
-rw-r--r--chirp/drivers/ft1d.py2
-rw-r--r--chirp/drivers/ft2800.py14
-rw-r--r--chirp/drivers/ft2900.py23
-rw-r--r--chirp/drivers/ft2d.py2
-rw-r--r--chirp/drivers/ft4.py61
-rw-r--r--chirp/drivers/ft450d.py13
-rw-r--r--chirp/drivers/ft50.py6
-rw-r--r--chirp/drivers/ft60.py12
-rw-r--r--chirp/drivers/ft70.py2382
-rw-r--r--chirp/drivers/ft7100.py6
-rw-r--r--chirp/drivers/ft7800.py8
-rw-r--r--chirp/drivers/ft8100.py10
-rw-r--r--chirp/drivers/ft817.py8
-rwxr-xr-xchirp/drivers/ft818.py2
-rw-r--r--chirp/drivers/ft857.py8
-rw-r--r--chirp/drivers/ft90.py21
-rw-r--r--chirp/drivers/ftlx011.py798
-rw-r--r--chirp/drivers/ftm350.py8
-rw-r--r--chirp/drivers/ftm7250d.py202
-rw-r--r--chirp/drivers/ga510.py850
-rw-r--r--chirp/drivers/generic_csv.py31
-rw-r--r--chirp/drivers/gmrsuv1.py325
-rw-r--r--chirp/drivers/gmrsv2.py1030
-rw-r--r--chirp/drivers/h777.py47
-rw-r--r--chirp/drivers/hg_uv98.py897
-rw-r--r--chirp/drivers/ic2200.py4
-rw-r--r--chirp/drivers/ic2300.py8
-rw-r--r--chirp/drivers/ic2730.py144
-rw-r--r--chirp/drivers/icf.py23
-rw-r--r--chirp/drivers/icomciv.py21
-rw-r--r--chirp/drivers/icp7.py2
-rw-r--r--chirp/drivers/ict8.py1
-rw-r--r--chirp/drivers/icv86.py371
-rw-r--r--chirp/drivers/icx90.py926
-rw-r--r--chirp/drivers/id51plus.py2
-rw-r--r--chirp/drivers/id880.py6
-rw-r--r--chirp/drivers/iradio_uv-5118.py1119
-rw-r--r--chirp/drivers/kenwood_live.py130
-rw-r--r--chirp/drivers/kg935g.py1547
-rw-r--r--chirp/drivers/kguv8d.py12
-rw-r--r--chirp/drivers/kguv8dplus.py24
-rw-r--r--chirp/drivers/kguv8e.py28
-rw-r--r--chirp/drivers/kguv920pa.py1407
-rw-r--r--chirp/drivers/kguv9dplus.py16
-rw-r--r--chirp/drivers/kyd.py3
-rw-r--r--chirp/drivers/kyd_IP620.py18
-rw-r--r--chirp/drivers/leixen.py31
-rw-r--r--chirp/drivers/lt725uv.py498
-rw-r--r--chirp/drivers/mursv1.py51
-rw-r--r--chirp/drivers/puxing.py4
-rw-r--r--chirp/drivers/puxing_px888k.py2
-rw-r--r--chirp/drivers/radioddity_r2.py22
-rw-r--r--chirp/drivers/radtel_t18.py954
-rw-r--r--chirp/drivers/retevis_rb15.py801
-rw-r--r--chirp/drivers/retevis_rb17p.py602
-rw-r--r--chirp/drivers/retevis_rt1.py25
-rw-r--r--chirp/drivers/retevis_rt21.py1594
-rw-r--r--chirp/drivers/retevis_rt22.py161
-rw-r--r--chirp/drivers/retevis_rt23.py35
-rw-r--r--chirp/drivers/retevis_rt26.py33
-rw-r--r--chirp/drivers/retevis_rt76p.py1009
-rw-r--r--chirp/drivers/retevis_rt87.py1042
-rw-r--r--chirp/drivers/retevis_rt98.py1400
-rw-r--r--chirp/drivers/rfinder.py4
-rw-r--r--chirp/drivers/rh5r_v2.py8
-rw-r--r--chirp/drivers/tdxone_tdq8a.py225
-rw-r--r--chirp/drivers/template.py6
-rw-r--r--chirp/drivers/tg_uv2p.py774
-rw-r--r--chirp/drivers/th350.py1
-rw-r--r--chirp/drivers/th7800.py16
-rw-r--r--chirp/drivers/th9000.py608
-rw-r--r--chirp/drivers/th9800.py74
-rw-r--r--chirp/drivers/th_uv8000.py15
-rw-r--r--chirp/drivers/th_uv88.py1112
-rw-r--r--chirp/drivers/th_uvf8d.py6
-rw-r--r--chirp/drivers/thd72.py16
-rw-r--r--chirp/drivers/thuv1f.py14
-rw-r--r--chirp/drivers/tk270.py18
-rw-r--r--chirp/drivers/tk760.py93
-rw-r--r--chirp/drivers/tk760g.py117
-rw-r--r--chirp/drivers/tk8180.py38
-rw-r--r--chirp/drivers/tmd710.py2099
-rw-r--r--chirp/drivers/ts2000.py6
-rw-r--r--chirp/drivers/ts480.py123
-rw-r--r--chirp/drivers/ts590.py10
-rw-r--r--chirp/drivers/ts850.py4
-rw-r--r--chirp/drivers/uv5r.py301
-rw-r--r--chirp/drivers/uv5x3.py252
-rw-r--r--chirp/drivers/uv6r.py30
-rw-r--r--chirp/drivers/uvb5.py2
-rw-r--r--chirp/drivers/vgc.py135
-rw-r--r--chirp/drivers/vx170.py2
-rw-r--r--chirp/drivers/vx3.py2
-rw-r--r--chirp/drivers/vx6.py4
-rw-r--r--chirp/drivers/vx8.py2
-rw-r--r--chirp/drivers/vxa700.py20
-rw-r--r--chirp/drivers/wouxun.py4
-rw-r--r--chirp/drivers/wouxun_common.py12
-rw-r--r--chirp/elib_intl.py2
-rw-r--r--chirp/import_logic.py4
-rw-r--r--chirp/logger.py2
-rw-r--r--chirp/platform.py13
-rw-r--r--chirp/pyPEG.py6
-rw-r--r--chirp/radioreference.py58
-rw-r--r--chirp/settings.py16
-rw-r--r--chirp/ui/bandplans.py115
-rw-r--r--chirp/ui/clone.py17
-rw-r--r--chirp/ui/editorset.py17
-rw-r--r--chirp/ui/importdialog.py11
-rw-r--r--chirp/ui/inputdialog.py45
-rw-r--r--chirp/ui/mainapp.py344
-rw-r--r--chirp/ui/memdetail.py12
-rw-r--r--chirp/ui/memedit.py121
-rw-r--r--chirp/ui/miscwidgets.py6
-rw-r--r--chirp/ui/settingsedit.py7
-rw-r--r--chirp/ui/shiftdialog.py5
-rw-r--r--chirp/wxui/clone.py203
-rw-r--r--chirp/wxui/common.py132
-rw-r--r--chirp/wxui/developer.py38
-rw-r--r--chirp/wxui/main.py210
-rw-r--r--chirp/wxui/memedit.py225
-rw-r--r--chirp/wxui/query_sources.py305
-rw-r--r--chirp/wxui/radiothread.py99
-rw-r--r--chirp/wxui/settingsedit.py107
-rw-r--r--chirpc2
-rwxr-xr-xchirpw23
-rwxr-xr-xchirpwx.py21
-rw-r--r--locale/Makefile2
-rw-r--r--locale/es_ES.po1497
-rw-r--r--locale/tr_TR.po2220
-rw-r--r--locale/zh_CN.po1275
-rw-r--r--requirements.txt3
-rwxr-xr-xshare/make_supported.py9
-rw-r--r--snap/snapcraft.yaml118
-rw-r--r--stock_configs/SE Jaktradio 155MHz.csv8
-rw-r--r--test-requirements.txt5
-rw-r--r--tests/Python3_Driver_Testing.md339
-rw-r--r--tests/__init__.py107
-rw-r--r--tests/images/Abbree_AR-518.imgbin0 -> 2293 bytes
-rw-r--r--tests/images/Abbree_AR-63.imgbin0 -> 481 bytes
-rw-r--r--tests/images/AnyTone_5888UV.imgbin0 -> 32945 bytes
-rw-r--r--tests/images/AnyTone_5888UVIII.imgbin0 -> 32945 bytes
-rw-r--r--tests/images/AnyTone_778UV.imgbin0 -> 13121 bytes
-rw-r--r--tests/images/Anysecu_WP-9900.imgbin0 -> 16545 bytes
-rw-r--r--tests/images/BTECH_FRS-A1.imgbin0 -> 3677 bytes
-rw-r--r--tests/images/BTECH_FRS-B1.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/BTECH_GMRS-20V2.imgbin0 -> 16549 bytes
-rw-r--r--tests/images/BTECH_GMRS-V2.imgbin0 -> 8353 bytes
-rw-r--r--tests/images/Baofeng_BF-T8.imgbin0 -> 3081 bytes
-rw-r--r--tests/images/CRT_Micron_UV.imgbin0 -> 13121 bytes
-rw-r--r--tests/images/Explorer_QRZ-1.imgbin0 -> 9041 bytes
-rw-r--r--tests/images/Kenwood_TM-D710G_CloneMode.imgbin0 -> 97721 bytes
-rw-r--r--tests/images/Kenwood_TM-D710_CloneMode.imgbin0 -> 40021 bytes
-rw-r--r--tests/images/LUITON_LT-580_UHF.imgbin0 -> 16565 bytes
-rw-r--r--tests/images/LUITON_LT-580_VHF.imgbin0 -> 16565 bytes
-rw-r--r--tests/images/Lanchonlh_HG-UV98.imgbin0 -> 8369 bytes
-rw-r--r--tests/images/Midland_DBR2500.imgbin0 -> 13121 bytes
-rw-r--r--tests/images/QYT_KT-8R.imgbin0 -> 16537 bytes
-rw-r--r--tests/images/QYT_KT-WP12.imgbin0 -> 16549 bytes
-rw-r--r--tests/images/Quansheng_TG-UV2+.imgbin0 -> 8417 bytes
-rw-r--r--tests/images/Radioddity_GA-510.imgbin0 -> 7345 bytes
-rw-r--r--tests/images/Radioddity_UV-5G.imgbin0 -> 6649 bytes
-rw-r--r--tests/images/Retevis_RA85.imgbin0 -> 7409 bytes
-rw-r--r--tests/images/Retevis_RB15.imgbin0 -> 2113 bytes
-rw-r--r--tests/images/Retevis_RB17.imgbin0 -> 1177 bytes
-rw-r--r--tests/images/Retevis_RB17A.imgbin0 -> 933 bytes
-rw-r--r--tests/images/Retevis_RB17P.imgbin0 -> 6309 bytes
-rw-r--r--tests/images/Retevis_RB17V.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RB18.imgbin0 -> 1793 bytes
-rw-r--r--tests/images/Retevis_RB19.imgbin0 -> 1169 bytes
-rw-r--r--tests/images/Retevis_RB19P.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RB23.imgbin0 -> 965 bytes
-rw-r--r--tests/images/Retevis_RB26.imgbin0 -> 965 bytes
-rw-r--r--tests/images/Retevis_RB27.imgbin0 -> 4325 bytes
-rw-r--r--tests/images/Retevis_RB27B.imgbin0 -> 4329 bytes
-rw-r--r--tests/images/Retevis_RB27V.imgbin0 -> 4329 bytes
-rw-r--r--tests/images/Retevis_RB615.imgbin0 -> 2117 bytes
-rw-r--r--tests/images/Retevis_RB617.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RB618.imgbin0 -> 1797 bytes
-rw-r--r--tests/images/Retevis_RB619.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RB627B.imgbin0 -> 4329 bytes
-rw-r--r--tests/images/Retevis_RB75.imgbin0 -> 1169 bytes
-rw-r--r--tests/images/Retevis_RB85.imgbin0 -> 1169 bytes
-rw-r--r--tests/images/Retevis_RT1.imgbin0 -> 1024 bytes
-rw-r--r--tests/images/Retevis_RT16.imgbin0 -> 3077 bytes
-rw-r--r--tests/images/Retevis_RT19.imgbin0 -> 549 bytes
-rw-r--r--tests/images/Retevis_RT22FRS.imgbin0 -> 1197 bytes
-rw-r--r--tests/images/Retevis_RT22S.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RT29_UHF.imgbin0 -> 1197 bytes
-rw-r--r--tests/images/Retevis_RT29_VHF.imgbin0 -> 1197 bytes
-rw-r--r--tests/images/Retevis_RT40B.imgbin0 -> 517 bytes
-rw-r--r--tests/images/Retevis_RT47.imgbin0 -> 1169 bytes
-rw-r--r--tests/images/Retevis_RT47V.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RT619.imgbin0 -> 445 bytes
-rw-r--r--tests/images/Retevis_RT622.imgbin0 -> 1189 bytes
-rw-r--r--tests/images/Retevis_RT647.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RT668.imgbin0 -> 1173 bytes
-rw-r--r--tests/images/Retevis_RT68.imgbin0 -> 1169 bytes
-rw-r--r--tests/images/Retevis_RT76.imgbin0 -> 645 bytes
-rw-r--r--tests/images/Retevis_RT87.imgbin0 -> 8341 bytes
-rw-r--r--tests/images/Retevis_RT9000D_136-174.imgbin0 -> 16569 bytes
-rw-r--r--tests/images/Retevis_RT9000D_220-260.imgbin0 -> 16569 bytes
-rw-r--r--tests/images/Retevis_RT9000D_400-490.imgbin0 -> 16569 bytes
-rw-r--r--tests/images/Retevis_RT9000D_66-88.imgbin0 -> 16569 bytes
-rw-r--r--tests/images/Retevis_RT95.imgbin0 -> 13121 bytes
-rw-r--r--tests/images/Rugged_RH5R-V2.imgbin0 -> 8360 bytes
-rw-r--r--tests/images/TYT_TH-UV88.imgbin0 -> 9029 bytes
-rw-r--r--tests/images/Vertex_Standard_FTL-2011.imgbin0 -> 589 bytes
-rw-r--r--tests/images/Wouxun_KG-935G.imgbin0 -> 32937 bytes
-rw-r--r--tests/images/Wouxun_KG-UV920P-A.imgbin0 -> 26345 bytes
-rwxr-xr-xtests/images/Yaesu_FTM-7250D_R.imgbin0 -> 65400 bytes
-rw-r--r--tests/py3_driver_testers.txt41
-rw-r--r--tests/py3_remaining.txt17
-rw-r--r--tests/run_tests.py13
-rw-r--r--tests/unit/base.py9
-rw-r--r--tests/unit/test_directory.py25
-rw-r--r--tests/unit/test_memedit_edits.py18
-rw-r--r--tests/unit/test_settings.py24
-rw-r--r--tests/unit/test_shiftdialog.py17
-rw-r--r--tests/unit/test_wxui_radiothread.py105
-rw-r--r--tools/cpep8.manifest33
-rwxr-xr-xtools/cpep8.py22
-rw-r--r--tools/img2thd72.py2
-rw-r--r--tools/py3_driver_progress.py96
-rw-r--r--tools/serialsniff.c2
-rw-r--r--tox.ini34
259 files changed, 38883 insertions, 4773 deletions
diff --git a/.github/actions/py2-tox/action.yaml b/.github/actions/py2-tox/action.yaml
new file mode 100644
index 0000000..2ff11b1
--- /dev/null
+++ b/.github/actions/py2-tox/action.yaml
@@ -0,0 +1,29 @@
+name: Python2 tox runner
+description: Runs tox py2 targets
+inputs:
+ tox_target:
+ required: true
+ type: string
+
+runs:
+ using: "composite"
+ steps:
+ - name: Install dependencies
+ shell: bash
+ run: |
+ sudo apt-get update
+ sudo apt-get remove -y python3-libxml2
+ sudo apt-get install -y libxml2-dev python-dev python-libxml2
+ curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
+ python get-pip.py
+ pip --version
+ python -m pip install --upgrade --no-deps --force-reinstall lxml
+ python -m pip install \
+ future \
+ pep8 \
+ pyserial \
+ tox
+ - name: Run tox
+ shell: bash
+ run: |
+ tox -e ${{ inputs.tox_target }}
diff --git a/.github/actions/py3-tox/action.yaml b/.github/actions/py3-tox/action.yaml
new file mode 100644
index 0000000..6eff4df
--- /dev/null
+++ b/.github/actions/py3-tox/action.yaml
@@ -0,0 +1,20 @@
+name: Python3 tox runner
+description: Runs tox py3 targets
+inputs:
+ tox_target:
+ required: true
+ type: string
+
+runs:
+ using: "composite"
+ steps:
+ - name: Install dependencies
+ shell: bash
+ run: |
+ sudo apt-get update
+ sudo apt-get install python3-pip python3-wxgtk4.0
+ sudo python3 -mpip install tox
+ - name: Run tox
+ shell: bash
+ run: |
+ tox -e ${{ inputs.tox_target }}
diff --git a/.github/workflows/py2-test.yaml b/.github/workflows/py2-test.yaml
new file mode 100644
index 0000000..b1a3b43
--- /dev/null
+++ b/.github/workflows/py2-test.yaml
@@ -0,0 +1,57 @@
+name: Tests
+on:
+ pull_request:
+ branches:
+ - master
+ push:
+ branches:
+ - master
+jobs:
+ style:
+ name: Style checks
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py2-tox
+ with:
+ tox_target: style
+
+ unit:
+ name: Unit tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py2-tox
+ with:
+ tox_target: unit
+
+ driver:
+ name: Driver tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py2-tox
+ with:
+ tox_target: driver
+
+ matrix:
+ name: Create support matrix
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py2-tox
+ with:
+ tox_target: makesupported
+ - name: Archive support matrix
+ uses: actions/upload-artifact@v3
+ with:
+ name: support-matrix
+ path: model_support.html
diff --git a/.github/workflows/py3-pr.yaml b/.github/workflows/py3-pr.yaml
new file mode 100644
index 0000000..e6e5a65
--- /dev/null
+++ b/.github/workflows/py3-pr.yaml
@@ -0,0 +1,51 @@
+name: Sync to py3 branch
+on:
+ push:
+ branches:
+ - master
+jobs:
+ makepr:
+ name: Generate PR
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Merge with py3
+ run: |
+ git fetch origin py3
+ git checkout origin/py3 -b py3-sync
+ git config --global user.email "bot@chirp.danplanet.com"
+ git config --global user.name "Merge Bot"
+ git merge $GITHUB_SHA --allow-unrelated-histories --no-edit || {
+ git add -u
+ git commit --no-edit
+ }
+ git checkout -b auto-py3-$GITHUB_SHA
+ - name: Update support matrix if needed
+ run: |
+ sudo apt-get update
+ sudo apt-get install python3-pip python3-wxgtk4.0
+ sudo python3 -mpip install tox
+ tox -e makesupported || git commit -m "Update support matrix" tests/Python3_Driver_Testing.md
+ - name: Push changes
+ run: |
+ git push origin auto-py3-$GITHUB_SHA:auto-py3-$GITHUB_SHA
+ - name: Update support matrix if needed
+ run: |
+ sudo apt-get update
+ sudo apt-get install python3-pip python3-wxgtk4.0
+ sudo python3 -mpip install tox
+ tox -e makesupported || git commit -m "Update support matrix" tests/Python3_Driver_Testing.md
+ - name: Push changes
+ run: |
+ git push origin auto-py3-$GITHUB_SHA:auto-py3-$GITHUB_SHA
+ - name: Create PR
+ uses: repo-sync/pull-request@v2
+ with:
+ github_token: ${{ secrets.PR_SYNC }}
+ source_branch: auto-py3-${{ github.sha }}
+ destination_branch: py3
+ pr_title: "[Automated] Sync master with py3"
+ pr_body: "Automated pull request to sync py3 with changes from master"
diff --git a/.github/workflows/py3-test.yaml b/.github/workflows/py3-test.yaml
new file mode 100644
index 0000000..91d5bd3
--- /dev/null
+++ b/.github/workflows/py3-test.yaml
@@ -0,0 +1,74 @@
+name: Tests
+on:
+ pull_request:
+ push:
+jobs:
+ style:
+ name: Style checks
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py3-tox
+ with:
+ tox_target: style
+
+ unit:
+ name: Unit tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py3-tox
+ with:
+ tox_target: py3unit
+ - name: Archive results
+ uses: actions/upload-artifact@v3
+ with:
+ name: unit_report
+ path: unit_report.html
+
+ driver:
+ name: Driver tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py3-tox
+ with:
+ tox_target: py3driver
+ - name: Archive results
+ uses: actions/upload-artifact@v3
+ with:
+ name: driver_report
+ path: driver_report.html
+
+ driver-py310:
+ name: Driver tests (Python 3.10)
+ runs-on: ubuntu-22.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py3-tox
+ with:
+ tox_target: py3driver
+
+ matrix:
+ name: Create support matrix
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Run tox
+ uses: ./.github/actions/py3-tox
+ with:
+ tox_target: makesupported
+ - name: Archive support matrix
+ uses: actions/upload-artifact@v3
+ with:
+ name: support-matrix
+ path: model_support.html
diff --git a/.github/workflows/test-py3-merge.yaml b/.github/workflows/test-py3-merge.yaml
new file mode 100644
index 0000000..bdd7c9b
--- /dev/null
+++ b/.github/workflows/test-py3-merge.yaml
@@ -0,0 +1,35 @@
+name: Test merging against py3
+on:
+ pull_request:
+ branches:
+ - master
+ push:
+ branches:
+ - master
+jobs:
+ test:
+ name: Merge and run all tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+ - name: Merge with py3
+ run: |
+ echo SHA $GITHUB_SHA
+ echo REF $GITHUB_REF
+ git fetch origin py3
+ git branch -a
+ git checkout origin/py3 -b py3-test
+ echo HEAD $(git rev-parse HEAD)
+ git config --global user.email "bot@chirp.danplanet.com"
+ git config --global user.name "Merge Bot"
+ git merge $GITHUB_SHA --allow-unrelated-histories --no-edit
+ - name: install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install python3-pip gobject-introspection python3-gi libgirepository1.0-dev
+ sudo python3 -mpip install tox
+ - name: Run tests
+ run: tox -e py3unit,py3driver,style
diff --git a/.hgignore b/.hgignore
new file mode 100644
index 0000000..6a9ef40
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,21 @@
+.*\~$
+.*\.pyc$
+.*\.orig$
+.*\.rej$
+dist
+build/bdist
+tools/cpep8.venv/
+tests/logs/
+logs/
+ignored/
+patch_queue/
+archived_builds/
+.tox/
+.*\.mo$
+.*\.pot$
+locale/.files
+MANIFEST
+.pytest_cache
+# for visual studio and visual studio code editors
+.vs/
+.vscode/
diff --git a/.hgtags b/.hgtags
new file mode 100644
index 0000000..3192edf
--- /dev/null
+++ b/.hgtags
@@ -0,0 +1,17 @@
+1428729c41b76d9e88023a8d9073bd947b1f64e4 release_0_1_1
+b6d7fbb63c67b431afb526c1c5682198884050e7 release_0_1_2
+1ed337baf81ee9e3a8cf80c095c79fda40f09000 release_0_1_3
+05dd19dd4db874ae9b94fd2ce4b81a9fe1a7b279 release_0_1_4
+5ab503b39a8609f428b4d44389507672090ddee6 release_0_1_5
+f31a4c4d772dfb9f0519586bfc683ac0c095e8a8 release_0_1_6
+61ed9897712816f2959ecda8135526e15ec7a046 release_0_1_7
+22c1e4d0f349c13e8a9e02cd2f0c4ba58033824e release_0_1_8
+c6f153e861ddca4b2568f83ef8d20c9ef3d6565e release_0_1_9
+03e812a988209069d5de9ff744a7c5d77bca4b94 release_0_1_10
+629e127c61ded83612f322d86b960c4fcbb5df7d release_0_1_11
+3dd33f5175ca34b06fd118a63c692297b5eb2550 release_0_1_12
+df5342f5ce3d3615dff38238d3112711c3628be6 release_0_2_0
+744ce08c8bea0868ce756e270043dbef59b5eb7f release_0_2_1
+30eeb96b77fb90ca88689cc2f76af379123e5e6e release_0_2_2
+e4901095dc40aa73cc9eb95105e7b32c756f53b0 release_0_3_0
+e91f09ca03d07a9f565291a60e8b84073298b8ac release_0_4_0
diff --git a/.pylintrc b/.pylintrc
new file mode 100644
index 0000000..8a8f0a3
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,308 @@
+# lint Python modules using external checkers.
+#
+# This is the main checker controling the other ones and the reports
+# generation. It is itself both a raw checker and an astng checker in order
+# to:
+# * handle message activation / deactivation at the module level
+# * handle some basic but necessary stats'data (number of classes, methods...)
+#
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add <file or directory> to the black list. It should be a base name, not a
+# path. You may set this option multiple times.
+ignore=dist
+ignore=icons
+ignore=.hg
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# Set the cache size for astng objects.
+cache-size=500
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+
+[MESSAGES CONTROL]
+
+# Enable only checker(s) with the given id(s). This option conflicts with the
+# disable-checker option
+#enable-checker=
+
+# Enable all checker(s) except those with the given id(s). This option
+# conflicts with the enable-checker option
+disable-checker=SIMILARITIES
+
+# Enable all messages in the listed categories.
+#enable-msg-cat=
+
+# Disable all messages in the listed categories.
+#disable-msg-cat=
+
+# Enable the message(s) with the given id(s).
+#enable-msg=
+
+# Disable the message(s) with the given id(s).
+disable-msg=W0142,C0111
+
+
+[REPORTS]
+
+# set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html
+output-format=text
+
+# Include message's id in output
+include-ids=no
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells wether to display a full report or only the messages
+reports=yes
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note).You have access to the variables errors warning, statement which
+# respectivly contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (R0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (R0004).
+comment=no
+
+# Enable the report(s) with the given id(s).
+#enable-report=
+
+# Disable the report(s) with the given id(s).
+#disable-report=
+
+
+# checks for :
+# * doc strings
+# * modules / classes / functions / methods / arguments / variables name
+# * number of arguments, local variables, branchs, returns and statements in
+# functions, methods
+# * required module attributes
+# * dangerous default values as arguments
+# * redefinition of function / method / class
+# * uses of the global statement
+#
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# Regular expression which should only match functions or classes name which do
+# not require a docstring
+#no-docstring-rgx=__.*__
+no-docstring-rgx=.*
+
+# Regular expression which should only match correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression which should only match correct module level names
+const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Regular expression which should only match correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression which should only match correct function names
+function-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct method names
+method-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct instance attribute names
+attr-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct argument names
+argument-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct variable names
+variable-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Regular expression which should only match correct list comprehension /
+# generator expression variable names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_,e
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=map,filter,apply,input
+
+
+# try to find bugs in the code using type inference
+#
+[TYPECHECK]
+
+# Tells wether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# When zope mode is activated, consider the acquired-members option to ignore
+# access to some undefined attributes.
+zope=no
+
+# List of members which are usually get through zope's acquisition mecanism and
+# so shouldn't trigger E0201 when accessed (need zope=yes to be considered).
+acquired-members=REQUEST,acl_users,aq_parent
+
+
+# checks for
+# * unused variables / imports
+# * undefined variables
+# * redefinition of variable from builtins or from an outer scope
+# * use of variable before assigment
+#
+[VARIABLES]
+
+# Tells wether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching names used for dummy variables (i.e. not used).
+dummy-variables-rgx=_|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+
+# checks for sign of poor/misdesign:
+# * number of methods, attributes, local variables...
+# * size, complexity of functions, methods
+#
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=5
+
+# Maximum number of locals for function / method body
+max-locals=15
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branchs=12
+
+# Maximum number of statements in function / method body
+max-statements=50
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+# checks for :
+# * methods without self as first argument
+# * overridden methods signature
+# * access only to existant members via self
+# * attributes not defined in the __init__ method
+# * supported interfaces implementation
+# * unreachable code
+#
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp
+
+
+# checks for
+# * external modules dependencies
+# * relative / wildcard imports
+# * cyclic imports
+# * uses of deprecated modules
+#
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report R0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report R0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report R0402 must
+# not be disabled)
+int-import-graph=
+
+
+# checks for:
+# * warning notes in the code like FIXME, XXX
+# * PEP 263: source code with non ascii character but no encoding declaration
+#
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,XXX,TODO
+
+
+# checks for :
+# * unauthorized constructions
+# * strict indentation
+# * line length
+# * use of <> instead of !=
+#
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=80
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string=' '
+
+
+# checks for similarities and duplicated code. This computation may be
+# memory / CPU intensive, so you should disable it if you experiments some
+# problems.
+#
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
diff --git a/README.chirpc b/README.chirpc
index a367fac..f6e176f 100644
--- a/README.chirpc
+++ b/README.chirpc
@@ -16,7 +16,7 @@ that you want unchanged.
Cookbook
========
-This section provides copy-and-paste recipies for accomplishing some
+This section provides copy-and-paste recipes for accomplishing some
tasks using the CLI.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..d752a18
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+# CHIRP Project
+
+This is the official git repository for the
+__[CHIRP](https://chirp.danplanet.com)__ project. This repo is mirrored to
+the legacy mercurial repo and patches are still accepted via the mailing list
+against that repository for existing contributors. New contributions are
+preferred as PRs here.
+
+When submitting PRs, please squash commits into logical units in a fashion
+similar to what is currently expected by the project on the mailing list.
+
+For Python3 driver testing status, see [this file](tests/Python3_Driver_Testing.md).
diff --git a/chirp/bandplan.py b/chirp/bandplan.py
index 19d70a3..21b3661 100644
--- a/chirp/bandplan.py
+++ b/chirp/bandplan.py
@@ -13,8 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import logging
+
from chirp import chirp_common
+LOG = logging.getLogger(__name__)
+
class Band(object):
def __init__(self, limits, name, mode=None, step_khz=None,
@@ -83,3 +87,68 @@ class Band(object):
return "%s-%s %s %s %s" % (
self.limits[0], self.limits[1], self.name, self.duplex, desc)
+
+
+class BandPlans(object):
+ def __init__(self, config):
+ self._config = config
+ self.plans = {}
+
+ # Migrate old "automatic repeater offset" setting to
+ # "North American Amateur Band Plan"
+ ro = self._config.get("autorpt", "memedit")
+ if ro is not None:
+ self._config.set_bool("north_america", ro, "bandplan")
+ self._config.remove_option("autorpt", "memedit")
+ # And default new users to North America.
+ if not self._config.is_defined("north_america", "bandplan"):
+ self._config.set_bool("north_america", True, "bandplan")
+
+ from chirp import bandplan_na, bandplan_au
+ from chirp import bandplan_iaru_r1, bandplan_iaru_r2, bandplan_iaru_r3
+
+ for plan in (bandplan_na, bandplan_au, bandplan_iaru_r1,
+ bandplan_iaru_r2, bandplan_iaru_r3):
+ name = plan.DESC.get("name", plan.SHORTNAME)
+ self.plans[plan.SHORTNAME] = (name, plan)
+
+ rpt_inputs = []
+ for band in plan.BANDS:
+ # Check for duplicates.
+ duplicates = [x for x in plan.BANDS if x == band]
+ if len(duplicates) > 1:
+ LOG.info("Bandplan %s has duplicates %s" %
+ (name, duplicates))
+ # Add repeater inputs.
+ rpt_input = band.inverse()
+ if rpt_input not in plan.BANDS:
+ rpt_inputs.append(band.inverse())
+ plan.bands = list(plan.BANDS)
+ plan.bands.extend(rpt_inputs)
+
+ def get_defaults_for_frequency(self, freq):
+ freq = int(freq)
+ result = Band((freq, freq), repr(freq))
+
+ for shortname, details in self.plans.items():
+ if self._config.get_bool(shortname, "bandplan"):
+ matches = [x for x in details[1].bands if x.contains(result)]
+ # Add matches to defaults, favoring more specific matches.
+ matches = sorted(matches, key=lambda x: x.width(),
+ reverse=True)
+ for match in matches:
+ result.mode = match.mode or result.mode
+ result.step_khz = match.step_khz or result.step_khz
+ result.offset = match.offset or result.offset
+ result.duplex = match.duplex or result.duplex
+ result.tones = match.tones or result.tones
+ if match.name:
+ result.name = '/'.join((result.name or '', match.name))
+ # Limit ourselves to one band plan match for simplicity.
+ # Note that if the user selects multiple band plans by editing
+ # the config file it will work as expected (except where plans
+ # conflict).
+ if matches:
+ break
+
+ return result
diff --git a/chirp/bitwise.py b/chirp/bitwise.py
index 4a6016d..39fc852 100644
--- a/chirp/bitwise.py
+++ b/chirp/bitwise.py
@@ -666,6 +666,8 @@ class bcdDataElement(DataElement):
self._data[self._offset] = data & 0xFF
elif isinstance(data, str):
self._data[self._offset] = string_straight_encode(data[0])
+ elif isinstance(data, bytes) and len(data) == 1:
+ self._data[self._offset] = int(data[0]) & 0xFF
else:
raise TypeError("Unable to set bcdDataElement from type %s" %
type(data))
@@ -799,7 +801,7 @@ class structDataElement(DataElement):
return string_straight_decode(raw)
def set_raw(self, buffer):
- if len(buffer) != (self.size() / 8):
+ if len(buffer) != (self.size() // 8):
raise ValueError("Struct size mismatch during set_raw()")
if isinstance(buffer, str):
buffer = string_straight_encode(buffer)
diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
index dd3cf7a..6b057ec 100644
--- a/chirp/chirp_common.py
+++ b/chirp/chirp_common.py
@@ -272,11 +272,11 @@ class Memory:
# or an empty list if none
extra = []
- def __init__(self):
+ def __init__(self, number=0, empty=False, name=""):
self.freq = 0
- self.number = 0
+ self.number = number
self.extd_number = ""
- self.name = ""
+ self.name = name
self.vfo = 0
self.rtone = 88.5
self.ctone = 88.5
@@ -294,7 +294,7 @@ class Memory:
self.comment = ""
- self.empty = False
+ self.empty = empty
self.immutable = []
@@ -1230,7 +1230,7 @@ class CloneModeRadio(FileBackedRadio):
if isinstance(pipe, str):
self.pipe = None
self.load_mmap(pipe)
- elif isinstance(pipe, memmap.MemoryMap):
+ elif isinstance(pipe, memmap.MemoryMapBytes):
self.pipe = None
self._mmap = pipe
self.process_mmap()
@@ -1251,7 +1251,7 @@ class CloneModeRadio(FileBackedRadio):
# Ideally, each radio would perform an intelligent analysis to
# make this determination to avoid model conflicts with
# memories of the same size.
- return len(filedata) == cls._memsize
+ return cls._memsize and len(filedata) == cls._memsize
def sync_in(self):
"Initiate a radio-to-PC clone operation"
diff --git a/chirp/directory.py b/chirp/directory.py
index f79f23d..7678fd6 100644
--- a/chirp/directory.py
+++ b/chirp/directory.py
@@ -114,12 +114,22 @@ def icf_to_image(icf_file, img_file):
raise Exception("Unsupported model")
+# This is a mapping table of radio models that have changed in the past.
+# ideally we would never do this, but in the case where a radio was added
+# as the wrong model name, or a model has to be split, we need to be able
+# to open older files and do something intelligent with them.
+MODEL_COMPAT = {
+ ('Retevis', 'RT-5R'): ('Retevis', 'RT5R'),
+ ('Retevis', 'RT-5RV'): ('Retevis', 'RT5RV'),
+}
+
+
def get_radio_by_image(image_file):
"""Attempt to get the radio class that owns @image_file"""
if image_file.startswith("radioreference://"):
- _, _, zipcode, username, password = image_file.split("/", 4)
+ _, _, zipcode, username, password, country = image_file.split("/", 5)
rr = radioreference.RadioReferenceRadio(None)
- rr.set_params(zipcode, username, password)
+ rr.set_params(zipcode, username, password, country)
return rr
# FIXME: Disable rfinder until the module is fixed
@@ -178,15 +188,19 @@ def get_radio_by_image(image_file):
LOG.error('Radio class %s failed during detection: %s' % (
rclass.__name__, error))
+ meta_vendor = metadata.get('vendor')
+ meta_model = metadata.get('model')
+
+ meta_vendor, meta_model = MODEL_COMPAT.get((meta_vendor, meta_model),
+ (meta_vendor, meta_model))
+
# If metadata, then it has to match one of the aliases or the parent
for alias in rclass.ALIASES + [rclass]:
- if (alias.VENDOR == metadata.get('vendor') and
- alias.MODEL == metadata.get('model')):
+ if (alias.VENDOR == meta_vendor and alias.MODEL == meta_model):
class DynamicRadioAlias(rclass):
- _orig_rclass = rclass
- VENDOR = metadata.get('vendor')
- MODEL = metadata.get('model')
+ VENDOR = meta_vendor
+ MODEL = meta_model
VARIANT = metadata.get('variant')
return DynamicRadioAlias(image_file)
diff --git a/chirp/drivers/alinco.py b/chirp/drivers/alinco.py
index 54d8ce3..df8622d 100644
--- a/chirp/drivers/alinco.py
+++ b/chirp/drivers/alinco.py
@@ -95,7 +95,7 @@ def tohex(data):
class AlincoStyleRadio(chirp_common.CloneModeRadio):
"""Base class for all known Alinco radios"""
_memsize = 0
- _model = "NONE"
+ _model = b"NONE"
def _send(self, data):
LOG.debug("PC->R: (%2i) %s" % (len(data), tohex(data)))
@@ -199,7 +199,7 @@ class AlincoStyleRadio(chirp_common.CloneModeRadio):
self._mmap = self._download(self._memsize)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -208,7 +208,7 @@ class AlincoStyleRadio(chirp_common.CloneModeRadio):
self._upload(self._memsize)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def get_raw_memory(self, number):
@@ -285,6 +285,7 @@ class DRx35Radio(AlincoStyleRadio):
rf.valid_tuning_steps = STEPS
rf.valid_name_length = 7
rf.valid_power_levels = self._power_levels
+ rf.valid_dtcs_codes = DCS_CODES[self.VENDOR]
return rf
def _get_used(self, number):
@@ -407,14 +408,14 @@ class DR03Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DR03T"
- _model = "DR135"
+ _model = b"DR135"
_memsize = 4096
_range = [(28000000, 29695000)]
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x64] == chr(0x00) and filedata[0x65] == chr(0x28)
+ filedata[0x64:0x66] == b'\x00\x28'
@directory.register
@@ -423,14 +424,14 @@ class DR06Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DR06T"
- _model = "DR435"
+ _model = b"DR435"
_memsize = 4096
_range = [(50000000, 53995000)]
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x64] == chr(0x00) and filedata[0x65] == chr(0x50)
+ filedata[0x64:0x66] == b'\x00\x50'
@directory.register
@@ -439,14 +440,14 @@ class DR135Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DR135T"
- _model = "DR135"
+ _model = b"DR135"
_memsize = 4096
_range = [(118000000, 173000000)]
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x64] == chr(0x01) and filedata[0x65] == chr(0x44)
+ filedata[0x64:0x66] == b'\x01\x44'
@directory.register
@@ -455,14 +456,14 @@ class DR235Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DR235T"
- _model = "DR235"
+ _model = b"DR235"
_memsize = 4096
_range = [(216000000, 280000000)]
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x64] == chr(0x02) and filedata[0x65] == chr(0x22)
+ filedata[0x64:0x66] == b'\x02\x22'
@directory.register
@@ -471,14 +472,14 @@ class DR435Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DR435T"
- _model = "DR435"
+ _model = b"DR435"
_memsize = 4096
_range = [(350000000, 511000000)]
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x64] == chr(0x04) and filedata[0x65] == chr(0x00)
+ filedata[0x64:0x66] == b'\x04\x00'
@directory.register
@@ -487,7 +488,7 @@ class DJ596Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DJ596"
- _model = "DJ596"
+ _model = b"DJ596"
_memsize = 4096
_range = [(136000000, 174000000), (400000000, 511000000)]
_power_levels = [chirp_common.PowerLevel("Low", watts=1.00),
@@ -496,7 +497,7 @@ class DJ596Radio(DRx35Radio):
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x64] == chr(0x45) and filedata[0x65] == chr(0x01)
+ filedata[0x64:0x66] == b'\x45\x01'
@directory.register
@@ -505,14 +506,14 @@ class JT220MRadio(DRx35Radio):
VENDOR = "Jetstream"
MODEL = "JT220M"
- _model = "DR136"
+ _model = b"DR136"
_memsize = 8192
_range = [(216000000, 280000000)]
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- filedata[0x60:0x64] == "2009"
+ filedata[0x60:0x64] == b'2009'
@directory.register
@@ -521,7 +522,7 @@ class DJ175Radio(DRx35Radio):
VENDOR = "Alinco"
MODEL = "DJ175"
- _model = "DJ175"
+ _model = b"DJ175"
_memsize = 6896
_range = [(136000000, 174000000), (400000000, 511000000)]
_power_levels = [
@@ -613,7 +614,7 @@ class AlincoDJG7EG(AlincoStyleRadio):
TMODES = ["", "??1", "Tone", "TSQL", "TSQL-R", "DTCS"]
# This is a bit of a hack to avoid overwriting _identify()
- _model = "AL~DJ-G7EG"
+ _model = b"AL~DJ-G7EG"
_memsize = 0x1a7c0
_range = [(500000, 1300000000)]
@@ -689,7 +690,7 @@ class AlincoDJG7EG(AlincoStyleRadio):
if self._identify():
return True
else:
- # Apparenly Alinco support suggests to try again at a lower baud
+ # Apparently Alinco support suggests to try again at a lower baud
# rate if their cable fails with the default rate. See #4355.
LOG.info("Could not talk to radio. Trying again at 19200 baud")
self.pipe.baudrate = 19200
@@ -816,7 +817,7 @@ class AlincoDJG7EG(AlincoStyleRadio):
# Get a low-level memory object mapped to the image
_mem = self._memobj.memory[mem.number]
if mem.empty:
- _mem.set_raw("\xff" * (_mem.size()/8))
+ _mem.set_raw("\xff" * (_mem.size() // 8))
_mem.empty = 0x00
else:
_mem.empty = self._get_empty_flag(mem.freq, mem.mode)
diff --git a/chirp/drivers/anytone.py b/chirp/drivers/anytone.py
index e99a25d..876583d 100644
--- a/chirp/drivers/anytone.py
+++ b/chirp/drivers/anytone.py
@@ -30,6 +30,18 @@ from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \
LOG = logging.getLogger(__name__)
+BLOCK_SIZE = 0x10
+NUMBER_OF_MEMORY_LOCATIONS = 758
+MEMORY_LOCATION_SIZE = 32
+ADDR_FIRST_WRITABLE_BYTE = 0x0100
+ADDR_LAST_BLOCK_BEFORE_MEMORIES = 0x19F0
+ADDR_FIRST_MEMORY_LOCATION = 0x2000
+
+
+# This _mem_format structure is defined separately from the rest because it
+# needs to be parsed twice -- once in the middle of downloading data from the
+# radio, and then again (along with everything else) once the download is
+# complete.
_mem_format = """
#seekto 0x0100;
struct {
@@ -53,12 +65,15 @@ struct memory {
rxinv:1,
txinv:1,
channel_width:2,
- unknownB:2;
- u8 unknown8:3,
+ rev:1,
+ txoff:1;
+ u8 talkaround:1,
+ compander:1,
+ unknown8:1,
is_am:1,
power:2,
duplex:2;
- u8 unknown4:4,
+ u8 dtmfSlotNum:4,
rxtmode:2,
txtmode:2;
u8 unknown5:2,
@@ -67,10 +82,25 @@ struct memory {
rxtone:6;
u8 txcode;
u8 rxcode;
- u8 unknown7[2];
- u8 unknown2[5];
+ u8 unknown10:2,
+ pttid:2,
+ unknown11:2,
+ bclo:2;
+ u8 unknown7;
+ u8 unknown9:5,
+ sqlMode:3; // [Carrier, CTCSS/DCS Tones,
+ // Opt Sig Only, Tones & Opt Sig,
+ // Tones or Opt Sig]
+ u8 unknown21:6,
+ optsig:2;
+ u8 unknown22:3,
+ twotone:5;
+ u8 unknown23:1,
+ fivetone:7;
+ u8 unknown24:4,
+ scramble:4;
char name[7];
- u8 unknownZ[2];
+ ul16 custtone;
};
#seekto 0x0030;
@@ -88,16 +118,19 @@ struct {
u8 unknown1:6,
display:2;
u8 unknown2[11];
+ // TODO Backlight brightness is in here (RGB)
u8 unknown3:3,
apo:5;
u8 unknown4a[2];
u8 unknown4b:6,
mute:2;
+ // TODO Keypad locked is in here (0=unlocked, 1=locked)
u8 unknown4;
u8 unknown5:5,
beep:1,
unknown6:2;
u8 unknown[334];
+ // TODO Programmable keys A-D are here
char welcome[8];
} settings;
@@ -105,7 +138,9 @@ struct {
struct memory memblk1[12];
#seekto 0x2000;
-struct memory memory[758];
+struct memory memory[758]; // FIXME It's actually only 750
+
+// TODO VFO scan limits are here (after the 750th memory; seekto 0x7DC0)
#seekto 0x7ec0;
struct memory memblk2[10];
@@ -163,11 +198,11 @@ def _is_loc_used(memobj, loc):
def _addr_to_loc(addr):
- return (addr - 0x2000) / 32
+ return (addr - ADDR_FIRST_MEMORY_LOCATION) / MEMORY_LOCATION_SIZE
def _should_send_addr(memobj, addr):
- if addr < 0x2000 or addr >= 0x7EC0:
+ if addr < ADDR_FIRST_MEMORY_LOCATION or addr >= 0x7EC0:
return True
else:
return _is_loc_used(memobj, _addr_to_loc(addr))
@@ -177,7 +212,7 @@ def _echo_write(radio, data):
try:
radio.pipe.write(data)
radio.pipe.read(len(data))
- except Exception, e:
+ except Exception as e:
LOG.error("Error writing to radio: %s" % e)
raise errors.RadioError("Unable to write to radio")
@@ -185,7 +220,7 @@ def _echo_write(radio, data):
def _read(radio, length):
try:
data = radio.pipe.read(length)
- except Exception, e:
+ except Exception as e:
LOG.error("Error reading from radio: %s" % e)
raise errors.RadioError("Unable to read from radio")
@@ -205,7 +240,7 @@ def _ident(radio):
response = radio.pipe.read(3)
if response != "QX\x06":
LOG.debug("Response was:\n%s" % util.hexprint(response))
- raise errors.RadioError("Unsupported model")
+ raise errors.RadioError("Unsupported model or bad connection")
_echo_write(radio, "\x02")
response = radio.pipe.read(16)
LOG.debug(util.hexprint(response))
@@ -274,11 +309,11 @@ def _download(radio):
data = ""
for start, end in radio._ranges:
- for addr in range(start, end, 0x10):
+ for addr in range(start, end, BLOCK_SIZE):
if memobj is not None and not _should_send_addr(memobj, addr):
- block = "\xFF" * 0x10
+ block = "\xFF" * BLOCK_SIZE
else:
- block = _send(radio, 'R', addr, 0x10)
+ block = _send(radio, 'R', addr, BLOCK_SIZE)
data += block
status = chirp_common.Status()
@@ -287,7 +322,7 @@ def _download(radio):
status.msg = "Cloning from radio"
radio.status_fn(status)
- if addr == 0x19F0:
+ if addr == ADDR_LAST_BLOCK_BEFORE_MEMORIES:
memobj = bitwise.parse(_mem_format, data)
_finish(radio)
@@ -299,12 +334,12 @@ def _upload(radio):
_ident(radio)
for start, end in radio._ranges:
- for addr in range(start, end, 0x10):
- if addr < 0x0100:
+ for addr in range(start, end, BLOCK_SIZE):
+ if addr < ADDR_FIRST_WRITABLE_BYTE:
continue
if not _should_send_addr(radio._memobj, addr):
continue
- block = radio._mmap[addr:addr + 0x10]
+ block = radio._mmap[addr:addr + BLOCK_SIZE]
_send(radio, 'W', addr, len(block), block)
status = chirp_common.Status()
@@ -318,12 +353,25 @@ def _upload(radio):
TONES = [62.5] + list(chirp_common.TONES)
TMODES = ['', 'Tone', 'DTCS', '']
-DUPLEXES = ['', '-', '+', '']
+DUPLEXES = ['', '-', '+', 'off']
MODES = ["FM", "FM", "NFM"]
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=50),
chirp_common.PowerLevel("Mid1", watts=25),
chirp_common.PowerLevel("Mid2", watts=10),
chirp_common.PowerLevel("Low", watts=5)]
+BCLO = ['Off', 'Repeater', 'Busy']
+DTMF_SLOTS = ['M%d' % x for x in range(1, 17)]
+# Chose not to expose SCRAMBLE_CODES = ['Off'] +
+# ['%d' % x for x in range(1, 10)] + ['Define 1', 'Define 2']
+TONE2_SLOTS = ['%d' % x for x in range(0, 24)]
+TONE5_SLOTS = ['%d' % x for x in range(0, 100)]
+SQL_MODES = ["Carrier", "CTCSS/DCS", "Opt Sig Only", "Tones AND Sig",
+ "Tones OR Sig"]
+OPT_SIG_SQL = ["Off"] + SQL_MODES[2:]
+OPT_SIGS = ['Off', 'DTMF', '2Tone', '5Tone']
+PTT_IDS = ['Off', 'Begin', 'End', 'Begin & End']
+TUNING_STEPS = [2.5, 5, 6.25, 10, 12.5, 15, 20, 25, 30, 50]
+# FIXME (1) Not sure if 15 is a valid step, (2) 100 might be a valid step
@directory.register
@@ -333,7 +381,7 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
VENDOR = "AnyTone"
MODEL = "5888UV"
BAUD_RATE = 9600
- _file_ident = "QX588UV"
+ _file_ident = [b"QX588UV", b"588UVN"]
# May try to mirror the OEM behavior later
_ranges = [
@@ -353,7 +401,8 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
rf.has_settings = True
rf.has_bank = False
rf.has_cross = True
- rf.has_tuning_step = False
+ rf.valid_duplexes = DUPLEXES
+ rf.valid_tuning_steps = TUNING_STEPS
rf.has_rx_dtcs = True
rf.valid_skips = ["", "S", "P"]
rf.valid_modes = ["FM", "NFM", "AM"]
@@ -365,7 +414,7 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "-"
rf.valid_name_length = 7
rf.valid_power_levels = POWER_LEVELS
- rf.memory_bounds = (1, 758)
+ rf.memory_bounds = (1, NUMBER_OF_MEMORY_LOCATIONS)
return rf
def sync_in(self):
@@ -410,21 +459,46 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
return mem
mem.freq = int(_mem.freq) * 100
+
+ # compensate for 6.25 and 12.5 kHz tuning steps, add 500 Hz if needed
+ lastdigit = int(_mem.freq) % 10
+ if (lastdigit == 2 or lastdigit == 7):
+ mem.freq += 50
+
mem.offset = int(_mem.offset) * 100
mem.name = str(_mem.name).rstrip()
mem.duplex = DUPLEXES[_mem.duplex]
mem.mode = _mem.is_am and "AM" or MODES[_mem.channel_width]
+ mem.tuning_step = TUNING_STEPS[_mem.tune_step]
+
+ if _mem.txoff:
+ mem.duplex = DUPLEXES[3]
rxtone = txtone = None
rxmode = TMODES[_mem.rxtmode]
+ if (_mem.sqlMode == SQL_MODES.index("Carrier") or
+ _mem.sqlMode == SQL_MODES.index("Opt Sig Only")):
+ rxmode = TMODES.index('')
txmode = TMODES[_mem.txtmode]
if txmode == "Tone":
- txtone = TONES[_mem.txtone]
+ # If custom tone is being used, show as 88.5 (and set
+ # checkbox in extras) Future: Improve chirp_common, so I
+ # can add "CUSTOM" into TONES
+ if _mem.txtone == len(TONES):
+ txtone = 88.5
+ else:
+ txtone = TONES[_mem.txtone]
elif txmode == "DTCS":
txtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(_mem,
'tx')]
if rxmode == "Tone":
- rxtone = TONES[_mem.rxtone]
+ # If custom tone is being used, show as 88.5 (and set
+ # checkbox in extras) Future: Improve chirp_common, so I
+ # can add "CUSTOM" into TONES
+ if _mem.rxtone == len(TONES):
+ rxtone = 88.5
+ else:
+ rxtone = TONES[_mem.rxtone]
elif rxmode == "DTCS":
rxtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(_mem,
'rx')]
@@ -439,6 +513,76 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
mem.skip = _flg.get_skip() and "S" or _flg.get_pskip() and "P" or ""
mem.power = POWER_LEVELS[_mem.power]
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ rs = RadioSetting("rev", "Reverse", RadioSettingValueBoolean(_mem.rev))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("compander", "Compander",
+ RadioSettingValueBoolean(_mem.compander))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("talkaround", "Talkaround",
+ RadioSettingValueBoolean(_mem.talkaround))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("pttid", "PTT ID",
+ RadioSettingValueList(PTT_IDS, PTT_IDS[_mem.pttid]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("bclo", "Busy Channel Lockout",
+ RadioSettingValueList(BCLO, BCLO[_mem.bclo]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("optsig", "Optional Signaling",
+ RadioSettingValueList(OPT_SIGS,
+ OPT_SIGS[_mem.optsig]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("OPTSIGSQL", "Squelch w/Opt Signaling",
+ RadioSettingValueList(
+ OPT_SIG_SQL, SQL_MODES[_mem.sqlMode]
+ if SQL_MODES[_mem.sqlMode] in OPT_SIG_SQL
+ else "Off"))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("dtmfSlotNum", "DTMF",
+ RadioSettingValueList(DTMF_SLOTS,
+ DTMF_SLOTS[_mem.dtmfSlotNum]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("twotone", "2-Tone",
+ RadioSettingValueList(TONE2_SLOTS,
+ TONE2_SLOTS[_mem.twotone]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("fivetone", "5-Tone",
+ RadioSettingValueList(TONE5_SLOTS,
+ TONE5_SLOTS[_mem.fivetone]))
+ mem.extra.append(rs)
+
+ # Chose not to expose scramble rs = RadioSetting("scramble",
+ # "Scrambler Switch", RadioSettingValueList(SCRAMBLE_CODES,
+ # SCRAMBLE_CODES[_mem.scramble])) mem.extra.append(rs)
+
+ # Memory properties dialog is only capable of Boolean and List
+ # RadioSettingValue classes, so cannot configure it rs =
+ # RadioSetting("custtone", "Custom CTCSS",
+ # RadioSettingValueFloat(min(TONES), max(TONES), _mem.custtone
+ # and _mem.custtone / 10 or 151.1, 0.1, 1))
+ # mem.extra.append(rs)
+ custToneStr = chirp_common.format_freq(_mem.custtone)
+
+ rs = RadioSetting("CUSTTONETX",
+ "Use Custom CTCSS (%s) for Tx" % custToneStr,
+ RadioSettingValueBoolean(_mem.txtone == len(TONES)))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("CUSTTONERX",
+ "Use Custom CTCSS (%s) for Rx" % custToneStr,
+ RadioSettingValueBoolean(_mem.rxtone == len(TONES)))
+ mem.extra.append(rs)
+
return mem
def set_memory(self, mem):
@@ -447,13 +591,19 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
_flg.set()
return
_flg.clear()
- _mem.set_raw("\x00" * 32)
+ _mem.set_raw("\x00" * MEMORY_LOCATION_SIZE)
_mem.freq = mem.freq / 100
_mem.offset = mem.offset / 100
_mem.name = mem.name.ljust(7)
_mem.is_am = mem.mode == "AM"
- _mem.duplex = DUPLEXES.index(mem.duplex)
+ _mem.tune_step = TUNING_STEPS.index(mem.tuning_step)
+ if mem.duplex == "off":
+ _mem.duplex = DUPLEXES.index("")
+ _mem.txoff = 1
+ else:
+ _mem.duplex = DUPLEXES.index(mem.duplex)
+ _mem.txoff = 0
try:
_mem.channel_width = MODES.index(mem.mode)
@@ -465,6 +615,10 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
_mem.txtmode = TMODES.index(txmode)
_mem.rxtmode = TMODES.index(rxmode)
+ if rxmode != '':
+ _mem.sqlMode = SQL_MODES.index("CTCSS/DCS")
+ else:
+ _mem.sqlMode = SQL_MODES.index("Carrier")
if txmode == "Tone":
_mem.txtone = TONES.index(txtone)
elif txmode == "DTCS":
@@ -487,6 +641,26 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
else:
_mem.power = 0
+ for setting in mem.extra:
+ if setting.get_name() == "ignore":
+ LOG.debug("*** ignore: %s" % str(setting.value))
+ # Future: elif setting.get_name() == "custtone": Future:
+ # setattr(_mem, "custtone", setting.value.get_value() *
+ # 10)
+ elif setting.get_name() == "OPTSIGSQL":
+ if str(setting.value) != "Off":
+ _mem.sqlMode = SQL_MODES.index(str(setting.value))
+ elif setting.get_name() == "CUSTTONETX":
+ if setting.value:
+ _mem.txtone = len(TONES)
+ elif setting.get_name() == "CUSTTONERX":
+ if setting.value:
+ _mem.rxtone = len(TONES)
+ else:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ return mem
+
def get_settings(self):
_settings = self._memobj.settings
basic = RadioSettingGroup("basic", "Basic")
@@ -511,19 +685,20 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
s_ += (c if c in chirp_common.CHARSET_ASCII else "")
return s_
+ welcome_msg = ''.join(filter(_settings.welcome))
rs = RadioSetting("welcome", "Welcome Message",
- RadioSettingValueString(0, 8,
- filter(_settings.welcome)))
+ RadioSettingValueString(0, 8, welcome_msg))
+
basic.append(rs)
rs = RadioSetting("beep", "Beep Enabled",
RadioSettingValueBoolean(_settings.beep))
basic.append(rs)
- mute = ["Off", "TX", "RX", "TX/RX"]
+ MUTE_CHOICES = ["Off", "TX", "RX", "TX/RX"]
rs = RadioSetting("mute", "Sub Band Mute",
- RadioSettingValueList(mute,
- mute[_settings.mute]))
+ RadioSettingValueList(MUTE_CHOICES,
+ MUTE_CHOICES[_settings.mute]))
basic.append(rs)
return settings
@@ -539,7 +714,10 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio,
@classmethod
def match_model(cls, filedata, filename):
- return cls._file_ident in filedata[0x20:0x40]
+ for _ident in cls._file_ident:
+ if _ident in filedata[0x20:0x40]:
+ return True
+ return False
@directory.register
@@ -547,7 +725,7 @@ class IntekHR2040Radio(AnyTone5888UVRadio):
"""Intek HR-2040"""
VENDOR = "Intek"
MODEL = "HR-2040"
- _file_ident = "HR-2040"
+ _file_ident = [b"HR-2040"]
@directory.register
@@ -555,7 +733,7 @@ class PolmarDB50MRadio(AnyTone5888UVRadio):
"""Polmar DB-50M"""
VENDOR = "Polmar"
MODEL = "DB-50M"
- _file_ident = "DB-50M"
+ _file_ident = [b"DB-50M"]
@directory.register
@@ -563,7 +741,7 @@ class PowerwerxDB750XRadio(AnyTone5888UVRadio):
"""Powerwerx DB-750X"""
VENDOR = "Powerwerx"
MODEL = "DB-750X"
- _file_ident = "DB-750X"
+ _file_ident = [b"DB-750X"]
def get_settings(self):
return {}
diff --git a/chirp/drivers/anytone778uv.py b/chirp/drivers/anytone778uv.py
new file mode 100644
index 0000000..ace5ab5
--- /dev/null
+++ b/chirp/drivers/anytone778uv.py
@@ -0,0 +1,1792 @@
+# Copyright 2020 Joe Milbourn <joe@milbourn.org.uk>
+# Copyright 2021 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# TODO use the band field from ver_response
+# TODO handle radio settings
+#
+# Supported features
+# * Read and write memory access for 200 normal memories
+# * CTCSS and DTCS for transmit and receive
+# * Scan list
+# * Tx off
+# * Duplex (+ve, -ve, odd, and off splits)
+# * Transmit power
+# * Channel width (25kHz and 12.5kHz)
+# * Retevis RT95, CRT Micron UV, and Midland DBR2500 radios
+# * Full range of frequencies for tx and rx, supported band read from radio
+# during download, not verified on upload. Radio will refuse to TX if out of
+# band.
+#
+# Unsupported features
+# * VFO1, VFO2, and TRF memories
+# * custom CTCSS tones
+# * Any non-memory radio settings
+# * Reverse, talkaround, scramble
+# * busy channel lock out
+# * probably other things too - like things encoded by the unknown bits in the
+# memory struct
+
+from chirp import chirp_common, directory, memmap, errors, util
+from chirp import bitwise
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
+
+import struct
+import time
+import logging
+
+LOG = logging.getLogger(__name__)
+
+# Gross hack to handle missing future module on un-updatable
+# platforms like MacOS. Just avoid registering these radio
+# classes for now.
+try:
+ from builtins import bytes
+ has_future = True
+except ImportError:
+ has_future = False
+ LOG.debug('python-future package is not '
+ 'available; %s requires it' % __name__)
+
+
+# Here is where we define the memory map for the radio. Since
+# We often just know small bits of it, we can use #seekto to skip
+# around as needed.
+
+MEM_FORMAT = '''
+#seekto 0x0000;
+struct {
+ bbcd freq[4];
+ bbcd offset[4];
+ u8 unknown1;
+ u8 talkaround:1,
+ scramble:1,
+ unknown:2,
+ txpower:2,
+ duplex:2;
+ u8 unknown_bits1:4,
+ channel_width:2,
+ reverse:1,
+ tx_off:1;
+ u8 unknown_bits2:4,
+ dtcs_decode_en:1,
+ ctcss_decode_en:1,
+ dtcs_encode_en:1,
+ ctcss_encode_en:1;
+ u8 ctcss_dec_tone;
+ u8 ctcss_enc_tone;
+ u8 dtcs_decode_code;
+ u8 unknown_bits6:6,
+ dtcs_decode_invert:1,
+ dtcs_decode_code_highbit:1;
+ u8 dtcs_encode_code;
+ u8 unknown_bits7:6,
+ dtcs_encode_invert:1,
+ dtcs_encode_code_highbit:1;
+ u8 unknown_bits4:6,
+ busy_channel_lockout:2;
+ u8 unknown6;
+ u8 unknown_bits5:7,
+ tone_squelch_en:1;
+ u8 unknown7;
+ u8 unknown8;
+ u8 unknown9;
+ char name[6]; // the VOX models have 6-character names
+ // the original models only have 5-character names
+ // the 1st byte is not used and will always be 0x00
+ ul16 customctcss;
+} memory[200];
+#seekto 0x1940;
+struct {
+ u8 occupied_bitfield[32];
+ u8 scan_enabled_bitfield[32];
+} memory_status;
+
+#seekto 0x1980;
+struct {
+ char line[7]; // starting display
+} starting_display;
+
+#seekto 0x1990;
+struct {
+ u8 code[16]; // DTMF Encode M1-M16
+} pttid[16];
+
+#seekto 0x1A90;
+struct {
+ u8 pttIdStart[16]; // 0x1A90 ptt id starting
+ u8 pttIdEnd[16]; // 0x1AA0 ptt id ending
+ u8 remoteStun[16]; // 0x1AB0 remotely stun
+ u8 remoteKill[16]; // 0x1AC0 remotely kill
+ u8 intervalChar; // 0x1AD0 dtmf interval character
+ u8 groupCode; // 0x1AD1 group code
+ u8 unk1ad2:6, // 0x1AD2
+ decodingResponse:2; // decoding response
+ u8 pretime; // 0x1AD3 pretime
+ u8 firstDigitTime; // 0x1AD4 first digit time
+ u8 autoResetTime; // 0x1AD5 auto reset time
+ u8 selfID[3]; // 0x1AD6 dtmf self id
+ u8 unk1ad9:7, // 0x1AD9
+ sideTone:1; // side tone
+ u8 timeLapse; // 0x1ADA time-lapse after encode
+ u8 pauseTime; // 0x1ADB ptt id pause time
+} dtmf;
+
+#seekto 0x3200;
+struct {
+ u8 unk3200:5, // 0x3200
+ beepVolume:3; // beep volume
+ u8 unk3201:4, // 0x3201
+ frequencyStep:4; // frequency step
+ u8 unk3202:6, // 0x3202
+ displayMode:2; // display mode
+ u8 unk0x3203;
+ u8 unk3204:4, // 0x3204
+ squelchLevelA:4; // squelch level a
+ u8 unk3205:4, // 0x3205
+ squelchLevelB:4; // squelch level b
+ u8 unk3206:2, // 0x3206
+ speakerVol:6; // speaker volume
+ u8 unk3207:7, // 0x3207
+ powerOnPasswd:1; // power-on password
+ u8 unk3208:6, // 0x3208
+ scanType:2; // scan type
+ u8 unk3209:6, // 0x3209
+ scanRecoveryT:2; // scan recovery time
+ u8 unk320a:7, // 0x320A
+ autoPowerOn:1; // auto power on
+ u8 unk320b:7, // 0x320B
+ main:1; // main
+ u8 unk320c:7, // 0x320C
+ dualWatch:1; // dual watch (rx way select)
+ u8 unk320d:5, // 0x320D
+ backlightBr:3; // backlight brightness
+ u8 unk320e:3, // 0x320E
+ timeOutTimer:5; // time out timer
+ u8 unk320f:6, // 0x320F
+ autoPowerOff:2; // auto power off
+ u8 unk3210:6, // 0x3210
+ tbstFrequency:2; // tbst frequency
+ u8 unk3211:7, // 0x3211
+ screenDir:1; // screen direction
+ u8 unk3212:2, // 0x3212
+ micKeyBrite:6; // hand mic key brightness
+ u8 unk3213:6, // 0x3213
+ speakerSwitch:2; // speaker switch
+ u8 keyPA; // 0x3214 key pa
+ u8 keyPB; // 0x3215 key pb
+ u8 keyPC; // 0x3216 key pc
+ u8 keyPD; // 0x3217 key pd
+ u8 unk3218:5, // 0x3218
+ steType:3; // ste type
+ u8 unk3219:6, // 0x3219
+ steFrequency:2; // ste frequency
+ u8 unk321a:5, // 0x321A
+ dtmfTxTime:3; // dtmf transmitting time
+ u8 unk_bit7_6:2, // 0x321B
+ monKeyFunction:1, // mon key function
+ channelLocked:1, // channel locked
+ saveChParameter:1, // save channel parameter
+ powerOnReset:1, // power on reset
+ trfEnable:1, // trf enable
+ knobMode:1; // knob mode
+ u8 unk321c:7, // 0x321C
+ voxOnOff:1; // vox on/off
+ u8 voxLevel; // 0x321D vox level
+ u8 voxDelay; // 0x321E vox delay
+} settings;
+
+#seekto 0x3240;
+struct {
+ char digits[6]; // password
+} password;
+
+#seekto 0x3250;
+struct {
+ u8 keyMode1P1; // 0x3250 key mode 1 p1
+ u8 keyMode1P2; // 0x3251 key mode 1 p2
+ u8 keyMode1P3; // 0x3252 key mode 1 p3
+ u8 keyMode1P4; // 0x3253 key mode 1 p4
+ u8 keyMode1P5; // 0x3254 key mode 1 p5
+ u8 keyMode1P6; // 0x3255 key mode 1 p6
+ u8 keyMode2P1; // 0x3256 key mode 2 p1
+ u8 keyMode2P2; // 0x3257 key mode 2 p2
+ u8 keyMode2P3; // 0x3258 key mode 2 p3
+ u8 keyMode2P4; // 0x3259 key mode 2 p4
+ u8 keyMode2P5; // 0x325A key mode 2 p5
+ u8 keyMode2P6; // 0x325B key mode 2 p6
+} pfkeys;
+
+#seekto 0x3260;
+struct {
+ u8 mrChanA; // 0x3260 mr channel a
+ u8 unknown1_0:7, // 0x3261
+ vfomrA:1; // vfo/mr mode a
+ u8 unknown2;
+ u8 unknown3;
+ u8 unknown4;
+ u8 unknown5;
+ u8 unknown6;
+ u8 mrChanB; // 0x3267 mr channel b
+ u8 unknown8_0:4, // 0x3268
+ scan_active:1,
+ unknown8_1:2,
+ vfomrB:1; // vfo/mr mode b
+ u8 unknown9;
+ u8 unknowna;
+ u8 unknownb;
+ u8 unknownc;
+ u8 bandlimit; // 0x326D mode
+ u8 unknownd;
+ u8 unknowne;
+ u8 unknownf;
+} radio_settings;
+'''
+
+# Format for the version messages returned by the radio
+VER_FORMAT = '''
+u8 hdr;
+char model[7];
+u8 bandlimit;
+char version[6];
+u8 ack;
+'''
+
+TXPOWER_LOW = 0x00
+TXPOWER_MED = 0x01
+TXPOWER_HIGH = 0x02
+
+DUPLEX_NOSPLIT = 0x00
+DUPLEX_POSSPLIT = 0x01
+DUPLEX_NEGSPLIT = 0x02
+DUPLEX_ODDSPLIT = 0x03
+
+CHANNEL_WIDTH_25kHz = 0x02
+CHANNEL_WIDTH_20kHz = 0x01
+CHANNEL_WIDTH_12d5kHz = 0x00
+
+BUSY_CHANNEL_LOCKOUT_OFF = 0x00
+BUSY_CHANNEL_LOCKOUT_REPEATER = 0x01
+BUSY_CHANNEL_LOCKOUT_BUSY = 0x02
+
+MEMORY_ADDRESS_RANGE = (0x0000, 0x3290)
+MEMORY_RW_BLOCK_SIZE = 0x10
+MEMORY_RW_BLOCK_CMD_SIZE = 0x16
+
+POWER_LEVELS = [chirp_common.PowerLevel('Low', dBm=37),
+ chirp_common.PowerLevel('Medium', dBm=40),
+ chirp_common.PowerLevel('High', dBm=44)]
+
+# CTCSS Tone definitions
+TONE_CUSTOM_CTCSS = 0x33
+TONE_MAP_VAL_TO_TONE = {0x00: 62.5, 0x01: 67.0, 0x02: 69.3,
+ 0x03: 71.9, 0x04: 74.4, 0x05: 77.0,
+ 0x06: 79.7, 0x07: 82.5, 0x08: 85.4,
+ 0x09: 88.5, 0x0a: 91.5, 0x0b: 94.8,
+ 0x0c: 97.4, 0x0d: 100.0, 0x0e: 103.5,
+ 0x0f: 107.2, 0x10: 110.9, 0x11: 114.8,
+ 0x12: 118.8, 0x13: 123.0, 0x14: 127.3,
+ 0x15: 131.8, 0x16: 136.5, 0x17: 141.3,
+ 0x18: 146.2, 0x19: 151.4, 0x1a: 156.7,
+ 0x1b: 159.8, 0x1c: 162.2, 0x1d: 165.5,
+ 0x1e: 167.9, 0x1f: 171.3, 0x20: 173.8,
+ 0x21: 177.3, 0x22: 179.9, 0x23: 183.5,
+ 0x24: 186.2, 0x25: 189.9, 0x26: 192.8,
+ 0x27: 196.6, 0x28: 199.5, 0x29: 203.5,
+ 0x2a: 206.5, 0x2b: 210.7, 0x2c: 218.1,
+ 0x2d: 225.7, 0x2e: 229.1, 0x2f: 233.6,
+ 0x30: 241.8, 0x31: 250.3, 0x32: 254.1}
+
+TONE_MAP_TONE_TO_VAL = {TONE_MAP_VAL_TO_TONE[val]: val
+ for val in TONE_MAP_VAL_TO_TONE}
+
+TONES_EN_TXTONE = (1 << 3)
+TONES_EN_RXTONE = (1 << 2)
+TONES_EN_TXCODE = (1 << 1)
+TONES_EN_RXCODE = (1 << 0)
+TONES_EN_NO_TONE = 0
+
+# Radio supports upper case and symbols
+CHARSET_ASCII_PLUS = chirp_common.CHARSET_UPPER_NUMERIC + '- '
+
+# Band limits as defined by the band byte in ver_response, defined in Hz, for
+# VHF and UHF, used for RX and TX.
+BAND_LIMITS = {0x00: [(144000000, 148000000), (430000000, 440000000)],
+ 0x01: [(136000000, 174000000), (400000000, 490000000)],
+ 0x02: [(144000000, 146000000), (430000000, 440000000)]}
+
+
+# Get band limits from a band limit value
+def get_band_limits_Hz(limit_value):
+ if limit_value not in BAND_LIMITS:
+ limit_value = 0x01
+ LOG.warning('Unknown band limit value 0x%02x, default to 0x01')
+ bandlimitfrequencies = BAND_LIMITS[limit_value]
+ return bandlimitfrequencies
+
+
+# Calculate the checksum used in serial packets
+def checksum(message_bytes):
+ mask = 0xFF
+ checksum = 0
+ for b in message_bytes:
+ checksum = (checksum + b) & mask
+ return checksum
+
+
+# Send a command to the radio, return any reply stripping the echo of the
+# command (tx and rx share a single pin in this radio)
+def send_serial_command(serial, command, expectedlen=None):
+ ''' send a command to the radio, and return any response.
+ set expectedlen to return as soon as that many bytes are read.
+ '''
+ serial.write(command)
+ serial.flush()
+
+ response = b''
+ tout = time.time() + 0.5
+ while time.time() < tout:
+ if serial.inWaiting():
+ response += serial.read()
+ # remember everything gets echo'd back
+ if len(response) - len(command) == expectedlen:
+ break
+
+ # cut off what got echo'd back, we don't need to see it again
+ if response.startswith(command):
+ response = response[len(command):]
+
+ return response
+
+
+# strip trailing 0x00 to convert a string returned by bitwise.parse into a
+# python string
+def cstring_to_py_string(cstring):
+ return "".join(c for c in cstring if c != '\x00')
+
+
+# Check the radio version reported to see if it's one we support,
+# returns bool version supported, and the band index
+def check_ver(ver_response, allowed_types):
+ ''' Check the returned radio version is one we approve of '''
+
+ LOG.debug('ver_response = ')
+ LOG.debug(util.hexprint(ver_response))
+
+ global HAS_VOX
+
+ resp = bitwise.parse(VER_FORMAT, ver_response)
+ verok = False
+
+ if resp.hdr == 0x49 and resp.ack == 0x06:
+ model, version = [cstring_to_py_string(bitwise.get_string(s)).strip()
+ for s in (resp.model, resp.version)]
+ LOG.debug('radio model: \'%s\' version: \'%s\'' %
+ (model, version))
+ LOG.debug('allowed_types = %s' % allowed_types)
+
+ HAS_VOX = "P" == model[-1:]
+
+ if model in allowed_types:
+ LOG.debug('model in allowed_types')
+
+ if version in allowed_types[model]:
+ LOG.debug('version in allowed_types[model]')
+ verok = True
+ else:
+ raise errors.RadioError('Failed to parse version response')
+
+ return verok, int(resp.bandlimit)
+
+
+# Put the radio in programming mode, sending the initial command and checking
+# the response. raise RadioError if there is no response (500ms timeout), and
+# if the returned version isn't matched by check_ver
+def enter_program_mode(radio):
+ serial = radio.pipe
+ # place the radio in program mode, and confirm
+ program_response = send_serial_command(serial, b'PROGRAM')
+
+ if program_response != b'QX\x06':
+ raise errors.RadioError('No initial response from radio.')
+ LOG.debug('entered program mode')
+
+ # read the radio ID string, make sure it matches one we know about
+ ver_response = send_serial_command(serial, b'\x02')
+
+ verok, bandlimit = check_ver(ver_response, radio.ALLOWED_RADIO_TYPES)
+ if not verok:
+ exit_program_mode(radio)
+ ver = "V2" if radio.VENDOR == "CRT" else "VOX"
+ if HAS_VOX and ("V2" and "VOX") not in radio.MODEL:
+ raise errors.RadioError(
+ 'Radio identified as model with VOX\n'
+ 'Try %s-%s %s' %
+ (radio.VENDOR, radio.MODEL, ver))
+ else:
+ raise errors.RadioError(
+ 'Radio version not in allowed list for %s-%s:\n'
+ '%s' %
+ (radio.VENDOR, radio.MODEL, util.hexprint(ver_response)))
+
+ return bandlimit
+
+
+# Exit programming mode
+def exit_program_mode(radio):
+ send_serial_command(radio.pipe, b'END')
+
+
+# Parse a packet from the radio returning the header (R/W, address, data, and
+# checksum valid
+def parse_read_response(resp):
+ addr = resp[:4]
+ data = bytes(resp[4:-2])
+ cs = checksum(ord(d) for d in resp[1:-2])
+ valid = cs == ord(resp[-2])
+ if not valid:
+ LOG.error('checksumfail: %02x, expected %02x' % (cs, ord(resp[-2])))
+ LOG.error('msg data: %s' % util.hexprint(resp))
+ return addr, data, valid
+
+
+# Download data from the radio and populate the memory map
+def do_download(radio):
+ '''Download memories from the radio'''
+
+ # Get the serial port connection
+ serial = radio.pipe
+
+ try:
+ enter_program_mode(radio)
+
+ memory_data = bytes()
+
+ # status info for the UI
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = (MEMORY_ADDRESS_RANGE[1] -
+ MEMORY_ADDRESS_RANGE[0])/MEMORY_RW_BLOCK_SIZE
+ status.msg = 'Cloning from radio...'
+ radio.status_fn(status)
+
+ for addr in range(MEMORY_ADDRESS_RANGE[0],
+ MEMORY_ADDRESS_RANGE[1] + MEMORY_RW_BLOCK_SIZE,
+ MEMORY_RW_BLOCK_SIZE):
+ read_command = struct.pack('>BHB', 0x52, addr,
+ MEMORY_RW_BLOCK_SIZE)
+ read_response = send_serial_command(serial, read_command,
+ MEMORY_RW_BLOCK_CMD_SIZE)
+ # LOG.debug('read response:\n%s' % util.hexprint(read_response))
+
+ address, data, valid = parse_read_response(read_response)
+ memory_data += data
+
+ # update UI
+ status.cur = (addr - MEMORY_ADDRESS_RANGE[0])\
+ / MEMORY_RW_BLOCK_SIZE
+ radio.status_fn(status)
+
+ exit_program_mode(radio)
+ except errors.RadioError as e:
+ raise e
+ except Exception as e:
+ raise errors.RadioError('Failed to download from radio: %s' % e)
+
+ return memmap.MemoryMapBytes(memory_data)
+
+
+# Build a write data command to send to the radio
+def make_write_data_cmd(addr, data, datalen):
+ cmd = struct.pack('>BHB', 0x57, addr, datalen)
+ cmd += data
+ cs = checksum(ord(c) for c in cmd[1:])
+ cmd += struct.pack('>BB', cs, 0x06)
+ return cmd
+
+
+# Upload a memory map to the radio
+def do_upload(radio):
+ try:
+ bandlimit = enter_program_mode(radio)
+
+ if bandlimit != radio._memobj.radio_settings.bandlimit:
+ LOG.warning('radio and image bandlimits differ'
+ ' some channels many not work'
+ ' (img:0x%02x radio:0x%02x)' %
+ (int(bandlimit),
+ int(radio._memobj.radio_settings.bandlimit)))
+ LOG.warning('radio bands: %s' % get_band_limits_Hz(
+ int(radio._memobj.radio_settings.bandlimit)))
+ LOG.warning('img bands: %s' % get_band_limits_Hz(bandlimit))
+
+ serial = radio.pipe
+
+ # send the initial message, radio responds with something that looks a
+ # bit like a bitfield, but I don't know what it is yet.
+ read_command = struct.pack('>BHB', 0x52, 0x3b10, MEMORY_RW_BLOCK_SIZE)
+ read_response = send_serial_command(serial, read_command,
+ MEMORY_RW_BLOCK_CMD_SIZE)
+ address, data, valid = parse_read_response(read_response)
+ LOG.debug('Got initial response from radio: %s' %
+ util.hexprint(read_response))
+
+ bptr = 0
+
+ memory_addrs = list(range(MEMORY_ADDRESS_RANGE[0],
+ MEMORY_ADDRESS_RANGE[1] +
+ MEMORY_RW_BLOCK_SIZE,
+ MEMORY_RW_BLOCK_SIZE))
+
+ # status info for the UI
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = len(memory_addrs)
+ status.msg = 'Cloning to radio...'
+ radio.status_fn(status)
+
+ for idx, addr in enumerate(memory_addrs):
+ write_command = make_write_data_cmd(
+ addr, radio._mmap[bptr:bptr+MEMORY_RW_BLOCK_SIZE],
+ MEMORY_RW_BLOCK_SIZE)
+ # LOG.debug('write data:\n%s' % util.hexprint(write_command))
+ write_response = send_serial_command(serial, write_command, 0x01)
+ bptr += MEMORY_RW_BLOCK_SIZE
+
+ if write_response == '\x0a':
+ # NACK from radio, e.g. checksum wrongn
+ LOG.debug('Radio returned 0x0a - NACK:')
+ LOG.debug(' * write cmd:\n%s' % util.hexprint(write_command))
+ LOG.debug(' * write response:\n%s' %
+ util.hexprint(write_response))
+ exit_program_mode(radio)
+ raise errors.RadioError('Radio NACK\'d write command')
+
+ # update UI
+ status.cur = idx
+ radio.status_fn(status)
+ exit_program_mode(radio)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError('Failed to download from radio: %s' % e)
+
+
+# Get the value of @bitfield @number of bits in from 0
+def get_bitfield(bitfield, number):
+ ''' Get the value of @bitfield @number of bits in '''
+ byteidx = number//8
+ bitidx = number - (byteidx * 8)
+ return bitfield[byteidx] & (1 << bitidx)
+
+
+# Set the @value of @bitfield @number of bits in from 0
+def set_bitfield(bitfield, number, value):
+ ''' Set the @value of @bitfield @number of bits in '''
+ byteidx = number//8
+ bitidx = number - (byteidx * 8)
+ if value is True:
+ bitfield[byteidx] |= (1 << bitidx)
+ else:
+ bitfield[byteidx] &= ~(1 << bitidx)
+ return bitfield
+
+
+# Translate the radio's version of a code as stored to a real code
+def dtcs_code_bits_to_val(highbit, lowbyte):
+ return chirp_common.ALL_DTCS_CODES[highbit*256 + lowbyte]
+
+
+# Translate the radio's version of a tone as stored to a real tone
+def ctcss_tone_bits_to_val(tone_byte):
+ # TODO use the custom setting 0x33 and ref the custom ctcss
+ # field
+ tone_byte = int(tone_byte)
+ if tone_byte in TONE_MAP_VAL_TO_TONE:
+ return TONE_MAP_VAL_TO_TONE[tone_byte]
+ elif tone_byte == TONE_CUSTOM_CTCSS:
+ LOG.info('custom ctcss not implemented (yet?).')
+ else:
+ raise errors.UnsupportedToneError('unknown ctcss tone value: %02x' %
+ tone_byte)
+
+
+# Translate a real tone to the radio's version as stored
+def ctcss_code_val_to_bits(tone_value):
+ if tone_value in TONE_MAP_TONE_TO_VAL:
+ return TONE_MAP_TONE_TO_VAL[tone_value]
+ else:
+ raise errors.UnsupportedToneError('Tone %f not supported' % tone_value)
+
+
+# Translate a real code to the radio's version as stored
+def dtcs_code_val_to_bits(code):
+ val = chirp_common.ALL_DTCS_CODES.index(code)
+ return (val & 0xFF), ((val >> 8) & 0x01)
+
+
+class AnyTone778UVBase(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
+ '''AnyTone 778UV and probably Retivis RT95 and others'''
+ BAUD_RATE = 9600
+ NEEDS_COMPAT_SERIAL = False
+ NAME_LENGTH = 5
+ HAS_VOX = False
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+
+ rp.experimental = \
+ ('This is experimental support for the %s %s. '
+ 'Please send in bug and enhancement requests!' %
+ (cls.VENDOR, cls.MODEL))
+
+ return rp
+
+ # Return information about this radio's features, including
+ # how many memories it has, what bands it supports, etc
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_bank = False
+ rf.has_settings = True
+ rf.can_odd_split = True
+ rf.has_name = True
+ rf.has_offset = True
+ rf.valid_name_length = self.NAME_LENGTH
+ rf.valid_duplexes = ['', '+', '-', 'split', 'off']
+ rf.valid_characters = CHARSET_ASCII_PLUS
+
+ rf.has_dtcs = True
+ rf.has_rx_dtcs = True
+ rf.has_dtcs_polarity = True
+ rf.valid_dtcs_codes = chirp_common.ALL_DTCS_CODES
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = ['Tone->Tone',
+ 'Tone->DTCS',
+ 'DTCS->Tone',
+ 'DTCS->DTCS',
+ 'DTCS->',
+ '->DTCS',
+ '->Tone']
+
+ rf.memory_bounds = (1, 200) # This radio supports memories 1-200
+ try:
+ rf.valid_bands = get_band_limits_Hz(
+ int(self._memobj.radio_settings.bandlimit))
+ except TypeError as e:
+ # If we're asked without memory loaded, assume the most permissive
+ rf.valid_bands = get_band_limits_Hz(1)
+ except Exception as e:
+ LOG.error('Failed to get band limits for anytone778uv: %s' % e)
+ rf.valid_bands = get_band_limits_Hz(1)
+ rf.valid_modes = ['FM', 'NFM']
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_tuning_steps = [2.5, 5, 6.25, 10, 12.5, 20, 25, 30, 50]
+ rf.has_tuning_step = False
+ return rf
+
+ # Do a download of the radio from the serial port
+ def sync_in(self):
+ self._mmap = do_download(self)
+ self.process_mmap()
+
+ # Do an upload of the radio to the serial port
+ def sync_out(self):
+ do_upload(self)
+
+ # Convert the raw byte array into a memory object structure
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ # Return a raw representation of the memory object, which
+ # is very helpful for development
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ # Extract a high-level memory object from the low-level memory map
+ # This is called to populate a memory in the UI
+ def get_memory(self, number):
+ number -= 1
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[number]
+ _mem_status = self._memobj.memory_status
+
+ # Create a high-level memory object to return to the UI
+ mem = chirp_common.Memory()
+ mem.number = number + 1 # Set the memory number
+
+ # Check if this memory is present in the occupied list
+ mem.empty = get_bitfield(_mem_status.occupied_bitfield, number) == 0
+
+ if not mem.empty:
+ # Check if this memory is in the scan enabled list
+ mem.skip = ''
+ if get_bitfield(_mem_status.scan_enabled_bitfield, number) == 0:
+ mem.skip = 'S'
+
+ # set the name
+ if self.NAME_LENGTH == 5:
+ # original models with 5-character name length
+ temp_name = str(_mem.name)
+ # Strip the first character and set the alpha tag
+ mem.name = str(temp_name[1:6]).rstrip()
+ else:
+ # new VOX models with 6-character name length
+ mem.name = str(_mem.name).rstrip() # Set the alpha tag
+
+ # Convert your low-level frequency and offset to Hertz
+ mem.freq = int(_mem.freq) * 10
+ mem.offset = int(_mem.offset) * 10
+
+ # Set the duplex flags
+ if _mem.duplex == DUPLEX_POSSPLIT:
+ mem.duplex = '+'
+ elif _mem.duplex == DUPLEX_NEGSPLIT:
+ mem.duplex = '-'
+ elif _mem.duplex == DUPLEX_NOSPLIT:
+ mem.duplex = ''
+ elif _mem.duplex == DUPLEX_ODDSPLIT:
+ mem.duplex = 'split'
+ else:
+ LOG.error('%s: get_mem: unhandled duplex: %02x' %
+ (mem.name, _mem.duplex))
+
+ # handle tx off
+ if _mem.tx_off:
+ mem.duplex = 'off'
+
+ # Set the channel width
+ if _mem.channel_width == CHANNEL_WIDTH_25kHz:
+ mem.mode = 'FM'
+ elif _mem.channel_width == CHANNEL_WIDTH_20kHz:
+ LOG.info(
+ '%s: get_mem: promoting 20kHz channel width to 25kHz' %
+ mem.name)
+ mem.mode = 'FM'
+ elif _mem.channel_width == CHANNEL_WIDTH_12d5kHz:
+ mem.mode = 'NFM'
+ else:
+ LOG.error('%s: get_mem: unhandled channel width: 0x%02x' %
+ (mem.name, _mem.channel_width))
+
+ # set the power level
+ if _mem.txpower == TXPOWER_LOW:
+ mem.power = POWER_LEVELS[0]
+ elif _mem.txpower == TXPOWER_MED:
+ mem.power = POWER_LEVELS[1]
+ elif _mem.txpower == TXPOWER_HIGH:
+ mem.power = POWER_LEVELS[2]
+ else:
+ LOG.error('%s: get_mem: unhandled power level: 0x%02x' %
+ (mem.name, _mem.txpower))
+
+ # CTCSS Tones
+ # TODO support custom ctcss tones here
+ txtone = None
+ rxtone = None
+ rxcode = None
+ txcode = None
+
+ # check if dtcs tx is enabled
+ if _mem.dtcs_encode_en:
+ txcode = dtcs_code_bits_to_val(_mem.dtcs_encode_code_highbit,
+ _mem.dtcs_encode_code)
+
+ # check if dtcs rx is enabled
+ if _mem.dtcs_decode_en:
+ rxcode = dtcs_code_bits_to_val(_mem.dtcs_decode_code_highbit,
+ _mem.dtcs_decode_code)
+
+ if txcode is not None:
+ LOG.debug('%s: get_mem dtcs_enc: %d' % (mem.name, txcode))
+ if rxcode is not None:
+ LOG.debug('%s: get_mem dtcs_dec: %d' % (mem.name, rxcode))
+
+ # tsql set if radio squelches on tone
+ tsql = _mem.tone_squelch_en
+
+ # check if ctcss tx is enabled
+ if _mem.ctcss_encode_en:
+ txtone = ctcss_tone_bits_to_val(_mem.ctcss_enc_tone)
+
+ # check if ctcss rx is enabled
+ if _mem.ctcss_decode_en:
+ rxtone = ctcss_tone_bits_to_val(_mem.ctcss_dec_tone)
+
+ # Define this here to allow a readable if-else tree enabling tone
+ # options
+ enabled = 0
+ enabled |= (txtone is not None) * TONES_EN_TXTONE
+ enabled |= (rxtone is not None) * TONES_EN_RXTONE
+ enabled |= (txcode is not None) * TONES_EN_TXCODE
+ enabled |= (rxcode is not None) * TONES_EN_RXCODE
+
+ # Add some debugging output for the tone bitmap
+ enstr = []
+ if enabled & TONES_EN_TXTONE:
+ enstr += ['TONES_EN_TXTONE']
+ if enabled & TONES_EN_RXTONE:
+ enstr += ['TONES_EN_RXTONE']
+ if enabled & TONES_EN_TXCODE:
+ enstr += ['TONES_EN_TXCODE']
+ if enabled & TONES_EN_RXCODE:
+ enstr += ['TONES_EN_RXCODE']
+ if enabled == 0:
+ enstr = ['TONES_EN_NOTONE']
+ LOG.debug('%s: enabled = %s' % (
+ mem.name, '|'.join(enstr)))
+
+ mem.tmode = ''
+ if enabled == TONES_EN_NO_TONE:
+ mem.tmode = ''
+ elif enabled == TONES_EN_TXTONE:
+ mem.tmode = 'Tone'
+ mem.rtone = txtone
+ elif enabled == TONES_EN_RXTONE and tsql:
+ mem.tmode = 'Cross'
+ mem.cross_mode = '->Tone'
+ mem.ctone = rxtone
+ elif enabled == (TONES_EN_TXTONE | TONES_EN_RXTONE) and tsql:
+ if txtone == rxtone: # TSQL
+ mem.tmode = 'TSQL'
+ mem.ctone = txtone
+ else: # Tone->Tone
+ mem.tmode = 'Cross'
+ mem.cross_mode = 'Tone->Tone'
+ mem.ctone = rxtone
+ mem.rtone = txtone
+ elif enabled == TONES_EN_TXCODE:
+ mem.tmode = 'Cross'
+ mem.cross_mode = 'DTCS->'
+ mem.dtcs = txcode
+ elif enabled == TONES_EN_RXCODE and tsql:
+ mem.tmode = 'Cross'
+ mem.cross_mode = '->DTCS'
+ mem.rx_dtcs = rxcode
+ elif enabled == (TONES_EN_TXCODE | TONES_EN_RXCODE) and tsql:
+ if rxcode == txcode:
+ mem.tmode = 'DTCS'
+ mem.rx_dtcs = rxcode
+ # #8327 Not sure this is the correct interpretation of
+ # DevelopersToneModes, but it seems to make it work round
+ # tripping with the anytone software. DTM implies that we
+ # might not need to set mem.dtcs, but if we do it only DTCS
+ # rx works (as if we were Cross:None->DTCS).
+ mem.dtcs = rxcode
+ else:
+ mem.tmode = 'Cross'
+ mem.cross_mode = 'DTCS->DTCS'
+ mem.rx_dtcs = rxcode
+ mem.dtcs = txcode
+ elif enabled == (TONES_EN_TXCODE | TONES_EN_RXTONE) and tsql:
+ mem.tmode = 'Cross'
+ mem.cross_mode = 'DTCS->Tone'
+ mem.dtcs = txcode
+ mem.ctone = rxtone
+ elif enabled == (TONES_EN_TXTONE | TONES_EN_RXCODE) and tsql:
+ mem.tmode = 'Cross'
+ mem.cross_mode = 'Tone->DTCS'
+ mem.rx_dtcs = rxcode
+ mem.rtone = txtone
+ else:
+ LOG.error('%s: Unhandled tmode enabled = %d.' % (
+ mem.name, enabled))
+
+ # Can get here if e.g. TONE_EN_RXCODE is set and tsql isn't
+ # In that case should we perhaps store the tone and code values
+ # if they're present and then setup tmode and cross_mode as
+ # appropriate later?
+
+ # set the dtcs polarity
+ dtcs_pol_bit_to_str = {0: 'N', 1: 'R'}
+ mem.dtcs_polarity = '%s%s' %\
+ (dtcs_pol_bit_to_str[_mem.dtcs_encode_invert == 1],
+ dtcs_pol_bit_to_str[_mem.dtcs_decode_invert == 1])
+
+ return mem
+
+ # Store details about a high-level memory to the memory map
+ # This is called when a user edits a memory in the UI
+ def set_memory(self, mem):
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[mem.number - 1]
+ _mem_status = self._memobj.memory_status
+
+ # set the occupied bitfield
+ _mem_status.occupied_bitfield = \
+ set_bitfield(_mem_status.occupied_bitfield, mem.number - 1,
+ not mem.empty)
+
+ # set the scan add bitfield
+ _mem_status.scan_enabled_bitfield = \
+ set_bitfield(_mem_status.scan_enabled_bitfield, mem.number - 1,
+ (not mem.empty) and (mem.skip != 'S'))
+
+ if mem.empty:
+ # Set the whole memory to 0xff
+ _mem.set_raw('\xff' * (_mem.size() // 8))
+ else:
+ _mem.set_raw('\x00' * (_mem.size() // 8))
+
+ _mem.freq = int(mem.freq / 10)
+ _mem.offset = int(mem.offset / 10)
+
+ # Store the alpha tag
+ if self.NAME_LENGTH == 5:
+ # original models with 5-character name length
+ temp_name = mem.name.ljust(self.NAME_LENGTH)[:self.NAME_LENGTH]
+ # prefix the 5-character name with 0x00 to fit structure
+ _mem.name = temp_name.rjust(6, chr(00))
+ else:
+ # new VOX models with 6-character name length
+ _mem.name = mem.name.ljust(self.NAME_LENGTH)[:self.NAME_LENGTH]
+
+ # TODO support busy channel lockout - disabled for now
+ _mem.busy_channel_lockout = BUSY_CHANNEL_LOCKOUT_OFF
+
+ # Set duplex bitfields
+ if mem.duplex == '+':
+ _mem.duplex = DUPLEX_POSSPLIT
+ elif mem.duplex == '-':
+ _mem.duplex = DUPLEX_NEGSPLIT
+ elif mem.duplex == '':
+ _mem.duplex = DUPLEX_NOSPLIT
+ elif mem.duplex == 'split':
+ # TODO: this is an unverified punt!
+ _mem.duplex = DUPLEX_ODDSPLIT
+ else:
+ LOG.error('%s: set_mem: unhandled duplex: %s' %
+ (mem.name, mem.duplex))
+
+ # handle tx off
+ _mem.tx_off = 0
+ if mem.duplex == 'off':
+ _mem.tx_off = 1
+
+ # Set the channel width - remember we promote 20kHz channels to FM
+ # on import
+ # , so don't handle them here
+ if mem.mode == 'FM':
+ _mem.channel_width = CHANNEL_WIDTH_25kHz
+ elif mem.mode == 'NFM':
+ _mem.channel_width = CHANNEL_WIDTH_12d5kHz
+ else:
+ LOG.error('%s: set_mem: unhandled mode: %s' % (
+ mem.name, mem.mode))
+
+ # set the power level
+ if mem.power == POWER_LEVELS[0]:
+ _mem.txpower = TXPOWER_LOW
+ elif mem.power == POWER_LEVELS[1]:
+ _mem.txpower = TXPOWER_MED
+ elif mem.power == POWER_LEVELS[2]:
+ _mem.txpower = TXPOWER_HIGH
+ else:
+ LOG.error('%s: set_mem: unhandled power level: %s' %
+ (mem.name, mem.power))
+
+ # TODO set the CTCSS values
+ # TODO support custom ctcss tones here
+ # Default - tones off, carrier sql
+ _mem.ctcss_encode_en = 0
+ _mem.ctcss_decode_en = 0
+ _mem.tone_squelch_en = 0
+ _mem.ctcss_enc_tone = 0x00
+ _mem.ctcss_dec_tone = 0x00
+ _mem.customctcss = 0x00
+ _mem.dtcs_encode_en = 0
+ _mem.dtcs_encode_code_highbit = 0
+ _mem.dtcs_encode_code = 0
+ _mem.dtcs_encode_invert = 0
+ _mem.dtcs_decode_en = 0
+ _mem.dtcs_decode_code_highbit = 0
+ _mem.dtcs_decode_code = 0
+ _mem.dtcs_decode_invert = 0
+
+ dtcs_pol_str_to_bit = {'N': 0, 'R': 1}
+ _mem.dtcs_encode_invert = dtcs_pol_str_to_bit[mem.dtcs_polarity[0]]
+ _mem.dtcs_decode_invert = dtcs_pol_str_to_bit[mem.dtcs_polarity[1]]
+
+ if mem.tmode == 'Tone':
+ _mem.ctcss_encode_en = 1
+ _mem.ctcss_enc_tone = ctcss_code_val_to_bits(mem.rtone)
+ elif mem.tmode == 'TSQL':
+ _mem.ctcss_encode_en = 1
+ _mem.ctcss_enc_tone = ctcss_code_val_to_bits(mem.ctone)
+ _mem.ctcss_decode_en = 1
+ _mem.tone_squelch_en = 1
+ _mem.ctcss_dec_tone = ctcss_code_val_to_bits(mem.ctone)
+ elif mem.tmode == 'DTCS':
+ _mem.dtcs_encode_en = 1
+ _mem.dtcs_encode_code, _mem.dtcs_encode_code_highbit = \
+ dtcs_code_val_to_bits(mem.rx_dtcs)
+ _mem.dtcs_decode_en = 1
+ _mem.dtcs_decode_code, _mem.dtcs_decode_code_highbit = \
+ dtcs_code_val_to_bits(mem.rx_dtcs)
+ _mem.tone_squelch_en = 1
+ elif mem.tmode == 'Cross':
+ txmode, rxmode = mem.cross_mode.split('->')
+
+ if txmode == 'Tone':
+ _mem.ctcss_encode_en = 1
+ _mem.ctcss_enc_tone = ctcss_code_val_to_bits(mem.rtone)
+ elif txmode == '':
+ pass
+ elif txmode == 'DTCS':
+ _mem.dtcs_encode_en = 1
+ _mem.dtcs_encode_code, _mem.dtcs_encode_code_highbit = \
+ dtcs_code_val_to_bits(mem.dtcs)
+ else:
+ LOG.error('%s: unhandled cross TX mode: %s' % (
+ mem.name, mem.cross_mode))
+
+ if rxmode == 'Tone':
+ _mem.ctcss_decode_en = 1
+ _mem.tone_squelch_en = 1
+ _mem.ctcss_dec_tone = ctcss_code_val_to_bits(mem.ctone)
+ elif rxmode == '':
+ pass
+ elif rxmode == 'DTCS':
+ _mem.dtcs_decode_en = 1
+ _mem.dtcs_decode_code, _mem.dtcs_decode_code_highbit = \
+ dtcs_code_val_to_bits(mem.rx_dtcs)
+ _mem.tone_squelch_en = 1
+ else:
+ LOG.error('%s: unhandled cross RX mode: %s' % (
+ mem.name, mem.cross_mode))
+ else:
+ LOG.error('%s: Unhandled tmode/cross %s/%s.' %
+ (mem.name, mem.tmode, mem.cross_mode))
+ LOG.debug('%s: tmode=%s, cross=%s, rtone=%f, ctone=%f' % (
+ mem.name, mem.tmode, mem.cross_mode, mem.rtone, mem.ctone))
+ LOG.debug('%s: CENC=%d, CDEC=%d, t(enc)=%02x, t(dec)=%02x' % (
+ mem.name,
+ _mem.ctcss_encode_en,
+ _mem.ctcss_decode_en,
+ ctcss_code_val_to_bits(mem.rtone),
+ ctcss_code_val_to_bits(mem.ctone)))
+
+ # set unknown defaults, based on reading memory set by vendor tool
+ _mem.unknown1 = 0x00
+ _mem.unknown6 = 0x00
+ _mem.unknown7 = 0x00
+ _mem.unknown8 = 0x00
+ _mem.unknown9 = 0x00
+
+ def get_settings(self):
+ """Translate the MEM_FORMAT structs into setstuf in the UI"""
+ _settings = self._memobj.settings
+ _radio_settings = self._memobj.radio_settings
+ _password = self._memobj.password
+ _pfkeys = self._memobj.pfkeys
+ _dtmf = self._memobj.dtmf
+
+ # Function Setup
+ function = RadioSettingGroup("function", "Function Setup")
+ group = RadioSettings(function)
+
+ # MODE SET
+ # Channel Locked
+ rs = RadioSettingValueBoolean(_settings.channelLocked)
+ rset = RadioSetting("settings.channelLocked", "Channel locked", rs)
+ function.append(rset)
+
+ # Menu 3 - Display Mode
+ options = ["Frequency", "Channel", "Name"]
+ rs = RadioSettingValueList(options, options[_settings.displayMode])
+ rset = RadioSetting("settings.displayMode", "Display Mode", rs)
+ function.append(rset)
+
+ # VFO/MR A
+ options = ["MR", "VFO"]
+ rs = RadioSettingValueList(options, options[_radio_settings.vfomrA])
+ rset = RadioSetting("radio_settings.vfomrA", "VFO/MR mode A", rs)
+ function.append(rset)
+
+ # MR Channel A
+ options = ["%s" % x for x in range(1, 201)]
+ rs = RadioSettingValueList(options, options[_radio_settings.mrChanA])
+ rset = RadioSetting("radio_settings.mrChanA", "MR channel A", rs)
+ function.append(rset)
+
+ # VFO/MR B
+ options = ["MR", "VFO"]
+ rs = RadioSettingValueList(options, options[_radio_settings.vfomrB])
+ rset = RadioSetting("radio_settings.vfomrB", "VFO/MR mode B", rs)
+ function.append(rset)
+
+ # MR Channel B
+ options = ["%s" % x for x in range(1, 201)]
+ rs = RadioSettingValueList(options, options[_radio_settings.mrChanB])
+ rset = RadioSetting("radio_settings.mrChanB", "MR channel B", rs)
+ function.append(rset)
+
+ # DISPLAY SET
+ # Starting Display
+ name = ""
+ for i in range(7): # 0 - 7
+ name += chr(int(self._memobj.starting_display.line[i]))
+ name = name.upper().rstrip() # remove trailing spaces
+
+ rs = RadioSettingValueString(0, 7, name)
+ rs.set_charset(chirp_common.CHARSET_ALPHANUMERIC)
+ rset = RadioSetting("starting_display.line", "Starting display", rs)
+ function.append(rset)
+
+ # Menu 11 - Backlight Brightness
+ options = ["%s" % x for x in range(1, 4)]
+ rs = RadioSettingValueList(options, options[_settings.backlightBr - 1])
+ rset = RadioSetting("settings.backlightBr", "Backlight brightness", rs)
+ function.append(rset)
+
+ # Menu 15 - Screen Direction
+ options = ["Positive", "Inverted"]
+ rs = RadioSettingValueList(options, options[_settings.screenDir])
+ rset = RadioSetting("settings.screenDir", "Screen direction", rs)
+ function.append(rset)
+
+ # Hand Mic Key Brightness
+ options = ["%s" % x for x in range(1, 32)]
+ rs = RadioSettingValueList(options, options[_settings.micKeyBrite - 1])
+ rset = RadioSetting("settings.micKeyBrite",
+ "Hand mic key brightness", rs)
+ function.append(rset)
+
+ # VOL SET
+ # Menu 1 - Beep Volume
+ options = ["OFF"] + ["%s" % x for x in range(1, 6)]
+ rs = RadioSettingValueList(options, options[_settings.beepVolume])
+ rset = RadioSetting("settings.beepVolume", "Beep volume", rs)
+ function.append(rset)
+
+ # Menu 5 - Volume level Setup
+ options = ["%s" % x for x in range(1, 37)]
+ rs = RadioSettingValueList(options, options[_settings.speakerVol - 1])
+ rset = RadioSetting("settings.speakerVol", "Speaker volume", rs)
+ function.append(rset)
+
+ # Menu 16 - Speaker Switch
+ options = ["Host on | Hand mic off", "Host on | Hand mic on",
+ "Host off | Hand mic on"]
+ rs = RadioSettingValueList(options, options[_settings.speakerSwitch])
+ rset = RadioSetting("settings.speakerSwitch", "Speaker switch", rs)
+ function.append(rset)
+
+ # STE SET
+ # STE Frequency
+ options = ["Off", "55.2 Hz", "259.2 Hz"]
+ rs = RadioSettingValueList(options, options[_settings.steFrequency])
+ rset = RadioSetting("settings.steFrequency", "STE frequency", rs)
+ function.append(rset)
+
+ # STE Type
+ options = ["Off", "Silent", "120 degrees", "180 degrees",
+ "240 degrees"]
+ rs = RadioSettingValueList(options, options[_settings.steType])
+ rset = RadioSetting("settings.steType", "STE type", rs)
+ function.append(rset)
+
+ # ON/OFF SET
+ # The Power-on Password feature is not available on models with VOX
+ if not self.HAS_VOX:
+ # Power-on Password
+ rs = RadioSettingValueBoolean(_settings.powerOnPasswd)
+ rset = RadioSetting("settings.powerOnPasswd", "Power-on Password",
+ rs)
+ function.append(rset)
+
+ # Password
+ def _char_to_str(chrx):
+ """ Remove ff pads from char array """
+ # chrx is char array
+ str1 = ""
+ for sx in chrx:
+ if int(sx) > 31 and int(sx) < 127:
+ str1 += chr(int(sx))
+ return str1
+
+ def _pswd_vfy(setting, obj, atrb):
+ """ Verify password is 1-6 chars, numbers 1-5 """
+ str1 = str(setting.value).strip() # initial
+ # valid chars
+ str2 = ''.join([c for c in str1 if c in '0123456789'])
+ if str1 != str2:
+ # Two lines due to python 73 char limit
+ sx = "Bad characters in Password"
+ raise errors.RadioError(sx)
+ str2 = str1.ljust(6, chr(00)) # pad to 6 with 00's
+ setattr(obj, atrb, str2)
+ return
+
+ sx = _char_to_str(_password.digits).strip()
+ rx = RadioSettingValueString(0, 6, sx)
+ sx = "Password (numerals 0-9)"
+ rset = RadioSetting("password.digits", sx, rx)
+ rset.set_apply_callback(_pswd_vfy, _password, "digits")
+ function.append(rset)
+
+ # Menu 9 - Auto Power On
+ rs = RadioSettingValueBoolean(_settings.autoPowerOn)
+ rset = RadioSetting("settings.autoPowerOn", "Auto power on", rs)
+ function.append(rset)
+
+ # Menu 13 - Auto Power Off
+ options = ["Off", "30 minutes", "60 minutes", "120 minutes"]
+ rs = RadioSettingValueList(options, options[_settings.autoPowerOff])
+ rset = RadioSetting("settings.autoPowerOff", "Auto power off", rs)
+ function.append(rset)
+
+ # Power On Reset Enable
+ rs = RadioSettingValueBoolean(_settings.powerOnReset)
+ rset = RadioSetting("settings.powerOnReset", "Power on reset", rs)
+ function.append(rset)
+
+ # FUNCTION SET
+ # Menu 4 - Squelch Level A
+ options = ["OFF"] + ["%s" % x for x in range(1, 10)]
+ rs = RadioSettingValueList(options, options[_settings.squelchLevelA])
+ rset = RadioSetting("settings.squelchLevelA", "Squelch level A", rs)
+ function.append(rset)
+
+ # Squelch Level B
+ options = ["OFF"] + ["%s" % x for x in range(1, 10)]
+ rs = RadioSettingValueList(options, options[_settings.squelchLevelB])
+ rset = RadioSetting("settings.squelchLevelB", "Squelch level B", rs)
+ function.append(rset)
+
+ # Menu 7 - Scan Type
+ options = ["Time operated (TO)", "Carrier operated (CO)",
+ "Search (SE)"]
+ rs = RadioSettingValueList(options, options[_settings.scanType])
+ rset = RadioSetting("settings.scanType", "Scan mode", rs)
+ function.append(rset)
+
+ # Menu 8 - Scan Recovery Time
+ options = ["%s seconds" % x for x in range(5, 20, 5)]
+ rs = RadioSettingValueList(options, options[_settings.scanRecoveryT])
+ rset = RadioSetting("settings.scanRecoveryT", "Scan recovery time", rs)
+ function.append(rset)
+
+ # Main
+ options = ["A", "B"]
+ rs = RadioSettingValueList(options, options[_settings.main])
+ rset = RadioSetting("settings.main", "Main", rs)
+ function.append(rset)
+
+ # Menu 10 - Dual Watch (RX Way Select)
+ rs = RadioSettingValueBoolean(_settings.dualWatch)
+ rset = RadioSetting("settings.dualWatch", "Dual watch", rs)
+ function.append(rset)
+
+ # Menu 12 - Time Out Timer
+ options = ["OFF"] + ["%s minutes" % x for x in range(1, 31)]
+ rs = RadioSettingValueList(options, options[_settings.timeOutTimer])
+ rset = RadioSetting("settings.timeOutTimer", "Time out timer", rs)
+ function.append(rset)
+
+ # TBST Frequency
+ options = ["1000 Hz", "1450 Hz", "1750 Hz", "2100 Hz"]
+ rs = RadioSettingValueList(options, options[_settings.tbstFrequency])
+ rset = RadioSetting("settings.tbstFrequency", "TBST frequency", rs)
+ function.append(rset)
+
+ # Save Channel Perameter
+ rs = RadioSettingValueBoolean(_settings.saveChParameter)
+ rset = RadioSetting("settings.saveChParameter",
+ "Save channel parameter", rs)
+ function.append(rset)
+
+ # MON Key Function
+ options = ["Squelch off momentary", "Squelch off"]
+ rs = RadioSettingValueList(options, options[_settings.monKeyFunction])
+ rset = RadioSetting("settings.monKeyFunction", "MON key function", rs)
+ function.append(rset)
+
+ # Frequency Step
+ options = ["2.5 KHz", "5 KHz", "6.25 KHz", "10 KHz", "12.5 KHz",
+ "20 KHz", "25 KHz", "30 KHz", "50 KHz"]
+ rs = RadioSettingValueList(options, options[_settings.frequencyStep])
+ rset = RadioSetting("settings.frequencyStep", "Frequency step", rs)
+ function.append(rset)
+
+ # Knob Mode
+ options = ["Volume", "Channel"]
+ rs = RadioSettingValueList(options, options[_settings.knobMode])
+ rset = RadioSetting("settings.knobMode", "Knob mode", rs)
+ function.append(rset)
+
+ # TRF Enable
+ rs = RadioSettingValueBoolean(_settings.trfEnable)
+ rset = RadioSetting("settings.trfEnable", "TRF enable", rs)
+ function.append(rset)
+
+ if self.HAS_VOX:
+ # VOX On/Off
+ rs = RadioSettingValueBoolean(_settings.voxOnOff)
+ rset = RadioSetting("settings.voxOnOff",
+ "VOX", rs)
+ function.append(rset)
+
+ # VOX Delay
+ options = ["0.5 S", "1.0 S", "1.5 S", "2.0 S", "2.5 S",
+ "3.0 S", "3.5 S", "4.0 S", "4.5 S"]
+ rs = RadioSettingValueList(options, options[_settings.voxDelay])
+ rset = RadioSetting("settings.voxDelay", "VOX delay", rs)
+ function.append(rset)
+
+ # VOX Level
+ options = ["%s" % x for x in range(1, 10)]
+ rs = RadioSettingValueList(options, options[_settings.voxLevel])
+ rset = RadioSetting("settings.voxLevel", "VOX Level", rs)
+ function.append(rset)
+
+ # Key Assignment
+ pfkeys = RadioSettingGroup("pfkeys", "Key Assignment")
+ group.append(pfkeys)
+
+ options = ["A/B", "V/M", "SQL", "VOL", "POW", "CDT", "REV", "SCN",
+ "CAL", "TALK", "BND", "SFT", "MON", "DIR", "TRF", "RDW",
+ "NULL"]
+
+ if self.HAS_VOX:
+ options.insert(16, "VOX")
+
+ # Key Mode 1
+ # P1
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode1P1 - 1])
+ rset = RadioSetting("pfkeys.keyMode1P1",
+ "Key mode 1 P1", rs)
+ pfkeys.append(rset)
+
+ # P2
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode1P2 - 1])
+ rset = RadioSetting("pfkeys.keyMode1P2",
+ "Key mode 1 P2", rs)
+ pfkeys.append(rset)
+
+ # P3
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode1P3 - 1])
+ rset = RadioSetting("pfkeys.keyMode1P3",
+ "Key mode 1 P3", rs)
+ pfkeys.append(rset)
+
+ # P4
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode1P4 - 1])
+ rset = RadioSetting("pfkeys.keyMode1P4",
+ "Key mode 1 P4", rs)
+ pfkeys.append(rset)
+
+ # P5
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode1P5 - 1])
+ rset = RadioSetting("pfkeys.keyMode1P5",
+ "Key mode 1 P5", rs)
+ pfkeys.append(rset)
+
+ # P6
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode1P6 - 1])
+ rset = RadioSetting("pfkeys.keyMode1P6",
+ "Key mode 1 P6", rs)
+ pfkeys.append(rset)
+
+ # Key Mode 2
+ # P1
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode2P1 - 1])
+ rset = RadioSetting("pfkeys.keyMode2P1",
+ "Key mode 2 P1", rs)
+ pfkeys.append(rset)
+
+ # P2
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode2P2 - 1])
+ rset = RadioSetting("pfkeys.keyMode2P2",
+ "Key mode 2 P2", rs)
+ pfkeys.append(rset)
+
+ # P3
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode2P3 - 1])
+ rset = RadioSetting("pfkeys.keyMode2P3",
+ "Key mode 2 P3", rs)
+ pfkeys.append(rset)
+
+ # P4
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode2P4 - 1])
+ rset = RadioSetting("pfkeys.keyMode2P4",
+ "Key mode 2 P4", rs)
+ pfkeys.append(rset)
+
+ # P5
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode2P5 - 1])
+ rset = RadioSetting("pfkeys.keyMode2P5",
+ "Key mode 2 P5", rs)
+ pfkeys.append(rset)
+
+ # P6
+ rs = RadioSettingValueList(options, options[_pfkeys.keyMode2P6 - 1])
+ rset = RadioSetting("pfkeys.keyMode2P6",
+ "Key mode 2 P6", rs)
+ pfkeys.append(rset)
+
+ options = ["V/M", "SQL", "VOL", "POW", "CDT", "REV", "SCN", "CAL",
+ "TALK", "BND", "SFT", "MON", "DIR", "TRF", "RDW"]
+
+ if self.HAS_VOX:
+ options.insert(15, "VOX")
+
+ # PA
+ rs = RadioSettingValueList(options, options[_settings.keyPA - 2])
+ rset = RadioSetting("settings.keyPA",
+ "Key PA", rs)
+ pfkeys.append(rset)
+
+ # PB
+ rs = RadioSettingValueList(options, options[_settings.keyPB - 2])
+ rset = RadioSetting("settings.keyPB",
+ "Key PB", rs)
+ pfkeys.append(rset)
+
+ # PC
+ rs = RadioSettingValueList(options, options[_settings.keyPC - 2])
+ rset = RadioSetting("settings.keyPC",
+ "Key PC", rs)
+ pfkeys.append(rset)
+
+ # PD
+ rs = RadioSettingValueList(options, options[_settings.keyPD - 2])
+ rset = RadioSetting("settings.keyPD",
+ "Key PD", rs)
+ pfkeys.append(rset)
+
+ # DTMF
+ dtmf = RadioSettingGroup("dtmf", "DTMF")
+ group.append(dtmf)
+
+ # DTMF Transmitting Time
+ options = ["50 milliseconds", "100 milliseconds", "200 milliseconds",
+ "300 milliseconds", "500 milliseconds"]
+ rs = RadioSettingValueList(options, options[_settings.dtmfTxTime])
+ rset = RadioSetting("settings.dtmfTxTime",
+ "DTMF transmitting time", rs)
+ dtmf.append(rset)
+
+ # DTMF Self ID
+
+ # DTMF Interval Character
+ IC_CHOICES = ["A", "B", "C", "D", "*", "#"]
+ IC_VALUES = [0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F]
+
+ def apply_ic_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) + " from list")
+ val = str(setting.value)
+ index = IC_CHOICES.index(val)
+ val = IC_VALUES[index]
+ obj.set_value(val)
+
+ if _dtmf.intervalChar in IC_VALUES:
+ idx = IC_VALUES.index(_dtmf.intervalChar)
+ else:
+ idx = IC_VALUES.index(0x0E)
+ rs = RadioSetting("dtmf.intervalChar", "DTMF interval character",
+ RadioSettingValueList(IC_CHOICES,
+ IC_CHOICES[idx]))
+ rs.set_apply_callback(apply_ic_listvalue, _dtmf.intervalChar)
+ dtmf.append(rs)
+
+ # Group Code
+ GC_CHOICES = ["Off", "A", "B", "C", "D", "*", "#"]
+ GC_VALUES = [0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F]
+
+ def apply_gc_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) + " from list")
+ val = str(setting.value)
+ index = GC_CHOICES.index(val)
+ val = GC_VALUES[index]
+ obj.set_value(val)
+
+ if _dtmf.groupCode in GC_VALUES:
+ idx = GC_VALUES.index(_dtmf.groupCode)
+ else:
+ idx = GC_VALUES.index(0x0A)
+ rs = RadioSetting("dtmf.groupCode", "DTMF interval character",
+ RadioSettingValueList(GC_CHOICES,
+ GC_CHOICES[idx]))
+ rs.set_apply_callback(apply_gc_listvalue, _dtmf.groupCode)
+ dtmf.append(rs)
+
+ # Decoding Response
+ options = ["None", "Beep tone", "Beep tone & respond"]
+ rs = RadioSettingValueList(options, options[_dtmf.decodingResponse])
+ rset = RadioSetting("dtmf.decodingResponse", "Decoding response", rs)
+ dtmf.append(rset)
+
+ # First Digit Time
+ options = ["%s" % x for x in range(0, 2510, 10)]
+ rs = RadioSettingValueList(options, options[_dtmf.firstDigitTime])
+ rset = RadioSetting("dtmf.firstDigitTime", "First Digit Time(ms)", rs)
+ dtmf.append(rset)
+
+ # First Digit Time
+ options = ["%s" % x for x in range(10, 2510, 10)]
+ rs = RadioSettingValueList(options, options[_dtmf.pretime - 1])
+ rset = RadioSetting("dtmf.pretime", "Pretime(ms)", rs)
+ dtmf.append(rset)
+
+ # Auto Reset Time
+ options = ["%s" % x for x in range(0, 25100, 100)]
+ rs = RadioSettingValueList(options, options[_dtmf.autoResetTime])
+ rset = RadioSetting("dtmf.autoResetTime", "Auto Reset time(ms)", rs)
+ dtmf.append(rset)
+
+ # Time-Lapse After Encode
+ options = ["%s" % x for x in range(10, 2510, 10)]
+ rs = RadioSettingValueList(options, options[_dtmf.timeLapse - 1])
+ rset = RadioSetting("dtmf.timeLapse",
+ "Time-lapse after encode(ms)", rs)
+ dtmf.append(rset)
+
+ # PTT ID Pause Time
+ options = ["Off", "-", "-", "-", "-"] + [
+ "%s" % x for x in range(5, 76)]
+ rs = RadioSettingValueList(options, options[_dtmf.pauseTime])
+ rset = RadioSetting("dtmf.pauseTime", "PTT ID pause time(s)", rs)
+ dtmf.append(rset)
+
+ # Side Tone
+ rs = RadioSettingValueBoolean(_dtmf.sideTone)
+ rset = RadioSetting("dtmf.sideTone", "Side tone", rs)
+ dtmf.append(rset)
+
+ # PTT ID Starting
+ DTMF_CHARS = "0123456789ABCD*# "
+ _codeobj = _dtmf.pttIdStart
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 16, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.pttIdStart", "PTT ID starting", val)
+
+ def apply_code(setting, obj):
+ code = []
+ for j in range(0, 16):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.pttIdStart = code
+ rs.set_apply_callback(apply_code, _dtmf)
+ dtmf.append(rs)
+
+ # PTT ID Ending
+ _codeobj = _dtmf.pttIdEnd
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 16, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.pttIdEnd", "PTT ID ending", val)
+
+ def apply_code(setting, obj):
+ code = []
+ for j in range(0, 16):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.pttIdEnd = code
+ rs.set_apply_callback(apply_code, _dtmf)
+ dtmf.append(rs)
+
+ # Remotely Kill
+ _codeobj = _dtmf.remoteKill
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 16, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.remoteKill", "Remotely kill", val)
+
+ def apply_code(setting, obj):
+ code = []
+ for j in range(0, 16):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.remoteKill = code
+ rs.set_apply_callback(apply_code, _dtmf)
+ dtmf.append(rs)
+
+ # Remotely Stun
+ _codeobj = _dtmf.remoteStun
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 16, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.remoteStun", "Remotely stun", val)
+
+ def apply_code(setting, obj):
+ code = []
+ for j in range(0, 16):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.remoteStun = code
+ rs.set_apply_callback(apply_code, _dtmf)
+ dtmf.append(rs)
+
+ # DTMF Encode
+ # M1 - M16
+ for i in range(0, 16):
+ _codeobj = self._memobj.pttid[i].code
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 16, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("pttid/%i.code" % i,
+ "DTMF encode M%i" % (i + 1), val)
+
+ def apply_code(setting, obj):
+ code = []
+ for j in range(0, 16):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.code = code
+ rs.set_apply_callback(apply_code, self._memobj.pttid[i])
+ dtmf.append(rs)
+
+ return group
+
+ def set_settings(self, settings):
+ _settings = self._memobj.settings
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = _settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif setting == "timeLapse":
+ setattr(obj, setting, int(element.value) + 1)
+ elif setting == "pretime":
+ setattr(obj, setting, int(element.value) + 1)
+ elif setting == "backlightBr":
+ setattr(obj, setting, int(element.value) + 1)
+ elif setting == "micKeyBrite":
+ setattr(obj, setting, int(element.value) + 1)
+ elif setting == "speakerVol":
+ setattr(obj, setting, int(element.value) + 1)
+ elif "keyMode" in setting:
+ setattr(obj, setting, int(element.value) + 1)
+ elif "keyP" in setting:
+ setattr(obj, setting, int(element.value) + 2)
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+# Original non-VOX models
+if has_future:
+ @directory.register
+ class AnyTone778UV(AnyTone778UVBase):
+ VENDOR = "AnyTone"
+ MODEL = "778UV"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'AT778UV': ['V100', 'V200']}
+
+ @directory.register
+ class RetevisRT95(AnyTone778UVBase):
+ VENDOR = "Retevis"
+ MODEL = "RT95"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'RT95': ['V100']}
+
+ @directory.register
+ class CRTMicronUV(AnyTone778UVBase):
+ VENDOR = "CRT"
+ MODEL = "Micron UV"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'MICRON': ['V100']}
+
+ @directory.register
+ class MidlandDBR2500(AnyTone778UVBase):
+ VENDOR = "Midland"
+ MODEL = "DBR2500"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'DBR2500': ['V100']}
+
+ @directory.register
+ class YedroYCM04vus(AnyTone778UVBase):
+ VENDOR = "Yedro"
+ MODEL = "YC-M04VUS"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'YCM04UV': ['V100']}
+
+
+class AnyTone778UVvoxBase(AnyTone778UVBase):
+ '''AnyTone 778UV VOX, Retivis RT95 VOX and others'''
+ NAME_LENGTH = 6
+ HAS_VOX = True
+
+# New VOX models
+if has_future:
+ @directory.register
+ class AnyTone778UVvox(AnyTone778UVvoxBase):
+ VENDOR = "AnyTone"
+ MODEL = "778UV VOX"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'778UV-P': ['V100']}
+
+ @directory.register
+ class RetevisRT95vox(AnyTone778UVvoxBase):
+ VENDOR = "Retevis"
+ MODEL = "RT95 VOX"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'RT95-P': ['V100']}
+
+ @directory.register
+ class CRTMicronUVvox(AnyTone778UVvoxBase):
+ VENDOR = "CRT"
+ MODEL = "Micron UV V2"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'MICRONP': ['V100']}
diff --git a/chirp/drivers/anytone_ht.py b/chirp/drivers/anytone_ht.py
index faa9bb8..4290800 100644
--- a/chirp/drivers/anytone_ht.py
+++ b/chirp/drivers/anytone_ht.py
@@ -34,36 +34,36 @@ LOG = logging.getLogger(__name__)
mem_format = """
struct memory {
bbcd freq[4];
- bbcd offset[4];
- u8 unknown1:4,
+ bbcd offset[4];
+ u8 unknown1:4,
tune_step:4;
- u8 unknown2:2,
+ u8 unknown2:2,
txdcsextra:1,
txinv:1,
channel_width:2,
unknown3:1,
tx_off:1;
- u8 unknown4:2,
+ u8 unknown4:2,
rxdcsextra:1,
rxinv:1,
power:2,
duplex:2;
- u8 unknown5:4,
+ u8 unknown5:4,
rxtmode:2,
txtmode:2;
- u8 unknown6:2,
+ u8 unknown6:2,
txtone:6;
- u8 unknown7:2,
+ u8 unknown7:2,
rxtone:6;
- u8 txcode;
- u8 rxcode;
- u8 unknown8[3];
- char name[6];
- u8 squelch:4,
+ u8 txcode;
+ u8 rxcode;
+ u8 unknown8[3];
+ char name[6];
+ u8 squelch:4,
unknown9:2,
bcl:2;
- u8 unknownA;
- u8 unknownB:7,
+ u8 unknownA;
+ u8 unknownB:7,
sqlmode:1;
u8 unknownC[4];
};
@@ -71,22 +71,22 @@ struct memory {
#seekto 0x0010;
struct {
u8 unknown1;
- u8 unknown2:5,
+ u8 unknown2:5,
bands1:3;
- char model[7];
- u8 unknown3:5,
+ char model[7];
+ u8 unknown3:5,
bands2:3;
- u8 unknown4[6];
- u8 unknown5[16];
- char date[9];
- u8 unknown6[7];
- u8 unknown7[16];
- u8 unknown8[16];
- char dealer[16];
- char stockdate[9];
- u8 unknown9[7];
- char selldate[9];
- u8 unknownA[7];
+ u8 unknown4[6];
+ u8 unknown5[16];
+ char date[9];
+ u8 unknown6[7];
+ u8 unknown7[16];
+ u8 unknown8[16];
+ char dealer[16];
+ char stockdate[9];
+ u8 unknown9[7];
+ char selldate[9];
+ u8 unknownA[7];
char seller[16];
} oem_info;
@@ -233,7 +233,7 @@ struct memory memory[200];
def _echo_write(radio, data):
try:
radio.pipe.write(data)
- except Exception, e:
+ except Exception as e:
LOG.error("Error writing to radio: %s" % e)
raise errors.RadioError("Unable to write to radio")
@@ -241,7 +241,7 @@ def _echo_write(radio, data):
def _read(radio, length):
try:
data = radio.pipe.read(length)
- except Exception, e:
+ except Exception as e:
LOG.error("Error reading from radio: %s" % e)
raise errors.RadioError("Unable to read from radio")
@@ -405,12 +405,12 @@ WORKMODE = ["Channel", "Bank"]
@directory.register
class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
- chirp_common.ExperimentalRadio):
+ chirp_common.ExperimentalRadio):
"""AnyTone TERMN-8R"""
VENDOR = "AnyTone"
MODEL = "TERMN-8R"
BAUD_RATE = 9600
- _file_ident = "TERMN8R"
+ _file_ident = b"TERMN8R"
# May try to mirror the OEM behavior later
_ranges = [
@@ -430,6 +430,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
rf.has_settings = True
rf.has_bank = False
rf.has_cross = True
+ rf.valid_tuning_steps = [2.5, 5, 6.25, 10, 12.5, 20, 25, 30, 50]
rf.has_tuning_step = False
rf.has_rx_dtcs = True
rf.valid_skips = ["", "S"]
@@ -447,7 +448,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
rf.can_odd_split = True
rf.memory_bounds = (0, 199)
return rf
-
+
def sync_in(self):
self._mmap = _download(self)
self.process_mmap()
@@ -485,12 +486,18 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
return mem
mem.freq = int(_mem.freq) * 100
+
+ # compensate for 6.25 and 12.5 kHz tuning steps, add 500 Hz if needed
+ lastdigit = int(_mem.freq) % 10
+ if (lastdigit == 2 or lastdigit == 7):
+ mem.freq += 50
+
mem.offset = int(_mem.offset) * 100
mem.name = self.filter_name(str(_mem.name).rstrip())
mem.duplex = DUPLEXES[_mem.duplex]
mem.mode = MODES[_mem.channel_width]
- if _mem.tx_off == True:
+ if _mem.tx_off is True:
mem.duplex = "off"
mem.offset = 0
@@ -705,7 +712,8 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
rs = RadioSetting("backlight", "Backlight",
RadioSettingValueList(BACKLIGHT,
- BACKLIGHT[_settings.backlight]))
+ BACKLIGHT[
+ _settings.backlight]))
cfg_grp.append(rs)
rs = RadioSetting("color", "Backlight Color",
@@ -930,7 +938,7 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -938,9 +946,10 @@ class AnyToneTERMN8RRadio(chirp_common.CloneModeRadio,
def match_model(cls, filedata, filename):
return cls._file_ident in filedata[0x10:0x20]
+
@directory.register
class AnyToneOBLTR8RRadio(AnyToneTERMN8RRadio):
"""AnyTone OBLTR-8R"""
VENDOR = "AnyTone"
MODEL = "OBLTR-8R"
- _file_ident = "OBLTR8R"
+ _file_ident = b"OBLTR8R"
diff --git a/chirp/drivers/anytone_iii.py b/chirp/drivers/anytone_iii.py
new file mode 100644
index 0000000..b72a4b6
--- /dev/null
+++ b/chirp/drivers/anytone_iii.py
@@ -0,0 +1,2039 @@
+# Copyright 2020 Brad Schuler K0BAS <brad@schuler.ws>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import struct
+import time
+import logging
+import string
+
+from chirp import bitwise
+from chirp import chirp_common
+from chirp import directory
+from chirp import errors
+from chirp import memmap
+from chirp import util
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueInteger, RadioSettingValueList, \
+ RadioSettingValueBoolean, RadioSettingValueString, \
+ RadioSettingValueFloat, InvalidValueError, RadioSettings
+
+
+class ATBankModel(chirp_common.BankModel):
+ """Anytone Banks A-J, Each chan in zero or one bank"""
+
+ def __init__(self, radio, name='Banks'):
+ super(ATBankModel, self).__init__(radio, name)
+ self._banks = []
+ self._memBounds = list(range(0, 750))
+ for i in range(0, 10):
+ self._banks.append(chirp_common.Bank(self, i, string.ascii_uppercase[i]))
+
+ def get_num_mappings(self):
+ return len(self._banks)
+
+ def get_mappings(self):
+ return self._banks
+
+ def add_memory_to_mapping(self, memory, bank):
+ self._radio.set_bank(memory.number, bank.get_index())
+
+ def remove_memory_from_mapping(self, memory, mapping):
+ # I would argue that removing a memory from a mapping in which it does
+ # not exist should not throw an error. The end result is the
+ # requested result. The memory is not in the mapping.
+ index = self._radio.get_bank(memory.number)
+ if (index is None or index != mapping.get_index()):
+ raise Exception("Memory %d is not in bank %s" %
+ (memory.number, bank.get_name()))
+ self._radio.clr_bank(memory.number)
+
+ def get_mapping_memories(self, bank):
+ memories = []
+ for i in self._memBounds:
+ bank_index = self._radio.get_bank(i)
+ if (bank_index is not None and bank_index == bank.get_index()):
+ memories.append(self._radio.get_memory(i))
+ return memories
+
+ def get_memory_mappings(self, memory):
+ bank_index = self._radio.get_bank(memory.number)
+ if bank_index is None:
+ return []
+ else:
+ return [self._banks[bank_index]]
+
+
+LOG = logging.getLogger(__name__)
+
+# TODO: Reverse engineer scramble codes
+# Examples: 1=x0300 1111=xDA0B 3300=x3323 3400=x4524
+# TODO: Reverse engineer derived-value for 2Tone frequencies
+# Below are some samples:
+# freq tone derived
+# 0000 0000
+# 288.0 0b40 0823 208.3
+# 321.7 0c91 0749 186.5
+# 526.8 1494 2397 911.1
+# 526.9 1495 2395 910.9
+# 712.3 1bd3 1a52 673.8
+# 928.1 2441 0286 64.6
+# 1527.3 3ba9 0c46 314.2
+# 1934.7 4b93 09b1 248.1
+# 3116.0 79b8 000c 1.2
+
+
+mem_format_thruflags = """
+struct flag { // Flags about a channel
+ u8 left_only:1, // Channel is 1.25m or AM (meaning left side only)
+ unused:1, // Unused flag
+ scan:2, // chirp_common.SKIP_VALUES
+ group:4; // [A-J, Off]
+};
+
+#seekto 0x0020; // Read Only
+struct {
+ u8 unknown1[16];
+ u8 unknown2[16];
+ char modellike[14];
+ u8 unknown3[2];
+ char serial[16];
+ u8 zeros16[16];
+ char date[16];
+ u8 zeros128[128];
+} oem_info;
+
+#seekto 0x0100;
+struct flag chan_flags[750]; // Channel flags
+struct flag limit_flags[10]; // Limit channel flags
+//u8 effs8[8];
+"""
+
+mem_format = mem_format_thruflags + """
+struct memory {
+ bbcd freq[5]; // rx freq
+ bbcd offset[3]; // tx offset from rx / 100
+ u8 unknown1:4,
+ tune_step:4; // [2.5k, 5k, 6.25k, 8.33k, 10k,
+ // 12.5k, 15k, 20k, 25k, 30k]
+ u8 rxdcsextra:1, // use with rxcode for index of rx DCS to use
+ txdcsextra:1, // use with txcode for index of tx DCS to use
+ rxdcsinv:1, // inverse DCS rx polarity
+ txdcsinv:1, // inverse DCS tx polarity
+ channel_width:2, // [25kHz, 20kHz, 12.5kHz]
+ rev:1, // reverse the tx and rx frequencies & tones
+ txoff:1; // prevent tx
+ u8 talkaround:1, // Use the rx freq & tone when transmitting
+ compander:1,
+ unknown2:1,
+ is_am:1, // modulation is AM
+ power:2, // [High, Mid1, Mid2, Low]
+ duplex:2; // ['', -, +, off]
+ u8 dtmf_enc_num:4, // zero-based DTMF slot to use for optional
+ // signalling (when optsig = DTMF)
+ rxtmode:2, // ['', Tone, DTCS]
+ txtmode:2; // ['', Tone, DTCS]
+ u8 unknown3:2,
+ txtone:6; // TONES[0..50] & 51=custom
+ u8 unknown4:2,
+ rxtone:6; // TONES[0..50] & 51=custom
+ u8 txcode; // use with txdcsextra for index of tx DCS to use
+ u8 rxcode; // use with rxdcsextra for index of rx DCS to use
+ u8 unknown5:2,
+ pttid:2, // [Off, Begin, End, Begin&End]
+ unknown6:2,
+ bclo:2; // [Off, Repeater, Busy]
+ u8 unknown7:6
+ band:2; // [2m, 1-1/4m, 350+ MHz, 70cm]
+ u8 unknown8:5,
+ sql_mode:3; // [Carrier, CTCSS/DCS Tones, Opt Sig Only,
+ // Tones & Opt Sig, Tones or Opt Sig]
+ // Implemented in GUI as a combination of rxmode
+ // and opt sig squelch list OPT_SIG_SQL
+ u8 unknown9:6,
+ optsig:2; // [Off, DTMF, 2Tone, 5Tone]
+ u8 unknown10:3,
+ twotone:5; // zero-based 2-tone slot to use for optional
+ // signalling (when optsig = 2Tone)
+ u8 unknown11:1,
+ fivetone:7; // zero-based 5-tone slot to use for optional
+ // signalling (when optsig = 5Tone)
+ u8 unknown12:4,
+ scramble:4; // [Off, 1 ... 9, Define 1, Define 2]
+ char name[7];
+ ul16 custtone; // custom ctcss tone (%5.1f) * 10
+};
+
+struct DTMF12p3 {
+ u8 dtmf[12]; // Each nibble is a DTMF code [0-9A-D*#]
+ u8 num_tones; // Quantity of nibbles/digits in above
+ u8 unknown3[3];
+};
+
+struct DTMF7 {
+ u8 dtmf[7]; // Each nibble is a DTMF code [0-9A-D*#]
+ u8 num_tones; // Quantity of nibbles/digits in above
+};
+
+#seekto 0x0400; // DTMF slots
+struct DTMF12p3 dtmf_encodings[16];
+
+//#seekto 0x0500;
+//u8 unknown[64];
+
+#seekto 0x0540; // Hyper channels (12 x 2)
+struct memory hyper_channels[24];
+
+#seekto 0x0840; // Settings
+struct {
+ u8 unknown1:6,
+ display:2; // Display Mode: [freq, chan, name]
+ u8 unknown2:3,
+ sql_left:5; // Left Squelch Level: 1..20
+ u8 unknown3:3,
+ sql_right:5; // Right Squelch Level: 1..20
+ u8 unknown4;
+ u8 unknown5:6,
+ scan_tot:2; // Scan Pause Time: [TO, CO, SE]
+ u8 unknown6:7,
+ scan_mode:1; // Scan Mode: [MEM, MSM(Pri Scan)]
+ u8 bg_red; // Background color red intensity
+ // 0-x1f displayed as 1-32d
+ u8 bg_green; // Background color green intensity
+ u8 bg_blue; // Background color blue intensity
+ u8 unknown7:5,
+ tbst_freq:3; // TBST Freq [Off, 1750, 2100, 1000, 1450] Hz
+ u8 unknown8:3,
+ ptt_tot:5; // Talk Timeout Timer: [Off, 1..30] minutes
+ u8 unknown9:6,
+ ptt_lockout:2; // PTT Key Lock: [Off, Right, Left, Both]
+ u8 unknown10:3,
+ apo:5; // Auto Power Off: [Off, 1..18] * 30 minutes
+ u8 unknown11:3,
+ key_bright:5; // Key Light Level: [00-1e] := [1-32]
+ u8 long_key_time; // Long Key Time: # seconds * 100,
+ // so 100 := 1.0 sec, 250 := 2.5 sec
+ u8 unknown12:6,
+ deputy_mute:2; // Mute the Deputy channel (sub band) when
+ // primary is doing this: [Off, Tx, Rx, Tx & Rx]
+ //#seekto 0x0850;
+ u8 disp_chan_lock:1, // Display Channel Lock when display=1(Chan)
+ unknown13:1,
+ keypad_lock:1, // Lock the keypad
+ beep_hi:1, // 0=low 1=high volume
+ no_init:1, // Prohibit initialization: 0=no 1=yes
+ unknown14:3;
+ u8 unknown15:2,
+ clk_shift:1, // CLK Shift: 0=off 1=on
+ ext_spk_on:1, // Enable the external speaker
+ alt_key_mode:1, // Use Alt Keypad Mode: 0=off 1=on
+ beep_on:1 // Enable beep
+ no_tone_elim_tail:1, // Elim squelch tail when no CTCSS/DCS signaling
+ sql_key_mode:1; // SQL Key Function: [Momentary, Toggle]
+ u8 unknown16:5,
+ dtmf_preload_time:3; // DTMF encode preload time:
+ // [100, 300, 500, 800, 1000] ms
+ u8 unknown17:5,
+ dtmf_speed:3; // DTMF transmit time/speed:
+ // [30, 50, 80, 100, 150, 200, 250] ms
+ u8 unknown19:6,
+ tail_elim_type:2; // Tail Eliminator Type: [Off, 120, 180] degrees
+ u8 unknown20:3,
+ key_a_func:5; // Programmable key A function [0-19]:
+ // [Off, DUP, ... Bandwidth, Talk Around]
+ u8 unknown21:3,
+ key_b_func:5; // Programmable key B function
+ u8 unknown22:3,
+ key_c_func:5; // Programmable key C function
+ u8 unknown23:3,
+ key_d_func:5; // Programmable key D function
+ u8 unknown24:7,
+ boot_pw_on:1; // Use boot password (verify password is set!)
+ u8 unknown25:5,
+ rfsql_left:3; // Left RF Squelch Level:
+ // [Off, S-2, S-5, S-9, FULL]
+ u8 unknown26:5,
+ rfsql_right:3; // Right RF Squelch Level
+ u8 scramble1[2]; // Scramble code #1 (unknown encoding)
+ u8 scramble2[2]; // Scramble code #2 (unknown encoding)
+
+ //#seekto 0x0860 & 0x0880
+ struct {
+ u8 unknown1;
+ u8 unknown2:6,
+ left_mode:2; // [VFO, Channel, Home]
+ u8 unknown3:6,
+ right_mode:2; // [VFO, Channel, Home]
+ u8 unknown4:6,
+ sub_display:2; // [Freq, DC IN, Off]
+ ul16 left_channel; // Zero-based chan number
+ ul16 right_channel; // Zero-based chan number
+ u8 unknown5;
+ u8 unknown6:6,
+ spkr_mode:2; // Hand/Main [Off/On, On/On, On/Off]
+ u8 unknown7:6,
+ left_vfo_band:2; // [108, 220, 350, 400] MHz
+ u8 unknown8:7,
+ right_vfo_band:1; // [136, 400] MHz
+ u8 unknown9;
+ u8 unknown10:1,
+ vfo_tracked:1,
+ auto_hyper_save:1,
+ auto_rpt_shift:1,
+ auto_am:1,
+ main:1, // [Left, Right]
+ vfo_band_edge:1,
+ unknown11:1;
+ u8 unknown12;
+ u8 unknown13;
+ //#seekto 0x0870 & 0x0890
+ u8 unknown14:4,
+ left_work_bank:4; // [A - J, Off]
+ u8 unknown15:7,
+ left_bank_mode:1; // [CH, Bank]
+ u8 unknown16:7,
+ left_bank_sw:1; // [Off, On]
+ u8 unknown17:4,
+ right_work_bank:4; // [A - J, Off]
+ u8 unknown18:7,
+ right_bank_mode:1; // [CH, Bank]
+ u8 unknown19:7,
+ right_bank_sw:1; // [Off, On]
+ // This would be better than below:
+ // struct { u8 unknown:7, linked:1; } linkedBanks[10];
+ // They would need to be in a sub-group of settings in the extras.
+ // A-J (one byte each) 00 or 01
+ u8 unknown20:7,
+ link_bank_A:1;
+ u8 unknown21:7,
+ link_bank_B:1;
+ u8 unknown22:7,
+ link_bank_C:1;
+ u8 unknown23:7,
+ link_bank_D:1;
+ u8 unknown24:7,
+ link_bank_E:1;
+ u8 unknown25:7,
+ link_bank_F:1;
+ u8 unknown26:7,
+ link_bank_G:1;
+ u8 unknown27:7,
+ link_bank_H:1;
+ u8 unknown28:7,
+ link_bank_I:1;
+ u8 unknown29:7,
+ link_bank_J:1;
+ } hyper_settings[2];
+
+ //#seekto 0x08a0;
+ char boot_password[7]; // Boot password
+ u8 unknown30[9];
+
+ //#seekto 0x08b0;
+ u8 unknown31[16];
+
+ //#seekto 0x08c0;
+ u8 unknown32:4,
+ dtmf_interval_char:4; // DTMF interval character
+ u8 dtmf_group_code; // DTMF Group Code: 0a-0f,ff displayed as A-#,Off
+ u8 unknown33:6,
+ dtmf_dec_resp:2; // DTMF Decoding Response:
+ // [None, Beep, Beep & Respond]
+ u8 unknown34;
+ u8 dtmf_first_dig_time; // DTMF First digit time: 0..250 * 10 ms
+ u8 dtmf_auto_rst_time; // DTMF auto reset time: 0..250
+ // displayed as 0.0-25.0 in 0.1 increments sec
+ u8 unknown35;
+ u8 dtmf_self_id[3]; // DTMF Self ID: low nibble of each byte is a
+ // DTMF char, exactly 3 chars
+ u8 unknown36;
+ u8 unknown37;
+ u8 unknown38;
+ u8 unknown39:7,
+ dtmf_sidetone_on:1; // DTMF side tone enabled
+ u8 dtmf_enc_delay; // DTMF encode delay: 1..250 * 10 ms
+ u8 dtmf_pttid_delay; // DTMF PTT ID delay: 0,5-75
+ // shown as [Off,5-75] sec
+
+ //#seekto 0x08d0;
+ struct DTMF7 dtmf_kill; // DTMF to remotely kill
+ struct DTMF7 dtmf_stun; // DTMF to remotely stun
+} settings;
+
+//#seekto 0x08e0; // 2 Tone settings - for future work
+//struct {
+// ul16 calltone1; // Call format 1st tone freq * 10
+// ul16 calltone2; // Call format 2nd tone freq * 10
+// // (or 00 00 for long tone version of 1st tone)
+// ul16 calltone1derived; // some derived freq? calculated from 1st tone
+// ul16 calltone2derived; // some derived freq? calculated from 2nd tone
+// u8 unknown1:6,
+// decode_resp:2; // Decode response [None, Beep, Beep & Respond]
+// u8 tone1_dur; // 1st tone duration * 10
+// // shown as range(0.5, 10, 0.1) seconds
+// u8 tone2_dur; // 2nd tone duration * 10
+// // shown as range(0.5, 10, 0.1) seconds
+// u8 longtone_dur; // Long tone duration * 10
+// // shown as range(0.5, 10, 0.1) seconds
+// u8 gap_time; // Gap time / 100
+// // shown as range(0, 2000, 100) msec
+// u8 auto_rst_time; // Auto reset time * 10
+// // shown as range(0, 25, 0.1) sec
+// u8 unknown:7,
+// enc_sidetone; // Encode side-tone 0=off 1=on
+// u8 unknown2:4,
+// call_format:4; // Call format [A-B, A-C, A-D, B-A, B-C, B-D,
+// // C-A, C-B, C-D, D-A, D-B, D-C,
+// // Long A, Long B, Long C]
+// // Be sure to change callTone1/2 and
+// // callTone1/2derived when callFormat is changed
+// //#seekto 0x08f0;
+// u16 a_tone; // A tone freq * 10
+// u16 b_tone; // B tone freq * 10
+// u16 c_tone; // C tone freq * 10
+// u16 d_tone; // D tone freq * 10
+// u8 zeros[8];
+//} twotone_settings;
+
+//#seekto 0x0900; // Unknown all 0x00
+//u8 zeros[512];
+
+//#seekto 0x0b00; // 2 Tone memories (24 slots of 16 bytes)
+//struct {
+// ul16 tone1derived; // some derived freq? calculated from 1st tone
+// ul16 tone2derived; // some derived freq? calculated from 2nd tone
+// ul16 tone1; // 1st tone freq * 10
+// ul16 tone2; // 2nd tone freq * 10
+// char name[7]; // Tone name (padded)
+// u8 zero;
+//} twotone_slots[24];
+
+//#seekto 0x0c80; // Unknown all 0x24
+//u8 twentyfours[128];
+
+//#seekto 0x0d00; // 5 Tone configs (100 slots of 32 bytes)
+//u8 fivetones[3200];
+
+#seekto 0x1980; // Communication notes
+struct {
+ char call_id[5]; // Call ID (numeric, max 5 digits (x30-x39)
+ u8 zeros[3]; // 0x00 * 3
+} note_call_ids[100];
+struct {
+ char name[7]; // Names (ALPHAnumeric max 7 chars)
+ char space; // 0x20
+} note_names[100];
+
+//#seekto 0x1fc0; // Unknown all 0x00
+//u8 zeros[64];
+
+#seekto 0x2000;
+struct memory channels[750]; // Normal channels (750 * 32 bytes)
+
+//#seekto 0x7dc0;
+struct memory limit_channels[10]; // Limit channels
+ // (10 * 32 bytes: Five pair of lo/hi)
+
+//#seekto 0x7f00; // Unknown
+//u8 unknown[32];
+
+#seekto 0x7f20;
+struct DTMF12p3 dtmf_pttid_bot; // DTMF PTT ID Start (BOT)
+struct DTMF12p3 dtmf_pttid_eot; // DTMF PTT ID End (EOT)
+
+//#seekto 0x7f40;
+//u8 unknown[64]
+
+#seekto 0x7f80; // Emergency Information
+struct {
+ u8 unknown:6,
+ mode:2; // [Alarm, Transpond+Background,
+ // Transpond+Alarm, Both]
+ u8 unknown:6,
+ eni_type:2; // [None, DTMF, 5Tone]
+ u8 id; // When DTMF: [M1-M16], When 5Tone: 0-99
+ u8 alarm_time; // [1-255] seconds
+ u8 tx_time; // [0-255] seconds
+ u8 rx_time; // [0-255] seconds
+ u8 unknown:7,
+ chan_select:1; // [Assigned, Selected]
+ ul16 channel; // [0-749]
+ u8 cycle; // [Continuous, 1-255]
+} emergency;
+u8 unknown9[6];
+
+//#seekto 0x7f90; // Unknown
+//u8 unknown[48]
+
+#seekto 0x7fc0; // Welcome message
+char welcome[7];
+//u8 zeros[9];
+
+//#seekto 0x7fd0;
+//u8 unknown[48];
+"""
+
+
+def _is_chan_used(memobj, num):
+ return not memobj.chan_flags[num].unused
+
+
+def _is_limit_chan_used(memobj, num):
+ return not memobj.limit_flags[num].unused
+
+
+def _should_send_addr(memobj, addr):
+ # Skip read-only & out of bounds
+ if addr < 0x0100 or addr >= 0x8000:
+ return False
+ # Skip regions of unknown or uncontrolled by this software
+ if ((addr >= 0x0500 and addr < 0x0540) or
+ (addr >= 0x08e0 and addr < 0x1980) or
+ (addr >= 0x1fc0 and addr < 0x2000) or
+ (addr >= 0x7f00 and addr < 0x7f20) or
+ (addr >= 0x7f40 and addr < 0x7f80) or
+ (addr >= 0x7f90 and addr < 0x7fc0) or
+ addr >= 0x7fd0):
+ return False
+ # Skip unused memories
+ if addr >= 0x2000 and addr < 0x7dc0:
+ return _is_chan_used(memobj, int((addr - 0x2000) / 0x20))
+ if addr >= 0x7dc0 and addr < 0x7f00:
+ return _is_limit_chan_used(memobj, int((addr - 0x7dc0) / 0x20))
+ return True
+
+
+def _echo_write(radio, data):
+ try:
+ radio.pipe.write(data)
+ radio.pipe.read(len(data))
+ except Exception as e:
+ LOG.error("Error writing to radio: %s" % e)
+ raise errors.RadioError("Unable to write to radio")
+
+
+def _read(radio, length):
+ try:
+ data = radio.pipe.read(length)
+ except Exception as e:
+ LOG.error("Error reading from radio: %s" % e)
+ raise errors.RadioError("Unable to read from radio")
+
+ if len(data) != length:
+ LOG.error("Short read from radio (%i, expected %i)" %
+ (len(data), length))
+ LOG.debug(util.hexprint(data))
+ raise errors.RadioError("Short read from radio")
+ return data
+
+valid_model = ['I588UVP']
+
+
+def _ident(radio):
+ radio.pipe.timeout = 1
+ _echo_write(radio, "PROGRAM")
+ response = radio.pipe.read(3)
+ if response != "QX\x06":
+ LOG.debug("Response was:\n%s" % util.hexprint(response))
+ raise errors.RadioError("Unsupported model")
+ _echo_write(radio, "\x02")
+ response = radio.pipe.read(16)
+ LOG.debug(util.hexprint(response))
+ if response[15] != "\x06":
+ LOG.debug("Response was:\n%s" % util.hexprint(response))
+ raise errors.RadioError("Missing ack")
+ if response[0:7] not in valid_model:
+ LOG.debug("Response was:\n%s" % util.hexprint(response))
+ raise errors.RadioError("Unsupported model")
+ # Manufacturer software does this also: _send(radio, 'R', 0x0080, 0x10)
+
+
+def _finish(radio):
+ endframe = "\x45\x4E\x44"
+ _echo_write(radio, endframe)
+ result = radio.pipe.read(1)
+ if result != "\x06":
+ LOG.debug("Got:\n%s" % util.hexprint(result))
+ raise errors.RadioError("Radio did not finish cleanly")
+
+
+def _checksum(data):
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+ return cs % 256
+
+
+def _send(radio, cmd, addr, length, data=None):
+ frame = struct.pack(">cHb", cmd, addr, length)
+ if data:
+ frame += data
+ frame += chr(_checksum(frame[1:]))
+ frame += "\x06"
+ _echo_write(radio, frame)
+ LOG.debug("Sent:\n%s" % util.hexprint(frame))
+ if data:
+ result = radio.pipe.read(1)
+ if result != "\x06":
+ LOG.debug("Ack was: %s" % repr(result))
+ raise errors.RadioError(
+ "Radio did not accept block at %04x" % addr)
+ return
+ result = _read(radio, length + 6)
+ LOG.debug("Got:\n%s" % util.hexprint(result))
+ header = result[0:4]
+ data = result[4:-2]
+ ack = result[-1]
+ if ack != "\x06":
+ LOG.debug("Ack was: %s" % repr(ack))
+ raise errors.RadioError("Radio NAK'd block at %04x" % addr)
+ _cmd, _addr, _length = struct.unpack(">cHb", header)
+ if _addr != addr or _length != _length:
+ LOG.debug("Expected/Received:")
+ LOG.debug(" Length: %02x/%02x" % (length, _length))
+ LOG.debug(" Addr: %04x/%04x" % (addr, _addr))
+ raise errors.RadioError("Radio send unexpected block")
+ cs = _checksum(result[1:-2])
+ if cs != ord(result[-2]):
+ LOG.debug("Calculated: %02x" % cs)
+ LOG.debug("Actual: %02x" % ord(result[-2]))
+ raise errors.RadioError("Block at 0x%04x failed checksum" % addr)
+ return data
+
+
+def _download(radio):
+ _ident(radio)
+
+ memobj = None
+
+ data = ""
+ for start, end in radio._ranges:
+ for addr in range(start, end, 0x10):
+ if memobj is not None and not _should_send_addr(memobj, addr):
+ block = "\x00" * 0x10
+ else:
+ block = _send(radio, 'R', addr, 0x10)
+ data += block
+
+ status = chirp_common.Status()
+ status.cur = len(data)
+ status.max = end
+ status.msg = "Cloning from radio"
+ radio.status_fn(status)
+
+ if addr == 0x0400 - 0x10:
+ memobj = bitwise.parse(mem_format_thruflags, data)
+
+ _finish(radio)
+
+ return memmap.MemoryMap(data)
+
+
+def _upload(radio):
+ _ident(radio)
+
+ for start, end in radio._ranges:
+ for addr in range(start, end, 0x10):
+ if not _should_send_addr(radio._memobj, addr):
+ continue
+ block = radio._mmap[addr:addr + 0x10]
+ _send(radio, 'W', addr, len(block), block)
+
+ status = chirp_common.Status()
+ status.cur = addr
+ status.max = end
+ status.msg = "Cloning to radio"
+ radio.status_fn(status)
+
+ _finish(radio)
+
+
+def _filter(s, charset):
+ rc = ""
+ for i in range(0, len(s)):
+ c = str(s[i])
+ rc += (c if c in charset else "")
+ return rc
+
+
+SEVEN_SPACES = " "
+APO = ['Off'] + ['%.1f hour(s)' % (0.5 * x) for x in range(1, 25)]
+ONEANDQTRBAND = (220000000, 260000000)
+LEFT_BANDS = [
+ (108000000, 180000000), # L-108
+ ONEANDQTRBAND, # L-220
+ (350000000, 399995000), # L-350
+ (400000000, 523000000) # L/R-400
+]
+RIGHT_BANDS = [
+ (136000000, 174000000), # R-136
+ (400000000, 523000000) # L/R-400
+]
+BCLO = ['Off', 'Repeater', 'Busy']
+BEEP_VOL = ['Low', 'High']
+CROSS_MODES = list(chirp_common.CROSS_MODES)
+CROSS_MODES.remove("Tone->")
+DISPLAY = ['Freq', 'Chan#', 'Name']
+DTMF_SLOTS = ['M%d' % x for x in range(1, 17)]
+DUPLEXES = ['', '-', '+', 'off']
+KEY_FUNCS = ['Off', 'DUP', 'PRI On', 'Power', 'Set DCS/CTCSS Code', 'MHz',
+ 'Reverse', 'HM Chan', 'Main L/R Switch', 'VFO/MR', 'Scan',
+ 'Squelch Off', 'Call TBST', 'Call', 'Tone Compande',
+ 'Scramble', 'Add Opt Signal', 'Bandwidth', 'Talk Around']
+MODES = ["WFM", "FM", "NFM"]
+OPT_SIGS = ['Off', 'DTMF', '2Tone', '5Tone']
+POWER_LEVELS = [chirp_common.PowerLevel("High", watts=50),
+ chirp_common.PowerLevel("Mid1", watts=25),
+ chirp_common.PowerLevel("Mid2", watts=10),
+ chirp_common.PowerLevel("Low", watts=5)]
+PTT_IDS = ['Off', 'Begin', 'End', 'Begin & End']
+RF_SQUELCHES = ['Off', 'S-2', 'S-5', 'S-9', 'FULL']
+SCAN_PAUSES = ['TO', 'CO', 'SE']
+SCAN_MODES = ['MEM', 'MSM (Pri Scan)']
+
+SCRAMBLE_CODES = ['Off']
+for x in range(1, 10):
+ SCRAMBLE_CODES.append('%d' % x)
+SCRAMBLE_CODES += ['Define 1', 'Define 2']
+
+T_MODES = ['', 'Tone', 'DTCS', '']
+TONE2_SLOTS = ['%d' % x for x in range(0, 24)]
+TONE5_SLOTS = ['%d' % x for x in range(0, 100)]
+# Future: chirp_common should present TONES instead of hard-coded list
+TONES = [62.5] + chirp_common.TONES
+TOT = ['Off'] + ['%s Minutes' % x for x in range(1, 31)]
+TUNING_STEPS = [2.5, 5, 6.25, 8.33, 10, 12.5, 15, 20, 25, 30]
+PTT_KEY_LOCKS = ["Off", "Right", "Left", "Both"]
+TBST_FREQS = ["Off", "1750 Hz", "2100 Hz", "1000 Hz", "1450 Hz"]
+LONG_KEY_TIMES = ["1 second", "1.5 seconds", "2 seconds", "2.5 seconds"]
+DEPUTY_CHAN_MUTES = ["Off", "Tx", "Rx", "Both"]
+SQL_BTN_MODES = ["Momentary", "Toggle"]
+SQL_MODES = ["Carrier", "CTCSS/DCS", "Opt Sig Only", "Tones AND Sig",
+ "Tones OR Sig"]
+OPT_SIG_SQL = ["Off"] + SQL_MODES[2:]
+TAIL_ELIM_TYPES = ["Off", "120 degrees", "180 degrees"]
+LIMIT_NAMES = ["Limit %s %d" % (c, i + 1)
+ for i in range(0, 5) for c in ('Lo', 'Hi')]
+HYPER_NAMES = ["Hyper-%s %s%s" % (h, x, y)
+ for h in ('1', '2')
+ for x in ('', 'H')
+ for y in ('L-108', 'L-220', 'L-350', 'L-400', 'R-136', 'R-400')]
+HYPER_MODES = ['VFO', 'Channel', 'Home']
+HYPER_SUB_DISPLAYS = ['Freq', 'DC IN', 'Off']
+HYPER_SPKR_MODES = ['Mic off', 'Mic on', 'Main off']
+HYPER_L_VFOS = ['108 MHz', '220 MHz', '350 MHz', '400 MHz']
+HYPER_R_VFOS = ['136 MHz', '400 MHz']
+HYPER_MAINS = ['Left', 'Right']
+HYPER_BANK_MODES = ['CH', 'Bank']
+EMER_MODES = ['Alarm', 'Transpond+Background', 'Transpond+Alarm', 'Both']
+EMER_ENI_TYPES = ['None', 'DTMF', '5Tone']
+EMER_CHAN_SEL = ['Assigned', 'Selected']
+EMER_CYCLES = ['Continuous'] + ["%d seconds" % x for x in range(1, 256)]
+BANK_CHOICES = ["%s" % chr(x) for x in range(ord("A"), ord("J") + 1)] + ['Off']
+DTMF_CHARS = "0123456789ABCD*#"
+DTMF_INTCHARS = "ABCD*#"
+DTMF_PRELOADS = ['100 ms', '300 ms', '500 ms', '800 ms', '1000 ms']
+DTMF_SPEEDS = ['30 ms', '50 ms', '80 ms', '100 ms',
+ '150 ms', '200 ms', '250 ms']
+DTMF_GROUPS = list("ABCDEF") + ['Off']
+DTMF_RESPONSES = ['None', 'Beep', 'Beep & Respond']
+DTMF_PTTDELAYS = ['Off'] + ["%d seconds" % x for x in range(5, 76)]
+
+
+def _dtmf_encode(dtmf_str, numBytes):
+ dtmf_bytes = []
+ if len(dtmf_str) != 0:
+ _byte = 0x00
+ for i in range(1, len(dtmf_str)+1):
+ if i % 2 == 0:
+ _byte |= DTMF_CHARS.index(dtmf_str[i-1])
+ dtmf_bytes.append(_byte)
+ _byte = 0x00
+ else:
+ _byte = DTMF_CHARS.index(dtmf_str[i-1]) << 4
+ if len(dtmf_str) % 2 == 1:
+ dtmf_bytes.append(_byte)
+ while (len(dtmf_bytes) < numBytes):
+ dtmf_bytes.append(0)
+ return dtmf_bytes
+
+
+def _dtmf_decode(dtmf_bytes, num_tones):
+ dtmf_str = ""
+ x = 1
+ while (x <= num_tones):
+ _byte = dtmf_bytes[(x-1)/2]
+ dtmf_str += DTMF_CHARS[_byte >> 4]
+ x += 1
+ if (x <= num_tones):
+ dtmf_str += DTMF_CHARS[_byte & 0x0F]
+ x += 1
+ return dtmf_str
+
+
+class _RadioSettingValueOffsetInt(RadioSettingValueInteger):
+ """An integer setting whose real value is offset from displayed value"""
+
+ def __init__(self, minval, maxval, current, step=1, offset=0):
+ RadioSettingValueInteger.__init__(self, minval, maxval, current, step)
+ self.offset = offset
+
+
+@directory.register
+class AnyTone5888UVIIIRadio(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
+ """AnyTone 5888UVIII"""
+ VENDOR = "AnyTone"
+ MODEL = "5888UVIII"
+ BAUD_RATE = 9600
+ _file_ident = b"588UVP"
+
+ _ranges = [
+ (0x0000, 0x8000)
+ ]
+
+ def get_bank_model(self):
+ return ATBankModel(self)
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = ("The Anytone 5888UVIII driver is currently "
+ "experimental. There are no known issues with it, "
+ "but you should proceed with caution. 2-tone, "
+ "5-tone, and scramble settings are limited. ")
+ return rp
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_rx_dtcs = True
+ rf.has_bank = True
+ rf.has_cross = True
+ rf.has_settings = True
+ rf.valid_modes = MODES + ['AM']
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = CROSS_MODES
+ rf.valid_duplexes = DUPLEXES
+ rf.valid_tuning_steps = TUNING_STEPS
+ rf.valid_bands = LEFT_BANDS + RIGHT_BANDS
+ rf.valid_skips = chirp_common.SKIP_VALUES
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "-"
+ rf.valid_name_length = 7
+ # Future: rf.valid_tones = TONES
+ # Future: update memdetail.py to use rf.valid_dtcs_codes
+ # Future: update memdetail.py to use rf.dtcs_polarity
+ rf.valid_dtcs_codes = chirp_common.ALL_DTCS_CODES
+ rf.memory_bounds = (1, 750)
+ rf.valid_special_chans = LIMIT_NAMES + HYPER_NAMES
+ return rf
+
+ def sync_in(self):
+ self._mmap = _download(self)
+ self.process_mmap()
+
+ def sync_out(self):
+ _upload(self)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(mem_format, self._mmap)
+
+ def _get_memobjs(self, number):
+ if number <= len(self._memobj.channels):
+ _mem = self._memobj.channels[number - 1]
+ _flg = self._memobj.chan_flags[number - 1]
+ elif (number <= len(self._memobj.channels) +
+ len(self._memobj.limit_channels)):
+ _mem = self._memobj.limit_channels[number -
+ len(self._memobj.channels) -
+ 1]
+ _flg = self._memobj.limit_flags[number -
+ len(self._memobj.channels) -
+ 1]
+ else:
+ _mem = self._memobj.hyper_channels[
+ number -
+ len(self._memobj.channels) -
+ len(self._memobj.limit_channels) -
+ 1]
+ _flg = None
+ return _mem, _flg
+
+ def _get_dcs_index(self, _mem, which):
+ base = getattr(_mem, '%scode' % which)
+ extra = getattr(_mem, '%sdcsextra' % which)
+ return (int(extra) << 8) | int(base)
+
+ def _set_dcs_index(self, _mem, which, index):
+ base = getattr(_mem, '%scode' % which)
+ extra = getattr(_mem, '%sdcsextra' % which)
+ base.set_value(index & 0xFF)
+ extra.set_value(index >> 8)
+
+ def get_raw_memory(self, number):
+ _mem, _flg = self._get_memobjs(number)
+ return repr(_mem) + repr(_flg)
+
+ def set_bank(self, number, bank_index):
+ _mem, _flg = self._get_memobjs(number)
+ _flg.group = bank_index
+
+ def clr_bank(self, number):
+ _mem, _flg = self._get_memobjs(number)
+ _flg.group = BANK_CHOICES.index('Off')
+
+ def get_bank(self, number):
+ _mem, _flg = self._get_memobjs(number)
+ if (_flg.group < 0xa):
+ return _flg.group
+ return None
+
+ def get_memory(self, number):
+ mem = chirp_common.Memory()
+ is_limit_chan = is_hyper_chan = False
+ if isinstance(number, str):
+ if number in LIMIT_NAMES:
+ is_limit_chan = True
+ mem.number = (len(self._memobj.channels) +
+ LIMIT_NAMES.index(number) +
+ 1)
+ elif number in HYPER_NAMES:
+ is_hyper_chan = True
+ mem.number = (len(self._memobj.channels) +
+ len(LIMIT_NAMES) +
+ HYPER_NAMES.index(number) +
+ 1)
+ mem.extd_number = number
+ elif number > (len(self._memobj.channels) +
+ len(self._memobj.limit_channels)):
+ is_hyper_chan = True
+ mem.number = number
+ mem.extd_number = HYPER_NAMES[number -
+ len(self._memobj.channels) -
+ len(self._memobj.limit_channels) -
+ 1]
+ elif number > len(self._memobj.channels):
+ is_limit_chan = True
+ mem.number = number
+ mem.extd_number = LIMIT_NAMES[number -
+ len(self._memobj.channels) -
+ 1]
+ else:
+ mem.number = number
+
+ _mem, _flg = self._get_memobjs(mem.number)
+
+ if not is_hyper_chan and _flg.unused:
+ mem.empty = True
+ _mem.set_raw("\x00" * 32)
+ _mem.name = SEVEN_SPACES
+ _flg.scan = 0
+
+ mem.freq = int(_mem.freq)
+
+ mem.offset = int(_mem.offset) * 100
+ mem.name = (str(_mem.name).rstrip()
+ if not is_limit_chan and not is_hyper_chan
+ else SEVEN_SPACES)
+ mem.duplex = DUPLEXES[_mem.duplex]
+ mem.mode = _mem.is_am and "AM" or MODES[_mem.channel_width]
+ mem.tuning_step = TUNING_STEPS[_mem.tune_step]
+
+ if _mem.txoff:
+ mem.duplex = DUPLEXES[3]
+
+ rxtone = txtone = None
+ rxmode = T_MODES[_mem.rxtmode]
+ if _mem.sql_mode == 0 or _mem.sql_mode == 2:
+ rxmode = T_MODES.index('')
+ txmode = T_MODES[_mem.txtmode]
+ if txmode == "Tone":
+ # If custom tone is being used, show as 88.5 and set checkbox in
+ # extras.
+ # Future: Improve chirp_common, so I can add "CUSTOM" into TONES
+ if _mem.txtone == len(TONES):
+ txtone = 88.5
+ else:
+ txtone = TONES[_mem.txtone]
+ elif txmode == "DTCS":
+ txtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(_mem,
+ 'tx')]
+ if rxmode == "Tone":
+ # If custom tone is being used, show as 88.5 and set checkbox in
+ # extras.
+ # Future: Improve chirp_common, so I can add "CUSTOM" into TONES
+ if _mem.rxtone == len(TONES):
+ rxtone = 88.5
+ else:
+ rxtone = TONES[_mem.rxtone]
+ elif rxmode == "DTCS":
+ rxtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(_mem,
+ 'rx')]
+
+ rxpol = _mem.rxdcsinv and "R" or "N"
+ txpol = _mem.txdcsinv and "R" or "N"
+
+ chirp_common.split_tone_decode(mem,
+ (txmode, txtone, txpol),
+ (rxmode, rxtone, rxpol))
+
+ mem.skip = chirp_common.SKIP_VALUES[_flg.scan
+ if not is_hyper_chan
+ else 0]
+ mem.power = POWER_LEVELS[_mem.power]
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ rs = RadioSetting("rev", "Reverse",
+ RadioSettingValueBoolean(_mem.rev))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("compander", "Compander",
+ RadioSettingValueBoolean(_mem.compander))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("talkaround", "Talkaround",
+ RadioSettingValueBoolean(_mem.talkaround))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("pttid", "PTT ID",
+ RadioSettingValueList(PTT_IDS,
+ PTT_IDS[_mem.pttid]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("bclo", "Busy Channel Lockout",
+ RadioSettingValueList(BCLO,
+ BCLO[_mem.bclo]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("optsig", "Optional Signaling",
+ RadioSettingValueList(OPT_SIGS,
+ OPT_SIGS[_mem.optsig]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("OPTSIGSQL", "Squelch w/Opt Signaling",
+ RadioSettingValueList(
+ OPT_SIG_SQL,
+ SQL_MODES[_mem.sql_mode]
+ if SQL_MODES[_mem.sql_mode] in OPT_SIG_SQL
+ else "Off"))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("dtmf_enc_num", "DTMF",
+ RadioSettingValueList(DTMF_SLOTS,
+ DTMF_SLOTS[_mem.dtmf_enc_num]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("twotone", "2-Tone",
+ RadioSettingValueList(TONE2_SLOTS,
+ TONE2_SLOTS[_mem.twotone]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("fivetone", "5-Tone",
+ RadioSettingValueList(TONE5_SLOTS,
+ TONE5_SLOTS[_mem.fivetone]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("scramble", "Scrambler Switch",
+ RadioSettingValueList(SCRAMBLE_CODES,
+ SCRAMBLE_CODES[_mem.scramble]))
+ mem.extra.append(rs)
+
+ # Memory properties dialog is only capable of Boolean and List
+ # RadioSettingValue classes, so cannot configure custtone.
+ # rs = RadioSetting("custtone", "Custom CTCSS",
+ # RadioSettingValueFloat(
+ # min(TONES),
+ # max(TONES),
+ # _mem.custtone and _mem.custtone / 10 or 151.1,
+ # 0.1,
+ # 1))
+ # mem.extra.append(rs)
+ custtone_str = chirp_common.format_freq(_mem.custtone)
+
+ rs = RadioSetting("CUSTTONETX",
+ "Use Custom CTCSS (%s) for Tx" % custtone_str,
+ RadioSettingValueBoolean(_mem.txtone == len(TONES)))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("CUSTTONERX",
+ "Use Custom CTCSS (%s) for Rx" % custtone_str,
+ RadioSettingValueBoolean(_mem.rxtone == len(TONES)))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ is_limit_chan = is_hyper_chan = False
+ if mem.number > (len(self._memobj.channels) +
+ len(self._memobj.limit_channels)):
+ is_hyper_chan = True
+ elif mem.number > len(self._memobj.channels):
+ is_limit_chan = True
+
+ _mem, _flg = self._get_memobjs(mem.number)
+
+ if mem.empty:
+ if is_hyper_chan:
+ raise errors.InvalidValueError("Hyper memories may not be "
+ "empty.")
+ _mem.set_raw("\x00" * 32)
+ _flg.unused = 1
+ _flg.group = BANK_CHOICES.index('Off')
+ return
+
+ if mem.mode == "AM" and (mem.freq < LEFT_BANDS[0][0] or
+ mem.freq > LEFT_BANDS[0][1]):
+ raise errors.InvalidValueError("AM modulation only allowed in 2m "
+ "band.")
+
+ _mem.set_raw("\x00" * 32)
+ _flg.unused = 0
+
+ _mem.freq = mem.freq
+
+ for band_idx in range(0, len(LEFT_BANDS)):
+ if (mem.freq >= LEFT_BANDS[band_idx][0] and
+ mem.freq <= LEFT_BANDS[band_idx][1]):
+ _mem.band = band_idx
+ break
+
+ _flg.left_only = 0
+ if (not is_hyper_chan):
+ if mem.mode == "AM":
+ _flg.left_only = 1
+ else:
+ _flg.left_only = 1
+ for low, high in RIGHT_BANDS:
+ if mem.freq >= low and mem.freq <= high:
+ _flg.left_only = 0
+ break
+
+ _mem.offset = mem.offset / 100
+
+ if is_hyper_chan:
+ mem.name = SEVEN_SPACES
+ else:
+ _mem.name = mem.name.ljust(7)
+
+ if mem.duplex == "off":
+ _mem.duplex = DUPLEXES.index("")
+ _mem.txoff = 1
+ else:
+ _mem.duplex = DUPLEXES.index(mem.duplex)
+ _mem.txoff = 0
+
+ _mem.is_am = mem.mode == "AM"
+
+ _mem.tune_step = TUNING_STEPS.index(mem.tuning_step)
+
+ try:
+ _mem.channel_width = MODES.index(mem.mode)
+ except ValueError:
+ _mem.channel_width = 0
+
+ ((txmode, txtone, txpol),
+ (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem)
+
+ _mem.txtmode = T_MODES.index(txmode)
+ _mem.rxtmode = T_MODES.index(rxmode)
+ if rxmode != '':
+ _mem.sql_mode = SQL_MODES.index("CTCSS/DCS")
+ else:
+ _mem.sql_mode = SQL_MODES.index("Carrier")
+ if txmode == "Tone":
+ _mem.txtone = TONES.index(txtone)
+ elif txmode == "DTCS":
+ self._set_dcs_index(_mem, 'tx',
+ chirp_common.ALL_DTCS_CODES.index(txtone))
+ if rxmode == "Tone":
+ _mem.rxtone = TONES.index(rxtone)
+ elif rxmode == "DTCS":
+ self._set_dcs_index(_mem, 'rx',
+ chirp_common.ALL_DTCS_CODES.index(rxtone))
+
+ _mem.txdcsinv = txpol == "R"
+ _mem.rxdcsinv = rxpol == "R"
+
+ if not is_hyper_chan:
+ _flg.scan = chirp_common.SKIP_VALUES.index(mem.skip)
+
+ if mem.power:
+ _mem.power = POWER_LEVELS.index(mem.power)
+ else:
+ _mem.power = 0
+
+ for setting in mem.extra:
+ if setting.get_name() == "ignore":
+ LOG.debug("*** ignore: %s" % str(setting.value))
+ # Future: elif setting.get_name() == "custtone":
+ # Future: setattr(_mem, "custtone", setting.value.get_value() * 10)
+ elif setting.get_name() == "OPTSIGSQL":
+ if str(setting.value) != "Off":
+ _mem.sql_mode = SQL_MODES.index(str(setting.value))
+ elif setting.get_name() == "CUSTTONETX":
+ if setting.value:
+ _mem.txtone = len(TONES)
+ elif setting.get_name() == "CUSTTONERX":
+ if setting.value:
+ _mem.rxtone = len(TONES)
+ else:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ return mem
+
+ def get_settings(self):
+ allGroups = RadioSettings()
+
+ _settings = self._memobj.settings
+
+ basic = RadioSettingGroup("basic", "Basic")
+ basic.append(
+ RadioSetting(
+ "welcome",
+ "Welcome Message",
+ RadioSettingValueString(
+ 0,
+ 7,
+ _filter(self._memobj.welcome,
+ chirp_common.CHARSET_ASCII))))
+ basic.append(
+ RadioSetting(
+ "display",
+ "Display",
+ RadioSettingValueList(DISPLAY, DISPLAY[_settings.display])))
+ basic.append(
+ RadioSetting(
+ "disp_chan_lock",
+ "Lock Chan# Disp",
+ RadioSettingValueBoolean(_settings.disp_chan_lock)))
+ basic.append(
+ RadioSetting(
+ "scan_tot",
+ "Scan Pause Time",
+ RadioSettingValueList(
+ SCAN_PAUSES,
+ SCAN_PAUSES[_settings.scan_tot])))
+ basic.append(
+ RadioSetting(
+ "scan_mode",
+ "Scan Mode",
+ RadioSettingValueList(
+ SCAN_MODES,
+ SCAN_MODES[_settings.scan_mode])))
+ basic.append(
+ RadioSetting(
+ "ptt_tot",
+ "Talk Timeout",
+ RadioSettingValueList(TOT, TOT[_settings.ptt_tot])))
+ basic.append(
+ RadioSetting(
+ "apo",
+ "Auto Power Off",
+ RadioSettingValueList(APO, APO[_settings.apo])))
+ basic.append(
+ RadioSetting(
+ "beep_on",
+ "Beep",
+ RadioSettingValueBoolean(_settings.beep_on)))
+ basic.append(
+ RadioSetting(
+ "beep_hi",
+ "Beep Volume",
+ RadioSettingValueList(BEEP_VOL, BEEP_VOL[_settings.beep_hi])))
+ basic.append(
+ RadioSetting(
+ "ext_spk_on",
+ "External Speaker",
+ RadioSettingValueBoolean(_settings.ext_spk_on)))
+ basic.append(
+ RadioSetting(
+ "deputy_mute",
+ "Deputy Chan Mute",
+ RadioSettingValueList(
+ DEPUTY_CHAN_MUTES,
+ DEPUTY_CHAN_MUTES[_settings.deputy_mute])))
+ basic.append(
+ RadioSetting(
+ "tail_elim_type",
+ "Tail Eliminator",
+ RadioSettingValueList(
+ TAIL_ELIM_TYPES,
+ TAIL_ELIM_TYPES[_settings.tail_elim_type])))
+ basic.append(
+ RadioSetting(
+ "no_tone_elim_tail",
+ "Eliminate SQL Tail When\nNo Tone Signaling",
+ RadioSettingValueBoolean(_settings.no_tone_elim_tail)))
+ allGroups.append(basic)
+
+ sqls = RadioSettingGroup("sql", "Squelch Levels")
+ sqls.append(
+ RadioSetting(
+ "sql_left",
+ "Left Squelch",
+ RadioSettingValueInteger(0, 20, _settings.sql_left)))
+ sqls.append(
+ RadioSetting(
+ "sql_right",
+ "Right Squelch",
+ RadioSettingValueInteger(0, 20, _settings.sql_right)))
+ sqls.append(
+ RadioSetting(
+ "rfsql_left",
+ "Left RF Squelch",
+ RadioSettingValueList(
+ RF_SQUELCHES,
+ RF_SQUELCHES[_settings.rfsql_left])))
+ sqls.append(
+ RadioSetting(
+ "rfsql_right",
+ "Right RF Squelch",
+ RadioSettingValueList(
+ RF_SQUELCHES,
+ RF_SQUELCHES[_settings.rfsql_right])))
+ allGroups.append(sqls)
+
+ keys = RadioSettingGroup("keys", "Keys / Buttons")
+ keys.append(
+ RadioSetting(
+ "sql_key_mode",
+ "SQL Key Mode",
+ RadioSettingValueList(
+ SQL_BTN_MODES,
+ SQL_BTN_MODES[_settings.sql_key_mode])))
+ keys.append(
+ RadioSetting(
+ "key_a_func",
+ "PA Key Function",
+ RadioSettingValueList(
+ KEY_FUNCS,
+ KEY_FUNCS[_settings.key_a_func])))
+ keys.append(
+ RadioSetting(
+ "key_b_func",
+ "PB Key Function",
+ RadioSettingValueList(
+ KEY_FUNCS,
+ KEY_FUNCS[_settings.key_b_func])))
+ keys.append(
+ RadioSetting(
+ "key_c_func",
+ "PC Key Function",
+ RadioSettingValueList(
+ KEY_FUNCS,
+ KEY_FUNCS[_settings.key_c_func])))
+ keys.append(
+ RadioSetting(
+ "key_d_func",
+ "PD Key Function",
+ RadioSettingValueList(
+ KEY_FUNCS,
+ KEY_FUNCS[_settings.key_d_func])))
+ keys.append(
+ RadioSetting(
+ "key_bright",
+ "Key Light Level",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 32,
+ _settings.key_bright + 1,
+ 1,
+ -1)))
+ keys.append(
+ RadioSetting(
+ "ptt_lockout",
+ "PTT Key Lock",
+ RadioSettingValueList(
+ PTT_KEY_LOCKS,
+ PTT_KEY_LOCKS[_settings.ptt_lockout])))
+ keys.append(
+ RadioSetting(
+ "keypad_lock",
+ "Keypad Lockout",
+ RadioSettingValueBoolean(_settings.keypad_lock)))
+ allGroups.append(keys)
+
+ bgColor = RadioSettingGroup("bgColor", "Background Color")
+ bgColor.append(
+ RadioSetting(
+ "bg_red",
+ "Red",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 32,
+ _settings.bg_red + 1,
+ 1,
+ -1)))
+ bgColor.append(
+ RadioSetting(
+ "bg_green",
+ "Green",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 32,
+ _settings.bg_green + 1,
+ 1,
+ -1)))
+ bgColor.append(
+ RadioSetting(
+ "bg_blue",
+ "Blue",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 32,
+ _settings.bg_blue + 1,
+ 1,
+ -1)))
+ allGroups.append(bgColor)
+
+ pwdGroup = RadioSettingGroup("pwdGroup", "Boot Password")
+ pwdGroup.append(
+ RadioSetting(
+ "boot_pw_on",
+ "Enable",
+ RadioSettingValueBoolean(_settings.boot_pw_on)))
+ pwdGroup.append(
+ RadioSetting(
+ "boot_password",
+ "Password (digits)",
+ RadioSettingValueString(
+ 0,
+ 7,
+ _filter(_settings.boot_password, string.digits),
+ False,
+ string.digits)))
+ allGroups.append(pwdGroup)
+
+ advanced = RadioSettingGroup("advanced", "Advanced")
+ advanced.append(
+ RadioSetting(
+ "tbst_freq",
+ "TBST Freq",
+ RadioSettingValueList(
+ TBST_FREQS,
+ TBST_FREQS[_settings.tbst_freq])))
+ advanced.append(
+ RadioSetting(
+ "long_key_time",
+ "Long Key Time",
+ RadioSettingValueList(
+ LONG_KEY_TIMES,
+ LONG_KEY_TIMES[int((_settings.long_key_time-100) / 50)])))
+ advanced.append(
+ RadioSetting(
+ "clk_shift",
+ "CLK Shift",
+ RadioSettingValueBoolean(_settings.clk_shift)))
+ advanced.append(
+ RadioSetting(
+ "alt_key_mode",
+ "Keypad Alt Mode",
+ RadioSettingValueBoolean(_settings.alt_key_mode)))
+ advanced.append(
+ RadioSetting(
+ "no_init",
+ "Prohibit Initialization",
+ RadioSettingValueBoolean(_settings.no_init)))
+ allGroups.append(advanced)
+
+ hyperGroups = [
+ RadioSettingGroup("hyper1", "Hyper 1"),
+ RadioSettingGroup("hyper2", "Hyper 2")
+ ]
+ for idx in range(0, len(hyperGroups)):
+ _hyperSettings = _settings.hyper_settings[idx]
+ hyperGroup = hyperGroups[idx]
+ hyperGroup.append(
+ RadioSetting(
+ "main",
+ "Main Band",
+ RadioSettingValueList(
+ HYPER_MAINS,
+ HYPER_MAINS[_hyperSettings.main])))
+ hyperGroup.append(
+ RadioSetting(
+ "sub_display",
+ "Sub Display",
+ RadioSettingValueList(
+ HYPER_SUB_DISPLAYS,
+ HYPER_SUB_DISPLAYS[_hyperSettings.sub_display])))
+ hyperGroup.append(
+ RadioSetting(
+ "spkr_mode",
+ "Speakers",
+ RadioSettingValueList(
+ HYPER_SPKR_MODES,
+ HYPER_SPKR_MODES[_hyperSettings.spkr_mode])))
+ hyperGroup.append(
+ RadioSetting(
+ "vfo_band_edge",
+ "VFO Band Lock",
+ RadioSettingValueBoolean(_hyperSettings.vfo_band_edge)))
+ hyperGroup.append(
+ RadioSetting(
+ "auto_am",
+ "Auto AM",
+ RadioSettingValueBoolean(_hyperSettings.auto_am)))
+ hyperGroup.append(
+ RadioSetting(
+ "auto_rpt_shift",
+ "Auto Repeater Shift",
+ RadioSettingValueBoolean(_hyperSettings.auto_rpt_shift)))
+ hyperGroup.append(
+ RadioSetting(
+ "auto_hyper_save",
+ "Auto Hyper Save",
+ RadioSettingValueBoolean(_hyperSettings.auto_hyper_save)))
+ hyperGroup.append(
+ RadioSetting(
+ "vfo_tracked",
+ "VFO Tracking",
+ RadioSettingValueBoolean(_hyperSettings.vfo_tracked)))
+ hyperGroup.append(
+ RadioSetting(
+ "left_mode",
+ "Left Mode",
+ RadioSettingValueList(
+ HYPER_MODES,
+ HYPER_MODES[_hyperSettings.left_mode])))
+ hyperGroup.append(
+ RadioSetting(
+ "right_mode",
+ "Right Mode",
+ RadioSettingValueList(
+ HYPER_MODES,
+ HYPER_MODES[_hyperSettings.right_mode])))
+ hyperGroup.append(
+ RadioSetting(
+ "left_channel",
+ "Left Channel",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 750,
+ _hyperSettings.left_channel + 1,
+ 1,
+ -1)))
+ hyperGroup.append(
+ RadioSetting(
+ "right_channel",
+ "Right Channel",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 750,
+ _hyperSettings.right_channel + 1,
+ 1,
+ -1)))
+ hyperGroup.append(
+ RadioSetting(
+ "left_vfo_band",
+ "Left VFO Band",
+ RadioSettingValueList(
+ HYPER_L_VFOS,
+ HYPER_L_VFOS[_hyperSettings.left_vfo_band])))
+ hyperGroup.append(
+ RadioSetting(
+ "right_vfo_band",
+ "Right VFO Band",
+ RadioSettingValueList(
+ HYPER_R_VFOS,
+ HYPER_R_VFOS[_hyperSettings.right_vfo_band])))
+ hyperGroup.append(
+ RadioSetting(
+ "left_work_bank",
+ "Left Work Bank",
+ RadioSettingValueList(
+ BANK_CHOICES,
+ BANK_CHOICES[_hyperSettings.left_work_bank])))
+ hyperGroup.append(
+ RadioSetting(
+ "right_work_bank",
+ "Right Work Bank",
+ RadioSettingValueList(
+ BANK_CHOICES,
+ BANK_CHOICES[_hyperSettings.right_work_bank])))
+ hyperGroup.append(
+ RadioSetting(
+ "left_bank_mode",
+ "Left Bank Mode",
+ RadioSettingValueList(
+ HYPER_BANK_MODES,
+ HYPER_BANK_MODES[_hyperSettings.left_bank_mode])))
+ hyperGroup.append(
+ RadioSetting(
+ "right_bank_mode",
+ "Right Bank Mode",
+ RadioSettingValueList(
+ HYPER_BANK_MODES,
+ HYPER_BANK_MODES[_hyperSettings.right_bank_mode])))
+ hyperGroup.append(
+ RadioSetting(
+ "left_bank_sw",
+ "Left Bank Switch",
+ RadioSettingValueBoolean(_hyperSettings.left_bank_sw)))
+ hyperGroup.append(
+ RadioSetting(
+ "right_bank_sw",
+ "Right Bank Switch",
+ RadioSettingValueBoolean(_hyperSettings.right_bank_sw)))
+ for bank in BANK_CHOICES[0:-1]:
+ hyperGroup.append(
+ RadioSetting(
+ "link_bank_%s" % bank,
+ "Bank %s" % bank,
+ RadioSettingValueBoolean(
+ getattr(_hyperSettings, "link_bank_%s" % bank))))
+ allGroups.append(hyperGroup)
+
+ notes = RadioSettingGroup("notes", "Comm Notes")
+ for idx in range(0, 100):
+ notes.append(
+ RadioSetting(
+ "note_call_ids.%d" % idx,
+ "Call ID %d (5 digits)" % idx,
+ RadioSettingValueString(
+ 0,
+ 5,
+ _filter(self._memobj.note_call_ids[idx].call_id,
+ string.digits)[idx*8:idx*8+5],
+ False,
+ string.digits)))
+ notes.append(
+ RadioSetting(
+ "note_names.%d" % idx,
+ "Name %d (7 ALPHAnumeric)" % idx,
+ RadioSettingValueString(
+ 0,
+ 7,
+ _filter(self._memobj.note_names[idx].name,
+ chirp_common.CHARSET_UPPER_NUMERIC)
+ [idx*8:idx*8+7],
+ True,
+ chirp_common.CHARSET_UPPER_NUMERIC)))
+ allGroups.append(notes)
+
+ _emergency = self._memobj.emergency
+ emer = RadioSettingGroup("emergency", "Emergency Info")
+ emer.append(
+ RadioSetting(
+ "mode",
+ "Alarm Mode",
+ RadioSettingValueList(
+ EMER_MODES,
+ EMER_MODES[_emergency.mode])))
+ emer.append(
+ RadioSetting(
+ "eni_type",
+ "ENI Type",
+ RadioSettingValueList(
+ EMER_ENI_TYPES,
+ EMER_ENI_TYPES[_emergency.eni_type])))
+ emer.append(
+ RadioSetting(
+ "emergency.id",
+ "DTMF ID",
+ RadioSettingValueList(
+ DTMF_SLOTS,
+ DTMF_SLOTS[_emergency.id]
+ if EMER_ENI_TYPES[_emergency.eni_type] == 'DTMF'
+ else DTMF_SLOTS[0])))
+ emer.append(
+ RadioSetting(
+ "5ToneId",
+ "5Tone ID",
+ RadioSettingValueInteger(
+ 0,
+ 99,
+ _emergency.id
+ if EMER_ENI_TYPES[_emergency.eni_type] == '5Tone'
+ else 0)))
+ emer.append(
+ RadioSetting(
+ "alarm_time",
+ "Alarm Time (sec)",
+ RadioSettingValueInteger(1, 255, _emergency.alarm_time)))
+ emer.append(
+ RadioSetting(
+ "tx_time",
+ "TX Duration (sec)",
+ RadioSettingValueInteger(1 if _emergency.tx_time > 0 else 0,
+ 255,
+ _emergency.tx_time)))
+ emer.append(
+ RadioSetting(
+ "rx_time",
+ "RX Duration (sec)",
+ RadioSettingValueInteger(1 if _emergency.rx_time > 0 else 0,
+ 255,
+ _emergency.rx_time)))
+ emer.append(
+ RadioSetting(
+ "chan_select",
+ "ENI Channel",
+ RadioSettingValueList(
+ EMER_CHAN_SEL,
+ EMER_CHAN_SEL[_emergency.chan_select])))
+ emer.append(
+ RadioSetting(
+ "channel",
+ "Assigned Channel",
+ _RadioSettingValueOffsetInt(
+ 1,
+ 750,
+ _emergency.channel + 1,
+ 1,
+ -1)))
+ emer.append(
+ RadioSetting(
+ "cycle",
+ "Cycle",
+ RadioSettingValueList(
+ EMER_CYCLES,
+ EMER_CYCLES[_emergency.cycle])))
+ allGroups.append(emer)
+
+ dtmfGroup = RadioSettingGroup("dtmf", "DTMF")
+ for idx in range(0, 16):
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_encodings.%d" % idx,
+ "Encode Tone %s" % DTMF_SLOTS[idx],
+ RadioSettingValueString(
+ 0,
+ 12,
+ _dtmf_decode(
+ self._memobj.dtmf_encodings[idx].dtmf,
+ self._memobj.dtmf_encodings[idx].num_tones),
+ False,
+ DTMF_CHARS)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_preload_time",
+ "Encode Preload Time",
+ RadioSettingValueList(
+ DTMF_PRELOADS,
+ DTMF_PRELOADS[_settings.dtmf_preload_time])))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_speed",
+ "Speed",
+ RadioSettingValueList(
+ DTMF_SPEEDS,
+ DTMF_SPEEDS[_settings.dtmf_speed])))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_interval_char",
+ "Interval Character",
+ RadioSettingValueList(
+ list(DTMF_INTCHARS),
+ DTMF_CHARS[_settings.dtmf_interval_char])))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_group_code",
+ "Group Code",
+ RadioSettingValueList(
+ DTMF_GROUPS,
+ DTMF_GROUPS[_settings.dtmf_group_code-0x0a]
+ if _settings.dtmf_group_code < 0xff
+ else DTMF_GROUPS[6])))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_dec_resp",
+ "Decode Response",
+ RadioSettingValueList(
+ DTMF_RESPONSES,
+ DTMF_RESPONSES[_settings.dtmf_dec_resp])))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_first_dig_time",
+ "1st Digit Time (ms)",
+ RadioSettingValueInteger(
+ 0,
+ 2500,
+ _settings.dtmf_first_dig_time * 10,
+ 10)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_auto_rst_time",
+ "Auto Reset Time (0-25 sec by 0.1)",
+ RadioSettingValueFloat(
+ 0,
+ 25,
+ _settings.dtmf_auto_rst_time / 10,
+ 0.1,
+ 1)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_self_id",
+ "Self ID",
+ RadioSettingValueString(
+ 3,
+ 3,
+ (DTMF_CHARS[_settings.dtmf_self_id[0] & 0x0F] +
+ DTMF_CHARS[_settings.dtmf_self_id[1] & 0x0F] +
+ DTMF_CHARS[_settings.dtmf_self_id[2] & 0x0F]),
+ True,
+ DTMF_CHARS)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_sidetone_on",
+ "Use Side Tone",
+ RadioSettingValueBoolean(_settings.dtmf_sidetone_on)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_enc_delay",
+ "Encode Delay (ms)",
+ RadioSettingValueInteger(
+ 10,
+ 2500,
+ _settings.dtmf_enc_delay * 10,
+ 10)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_pttid_delay",
+ "PTT ID Delay",
+ RadioSettingValueList(
+ DTMF_PTTDELAYS,
+ DTMF_PTTDELAYS[_settings.dtmf_pttid_delay-4]
+ if _settings.dtmf_pttid_delay >= 5
+ else DTMF_PTTDELAYS[0])))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_kill",
+ "Remote Kill",
+ RadioSettingValueString(
+ 0,
+ 7,
+ _dtmf_decode(_settings.dtmf_kill.dtmf,
+ _settings.dtmf_kill.num_tones),
+ False,
+ DTMF_CHARS)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_stun",
+ "Remote Stun",
+ RadioSettingValueString(
+ 0,
+ 7,
+ _dtmf_decode(_settings.dtmf_stun.dtmf,
+ _settings.dtmf_stun.num_tones),
+ False,
+ DTMF_CHARS)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_pttid_bot",
+ "PTT ID Start (BOT)",
+ RadioSettingValueString(
+ 0,
+ 12,
+ _dtmf_decode(self._memobj.dtmf_pttid_bot.dtmf,
+ self._memobj.dtmf_pttid_bot.num_tones),
+ False,
+ DTMF_CHARS)))
+ dtmfGroup.append(
+ RadioSetting(
+ "dtmf_pttid_eot",
+ "PTT ID Start (EOT)",
+ RadioSettingValueString(
+ 0,
+ 12,
+ _dtmf_decode(self._memobj.dtmf_pttid_eot.dtmf,
+ self._memobj.dtmf_pttid_eot.num_tones),
+ False,
+ DTMF_CHARS)))
+ allGroups.append(dtmfGroup)
+
+ # TODO: 2-Tone settings
+ # TODO: 5-Tone settings
+
+ return allGroups
+
+ def _set_hyper_settings(self, settings, _hyperSettings):
+ for element in settings:
+ name = element.get_name()
+ if not isinstance(element, RadioSetting):
+ self._set_hyper_settings(element, _hyperSettings)
+ continue
+ elif isinstance(element.value, _RadioSettingValueOffsetInt):
+ setattr(_hyperSettings,
+ name,
+ int(element.value) + element.value.offset)
+ else:
+ setattr(_hyperSettings, name, element.value)
+
+ def _set_pwd_settings(self, settings):
+ _settings = self._memobj.settings
+ use_pw = pwd = None
+ for element in settings:
+ name = element.get_name()
+ if not isinstance(element, RadioSetting):
+ self._set_pwd_settings(element)
+ continue
+ elif name == "boot_pw_on":
+ use_pw = bool(element.value)
+ elif name == "boot_password":
+ pwd = _filter(str(element.value), string.digits)
+ if (pwd is not None and (len(pwd) or use_pw is False)):
+ setattr(_settings, "boot_pw_on", use_pw and 1 or 0)
+ pwd = pwd + "\x00"*(7-len(pwd))
+ setattr(_settings, "boot_password", pwd)
+ elif (use_pw is not None and use_pw is True):
+ raise errors.InvalidValueError("Password may not be enabled "
+ "without being set.")
+
+ def _set_notes_settings(self, settings):
+ _noteCalls = self._memobj.note_call_ids
+ _noteNames = self._memobj.note_names
+ for element in settings:
+ name = str(element.get_name())
+ if not isinstance(element, RadioSetting):
+ self._set_notes_settings(element)
+ continue
+ elif name.startswith("note_call_ids."):
+ idx = int(name[len("note_call_ids."):])
+ setattr(self._memobj.note_call_ids[idx],
+ "call_id",
+ str(element.value).ljust(5, "\x00"))
+ elif name.startswith("note_names."):
+ idx = int(name[len("note_names."):])
+ setattr(self._memobj.note_names[idx],
+ "name",
+ str(element.value).ljust(7))
+
+ def _set_emer_settings(self, settings):
+ _emergency = self._memobj.emergency
+ dtmf_id = fivetone_id = None
+ for element in settings:
+ name = str(element.get_name())
+ if not isinstance(element, RadioSetting):
+ self._set_emer_settings(element)
+ continue
+ elif name == "emergency.id":
+ dtmf_id = element.value
+ elif name == "5ToneId":
+ fivetone_id = element.value
+ elif name == "channel":
+ zb_mem_num = int(element.value) + element.value.offset
+ _mem, _flg = self._get_memobjs(zb_mem_num + 1)
+ if _flg.unused:
+ raise errors.InvalidValueError("Assigned emergency ENI "
+ "channel is empty.")
+ else:
+ setattr(_emergency, name, zb_mem_num)
+ elif isinstance(element.value, _RadioSettingValueOffsetInt):
+ setattr(_emergency,
+ name,
+ int(element.value) + element.value.offset)
+ else:
+ setattr(_emergency, name, element.value)
+ if EMER_ENI_TYPES[_emergency.eni_type] == 'DTMF':
+ setattr(_emergency, "id", dtmf_id)
+ elif EMER_ENI_TYPES[_emergency.eni_type] == '5Tone':
+ setattr(_emergency, "id", fivetone_id)
+
+ def _set_dtmf_settings(self, settings):
+ def _setDtmf(dtmfStruct, newVal):
+ dtmfStruct.num_tones.set_value(len(newVal))
+ dtmfStruct.dtmf.set_value(_dtmf_encode(newVal,
+ len(dtmfStruct.dtmf)))
+
+ for element in settings:
+ name = str(element.get_name())
+ if not isinstance(element, RadioSetting):
+ self._set_dtmf_settings(element)
+ continue
+ if name.startswith("dtmf_encodings."):
+ idx = int(name[len("dtmf_encodings."):])
+ _setDtmf(self._memobj.dtmf_encodings[idx], str(element.value))
+ elif name == "dtmf_interval_char":
+ setattr(self._memobj.settings.dtmf_interval_char,
+ name,
+ DTMF_CHARS.index(str(element.value)))
+ elif name == "dtmf_group_code":
+ setattr(self._memobj.settings,
+ name,
+ int(element.value)+0x0a
+ if int(element.value) != 6
+ else 0xff)
+ elif name == "dtmf_first_dig_time" or name == "dtmf_enc_delay":
+ setattr(self._memobj.settings, name, int(element.value) / 10)
+ elif name == "dtmf_auto_rst_time":
+ setattr(self._memobj.settings, name, int(element.value) * 10)
+ elif name == "dtmf_self_id":
+ newStr = str(element.value)
+ newVal = []
+ for charIdx in range(0, 3):
+ newVal.append(DTMF_CHARS.index(newStr[charIdx]))
+ setattr(self._memobj.settings, name, newVal)
+ elif name == "dtmf_pttid_delay":
+ setattr(self._memobj.settings,
+ name,
+ DTMF_PTTDELAYS.index(str(element.value))+4
+ if element.value != DTMF_PTTDELAYS[0]
+ else 0)
+ elif name == "dtmf_kill" or name == "dtmf_stun":
+ _setDtmf(getattr(self._memobj.settings, name),
+ str(element.value))
+ elif name == "dtmf_pttid_bot" or name == "dtmf_pttid_eot":
+ _setDtmf(getattr(self._memobj, name), str(element.value))
+ else:
+ setattr(self._memobj.settings, name, element.value)
+
+ def set_settings(self, settings):
+ _root = self._memobj
+ _settings = self._memobj.settings
+ for element in settings:
+ name = element.get_name()
+ if isinstance(element, RadioSettingGroup):
+ if name == "hyper1":
+ self._set_hyper_settings(
+ element,
+ _settings.hyper_settings[0])
+ continue
+ elif name == "hyper2":
+ self._set_hyper_settings(
+ element,
+ _settings.hyper_settings[1])
+ continue
+ elif name == "pwdGroup":
+ self._set_pwd_settings(element)
+ continue
+ elif name == "notes":
+ self._set_notes_settings(element)
+ continue
+ elif name == "emergency":
+ self._set_emer_settings(element)
+ continue
+ elif name == "dtmf":
+ self._set_dtmf_settings(element)
+ continue
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ if name == "ignore":
+ LOG.debug("*** ignore: %s" % str(element.value))
+ elif name == "welcome":
+ setattr(_root, "welcome", element.value)
+ elif name == "long_key_time":
+ setattr(_settings, name, 100 + 50 * int(element.value))
+ elif isinstance(element.value, _RadioSettingValueOffsetInt):
+ setattr(_settings, name, (int(element.value) +
+ element.value.offset))
+ else:
+ setattr(_settings, name, element.value)
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return cls._file_ident in filedata[0x40:0x4D]
diff --git a/chirp/drivers/baofeng_common.py b/chirp/drivers/baofeng_common.py
index 9a6581c..384e922 100644
--- a/chirp/drivers/baofeng_common.py
+++ b/chirp/drivers/baofeng_common.py
@@ -140,7 +140,7 @@ def _do_ident(radio, magic):
if not ident.startswith("\xaa") or not ident.endswith("\xdd"):
# bad response
msg = "Unexpected response, got this:"
- msg += util.hexprint(ident)
+ msg += util.hexprint(ident)
LOG.debug(msg)
raise errors.RadioError("Unexpected response from radio.")
@@ -164,8 +164,8 @@ def _ident_radio(radio):
try:
data = _do_ident(radio, magic)
return data
- except errors.RadioError, e:
- print e
+ except errors.RadioError as e:
+ print(e)
error = e
time.sleep(2)
if error:
@@ -307,13 +307,23 @@ def _split(rf, f1, f2):
# if you get here is because the freq pairs are split
return True
+
class BaofengCommonHT(chirp_common.CloneModeRadio,
chirp_common.ExperimentalRadio):
- """Baofeng HT Sytle Radios"""
+ """Baofeng HT Style Radios"""
VENDOR = "Baofeng"
MODEL = ""
IDENT = ""
+ GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+ GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+ GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+ GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+ _gmrs = False
+
def sync_in(self):
"""Download from radio"""
try:
@@ -336,13 +346,13 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
# If anything unexpected happens, make sure we raise
# a RadioError and log the problem
LOG.exception('Unexpected error during upload')
raise errors.RadioError('Unexpected error communicating '
'with the radio')
-
+
def get_features(self):
"""Get the radio's features"""
@@ -380,7 +390,7 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
rf.valid_tuning_steps = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
return rf
-
+
def _is_txinh(self, _mem):
raw_tx = ""
for i in range(0, 4):
@@ -408,7 +418,8 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
# TX freq set
offset = (int(_mem.txfreq) * 10) - mem.freq
if offset != 0:
- if _split(self.get_features(), mem.freq, int(_mem.txfreq) * 10):
+ if _split(self.get_features(), mem.freq, int(
+ _mem.txfreq) * 10):
mem.duplex = "split"
mem.offset = int(_mem.txfreq) * 10
elif offset < 0:
@@ -514,6 +525,33 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
_mem.set_raw("\x00" * 16)
+ if self._gmrs:
+ if mem.number >= 1 and mem.number <= 30:
+ GMRS_FREQ = int(self.GMRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = GMRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[2]
+ if mem.number > 22:
+ mem.duplex = '+'
+ mem.offset = 5000000
+ elif float(mem.freq) / 1000000 in self.GMRS_FREQS:
+ if float(mem.freq) / 1000000 in self.GMRS_FREQS2:
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[2]
+ if float(mem.freq) / 1000000 in self.GMRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
@@ -622,7 +660,7 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -636,6 +674,6 @@ class BaofengCommonHT(chirp_common.CloneModeRadio,
value = int(val.get_value() * 10)
LOG.debug("Setting fm_presets = %s" % (value))
self._memobj.fm_presets = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/baofeng_uv3r.py b/chirp/drivers/baofeng_uv3r.py
index a68bc60..c02bdd6 100644
--- a/chirp/drivers/baofeng_uv3r.py
+++ b/chirp/drivers/baofeng_uv3r.py
@@ -19,7 +19,7 @@ import time
import os
import logging
-from wouxun_common import do_download, do_upload
+from chirp.drivers.wouxun_common import do_download, do_upload
from chirp import util, chirp_common, bitwise, errors, directory
from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueBoolean, RadioSettingValueList, \
@@ -51,7 +51,7 @@ def uv3r_prep(radio):
for _i in range(0, 10):
try:
return _uv3r_prep(radio)
- except errors.RadioError, e:
+ except errors.RadioError as e:
time.sleep(1)
raise e
@@ -64,7 +64,7 @@ def uv3r_download(radio):
return do_download(radio, 0x0000, 0x0E40, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -75,7 +75,7 @@ def uv3r_upload(radio):
return do_upload(radio, 0x0000, 0x0E40, 0x0010)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -623,7 +623,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -631,7 +631,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
for element in settings:
try:
index = (int(element.get_name().split("_")[-1]))
- val = element.value
+ val = list(element.value)
if val[0].get_value():
value = int(val[1].get_value() * 10 - 650)
else:
@@ -639,7 +639,7 @@ class UV3RRadio(chirp_common.CloneModeRadio):
LOG.debug("Setting fm_presets[%1i] = %s" % (index, value))
setting = self._memobj.fm_presets
setting[index] = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/baofeng_wp970i.py b/chirp/drivers/baofeng_wp970i.py
index 6feda61..0c3b88a 100644
--- a/chirp/drivers/baofeng_wp970i.py
+++ b/chirp/drivers/baofeng_wp970i.py
@@ -36,6 +36,9 @@ LOG = logging.getLogger(__name__)
# Baofeng WP970I magic string
MSTRING_WP970I = "\x50\xBB\xFF\x20\x14\x04\x13"
+# Baofeng UV-9G magic string
+MSTRING_UV9G = "\x50\xBB\xFF\x20\x12\x05\x25"
+
DTMF_CHARS = "0123456789 *#ABCD"
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
@@ -70,7 +73,7 @@ def model_match(cls, data):
if len(data) > 0x2008:
rid = data[0x2008:0x2010]
- return rid.startswith(cls.MODEL)
+ return rid.startswith(cls.MODEL.encode())
elif len(data) == 0x2008:
rid = data[0x1EF0:0x1EF7]
return rid in cls._fileid
@@ -83,6 +86,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
VENDOR = "Baofeng"
MODEL = "WP970I"
+ _tri_band = False
_fileid = []
_magic = [MSTRING_WP970I, ]
_magic_response_length = 8
@@ -109,6 +113,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
chirp_common.PowerLevel("Med", watts=3.00),
chirp_common.PowerLevel("Low", watts=1.00)]
_vhf_range = (130000000, 180000000)
+ _vhf2_range = (200000000, 260000000)
_uhf_range = (400000000, 521000000)
VALID_BANDS = [_vhf_range,
_uhf_range]
@@ -302,6 +307,7 @@ class WP970I(baofeng_common.BaofengCommonHT):
struct {
struct limit vhf;
struct limit uhf;
+ struct limit vhf2;
} limits;
"""
@@ -591,6 +597,19 @@ class WP970I(baofeng_common.BaofengCommonHT):
lower, upper, _mem.limits.vhf.upper))
other.append(rs)
+ if self._tri_band:
+ lower = 200
+ upper = 260
+ rs = RadioSetting("limits.vhf2.lower", "VHF2 Lower Limit (MHz)",
+ RadioSettingValueInteger(
+ lower, upper, _mem.limits.vhf2.lower))
+ other.append(rs)
+
+ rs = RadioSetting("limits.vhf2.upper", "VHF2 Upper Limit (MHz)",
+ RadioSettingValueInteger(
+ lower, upper, _mem.limits.vhf2.upper))
+ other.append(rs)
+
lower = 400
upper = 520
rs = RadioSetting("limits.uhf.lower", "UHF Lower Limit (MHz)",
@@ -859,12 +878,17 @@ class UV82IIIAlias(chirp_common.Alias):
MODEL = "UV-82III"
+class UV9RPROAlias(chirp_common.Alias):
+ VENDOR = "Baofeng"
+ MODEL = "UV-9R Pro"
+
+
@directory.register
class BFA58(WP970I):
"""Baofeng BF-A58"""
VENDOR = "Baofeng"
MODEL = "BF-A58"
- ALIASES = [RH5XAlias]
+ ALIASES = [RH5XAlias, UV9RPROAlias]
_fileid = ["BFT515 ", "BFT517 "]
@@ -881,6 +905,7 @@ class GT3WP(WP970I):
"""Baofeng GT-3WP"""
VENDOR = "Baofeng"
MODEL = "GT-3WP"
+ LENGTH_NAME = 7
@directory.register
@@ -894,12 +919,14 @@ class RT6(WP970I):
class BFA58S(WP970I):
VENDOR = "Baofeng"
MODEL = "BF-A58S"
+ LENGTH_NAME = 7
ALIASES = [UV82IIIAlias]
+ _tri_band = True
def get_features(self):
rf = WP970I.get_features(self)
rf.valid_bands = [self._vhf_range,
- (200000000, 260000000),
+ self._vhf2_range,
self._uhf_range]
return rf
@@ -910,3 +937,23 @@ class UV9R(WP970I):
VENDOR = "Baofeng"
MODEL = "UV-9R"
LENGTH_NAME = 7
+
+
+@directory.register
+class UV9G(WP970I):
+ """Baofeng UV-9G"""
+ VENDOR = "Baofeng"
+ MODEL = "UV-9G"
+ LENGTH_NAME = 7
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Med", watts=0.50),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+ _magic = [MSTRING_UV9G, ]
+ _gmrs = True
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
diff --git a/chirp/drivers/bf-t1.py b/chirp/drivers/bf-t1.py
index c5b4e04..66a00cc 100644
--- a/chirp/drivers/bf-t1.py
+++ b/chirp/drivers/bf-t1.py
@@ -39,7 +39,7 @@ import logging
LOG = logging.getLogger(__name__)
-# A note about the memmory in these radios
+# A note about the memory in these radios
#
# The '9100' OEM software only manipulates the lower 0x0180 bytes on read/write
# operations as we know, the file generated by the OEM software IS NOT an exact
@@ -85,7 +85,7 @@ debug = False
# BF-T1 handheld
BFT1_magic = "\x05PROGRAM"
-BFT1_ident = " BF9100S"
+BFT1_ident = b" BF9100S"
def _clean_buffer(radio):
@@ -225,7 +225,7 @@ def _start_clone_mode(radio, status):
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error sending Magic to radio:\n%s" % e)
@@ -503,7 +503,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
"""Get the radio's features"""
rf = chirp_common.RadioFeatures()
- rf.valid_special_chans = SPECIALS.keys()
+ rf.valid_special_chans = list(SPECIALS.keys())
rf.has_settings = True
rf.has_bank = False
rf.has_tuning_step = False
@@ -561,7 +561,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error: %s" % e)
def _decode_tone(self, val, inv):
@@ -690,7 +690,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
# get the eprom representation of this channel
_mem = self._get_special(mem.number)
- # if empty memmory
+ # if empty memory
if mem.empty:
# the channel itself
_mem.set_raw("\xFF" * 16)
@@ -894,7 +894,7 @@ class BFT1(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
setattr(_settings, name, value)
LOG.debug("Setting %s: %s" % (name, value))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/bf-t8.py b/chirp/drivers/bf-t8.py
new file mode 100644
index 0000000..27fbbbf
--- /dev/null
+++ b/chirp/drivers/bf-t8.py
@@ -0,0 +1,1024 @@
+# Copyright 2022 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import os
+import struct
+import logging
+
+from chirp import (
+ bitwise,
+ chirp_common,
+ directory,
+ errors,
+ memmap,
+ util,
+)
+from chirp.settings import (
+ RadioSetting,
+ RadioSettingGroup,
+ RadioSettings,
+ RadioSettingValueBoolean,
+ RadioSettingValueFloat,
+ RadioSettingValueInteger,
+ RadioSettingValueList,
+ RadioSettingValueString,
+)
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4]; // RX Frequency
+ lbcd txfreq[4]; // TX Frequency
+ u8 rx_tmode; // RX Tone Mode
+ u8 rx_tone; // PL/DPL Decode
+ u8 tx_tmode; // TX Tone Mode
+ u8 tx_tone; // PL/DPL Encode
+ u8 unknown1:3, //
+ skip:1, // Scan Add: 1 = Skip, 0 = Scan
+ unknown2:2,
+ isnarrow:1, // W/N: 1 = Narrow, 0 = Wide
+ lowpower:1; // TX Power: 1 = Low, 0 = High
+ u8 unknown3[3]; //
+} memory[%d];
+
+#seekto 0x0630;
+struct {
+ u8 squelch; // SQL
+ u8 vox; // Vox Lv
+ u8 tot; // TOT
+ u8 unk1:3, //
+ ste:1, // Tail Clear
+ bcl:1, // BCL
+ save:1, // Save
+ tdr:1, // TDR
+ beep:1; // Beep
+ u8 voice; // Voice
+ u8 abr; // Back Light
+ u8 ring; // Ring
+ u8 mdf; // Display Type
+ u8 mra; // MR Channel A
+ u8 mrb; // MR Channel B
+ u8 disp_ab; // Display A/B Selected
+ u16 fmcur; // Broadcast FM station
+ u8 workmode; // Work Mode
+ u8 wx; // NOAA WX ch#
+ u8 area; // Area Selected
+} settings;
+
+#seekto 0x0D00;
+struct {
+ char name[6];
+ u8 unknown1[2];
+} names[%d];
+"""
+
+CMD_ACK = "\x06"
+
+TONES = chirp_common.TONES
+TMODES = ["", "Tone", "DTCS", "DTCS"]
+
+AB_LIST = ["A", "B"]
+ABR_LIST = ["OFF", "ON", "Key"]
+AREA_LIST = ["China", "Japan", "Korea", "Malaysia", "American",
+ "Australia", "Iran", "Taiwan", "Europe", "Russia"]
+MDF_LIST = ["Frequency", "Channel #", "Name"]
+RING_LIST = ["OFF"] + ["%s" % x for x in range(1, 11)]
+TOT_LIST = ["OFF"] + ["%s seconds" % x for x in range(30, 210, 30)]
+TOT2_LIST = TOT_LIST[1:]
+VOICE_LIST = ["Off", "Chinese", "English"]
+VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 6)]
+WORKMODE_LIST = ["General", "PMR"]
+WX_LIST = ["CH01 - 162.550",
+ "CH02 - 162.400",
+ "CH03 - 162.475",
+ "CH04 - 162.425",
+ "CH05 - 162.450",
+ "CH06 - 162.500",
+ "CH07 - 162.525",
+ "CH08 - 161.650",
+ "CH09 - 161.775",
+ "CH10 - 161.750",
+ "CH11 - 162.000"
+ ]
+
+SETTING_LISTS = {
+ "ab": AB_LIST,
+ "abr": ABR_LIST,
+ "area": AREA_LIST,
+ "mdf": MDF_LIST,
+ "ring": RING_LIST,
+ "tot": TOT_LIST,
+ "tot": TOT2_LIST,
+ "voice": VOICE_LIST,
+ "vox": VOX_LIST,
+ "workmode": WORKMODE_LIST,
+ "wx": WX_LIST,
+ }
+
+FRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+FRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+FRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+FRS_FREQS = FRS_FREQS1 + FRS_FREQS2 + FRS_FREQS3
+
+GMRS_FREQS = FRS_FREQS + FRS_FREQS3
+
+MURS_FREQS = [151.820, 151.880, 151.940, 154.570, 154.600]
+
+PMR_FREQS1 = [446.00625, 446.01875, 446.03125, 446.04375, 446.05625,
+ 446.06875, 446.08125, 446.09375]
+PMR_FREQS2 = [446.10625, 446.11875, 446.13125, 446.14375, 446.15625,
+ 446.16875, 446.18125, 446.19375]
+PMR_FREQS = PMR_FREQS1 + PMR_FREQS2
+
+VOICE_CHOICES = ["Off", "On"]
+VOICE_VALUES = [0x00, 0x02]
+
+
+def _enter_programming_mode(radio):
+ serial = radio.pipe
+
+ exito = False
+ for i in range(0, 5):
+ serial.write(radio._magic)
+ ack = serial.read(1)
+
+ try:
+ if ack == CMD_ACK:
+ exito = True
+ break
+ except:
+ LOG.debug("Attempt #%s, failed, trying again" % i)
+ pass
+
+ # check if we had EXITO
+ if exito is False:
+ _exit_programming_mode(radio)
+ msg = "The radio did not accept program mode after five tries.\n"
+ msg += "Check you interface cable and power cycle your radio."
+ raise errors.RadioError(msg)
+
+ try:
+ serial.write("\x02")
+ ident = serial.read(len(radio._fingerprint))
+ except:
+ _exit_programming_mode(radio)
+ raise errors.RadioError("Error communicating with radio")
+
+ if not ident == radio._fingerprint:
+ _exit_programming_mode(radio)
+ LOG.debug(util.hexprint(ident))
+ raise errors.RadioError("Radio returned unknown identification string")
+
+ try:
+ serial.write(CMD_ACK)
+ ack = serial.read(1)
+ except:
+ _exit_programming_mode(radio)
+ raise errors.RadioError("Error communicating with radio")
+
+ if ack != CMD_ACK:
+ _exit_programming_mode(radio)
+ raise errors.RadioError("Radio refused to enter programming mode")
+
+
+def _exit_programming_mode(radio):
+ serial = radio.pipe
+ try:
+ serial.write("E")
+ except:
+ raise errors.RadioError("Radio refused to exit programming mode")
+
+
+def _read_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">cHb", 'R', block_addr, block_size)
+ expectedresponse = "W" + cmd[1:]
+ LOG.debug("Reading block %04x..." % (block_addr))
+
+ try:
+ serial.write(cmd)
+ response = serial.read(4 + block_size)
+ if response[:4] != expectedresponse:
+ raise Exception("Error reading block %04x." % (block_addr))
+
+ block_data = response[4:]
+
+ serial.write(CMD_ACK)
+ ack = serial.read(1)
+ except:
+ _exit_programming_mode(radio)
+ raise errors.RadioError("Failed to read block at %04x" % block_addr)
+
+ if ack != CMD_ACK:
+ _exit_programming_mode(radio)
+ raise Exception("No ACK reading block %04x." % (block_addr))
+
+ return block_data
+
+
+def _write_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">cHb", 'W', block_addr, block_size)
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
+
+ LOG.debug("Writing Data:")
+ LOG.debug(util.hexprint(cmd + data))
+
+ try:
+ serial.write(cmd + data)
+ if serial.read(1) != CMD_ACK:
+ raise Exception("No ACK")
+ except:
+ _exit_programming_mode(radio)
+ raise errors.RadioError("Failed to send block "
+ "to radio at %04x" % block_addr)
+
+
+def do_download(radio):
+ LOG.debug("download")
+ _enter_programming_mode(radio)
+
+ data = ""
+
+ status = chirp_common.Status()
+ status.msg = "Cloning from radio"
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+
+ block = _read_block(radio, addr, radio.BLOCK_SIZE)
+ data += block
+
+ LOG.debug("Address: %04x" % addr)
+ LOG.debug(util.hexprint(block))
+
+ _exit_programming_mode(radio)
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ status = chirp_common.Status()
+ status.msg = "Uploading to radio"
+
+ _enter_programming_mode(radio)
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for start_addr, end_addr in radio._ranges:
+ for addr in range(start_addr, end_addr, radio.BLOCK_SIZE_UP):
+ status.cur = addr + radio.BLOCK_SIZE_UP
+ radio.status_fn(status)
+ _write_block(radio, addr, radio.BLOCK_SIZE_UP)
+
+ _exit_programming_mode(radio)
+
+
+class BFT8Radio(chirp_common.CloneModeRadio):
+ """Baofeng BF-T8"""
+ VENDOR = "Baofeng"
+ MODEL = "BF-T8"
+ BAUD_RATE = 9600
+ BLOCK_SIZE = BLOCK_SIZE_UP = 0x10
+ ODD_SPLIT = True
+ HAS_NAMES = False
+ NAME_LENGTH = 0
+ VALID_CHARS = ""
+ CH_OFFSET = False
+ SKIP_VALUES = []
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES)
+ DUPLEXES = ["", "-", "+", "split", "off"]
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+ VALID_BANDS = [(400000000, 470000000)]
+
+ _magic = "\x02" + "PROGRAM"
+ _fingerprint = "\x2E" + "BF-T6" + "\x2E"
+ _upper = 99
+ _mem_params = (_upper, # number of channels
+ _upper # number of names
+ )
+ _frs = _gmrs = _murs = _pmr = False
+
+ _ranges = [
+ (0x0000, 0x0B60),
+ ]
+ _memsize = 0x0B60
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_rx_dtcs = True
+ rf.has_tuning_step = False
+ rf.has_name = self.HAS_NAMES
+ rf.can_odd_split = self.ODD_SPLIT
+ rf.valid_name_length = self.NAME_LENGTH
+ rf.valid_characters = self.VALID_CHARS
+ rf.valid_skips = self.SKIP_VALUES
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
+ rf.valid_dtcs_codes = self.DTCS_CODES
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_duplexes = self.DUPLEXES
+ rf.valid_modes = ["FM", "NFM"] # 25 kHz, 12.5 KHz.
+ rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
+ rf.valid_bands = self.VALID_BANDS
+
+ return rf
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT % self._mem_params, self._mmap)
+
+ def validate_memory(self, mem):
+ msgs = ""
+ msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
+
+ _msg_freq = 'Memory location cannot change frequency'
+ _msg_simplex = 'Memory location only supports Duplex:(None)'
+ _msg_duplex = 'Memory location only supports Duplex: +'
+ _msg_nfm = 'Memory location only supports Mode: NFM'
+ _msg_txp = 'Memory location only supports Power: Low'
+
+ # FRS only models
+ if self._frs:
+ # range of memories with values set by FCC rules
+ if mem.freq != int(FRS_FREQS[mem.number - 1] * 1000000):
+ # warn user can't change frequency
+ msgs.append(chirp_common.ValidationError(_msg_freq))
+
+ # channels 1 - 22 are simplex only
+ if str(mem.duplex) != "":
+ # warn user can't change duplex
+ msgs.append(chirp_common.ValidationError(_msg_simplex))
+
+ # channels 1 - 22 are NFM only
+ if str(mem.mode) != "NFM":
+ # warn user can't change mode
+ msgs.append(chirp_common.ValidationError(_msg_nfm))
+
+ # channels 8 - 14 are low power only
+ if mem.number >= 8 and mem.number <= 14:
+ if str(mem.power) != "Low":
+ # warn user can't change power
+ msgs.append(chirp_common.ValidationError(_msg_txp))
+
+ # MURS only models
+ if self._murs:
+ # range of memories with values set by FCC rules
+ if mem.freq != int(MURS_FREQS[mem.number - 1] * 1000000):
+ # warn user can't change frequency
+ msgs.append(chirp_common.ValidationError(_msg_freq))
+
+ # channels 1 - 5 are simplex only
+ if str(mem.duplex) != "":
+ # warn user can't change duplex
+ msgs.append(chirp_common.ValidationError(_msg_simplex))
+
+ # channels 1 - 3 are NFM only
+ if mem.number <= 3:
+ if mem.mode != "NFM":
+ # warn user can't change mode
+ msgs.append(chirp_common.ValidationError(_msg_nfm))
+
+ # PMR only models
+ if self._pmr:
+ # range of memories with values set by governmental rules
+ if mem.freq != int(PMR_FREQS[mem.number - 1] * 1000000):
+ # warn user can't change frequency
+ msgs.append(chirp_common.ValidationError(_msg_freq))
+
+ # channels 1 - 16 are simplex only
+ if str(mem.duplex) != "":
+ # warn user can't change duplex
+ msgs.append(chirp_common.ValidationError(_msg_simplex))
+
+ # channels 1 - 16 are NFM only
+ if mem.mode != "NFM":
+ # warn user can't change mode
+ msgs.append(chirp_common.ValidationError(_msg_nfm))
+
+ # channels 1 - 16 are low power only
+ if str(mem.power) != "Low":
+ # warn user can't change power
+ msgs.append(chirp_common.ValidationError(_msg_txp))
+
+ return msgs
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ data = do_download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = data
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ do_upload(self)
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ def _get_tone(self, mem, _mem):
+ rx_tone = tx_tone = None
+
+ tx_tmode = TMODES[_mem.tx_tmode]
+ rx_tmode = TMODES[_mem.rx_tmode]
+
+ if tx_tmode == "Tone":
+ tx_tone = TONES[_mem.tx_tone]
+ elif tx_tmode == "DTCS":
+ tx_tone = self.DTCS_CODES[_mem.tx_tone]
+
+ if rx_tmode == "Tone":
+ rx_tone = TONES[_mem.rx_tone]
+ elif rx_tmode == "DTCS":
+ rx_tone = self.DTCS_CODES[_mem.rx_tone]
+
+ tx_pol = _mem.tx_tmode == 0x03 and "R" or "N"
+ rx_pol = _mem.rx_tmode == 0x03 and "R" or "N"
+
+ chirp_common.split_tone_decode(mem, (tx_tmode, tx_tone, tx_pol),
+ (rx_tmode, rx_tone, rx_pol))
+
+ def _is_txinh(self, _mem):
+ raw_tx = ""
+ for i in range(0, 4):
+ raw_tx += _mem.txfreq[i].get_raw()
+ return raw_tx == "\xFF\xFF\xFF\xFF"
+
+ def _get_mem(self, number):
+ return self._memobj.memory[number - 1]
+
+ def _get_nam(self, number):
+ return self._memobj.names[number - 1]
+
+ def get_memory(self, number):
+ _mem = self._get_mem(number)
+ if self.HAS_NAMES:
+ _nam = self._get_nam(number)
+
+ mem = chirp_common.Memory()
+
+ mem.number = number
+ mem.freq = int(_mem.rxfreq) * 10
+
+ # We'll consider any blank (i.e. 0MHz frequency) to be empty
+ if mem.freq == 0:
+ mem.empty = True
+ return mem
+
+ if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
+ mem.freq = 0
+ mem.empty = True
+ return mem
+
+ if _mem.get_raw() == ("\xFF" * 16):
+ LOG.debug("Initializing empty memory")
+ _mem.set_raw("\x00" * 13 + "\xFF" * 3)
+
+ if self._is_txinh(_mem):
+ mem.duplex = "off"
+ mem.offset = 0
+ elif int(_mem.rxfreq) == int(_mem.txfreq):
+ mem.duplex = ""
+ mem.offset = 0
+ else:
+ mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
+ mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
+
+ # wide/narrow
+ mem.mode = _mem.isnarrow and "NFM" or "FM"
+
+ mem.skip = _mem.skip and "S" or ""
+
+ if self.HAS_NAMES:
+ for char in _nam.name:
+ if str(char) == "\xFF":
+ char = " " # The OEM software may have 0xFF mid-name
+ mem.name += str(char)
+ mem.name = mem.name.rstrip()
+
+ # tone data
+ self._get_tone(mem, _mem)
+
+ # tx power
+ levels = self.POWER_LEVELS
+ try:
+ mem.power = levels[_mem.lowpower]
+ except IndexError:
+ LOG.error("Radio reported invalid power level %s (in %s)" %
+ (_mem.lowpower, levels))
+ mem.power = levels[0]
+
+ if mem.number <= 22 and self._frs:
+ FRS_IMMUTABLE = ["freq", "duplex", "offset", "mode"]
+ if mem.number >= 8 and mem.number <= 14:
+ mem.immutable = FRS_IMMUTABLE + ["power"]
+ else:
+ mem.immutable = FRS_IMMUTABLE
+
+ if mem.number <= 30 and self._gmrs:
+ GMRS_IMMUTABLE = ["freq", "duplex", "offset"]
+ if mem.number >= 8 and mem.number <= 14:
+ mem.immutable = GMRS_IMMUTABLE + ["mode", "power"]
+ else:
+ mem.immutable = GMRS_IMMUTABLE
+
+ if mem.number <= 5 and self._murs:
+ MURS_IMMUTABLE = ["freq", "duplex", "offset"]
+ if mem.number <= 3:
+ mem.immutable = MURS_IMMUTABLE + ["mode"]
+ else:
+ mem.immutable = MURS_IMMUTABLE
+
+ if mem.number <= 16 and self._pmr:
+ PMR_IMMUTABLE = ["freq", "duplex", "offset", "mode", "power"]
+ mem.immutable = PMR_IMMUTABLE
+
+ return mem
+
+ def _set_tone(self, mem, _mem):
+ ((txmode, txtone, txpol),
+ (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem)
+
+ _mem.tx_tmode = TMODES.index(txmode)
+ _mem.rx_tmode = TMODES.index(rxmode)
+ if txmode == "Tone":
+ _mem.tx_tone = TONES.index(txtone)
+ elif txmode == "DTCS":
+ _mem.tx_tmode = txpol == "R" and 0x03 or 0x02
+ _mem.tx_tone = self.DTCS_CODES.index(txtone)
+ if rxmode == "Tone":
+ _mem.rx_tone = TONES.index(rxtone)
+ elif rxmode == "DTCS":
+ _mem.rx_tmode = rxpol == "R" and 0x03 or 0x02
+ _mem.rx_tone = self.DTCS_CODES.index(rxtone)
+
+ def _set_mem(self, number):
+ return self._memobj.memory[number - 1]
+
+ def _set_nam(self, number):
+ return self._memobj.names[number - 1]
+
+ def set_memory(self, mem):
+ _mem = self._set_mem(mem.number)
+ if self.HAS_NAMES:
+ _nam = self._set_nam(mem.number)
+
+ # if empty memory
+ if mem.empty:
+ if mem.number <= 22 and self._frs:
+ _mem.set_raw("\xFF" * 8 + "\x00" * 5 + "\xFF" * 3)
+ FRS_FREQ = int(FRS_FREQS[mem.number - 1] * 100000)
+ _mem.rxfreq = _mem.txfreq = FRS_FREQ
+ _mem.isnarrow = True
+ if mem.number >= 8 and mem.number <= 14:
+ _mem.lowpower = True
+ else:
+ _mem.lowpower = False
+ elif self._murs:
+ if mem.number <= 5:
+ _mem.set_raw("\xFF" * 8 + "\x00" * 5 + "\xFF" * 3)
+ MURS_FREQ = int(MURS_FREQS[mem.number - 1] * 100000)
+ _mem.rxfreq = _mem.txfreq = MURS_FREQ
+ _mem.lowpower = False
+ if mem.number <= 3:
+ _mem.isnarrow = True
+ else:
+ _mem.isnarrow = False
+ elif self._pmr:
+ if mem.number <= 16:
+ _mem.set_raw("\xFF" * 8 + "\x00" * 5 + "\xFF" * 3)
+ PMR_FREQ = int(PMR_FREQS[mem.number - 1] * 100000)
+ _mem.rxfreq = _mem.txfreq = PMR_FREQ
+ _mem.lowpower = True
+ _mem.isnarrow = True
+ else:
+ _mem.set_raw("\xFF" * 8 + "\x00" * 4 + "\x03" + "\xFF" * 3)
+
+ if self.HAS_NAMES:
+ for i in range(0, self.NAME_LENGTH):
+ _nam.name[i].set_raw("\xFF")
+
+ return mem
+
+ _mem.set_raw("\x00" * 13 + "\xFF" * 3)
+
+ if self._gmrs:
+ if mem.number >= 1 and mem.number <= 30:
+ GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = GMRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ if mem.number > 22:
+ mem.duplex = '+'
+ mem.offset = 5000000
+ elif float(mem.freq) / 1000000 in GMRS_FREQS:
+ if float(mem.freq) / 1000000 in FRS_FREQS1:
+ mem.duplex = ''
+ mem.offset = 0
+ if float(mem.freq) / 1000000 in FRS_FREQS2:
+ mem.duplex = ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ if float(mem.freq) / 1000000 in FRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.duplex = ''
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
+ # frequency
+ _mem.rxfreq = mem.freq / 10
+
+ if mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw("\xFF")
+ elif mem.duplex == "split":
+ _mem.txfreq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.txfreq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.txfreq = mem.freq / 10
+
+ # wide/narrow
+ _mem.isnarrow = mem.mode == "NFM"
+
+ _mem.skip = mem.skip == "S"
+
+ if self.HAS_NAMES:
+ for i in range(self.NAME_LENGTH):
+ try:
+ _nam.name[i] = mem.name[i]
+ except IndexError:
+ _nam.name[i] = "\xFF"
+
+ # tone data
+ self._set_tone(mem, _mem)
+
+ # tx power
+ if mem.power:
+ _mem.lowpower = self.POWER_LEVELS.index(mem.power)
+ else:
+ _mem.lowpower = 0
+
+ return mem
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ top = RadioSettings(basic)
+
+ # Menu 03
+ rs = RadioSettingValueInteger(0, 9, _settings.squelch)
+ rset = RadioSetting("squelch", "Squelch Level", rs)
+ basic.append(rset)
+
+ model_list = ["RB27B", "RB27V", "RB627B"]
+ if self.MODEL in model_list:
+ # Menu 09 (RB27x/RB627x)
+ rs = RadioSettingValueList(TOT2_LIST, TOT2_LIST[_settings.tot])
+ else:
+ # Menu 11 / 09 (RB27)
+ rs = RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot])
+ rset = RadioSetting("tot", "Time-out timer", rs)
+ basic.append(rset)
+
+ # Menu 06
+ rs = RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox])
+ rset = RadioSetting("vox", "VOX Level", rs)
+ basic.append(rset)
+
+ # Menu 15 (BF-T8) / Menu 14 (FRS-A1)
+ if self.MODEL == "FRS-A1":
+ # Menu 14 (FRS-A1)
+ def apply_voice_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = VOICE_CHOICES.index(val)
+ val = VOICE_VALUES[index]
+ obj.set_value(val)
+
+ if _settings.voice in VOICE_VALUES:
+ idx = VOICE_VALUES.index(_settings.voice)
+ else:
+ idx = VOICE_VALUES.index(0x00)
+ rs = RadioSettingValueList(VOICE_CHOICES, VOICE_CHOICES[idx])
+ rset = RadioSetting("voice", "Voice", rs)
+ rset.set_apply_callback(apply_voice_listvalue, _settings.voice)
+ basic.append(rset)
+ else:
+ # Menu 15 (BF-T8)
+ rs = RadioSettingValueList(VOICE_LIST, VOICE_LIST[_settings.voice])
+ rset = RadioSetting("voice", "Voice", rs)
+ basic.append(rset)
+
+ # Menu 12
+ rs = RadioSettingValueBoolean(_settings.bcl)
+ rset = RadioSetting("bcl", "Busy Channel Lockout", rs)
+ basic.append(rset)
+
+ # Menu 10 / 08 (RB27/RB627)
+ rs = RadioSettingValueBoolean(_settings.save)
+ rset = RadioSetting("save", "Battery Saver", rs)
+ basic.append(rset)
+
+ # Menu 08 / 07 (RB-27/RB627)
+ rs = RadioSettingValueBoolean(_settings.tdr)
+ rset = RadioSetting("tdr", "Dual Watch", rs)
+ basic.append(rset)
+
+ # Menu 05
+ rs = RadioSettingValueBoolean(_settings.beep)
+ rset = RadioSetting("beep", "Beep", rs)
+ basic.append(rset)
+
+ # Menu 04
+ rs = RadioSettingValueList(ABR_LIST, ABR_LIST[_settings.abr])
+ rset = RadioSetting("abr", "Back Light", rs)
+ basic.append(rset)
+
+ # Menu 13 / 11 (RB-27/RB627)
+ rs = RadioSettingValueList(RING_LIST, RING_LIST[_settings.ring])
+ rset = RadioSetting("ring", "Ring", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(not _settings.ste)
+ rset = RadioSetting("ste", "Squelch Tail Eliminate", rs)
+ basic.append(rset)
+
+ # Menu 15 (FRS-A1)
+ if self.MODEL == "FRS-A1":
+ rs = RadioSettingValueList(MDF_LIST, MDF_LIST[_settings.mdf])
+ rset = RadioSetting("mdf", "Display Type", rs)
+ basic.append(rset)
+
+ if self.CH_OFFSET:
+ rs = RadioSettingValueInteger(1, self._upper, _settings.mra + 1)
+ else:
+ rs = RadioSettingValueInteger(1, self._upper, _settings.mra)
+ rset = RadioSetting("mra", "MR A Channel #", rs)
+ basic.append(rset)
+
+ if self.CH_OFFSET:
+ rs = RadioSettingValueInteger(1, self._upper, _settings.mrb + 1)
+ else:
+ rs = RadioSettingValueInteger(1, self._upper, _settings.mrb)
+ rset = RadioSetting("mrb", "MR B Channel #", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(AB_LIST, AB_LIST[_settings.disp_ab])
+ rset = RadioSetting("disp_ab", "Selected Display Line", rs)
+ basic.append(rset)
+
+ if not self.MODEL.startswith("RB627"):
+ if self.MODEL == "FRS-A1":
+ del WX_LIST[7:]
+ rs = RadioSettingValueList(WX_LIST, WX_LIST[_settings.wx])
+ rset = RadioSetting("wx", "NOAA WX Radio", rs)
+ basic.append(rset)
+
+ def myset_freq(setting, obj, atrb, mult):
+ """ Callback to set frequency by applying multiplier"""
+ value = int(float(str(setting.value)) * mult)
+ setattr(obj, atrb, value)
+ return
+
+ # FM Broadcast Settings
+ val = _settings.fmcur
+ val = val / 10.0
+ val_low = 76.0
+ if self.MODEL == "FRS-A1":
+ val_low = 87.0
+ if val < val_low or val > 108.0:
+ val = 90.4
+ rx = RadioSettingValueFloat(val_low, 108.0, val, 0.1, 1)
+ rset = RadioSetting("settings.fmcur", "Broadcast FM Radio (MHz)", rx)
+ rset.set_apply_callback(myset_freq, _settings, "fmcur", 10)
+ basic.append(rset)
+
+ model_list = ["BF-T8", "BF-U9", "AR-8"]
+ if self.MODEL in model_list:
+ rs = RadioSettingValueList(WORKMODE_LIST,
+ WORKMODE_LIST[_settings.workmode])
+ rset = RadioSetting("workmode", "Work Mode", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(AREA_LIST, AREA_LIST[_settings.area])
+ rs.set_mutable(False)
+ rset = RadioSetting("area", "Area", rs)
+ basic.append(rset)
+
+ return top
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif setting == "mra" and self.CH_OFFSET:
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "mrb" and self.CH_OFFSET:
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "ste":
+ setattr(obj, setting, not int(element.value))
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+class BFU9Alias(chirp_common.Alias):
+ VENDOR = "Baofeng"
+ MODEL = "BF-U9"
+
+
+class AR8Alias(chirp_common.Alias):
+ VENDOR = "Arcshell"
+ MODEL = "AR-8"
+
+
+@directory.register
+class BaofengBFT8Generic(BFT8Radio):
+ ALIASES = [BFU9Alias, AR8Alias, ]
+
+
+@directory.register
+class RetevisRT16(BFT8Radio):
+ VENDOR = "Retevis"
+ MODEL = "RT16"
+
+ _upper = 22
+ _frs = True
+
+
+@directory.register
+class RetevisRB27B(BFT8Radio):
+ VENDOR = "Retevis"
+ MODEL = "RB27B"
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
+ HAS_NAMES = True
+ NAME_LENGTH = 6
+ VALID_CHARS = chirp_common.CHARSET_UPPER_NUMERIC + "-"
+ CH_OFFSET = True
+ SKIP_VALUES = ["", "S"]
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+ VALID_BANDS = [(400000000, 520000000)]
+
+ _upper = 22
+ _frs = True
+ _gmrs = _murs = _pmr = False
+
+ _ranges = [
+ (0x0000, 0x0640),
+ (0x0D00, 0x1040),
+ ]
+ _memsize = 0x1040
+
+
+@directory.register
+class RetevisRB27(RetevisRB27B):
+ VENDOR = "Retevis"
+ MODEL = "RB27"
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+ VALID_BANDS = [(136000000, 174000000),
+ (400000000, 520000000)]
+
+ _upper = 99
+ _gmrs = True
+ _frs = _murs = _pmr = False
+
+
+@directory.register
+class RetevisRB27V(RetevisRB27B):
+ VENDOR = "Retevis"
+ MODEL = "RB27V"
+ VALID_BANDS = [(136000000, 174000000)]
+
+ _upper = 5
+ _murs = True
+ _frs = _gmrs = _pmr = False
+
+
+@directory.register
+class RetevisRB627B(RetevisRB27B):
+ VENDOR = "Retevis"
+ MODEL = "RB627B"
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=0.50),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _upper = 16
+ _pmr = True
+ _frs = _gmrs = _murs = False
+
+
+@directory.register
+class FRSA1Radio(BFT8Radio):
+ """BTECH FRS-A1"""
+ VENDOR = "BTECH"
+ MODEL = "FRS-A1"
+ ODD_SPLIT = False
+ HAS_NAMES = True
+ NAME_LENGTH = 6
+ SKIP_VALUES = ["", "S"]
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
+ DUPLEXES = ["", "-", "+", "off"]
+
+ _fingerprint = "BF-T8A" + "\x2E"
+ _upper = 22
+ _frs = _upper == 22
+
+ _ranges = [
+ (0x0000, 0x0640),
+ (0x0D00, 0x0DC0),
+ ]
+ _memsize = 0x0DC0
+
+ def get_features(self):
+ rf = BFT8Radio.get_features(self)
+ rf.valid_name_length = 6
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "-"
+ return rf
diff --git a/chirp/drivers/bj9900.py b/chirp/drivers/bj9900.py
index ef92d64..ca9197a 100644
--- a/chirp/drivers/bj9900.py
+++ b/chirp/drivers/bj9900.py
@@ -63,7 +63,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
# plus an empty line at the end
_datsize = (_memsize * 2) / 96 * 98 + 2
- # block are read in same order as original sw eventhough they are not
+ # block are read in same order as original sw even though they are not
# in physical order
_blocks = [
(0x400, 0x1BFF, 0x30),
@@ -214,7 +214,7 @@ class BJ9900Radio(chirp_common.CloneModeRadio,
rf.valid_cross_modes = list(self.CROSS_MODES)
rf.valid_duplexes = list(self.DUPLEX)
rf.has_tuning_step = False
- # rf.valid_tuning_steps = list(self.STEPS)
+ rf.valid_tuning_steps = list(self.STEPS)
rf.valid_bands = self.VALID_BANDS
rf.valid_skips = [""]
rf.valid_power_levels = self.POWER_LEVELS
diff --git a/chirp/drivers/bjuv55.py b/chirp/drivers/bjuv55.py
index 36cb98e..fc29170 100644
--- a/chirp/drivers/bjuv55.py
+++ b/chirp/drivers/bjuv55.py
@@ -237,7 +237,7 @@ struct {
class BaojieBJUV55Radio(uv5r.BaofengUV5R):
VENDOR = "Baojie"
MODEL = "BJ-UV55"
- _basetype = ["BJ55"]
+ _basetype = [b"BJ55"]
_idents = [BJUV55_MODEL]
_mem_params = (0x1928 # poweron_msg offset
)
@@ -647,6 +647,6 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
value = int(val.get_value() * 10 - 870)
LOG.debug("Setting fm_preset = %s" % (value))
self._memobj.fm_preset = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/boblov_x3plus.py b/chirp/drivers/boblov_x3plus.py
index dd861e8..76283ee 100644
--- a/chirp/drivers/boblov_x3plus.py
+++ b/chirp/drivers/boblov_x3plus.py
@@ -136,7 +136,7 @@ class BoblovX3Plus(chirp_common.CloneModeRadio,
LOG.debug('Boblov_x3plus: match_model: size matches')
- if 'P310' in filedata[0x03D0:0x03D8]:
+ if b'P310' in filedata[0x03D0:0x03D8]:
LOG.debug('Boblov_x3plus: match_model: radio ID matches')
return True
@@ -322,7 +322,7 @@ class BoblovX3Plus(chirp_common.CloneModeRadio,
if memory.duplex == 'off':
for i in range(0, 4):
rmem.txfreq[i].set_raw('\xFF')
- # If recieve only then txtone value should be none
+ # If receive only then txtone value should be none
self._encode_tone(rmem.txtone, mode='', value=None, pol=None)
set_txtone = False
elif memory.duplex == 'split':
diff --git a/chirp/drivers/btech.py b/chirp/drivers/btech.py
index dca1560..7b5c9d6 100644
--- a/chirp/drivers/btech.py
+++ b/chirp/drivers/btech.py
@@ -1,4 +1,4 @@
-# Copyright 2016-2017:
+# Copyright 2016-2022:
# * Pavel Milanes CO7WT, <pavelmc@gmail.com>
# * Jim Unroe KC9HI, <rock.unroe@gmail.com>
#
@@ -32,7 +32,7 @@ from textwrap import dedent
LOG = logging.getLogger(__name__)
-# A note about the memmory in these radios
+# A note about the memory in these radios
#
# The real memory of these radios extends to 0x4000
# On read the factory software only uses up to 0x3200
@@ -57,14 +57,15 @@ SPMUTE_LIST = ["Tone/DTCS", "Tone/DTCS and Optsig", "Tone/DTCS or Optsig"]
# lists
LIST_AB = ["A", "B"]
+LIST_ABC = LIST_AB + ["C"]
LIST_ABCD = LIST_AB + ["C", "D"]
LIST_ANIL = ["3", "4", "5"]
LIST_APO = ["Off"] + ["%s minutes" % x for x in range(30, 330, 30)]
LIST_COLOR4 = ["Off", "Blue", "Orange", "Purple"]
-LIST_COLOR7 = ["White", "Red", "Blue", "Green", "Yellow", "Indego",
+LIST_COLOR8 = ["White", "Red", "Blue", "Green", "Yellow", "Indigo",
"Purple", "Gray"]
-LIST_COLOR8 = ["Black"] + LIST_COLOR7
-LIST_DTMFST = ["OFF", "Keyboard", "ANI", "Keyboad + ANI"]
+LIST_COLOR9 = ["Black"] + LIST_COLOR8
+LIST_DTMFST = ["OFF", "Keyboard", "ANI", "Keyboard + ANI"]
LIST_EMCTP = ["TX alarm sound", "TX ANI", "Both"]
LIST_EMCTPX = ["Off"] + LIST_EMCTP
LIST_LANGUA = ["English", "Chinese"]
@@ -72,17 +73,20 @@ LIST_MDF = ["Frequency", "Channel", "Name"]
LIST_OFF1TO9 = ["Off"] + ["%s seconds" % x for x in range(1, 10)]
LIST_OFF1TO10 = ["Off"] + ["%s seconds" % x for x in range(1, 11)]
LIST_OFF1TO50 = ["Off"] + ["%s seconds" % x for x in range(1, 51)]
+LIST_OFF1TO60 = ["Off"] + ["%s seconds" % x for x in range(1, 61)]
LIST_PONMSG = ["Full", "Message", "Battery voltage"]
LIST_REPM = ["Off", "Carrier", "CTCSS or DCS", "Tone", "DTMF"]
LIST_REPS = ["1000 Hz", "1450 Hz", "1750 Hz", "2100Hz"]
-LIST_RPTDL = ["Off"] + ["%s ms" % x for x in range(1, 10)]
+LIST_REPSW = ["Off", "RX", "TX"]
+LIST_RPTDL = ["Off"] + ["%s ms" % x for x in range(1, 11)]
LIST_SCMODE = ["Off", "PTT-SC", "MEM-SC", "PON-SC"]
LIST_SHIFT = ["Off", "+", "-"]
LIST_SKIPTX = ["Off", "Skip 1", "Skip 2"]
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
LIST_STEP = [str(x) for x in STEPS]
LIST_SYNC = ["Off", "AB", "CD", "AB+CD"]
-# the first 12 TMR choices common to all color display mobile radios
+LIST_SYNCV2 = ["Off", "AB", "AC", "BC", "ABC"]
+# the first 12 TMR choices common to all 4-line color display mobile radios
LIST_TMR12 = ["OFF", "M+A", "M+B", "M+C", "M+D", "M+A+B", "M+A+C", "M+A+D",
"M+B+C", "M+B+D", "M+C+D", "M+A+B+C"]
# the 16 choice list for color display mobile radios that correctly implement
@@ -91,12 +95,18 @@ LIST_TMR16 = LIST_TMR12 + ["M+A+B+D", "M+A+C+D", "M+B+C+D", "A+B+C+D"]
# the 15 choice list for color mobile radios that are missing the M+A+B+D
# choice in the TMR menu
LIST_TMR15 = LIST_TMR12 + ["M+A+C+D", "M+B+C+D", "A+B+C+D"]
+# the 7 TMR choices for the 3-line color display mobile radios
+LIST_TMR7 = ["OFF", "M+A", "M+B", "M+C", "M+AB", "M+AC", "M+BC", "M+ABC"]
+LIST_TMRTX = ["Track", "Fixed"]
LIST_TOT = ["%s sec" % x for x in range(15, 615, 15)]
LIST_TXDISP = ["Power", "Mic Volume"]
LIST_TXP = ["High", "Low"]
LIST_TXP3 = ["High", "Mid", "Low"]
LIST_SCREV = ["TO (timeout)", "CO (carrier operated)", "SE (search)"]
LIST_VFOMR = ["Frequency", "Channel"]
+LIST_VOICE = ["Off"] + LIST_LANGUA
+LIST_VOX = ["Off"] + ["%s" % x for x in range(1, 11)]
+LIST_VOXT = ["%s seconds" % x for x in range(0, 21)]
LIST_WIDE = ["Wide", "Narrow"]
# lists related to DTMF, 2TONE and 5TONE settings
@@ -131,8 +141,7 @@ LIST_2TONE_DEC = ["A-B", "A-C", "A-D",
LIST_2TONE_RESPONSE = ["None", "Alert", "Transpond", "Alert+Transpond"]
# This is a general serial timeout for all serial read functions.
-# Practice has show that about 0.7 sec will be enough to cover all radios.
-STIMEOUT = 0.7
+STIMEOUT = 0.25
# this var controls the verbosity in the debug and by default it's low (False)
# make it True and you will to get a very verbose debug.log
@@ -142,6 +151,14 @@ debug = False
VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
"`{|}!\"#$%&'()*+,-./:;<=>?@[]^_"
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+
# #### ID strings #####################################################
@@ -190,6 +207,11 @@ UV50X2_fp = b"UC2M12"
GMRS50X1_fp = "NC1802"
GMRS50X1_fp1 = "NC1932"
+# B-TECH GMRS-20V2
+GMRS20V2_fp = "WP4204"
+GMRS20V2_fp1 = "VW2112"
+GMRS20V2_fp2 = "VWG728"
+
# special var to know when we found a BTECH Gen 3
BTECH3 = [UV2501G3_fp, UV2501_220G3_fp, UV5001G3_fp]
@@ -209,6 +231,8 @@ KT8900_fp2 = b"M2G1F4"
KT8900_fp3 = b"M2G2F4"
KT8900_fp4 = b"M2G304"
KT8900_fp5 = b"M2G314"
+KT8900_fp6 = b"M2G424"
+KT8900_fp7 = b"M27184"
# this radio has an extra ID
KT8900_id = b"303688"
@@ -222,15 +246,19 @@ KT8900R_fp2 = b"M3C234"
KT8900R_fp3 = b"M39164"
# another model
KT8900R_fp4 = b"M3G314"
-# this radio has an extra ID
-KT8900R_id = b"280528"
-# another extra ID in dec/2018
-KT8900R_id2 = b"\x05\x58\x3d\xf0\x10"
+# AC3MB: another id
+KT8900R_fp5 = b"M3B064"
# KT7900D (quad band)
KT7900D_fp = b"VC4004"
KT7900D_fp1 = b"VC4284"
KT7900D_fp2 = b"VC4264"
+KT7900D_fp3 = b"VC4114"
+KT7900D_fp4 = b"VC4104"
+KT7900D_fp5 = b"VC4254"
+KT7900D_fp6 = b"VC5264"
+KT7900D_fp7 = b"VC9204"
+KT7900D_fp8 = b"VC9214"
# QB25 (quad band) - a clone of KT7900D
QB25_fp = b"QB-25"
@@ -238,12 +266,36 @@ QB25_fp = b"QB-25"
# KT8900D (dual band)
KT8900D_fp = b"VC2002"
KT8900D_fp1 = b"VC8632"
+KT8900D_fp2 = b"VC3402"
+KT8900D_fp3 = b"VC7062"
# LUITON LT-588UV
LT588UV_fp = b"V2G1F4"
# Added by rstrickoff gen 2 id
LT588UV_fp1 = b"V2G214"
+# QYT KT-8R (quad band ht)
+KT8R_fp = "MCB264"
+KT8R_fp1 = "MCB284"
+KT8R_fp2 = "MC5264"
+
+# QYT KT5800 (dual band)
+KT5800_fp = "VCB222"
+
+# QYT KT980Plus (dual band)
+KT980PLUS_fp = "VC2002"
+KT980PLUS_fp1 = "VC6042"
+
+# Radioddity DB25-G (gmrs)
+DB25G_fp = "VC6182"
+DB25G_fp1 = "VC7062"
+
+# QYT KT-WP12 and KT-9900
+KTWP12_fp = "WP3094"
+
+# Anysecu WP-9900
+WP9900_fp = "WP3094"
+
# ### MAGICS
# for the Waccom Mini-8900
@@ -263,6 +315,12 @@ MSTRING_UV25X2 = b"\x55\x20\x16\x12\x28\xFF\xDC\x02"
MSTRING_UV25X4 = "\x55\x20\x16\x11\x18\xFF\xDC\x02"
# for the BTECH GMRS-50X1
MSTRING_GMRS50X1 = "\x55\x20\x18\x10\x18\xFF\xDC\x02"
+# for the BTECH GMRS-20V2
+MSTRING_GMRS20V2 = "\x55\x20\x21\x03\x27\xFF\xDC\x02"
+# for the QYT KT-8R
+MSTRING_KT8R = "\x55\x20\x17\x07\x03\xFF\xDC\x02"
+# for the QYT KT-WP12, KT-9900 and Anysecu WP-9900
+MSTRING_KTWP12 = "\x55\x20\x18\x11\x02\xFF\xDC\x02"
def _clean_buffer(radio):
@@ -324,19 +382,7 @@ def _send(radio, data):
"""Send data to the radio device"""
try:
- for byte in data:
- radio.pipe.write(bytes([byte]))
- # Some OS (mainly Linux ones) are too fast on the serial and
- # get the MCU inside the radio stuck in the early stages, this
- # hits some models more than others.
- #
- # To cope with that we introduce a delay on the writes.
- # Many option have been tested (delaying only after error occures,
- # after short reads, only for linux, ...)
- # Finally, a static delay was chosen as simplest of all solutions
- # (Michael Wagner, OE4AMW)
- # (for details, see issue 3993)
- sleep(0.002)
+ radio.pipe.write(bytes(data))
# DEBUG
if debug is True:
@@ -384,66 +430,27 @@ def _recv(radio, addr):
return block[5:]
-def _start_clone_mode(radio, status):
- """Put the radio in clone mode and get the ident string, 3 tries"""
-
- # cleaning the serial buffer
- _clean_buffer(radio)
-
- # prep the data to show in the UI
- status.cur = 0
- status.msg = "Identifying the radio..."
- status.max = 3
- radio.status_fn(status)
-
- try:
- for a in range(0, status.max):
- # Update the UI
- status.cur = a + 1
- radio.status_fn(status)
-
- # send the magic word
- _send(radio, radio._magic)
-
- # Now you get a x06 of ACK if all goes well
- ack = radio.pipe.read(1)
-
- if ack[:1] == ACK_CMD:
- # DEBUG
- LOG.info("Magic ACK received")
- status.cur = status.max
- radio.status_fn(status)
-
- return True
-
- return False
-
- except errors.RadioError:
- raise
- except Exception as e:
- raise errors.RadioError("Error sending Magic to radio:\n%s" % e)
-
-
def _do_ident(radio, status, upload=False):
"""Put the radio in PROGRAM mode & identify it"""
# set the serial discipline
radio.pipe.baudrate = 9600
radio.pipe.parity = "N"
- # open the radio into program mode
- if _start_clone_mode(radio, status) is False:
- msg = "Radio did not enter clone mode"
- # warning about old versions of QYT KT8900
- if radio.MODEL == "KT8900":
- msg += ". You may want to try it as a WACCOM MINI-8900, there is a"
- msg += " known variant of this radios that is a clone of it."
- raise errors.RadioError(msg)
+ # lengthen the timeout here as these radios are resetting due to timeout
+ radio.pipe.timeout = 0.75
- # Ok, get the ident string
- ident = _rawrecv(radio, 49)
+ # send the magic word
+ _send(radio, radio._magic)
- # basic check for the ident
- if len(ident) != 49:
+ # Now you get a 50 byte reply if all goes well
+ ident = _rawrecv(radio, 50)
+
+ # checking for the ack
+ if ident[0] != ACK_CMD:
+ raise errors.RadioError("Bad ack from radio")
+
+ # basic check for the ident block
+ if len(ident) != 50:
raise errors.RadioError("Radio send a short ident block.")
# check if ident is OK
@@ -462,62 +469,52 @@ def _do_ident(radio, status, upload=False):
LOG.debug("Incorrect model ID, got this:\n\n" + util.hexprint(ident))
raise errors.RadioError("Radio identification failed.")
- # some radios needs a extra read and check for a code on it, this ones
- # has the check value in the _id2 var, others simply False
- if radio._id2 is not False:
- # lower the timeout here as this radios are reseting due to timeout
- radio.pipe.timeout = 0.05
-
- # query & receive the extra ID
- _send(radio, _make_frame("S", 0x3DF0, 16))
- id2 = _rawrecv(radio, 21)
-
- # WARNING !!!!!!
- # different radios send a response with a different amount of data
- # it seems that it's padded with \xff, \x20 and some times with \x00
- # we just care about the first 16, our magic string is in there
- if len(id2) < 16:
- raise errors.RadioError("The extra ID is short, aborting.")
-
- # ok, the correct string must be in the received data
- # the radio._id2 var will be always a list
- flag2 = False
- for _id2 in radio._id2:
- if _id2 in id2:
- flag2 = True
-
- if not flag2:
- LOG.debug("Full *BAD* extra ID on the %s is: \n%s" %
- (radio.MODEL, util.hexprint(id2)))
- raise errors.RadioError("The extra ID is wrong, aborting.")
-
- # this radios need a extra request/answer here on the upload
- # the amount of data received depends of the radio type
+ # pause here for the radio to catch up
+ sleep(0.1)
+
+ # the OEM software reads this additional block, so we will, too
+
+ # Get the full 21 bytes at a time to reduce load
+ # 1 byte ACK + 4 bytes header + 16 bytes of data (BLOCK_SIZE)
+ frame = _make_frame("S", 0x3DF0, 16)
+ _send(radio, frame)
+ id2 = _rawrecv(radio, 21)
+
+ # restore the default serial timeout
+ radio.pipe.timeout = STIMEOUT
+
+ # checking for the ack
+ if id2[0] not in "\x06\x05":
+ raise errors.RadioError("Bad ack from radio")
+
+ # basic check for the additional block
+ if len(id2) < 21:
+ raise errors.RadioError("The extra ID is short, aborting.")
+
+ # this radios need a extra request/answer here on the upload
+ # the amount of data received depends of the radio type
+ #
+ # also the first block of TX must no have the ACK at the beginning
+ # see _upload for this.
+ if upload is True:
+ # send an ACK
+ _send(radio, ACK_CMD)
+
+ # the amount of data depend on the radio, so far we have two radios
+ # reading two bytes with an ACK at the end and just ONE with just
+ # one byte (QYT KT8900)
+ # the JT-6188 appears a clone of the last, but reads TWO bytes.
#
- # also the first block of TX must no have the ACK at the beginning
- # see _upload for this.
- if upload is True:
- # send an ACK
- _send(radio, ACK_CMD)
-
- # the amount of data depend on the radio, so far we have two radios
- # reading two bytes with an ACK at the end and just ONE with just
- # one byte (QYT KT8900)
- # the JT-6188 appears a clone of the last, but reads TWO bytes.
- #
- # we will read two bytes with a custom timeout to not penalize the
- # users for this.
- #
- # we just check for a response and last byte being a ACK, that is
- # the common stone for all radios (3 so far)
- ack = _rawrecv(radio, 2)
-
- # checking
- if len(ack) == 0 or ack[-1:] != ACK_CMD:
- raise errors.RadioError("Radio didn't ACK the upload")
-
- # restore the default serial timeout
- radio.pipe.timeout = STIMEOUT
+ # we will read two bytes with a custom timeout to not penalize the
+ # users for this.
+ #
+ # we just check for a response and last byte being a ACK, that is
+ # the common stone for all radios (3 so far)
+ ack = _rawrecv(radio, 2)
+
+ # checking
+ if len(ack) == 0 or ack[-1:] != ACK_CMD:
+ raise errors.RadioError("Radio didn't ACK the upload")
# DEBUG
LOG.info("Positive ident, this is a %s %s" % (radio.VENDOR, radio.MODEL))
@@ -534,25 +531,13 @@ def _download(radio):
# put radio in program mode and identify it
_do_ident(radio, status)
- # the models that doesn't have the extra ID have to make a dummy read here
- if radio._id2 is False:
- _send(radio, _make_frame("S", 0, BLOCK_SIZE))
- discard = _rawrecv(radio, BLOCK_SIZE + 5)
-
- if debug is True:
- LOG.info("Dummy first block read done, got this:\n\n %s",
- util.hexprint(discard))
-
# reset the progress bar in the UI
status.max = MEM_SIZE / BLOCK_SIZE
status.msg = "Cloning from radio..."
status.cur = 0
radio.status_fn(status)
- # cleaning the serial buffer
- _clean_buffer(radio)
-
- data = bytes(b"")
+ data = b""
for addr in range(0, MEM_SIZE, BLOCK_SIZE):
# sending the read request
_send(radio, _make_frame("S", addr, BLOCK_SIZE))
@@ -575,7 +560,7 @@ def _upload(radio):
"""Upload procedure"""
# The UPLOAD mem is restricted to lower than 0x3100,
- # so we will overide that here localy
+ # so we will override that here localy
MEM_SIZE = radio.UPLOAD_MEM_SIZE
# UI progress
@@ -593,13 +578,6 @@ def _upload(radio):
status.msg = "Cloning to radio..."
radio.status_fn(status)
- # the radios that doesn't have the extra ID 'may' do a dummy write, I found
- # that leveraging the bad ACK and NOT doing the dummy write is ok, as the
- # dummy write is accepted (it actually writes to the mem!) by the radio.
-
- # cleaning the serial buffer
- _clean_buffer(radio)
-
# the fun start here
for addr in range(0, MEM_SIZE, TX_BLOCK_SIZE):
# getting the block of data to send
@@ -610,7 +588,7 @@ def _upload(radio):
# first block must not send the ACK at the beginning for the
# ones that has the extra id, since this have to do a extra step
- if addr == 0 and radio._id2 is not False:
+ if addr == 0:
frame = frame[1:]
# send the frame
@@ -676,7 +654,9 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
IDENT = ""
BANDS = 2
COLOR_LCD = False
- COLOR_LCD2 = False
+ COLOR_LCD2 = False # BTech Original GMRS Radios
+ COLOR_LCD3 = False # Color HT Radios
+ COLOR_LCD4 = False # Waterproof Mobile Radios
NAME_LENGTH = 6
NEEDS_COMPAT_SERIAL = False
UPLOAD_MEM_SIZE = 0X3100
@@ -691,6 +671,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_fileid = None
_id2 = False
btech3 = False
+ _gmrs = False
@classmethod
def get_prompts(cls):
@@ -777,6 +758,15 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
return rf
+ def validate_memory(self, mem):
+ msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
+
+ _msg_duplex1 = 'Memory location only supports "Low"'
+ _msg_duplex2 = 'Memory location only supports "off"'
+ _msg_duplex3 = 'Memory location only supports "(None)", "+" or "off"'
+
+ return msgs
+
def sync_in(self):
"""Download from radio"""
data = _download(self)
@@ -951,7 +941,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LOG.debug("This mem was empty before")
mem_was_empty = True
- # if empty memmory
+ # if empty memory
if mem.empty:
# the channel itself
_mem.set_raw("\xFF" * 16)
@@ -965,6 +955,49 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LOG.debug('Zeroing new memory')
_mem.set_raw('\x00' * 16)
+ if self._gmrs:
+ if self.MODEL == "GMRS-50X1":
+ if mem.number >= 1 and mem.number <= 30:
+ GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = GMRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number <= 7:
+ mem.power = POWER_LEVELS[2]
+ if mem.number >= 8 and mem.number <= 14:
+ mem.duplex = 'off'
+ mem.offset = 0
+ mem.mode = 'NFM'
+ mem.power = POWER_LEVELS[2]
+ if mem.number > 22:
+ mem.duplex = '+'
+ mem.offset = 5000000
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+ if self.MODEL == "GMRS-20V2":
+ if float(mem.freq) / 1000000 in GMRS_FREQS1:
+ mem.duplex = ''
+ mem.offset = 0
+ mem.power = POWER_LEVELS[2]
+ elif float(mem.freq) / 1000000 in GMRS_FREQS2:
+ mem.duplex = 'off'
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = POWER_LEVELS[2]
+ elif float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.power == POWER_LEVELS[1]:
+ mem.power = POWER_LEVELS[0]
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.duplex == ''
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
# frequency
_mem.rxfreq = mem.freq / 10
@@ -1002,7 +1035,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
# scan add property
_mem.add = SKIP_VALUES.index(mem.skip)
- # reseting unknowns, this have to be set by hand
+ # resetting unknowns, this have to be set by hand
_mem.unknown0 = 0
_mem.unknown1 = 0
_mem.unknown2 = 0
@@ -1076,24 +1109,37 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.settings.autolk))
basic.append(autolk)
+ if self.MODEL == "DB25-G":
+ rs = RadioSettingValueInteger(0, 127, _mem.settings.mgain2)
+ mgain2 = RadioSetting("settings.mgain2", "Mic gain", rs)
+ basic.append(mgain2)
+
tot = RadioSetting("settings.tot", "Time out timer",
RadioSettingValueList(
LIST_TOT,
LIST_TOT[_mem.settings.tot]))
basic.append(tot)
- if self.VENDOR == "BTECH" or self.COLOR_LCD:
- apo = RadioSetting("settings.apo", "Auto power off timer",
- RadioSettingValueList(
- LIST_APO,
- LIST_APO[_mem.settings.apo]))
- basic.append(apo)
- else:
- toa = RadioSetting("settings.apo", "Time out alert timer",
- RadioSettingValueList(
- LIST_OFF1TO10,
- LIST_OFF1TO10[_mem.settings.apo]))
- basic.append(toa)
+ if self.MODEL == "KT-8R":
+ save = RadioSetting("settings.save", "Battery Save",
+ RadioSettingValueBoolean(
+ _mem.settings.save))
+ basic.append(save)
+
+ model_list = ["KT-8R", "KT-WP12", "WP-9900"]
+ if self.MODEL not in model_list:
+ if self.VENDOR == "BTECH" or self.COLOR_LCD:
+ apo = RadioSetting("settings.apo", "Auto power off timer",
+ RadioSettingValueList(
+ LIST_APO,
+ LIST_APO[_mem.settings.apo]))
+ basic.append(apo)
+ else:
+ toa = RadioSetting("settings.apo", "Time out alert timer",
+ RadioSettingValueList(
+ LIST_OFF1TO10,
+ LIST_OFF1TO10[_mem.settings.apo]))
+ basic.append(toa)
abr = RadioSetting("settings.abr", "Backlight timer",
RadioSettingValueList(
@@ -1105,11 +1151,33 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
RadioSettingValueBoolean(_mem.settings.beep))
basic.append(beep)
- dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
- RadioSettingValueList(
- LIST_DTMFST,
- LIST_DTMFST[_mem.settings.dtmfst]))
- basic.append(dtmfst)
+ if self.MODEL == "GMRS-20V2":
+ rs = RadioSettingValueInteger(0, 58, _mem.settings.volume)
+ volume = RadioSetting("settings.volume", "Volume", rs)
+ basic.append(volume)
+
+ if self.MODEL == "KT-WP12" or self.MODEL == "WP-9900":
+ rs = RadioSettingValueInteger(1, 51, _mem.settings.volume + 1)
+ volume = RadioSetting("settings.volume", "Volume", rs)
+ basic.append(volume)
+
+ if self.MODEL == "KT-8R":
+ dsub = RadioSetting("settings.dsub", "CTCSS/DCS code display",
+ RadioSettingValueBoolean(
+ _mem.settings.dsub))
+ basic.append(dsub)
+
+ if self.MODEL == "KT-8R" or self.COLOR_LCD4:
+ dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
+ RadioSettingValueBoolean(
+ _mem.settings.dtmfst))
+ basic.append(dtmfst)
+ else:
+ dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
+ RadioSettingValueList(
+ LIST_DTMFST,
+ LIST_DTMFST[_mem.settings.dtmfst]))
+ basic.append(dtmfst)
if not self.COLOR_LCD:
prisc = RadioSetting("settings.prisc", "Priority scan",
@@ -1133,7 +1201,8 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.settings.pttlt))
basic.append(pttlt)
- if self.VENDOR == "BTECH" and self.COLOR_LCD:
+ if self.VENDOR == "BTECH" and self.COLOR_LCD and not \
+ self.MODEL == "GMRS-20V2":
emctp = RadioSetting("settings.emctp", "Alarm mode",
RadioSettingValueList(
LIST_EMCTPX,
@@ -1185,34 +1254,64 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_MDF[_mem.settings.ccmdf]))
basic.append(ccmdf)
- cdmdf = RadioSetting("settings.cdmdf", "Display mode D",
+ if not self.COLOR_LCD4:
+ cdmdf = RadioSetting("settings.cdmdf", "Display mode D",
+ RadioSettingValueList(
+ LIST_MDF,
+ LIST_MDF[_mem.settings.cdmdf]))
+ basic.append(cdmdf)
+
+ langua = RadioSetting("settings.langua", "Language",
+ RadioSettingValueList(
+ LIST_LANGUA,
+ LIST_LANGUA[_mem.settings.langua]))
+ basic.append(langua)
+
+ if self.MODEL == "KT-8R":
+ voice = RadioSetting("settings.voice", "Voice prompt",
RadioSettingValueList(
- LIST_MDF,
- LIST_MDF[_mem.settings.cdmdf]))
- basic.append(cdmdf)
+ LIST_VOICE,
+ LIST_VOICE[_mem.settings.voice]))
+ basic.append(voice)
- langua = RadioSetting("settings.langua", "Language",
- RadioSettingValueList(
- LIST_LANGUA,
- LIST_LANGUA[_mem.settings.langua]))
- basic.append(langua)
+ if self.MODEL == "KT-8R" or self.COLOR_LCD4:
+ vox = RadioSetting("settings.vox", "VOX",
+ RadioSettingValueList(
+ LIST_VOX,
+ LIST_VOX[_mem.settings.vox]))
+ basic.append(vox)
+
+ voxt = RadioSetting("settings.voxt", "VOX delay time",
+ RadioSettingValueList(
+ LIST_VOXT,
+ LIST_VOXT[_mem.settings.voxt]))
+ basic.append(voxt)
if self.VENDOR == "BTECH":
if self.COLOR_LCD:
- sync = RadioSetting("settings.sync", "Channel display sync",
- RadioSettingValueList(
- LIST_SYNC,
- LIST_SYNC[_mem.settings.sync]))
- basic.append(sync)
+ if self.MODEL == "GMRS-20V2":
+ val = RadioSettingValueList(LIST_SYNCV2,
+ LIST_SYNCV2[
+ _mem.settings.sync])
+ sync = RadioSetting("settings.sync",
+ "Channel display sync", val)
+ basic.append(sync)
+ else:
+ val = RadioSettingValueList(LIST_SYNC,
+ LIST_SYNC[_mem.settings.sync])
+ sync = RadioSetting("settings.sync",
+ "Channel display sync", val)
+ basic.append(sync)
else:
sync = RadioSetting("settings.sync", "A/B channel sync",
RadioSettingValueBoolean(
_mem.settings.sync))
basic.append(sync)
- else:
- autolk = RadioSetting("settings.sync", "Auto keylock",
+
+ if self.COLOR_LCD4:
+ autolk = RadioSetting("settings.autolock", "Auto keylock",
RadioSettingValueBoolean(
- _mem.settings.sync))
+ _mem.settings.autolock))
basic.append(autolk)
if not self.COLOR_LCD:
@@ -1222,171 +1321,265 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_PONMSG[_mem.settings.ponmsg]))
basic.append(ponmsg)
- if self.COLOR_LCD and not self.COLOR_LCD2:
+ if self.COLOR_LCD and not (self.COLOR_LCD2 or self.COLOR_LCD3 or
+ self.COLOR_LCD4):
mainfc = RadioSetting("settings.mainfc",
"Main LCD foreground color",
RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.mainfc]))
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.mainfc]))
basic.append(mainfc)
- mainbc = RadioSetting("settings.mainbc",
- "Main LCD background color",
- RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.mainbc]))
- basic.append(mainbc)
+ if not self.COLOR_LCD4:
+ mainbc = RadioSetting("settings.mainbc",
+ "Main LCD background color",
+ RadioSettingValueList(
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.mainbc]))
+ basic.append(mainbc)
menufc = RadioSetting("settings.menufc", "Menu foreground color",
RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.menufc]))
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.menufc]))
basic.append(menufc)
- menubc = RadioSetting("settings.menubc", "Menu background color",
- RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.menubc]))
- basic.append(menubc)
+ if not self.COLOR_LCD4:
+ val = RadioSettingValueList(LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.menubc])
+ menubc = RadioSetting("settings.menubc",
+ "Menu background color", val)
+ basic.append(menubc)
stafc = RadioSetting("settings.stafc",
"Top status foreground color",
RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.stafc]))
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.stafc]))
basic.append(stafc)
- stabc = RadioSetting("settings.stabc",
- "Top status background color",
- RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.stabc]))
- basic.append(stabc)
+ if not self.COLOR_LCD4:
+ stabc = RadioSetting("settings.stabc",
+ "Top status background color",
+ RadioSettingValueList(
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.stabc]))
+ basic.append(stabc)
sigfc = RadioSetting("settings.sigfc",
"Bottom status foreground color",
RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.sigfc]))
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.sigfc]))
basic.append(sigfc)
- sigbc = RadioSetting("settings.sigbc",
- "Bottom status background color",
- RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.sigbc]))
- basic.append(sigbc)
+ if not self.COLOR_LCD4:
+ sigbc = RadioSetting("settings.sigbc",
+ "Bottom status background color",
+ RadioSettingValueList(
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.sigbc]))
+ basic.append(sigbc)
rxfc = RadioSetting("settings.rxfc", "Receiving character color",
RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.rxfc]))
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.rxfc]))
basic.append(rxfc)
txfc = RadioSetting("settings.txfc",
"Transmitting character color",
RadioSettingValueList(
- LIST_COLOR8,
- LIST_COLOR8[_mem.settings.txfc]))
+ LIST_COLOR9,
+ LIST_COLOR9[_mem.settings.txfc]))
basic.append(txfc)
- txdisp = RadioSetting("settings.txdisp",
- "Transmitting status display",
- RadioSettingValueList(
- LIST_TXDISP,
- LIST_TXDISP[_mem.settings.txdisp]))
- basic.append(txdisp)
- elif self.COLOR_LCD2:
+ if not self.COLOR_LCD4:
+ txdisp = RadioSetting("settings.txdisp",
+ "Transmitting status display",
+ RadioSettingValueList(
+ LIST_TXDISP,
+ LIST_TXDISP[_mem.settings.txdisp]))
+ basic.append(txdisp)
+
+ elif self.COLOR_LCD2 or self.COLOR_LCD3:
stfc = RadioSetting("settings.stfc",
"ST-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.stfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.stfc]))
basic.append(stfc)
mffc = RadioSetting("settings.mffc",
"MF-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.mffc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.mffc]))
basic.append(mffc)
sfafc = RadioSetting("settings.sfafc",
"SFA-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.sfafc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.sfafc]))
basic.append(sfafc)
sfbfc = RadioSetting("settings.sfbfc",
"SFB-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.sfbfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.sfbfc]))
basic.append(sfbfc)
sfcfc = RadioSetting("settings.sfcfc",
"SFC-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.sfcfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.sfcfc]))
basic.append(sfcfc)
sfdfc = RadioSetting("settings.sfdfc",
"SFD-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.sfdfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.sfdfc]))
basic.append(sfdfc)
subfc = RadioSetting("settings.subfc",
"SUB-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.subfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.subfc]))
basic.append(subfc)
fmfc = RadioSetting("settings.fmfc",
"FM-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.fmfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.fmfc]))
basic.append(fmfc)
sigfc = RadioSetting("settings.sigfc",
"SIG-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.sigfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.sigfc]))
basic.append(sigfc)
- modfc = RadioSetting("settings.modfc",
- "MOD-FC",
- RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.modfc]))
- basic.append(modfc)
+ if not self.MODEL == "KT-8R":
+ modfc = RadioSetting("settings.modfc",
+ "MOD-FC",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.modfc]))
+ basic.append(modfc)
menufc = RadioSetting("settings.menufc",
"MENUFC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.menufc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.menufc]))
basic.append(menufc)
txfc = RadioSetting("settings.txfc",
"TX-FC",
RadioSettingValueList(
- LIST_COLOR7,
- LIST_COLOR7[_mem.settings.txfc]))
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.txfc]))
basic.append(txfc)
- txdisp = RadioSetting("settings.txdisp",
- "Transmitting status display",
+ if self.MODEL == "KT-8R":
+ rxfc = RadioSetting("settings.rxfc",
+ "RX-FC",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.rxfc]))
+ basic.append(rxfc)
+
+ if not self.MODEL == "KT-8R":
+ txdisp = RadioSetting("settings.txdisp",
+ "Transmitting status display",
+ RadioSettingValueList(
+ LIST_TXDISP,
+ LIST_TXDISP[_mem.settings.txdisp]))
+ basic.append(txdisp)
+ elif self.COLOR_LCD4:
+ asfc = RadioSetting("settings.asfc",
+ "Above Stat fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.asfc]))
+ basic.append(asfc)
+
+ mainfc = RadioSetting("settings.mainfc",
+ "Main fore color",
RadioSettingValueList(
- LIST_TXDISP,
- LIST_TXDISP[_mem.settings.txdisp]))
- basic.append(txdisp)
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.mainfc]))
+ basic.append(mainfc)
+
+ a_fc = RadioSetting("settings.a_fc",
+ "A - fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.a_fc]))
+ basic.append(a_fc)
+
+ b_fc = RadioSetting("settings.b_fc",
+ "B - fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.b_fc]))
+ basic.append(b_fc)
+
+ c_fc = RadioSetting("settings.c_fc",
+ "C - fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.c_fc]))
+ basic.append(c_fc)
+
+ subfc = RadioSetting("settings.subfc",
+ "Sub fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.subfc]))
+ basic.append(subfc)
+
+ battfc = RadioSetting("settings.battfc",
+ "Battery fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.battfc]))
+ basic.append(battfc)
+
+ sigfc = RadioSetting("settings.sigfc",
+ "Signal fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.sigfc]))
+ basic.append(sigfc)
+
+ menufc = RadioSetting("settings.menufc",
+ "Menu fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.menufc]))
+ basic.append(menufc)
+
+ txfc = RadioSetting("settings.txfc",
+ "TX fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.txfc]))
+ basic.append(txfc)
+
+ rxfc = RadioSetting("settings.rxfc",
+ "RX fore color",
+ RadioSettingValueList(
+ LIST_COLOR8,
+ LIST_COLOR8[_mem.settings.rxfc]))
+ basic.append(rxfc)
else:
wtled = RadioSetting("settings.wtled", "Standby backlight Color",
RadioSettingValueList(
@@ -1418,7 +1611,21 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_REPS[_mem.settings.reps]))
basic.append(reps)
- if not self.MODEL == "GMRS-50X1":
+ if self.COLOR_LCD4:
+ dsub = RadioSetting("settings.dsub", "Subtone display",
+ RadioSettingValueBoolean(
+ _mem.settings.dsub))
+ basic.append(dsub)
+
+ if self.MODEL == "GMRS-20V2":
+ repsw = RadioSetting("settings.repsw", "Repeater SW",
+ RadioSettingValueList(
+ LIST_REPSW,
+ LIST_REPSW[_mem.settings.repsw]))
+ basic.append(repsw)
+
+ model_list = ["GMRS-50X1", "KT-8R", "KT-WP12", "WP-9900"]
+ if self.MODEL not in model_list:
repm = RadioSetting("settings.repm", "Relay condition",
RadioSettingValueList(
LIST_REPM,
@@ -1443,17 +1650,36 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
RadioSettingValueBoolean(_mem.settings.ste))
basic.append(ste)
- rpste = RadioSetting("settings.rpste", "Repeater STE",
- RadioSettingValueList(
- LIST_OFF1TO9,
- LIST_OFF1TO9[_mem.settings.rpste]))
- basic.append(rpste)
+ if self.COLOR_LCD4:
+ rpste = RadioSetting("settings.rpste", "Repeater STE",
+ RadioSettingValueList(
+ LIST_OFF1TO10,
+ LIST_OFF1TO10[_mem.settings.rpste]))
+ basic.append(rpste)
+ else:
+ rpste = RadioSetting("settings.rpste", "Repeater STE",
+ RadioSettingValueList(
+ LIST_OFF1TO9,
+ LIST_OFF1TO9[_mem.settings.rpste]))
+ basic.append(rpste)
- rptdl = RadioSetting("settings.rptdl", "Repeater STE delay",
- RadioSettingValueList(
- LIST_RPTDL,
- LIST_RPTDL[_mem.settings.rptdl]))
- basic.append(rptdl)
+ if self.COLOR_LCD4:
+ rptdl = RadioSetting("settings.rptdl", "Repeater STE delay",
+ RadioSettingValueList(
+ LIST_OFF1TO60,
+ LIST_OFF1TO60[_mem.settings.rptdl]))
+ basic.append(rptdl)
+ else:
+ rptdl = RadioSetting("settings.rptdl", "Repeater STE delay",
+ RadioSettingValueList(
+ LIST_RPTDL,
+ LIST_RPTDL[_mem.settings.rptdl]))
+ basic.append(rptdl)
+
+ if self.MODEL == "DB25-G":
+ mgain = RadioSetting("settings.mgain", "Auto power-on",
+ RadioSettingValueBoolean(_mem.settings.mgain))
+ basic.append(mgain)
if str(_mem.fingerprint.fp) in BTECH3:
mgain = RadioSetting("settings.mgain", "Mic gain",
@@ -1469,7 +1695,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if self.VENDOR == "BTECH" and self.COLOR_LCD:
mgain = RadioSetting("settings.mgain", "Mic gain",
- RadioSettingValueInteger(0, 120,
+ RadioSettingValueInteger(0, 127,
_mem.settings.mgain))
basic.append(mgain)
@@ -1485,6 +1711,15 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_SCMODE[_mem.settings.scmode]))
basic.append(scmode)
+ if self.MODEL == "KT-8R" or self.MODEL == "UV-25X2" \
+ or self.MODEL == "UV-25X4" or self.MODEL == "UV-50X2" \
+ or self.MODEL == "GMRS-50X1" or self.MODEL == "GMRS-20V2":
+ tmrtx = RadioSetting("settings.tmrtx", "TX in multi-standby",
+ RadioSettingValueList(
+ LIST_TMRTX,
+ LIST_TMRTX[_mem.settings.tmrtx]))
+ basic.append(tmrtx)
+
# Advanced
def _filter(name):
filtered = ""
@@ -1495,7 +1730,8 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
filtered += " "
return filtered
- if self.COLOR_LCD and not self.COLOR_LCD2:
+ if self.COLOR_LCD and not (self.COLOR_LCD2 or self.COLOR_LCD3 or
+ self.COLOR_LCD4):
_msg = self._memobj.poweron_msg
line1 = RadioSetting("poweron_msg.line1",
"Power-on message line 1",
@@ -1536,7 +1772,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
RadioSettingValueString(0, 8, _filter(
_msg.line8)))
advanced.append(line8)
- elif self.COLOR_LCD2:
+ elif self.COLOR_LCD2 or self.COLOR_LCD3 or self.COLOR_LCD4:
_msg = self._memobj.static_msg
line = RadioSetting("static_msg.line", "Static message",
RadioSettingValueString(0, 16, _filter(
@@ -1644,7 +1880,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
other.append(fp)
# Work
- if self.COLOR_LCD:
+ if self.COLOR_LCD4:
+ dispab = RadioSetting("settings2.dispab", "Display",
+ RadioSettingValueList(
+ LIST_ABC,
+ LIST_ABC[_mem.settings2.dispab]))
+ work.append(dispab)
+ elif self.COLOR_LCD:
dispab = RadioSetting("settings2.dispab", "Display",
RadioSettingValueList(
LIST_ABCD,
@@ -1676,11 +1918,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_VFOMR[_mem.settings2.vfomrc]))
work.append(vfomrc)
- vfomrd = RadioSetting("settings2.vfomrd", "VFO/MR D mode",
- RadioSettingValueList(
- LIST_VFOMR,
- LIST_VFOMR[_mem.settings2.vfomrd]))
- work.append(vfomrd)
+ if not self.COLOR_LCD4:
+ vfomrd = RadioSetting("settings2.vfomrd", "VFO/MR D mode",
+ RadioSettingValueList(
+ LIST_VFOMR,
+ LIST_VFOMR[_mem.settings2.vfomrd]))
+ work.append(vfomrd)
else:
vfomr = RadioSetting("settings2.vfomr", "VFO/MR mode",
RadioSettingValueList(
@@ -1709,10 +1952,11 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
0, self._upper, _mem.settings2.mrchc))
work.append(mrchc)
- mrchd = RadioSetting("settings2.mrchd", "MR D channel",
- RadioSettingValueInteger(
- 0, self._upper, _mem.settings2.mrchd))
- work.append(mrchd)
+ if not self.COLOR_LCD4:
+ mrchd = RadioSetting("settings2.mrchd", "MR D channel",
+ RadioSettingValueInteger(
+ 0, self._upper, _mem.settings2.mrchd))
+ work.append(mrchd)
def convert_bytes_to_freq(bytes):
real_freq = 0
@@ -1791,12 +2035,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
vfocfreq.set_apply_callback(apply_freq, _mem.vfo.c)
work.append(vfocfreq)
- val1d = RadioSettingValueString(0, 10, convert_bytes_to_freq(
- _mem.vfo.d.freq))
- val1d.set_validate_callback(my_validate)
- vfodfreq = RadioSetting("vfo.d.freq", "VFO D frequency", val1d)
- vfodfreq.set_apply_callback(apply_freq, _mem.vfo.d)
- work.append(vfodfreq)
+ if not self.COLOR_LCD4:
+ val1d = RadioSettingValueString(0, 10, convert_bytes_to_freq(
+ _mem.vfo.d.freq))
+ val1d.set_validate_callback(my_validate)
+ vfodfreq = RadioSetting("vfo.d.freq", "VFO D frequency", val1d)
+ vfodfreq.set_apply_callback(apply_freq, _mem.vfo.d)
+ work.append(vfodfreq)
if not self.MODEL == "GMRS-50X1":
vfoashiftd = RadioSetting("vfo.a.shiftd", "VFO A shift",
@@ -1818,11 +2063,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_SHIFT[_mem.vfo.c.shiftd]))
work.append(vfocshiftd)
- vfodshiftd = RadioSetting("vfo.d.shiftd", "VFO D shift",
- RadioSettingValueList(
- LIST_SHIFT,
- LIST_SHIFT[_mem.vfo.d.shiftd]))
- work.append(vfodshiftd)
+ if not self.COLOR_LCD4:
+ val = RadioSettingValueList(LIST_SHIFT,
+ LIST_SHIFT[_mem.vfo.d.shiftd])
+ vfodshiftd = RadioSetting("vfo.d.shiftd", "VFO D shift",
+ val)
+ work.append(vfodshiftd)
def convert_bytes_to_offset(bytes):
real_offset = 0
@@ -1862,13 +2108,15 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
vfocoffset.set_apply_callback(apply_offset, _mem.vfo.c)
work.append(vfocoffset)
- val1d = RadioSettingValueString(0, 10, convert_bytes_to_offset(
- _mem.vfo.d.offset))
- vfodoffset = RadioSetting("vfo.d.offset",
- "VFO D offset (0.000-999.999)",
- val1d)
- vfodoffset.set_apply_callback(apply_offset, _mem.vfo.d)
- work.append(vfodoffset)
+ if not self.COLOR_LCD4:
+ val1d = RadioSettingValueString(0, 10,
+ convert_bytes_to_offset(
+ _mem.vfo.d.offset))
+ vfodoffset = RadioSetting("vfo.d.offset",
+ "VFO D offset (0.000-999.999)",
+ val1d)
+ vfodoffset.set_apply_callback(apply_offset, _mem.vfo.d)
+ work.append(vfodoffset)
else:
val1a = RadioSettingValueString(0, 10, convert_bytes_to_offset(
_mem.vfo.a.offset))
@@ -1904,11 +2152,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_TXP[_mem.vfo.c.power]))
work.append(vfoctxp)
- vfodtxp = RadioSetting("vfo.d.power", "VFO D power",
- RadioSettingValueList(
- LIST_TXP,
- LIST_TXP[_mem.vfo.d.power]))
- work.append(vfodtxp)
+ if not self.COLOR_LCD4:
+ vfodtxp = RadioSetting("vfo.d.power", "VFO D power",
+ RadioSettingValueList(
+ LIST_TXP,
+ LIST_TXP[_mem.vfo.d.power]))
+ work.append(vfodtxp)
if not self.MODEL == "GMRS-50X1":
vfoawide = RadioSetting("vfo.a.wide", "VFO A bandwidth",
@@ -1930,11 +2179,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_WIDE[_mem.vfo.c.wide]))
work.append(vfocwide)
- vfodwide = RadioSetting("vfo.d.wide", "VFO D bandwidth",
- RadioSettingValueList(
- LIST_WIDE,
- LIST_WIDE[_mem.vfo.d.wide]))
- work.append(vfodwide)
+ if not self.COLOR_LCD4:
+ vfodwide = RadioSetting("vfo.d.wide", "VFO D bandwidth",
+ RadioSettingValueList(
+ LIST_WIDE,
+ LIST_WIDE[_mem.vfo.d.wide]))
+ work.append(vfodwide)
vfoastep = RadioSetting("vfo.a.step", "VFO A step",
RadioSettingValueList(
@@ -1955,11 +2205,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
LIST_STEP[_mem.vfo.c.step]))
work.append(vfocstep)
- vfodstep = RadioSetting("vfo.d.step", "VFO D step",
- RadioSettingValueList(
- LIST_STEP,
- LIST_STEP[_mem.vfo.d.step]))
- work.append(vfodstep)
+ if not self.COLOR_LCD4:
+ vfodstep = RadioSetting("vfo.d.step", "VFO D step",
+ RadioSettingValueList(
+ LIST_STEP,
+ LIST_STEP[_mem.vfo.d.step]))
+ work.append(vfodstep)
vfoaoptsig = RadioSetting("vfo.a.optsig", "VFO A optional signal",
RadioSettingValueList(
@@ -1980,11 +2231,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
OPTSIG_LIST[_mem.vfo.c.optsig]))
work.append(vfocoptsig)
- vfodoptsig = RadioSetting("vfo.d.optsig", "VFO D optional signal",
- RadioSettingValueList(
- OPTSIG_LIST,
- OPTSIG_LIST[_mem.vfo.d.optsig]))
- work.append(vfodoptsig)
+ if not self.COLOR_LCD4:
+ val = RadioSettingValueList(OPTSIG_LIST,
+ OPTSIG_LIST[_mem.vfo.d.optsig])
+ vfodoptsig = RadioSetting("vfo.d.optsig",
+ "VFO D optional signal", val)
+ work.append(vfodoptsig)
vfoaspmute = RadioSetting("vfo.a.spmute", "VFO A speaker mute",
RadioSettingValueList(
@@ -2005,11 +2257,12 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
SPMUTE_LIST[_mem.vfo.c.spmute]))
work.append(vfocspmute)
- vfodspmute = RadioSetting("vfo.d.spmute", "VFO D speaker mute",
- RadioSettingValueList(
- SPMUTE_LIST,
- SPMUTE_LIST[_mem.vfo.d.spmute]))
- work.append(vfodspmute)
+ if not self.COLOR_LCD4:
+ vfodspmute = RadioSetting("vfo.d.spmute", "VFO D speaker mute",
+ RadioSettingValueList(
+ SPMUTE_LIST,
+ SPMUTE_LIST[_mem.vfo.d.spmute]))
+ work.append(vfodspmute)
if not self.COLOR_LCD or \
(self.COLOR_LCD and not self.VENDOR == "BTECH"):
@@ -2054,11 +2307,13 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
PTTIDCODE_LIST[_mem.vfo.c.scode]))
work.append(vfocscode)
- vfodscode = RadioSetting("vfo.d.scode", "VFO D PTT-ID",
- RadioSettingValueList(
- PTTIDCODE_LIST,
- PTTIDCODE_LIST[_mem.vfo.d.scode]))
- work.append(vfodscode)
+ if not self.COLOR_LCD4:
+ val = RadioSettingValueList(PTTIDCODE_LIST,
+ PTTIDCODE_LIST[
+ _mem.vfo.d.scode])
+ vfodscode = RadioSetting("vfo.d.scode", "VFO D PTT-ID",
+ val)
+ work.append(vfodscode)
if not self.MODEL == "GMRS-50X1":
pttid = RadioSetting("settings.pttid", "PTT ID",
@@ -2136,20 +2391,28 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.rxdisable))
dtmf_enc_settings.append(rxdisable)
+ if _mem.dtmf_settings.dtmfspeed_on > 0x0F:
+ val = 0x03
+ else:
+ val = _mem.dtmf_settings.dtmfspeed_on
dtmfspeed_on = RadioSetting(
"dtmf_settings.dtmfspeed_on",
"DTMF Speed (On Time)",
RadioSettingValueList(LIST_DTMF_SPEED,
LIST_DTMF_SPEED[
- _mem.dtmf_settings.dtmfspeed_on]))
+ val]))
dtmf_enc_settings.append(dtmfspeed_on)
+ if _mem.dtmf_settings.dtmfspeed_off > 0x0F:
+ val = 0x03
+ else:
+ val = _mem.dtmf_settings.dtmfspeed_off
dtmfspeed_off = RadioSetting(
"dtmf_settings.dtmfspeed_off",
"DTMF Speed (Off Time)",
RadioSettingValueList(LIST_DTMF_SPEED,
LIST_DTMF_SPEED[
- _mem.dtmf_settings.dtmfspeed_off]))
+ val]))
dtmf_enc_settings.append(dtmfspeed_off)
def memory2string(dmtf_mem):
@@ -2329,7 +2592,11 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
val = LIST_DTMF_SPECIAL_VALUES[index]
obj.set_value(val)
- idx = LIST_DTMF_SPECIAL_VALUES.index(_mem.dtmf_settings.groupcode)
+ if _mem.dtmf_settings.groupcode not in LIST_DTMF_SPECIAL_VALUES:
+ val = 0x0B
+ else:
+ val = _mem.dtmf_settings.groupcode
+ idx = LIST_DTMF_SPECIAL_VALUES.index(val)
line = RadioSetting(
"dtmf_settings.groupcode",
"Group Code",
@@ -2339,7 +2606,11 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.groupcode)
dtmf_dec_settings.append(line)
- idx = LIST_DTMF_SPECIAL_VALUES.index(_mem.dtmf_settings.spacecode)
+ if _mem.dtmf_settings.spacecode not in LIST_DTMF_SPECIAL_VALUES:
+ val = 0x0C
+ else:
+ val = _mem.dtmf_settings.spacecode
+ idx = LIST_DTMF_SPECIAL_VALUES.index(val)
line = RadioSetting(
"dtmf_settings.spacecode",
"Space Code",
@@ -2350,12 +2621,16 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
dtmf_dec_settings.append(line)
if self.COLOR_LCD:
+ if _mem.dtmf_settings.resettime > 0x63:
+ val = 0x4F
+ else:
+ val = _mem.dtmf_settings.resettime
line = RadioSetting(
"dtmf_settings.resettime",
"Reset time",
RadioSettingValueList(LIST_5TONE_RESET_COLOR,
LIST_5TONE_RESET_COLOR[
- _mem.dtmf_settings.resettime]))
+ val]))
dtmf_dec_settings.append(line)
else:
line = RadioSetting(
@@ -2366,12 +2641,16 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
_mem.dtmf_settings.resettime]))
dtmf_dec_settings.append(line)
+ if _mem.dtmf_settings.delayproctime > 0x27:
+ val = 0x04
+ else:
+ val = _mem.dtmf_settings.delayproctime
line = RadioSetting(
"dtmf_settings.delayproctime",
"Delay processing time",
RadioSettingValueList(LIST_DTMF_DELAY,
LIST_DTMF_DELAY[
- _mem.dtmf_settings.delayproctime]))
+ val]))
dtmf_dec_settings.append(line)
# 5 Tone Settings
@@ -2607,7 +2886,8 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
"5 Tone Delay Frame 1", list)
group_5tone.append(line)
else:
- LOG.debug("Invalid value for 5tone delay (frame1) ! Disabling.")
+ LOG.debug(
+ "Invalid value for 5tone delay (frame1) ! Disabling.")
_5tone_delay2 = _mem._5tone_settings._5tone_delay2
if _5tone_delay2 == 255:
@@ -2642,7 +2922,7 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
ext_length = _mem._5tone_settings._5tone_first_digit_ext_length
if ext_length == 255:
ext_length = 0
- LOG.debug("1st Tone ext lenght unconfigured! Resetting to 0")
+ LOG.debug("1st Tone ext length unconfigured! Resetting to 0")
if ext_length <= len(LIST_5TONE_DELAY):
list = RadioSettingValueList(
@@ -2685,11 +2965,11 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
duration_1st_tone = 60
if duration_1st_tone <= len(LIST_5TONE_DELAY):
+ val = RadioSettingValueList(LIST_5TONE_DELAY,
+ LIST_5TONE_DELAY[
+ duration_1st_tone])
line = RadioSetting("_2tone.duration_1st_tone",
- "Duration 1st Tone",
- RadioSettingValueList(LIST_5TONE_DELAY,
- LIST_5TONE_DELAY[
- duration_1st_tone]))
+ "Duration 1st Tone", val)
encode_2tone.append(line)
duration_2nd_tone = self._memobj._2tone.duration_2nd_tone
@@ -2699,11 +2979,11 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
duration_2nd_tone = 60
if duration_2nd_tone <= len(LIST_5TONE_DELAY):
+ val = RadioSettingValueList(LIST_5TONE_DELAY,
+ LIST_5TONE_DELAY[
+ duration_2nd_tone])
line = RadioSetting("_2tone.duration_2nd_tone",
- "Duration 2nd Tone",
- RadioSettingValueList(LIST_5TONE_DELAY,
- LIST_5TONE_DELAY[
- duration_2nd_tone]))
+ "Duration 2nd Tone", val)
encode_2tone.append(line)
duration_gap = self._memobj._2tone.duration_gap
@@ -2824,30 +3104,35 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
val = dec.response
if val == 255:
- LOG.debug("Response for Code " + str(i) + " Dec " +
- str(j) + " is not yet configured. Setting to 0.")
+ LOG.debug("Response for Code " +
+ str(i) + " Dec " + str(j) +
+ " is not yet configured. Setting to 0.")
val = 0
if val <= len(LIST_2TONE_RESPONSE):
line = RadioSetting(
- "_2tone_dec_settings_" + str(i) + "_resp_" + str(j),
+ "_2tone_dec_settings_" +
+ str(i) + "_resp_" + str(j),
"Response " + str(j), RadioSettingValueList
(LIST_2TONE_RESPONSE,
LIST_2TONE_RESPONSE[val]))
line.set_apply_callback(apply_list_value, dec.response)
_2tone_dec_code.append(line)
else:
- LOG.debug("Invalid value for 2tone response! Disabling.")
+ LOG.debug(
+ "Invalid value for 2tone response! Disabling.")
val = dec.alert
if val == 255:
- LOG.debug("Alert for Code " + str(i) + " Dec " + str(j) +
+ LOG.debug("Alert for Code " +
+ str(i) + " Dec " + str(j) +
" is not yet configured. Setting to 0.")
val = 0
if val <= len(PTTIDCODE_LIST):
line = RadioSetting(
- "_2tone_dec_settings_" + str(i) + "_alert_" + str(j),
+ "_2tone_dec_settings_" +
+ str(i) + "_alert_" + str(j),
"Alert " + str(j), RadioSettingValueList
(PTTIDCODE_LIST,
PTTIDCODE_LIST[val]))
@@ -2873,7 +3158,8 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
". Disabling 2Tone Decode Freqs!")
break
val = RadioSettingValueInteger(0, 65535, tmp)
- frq = RadioSetting("2tone_dec_" + str(i) + "_freq" + str(char),
+ frq = RadioSetting("2tone_dec_" + str(i) +
+ "_freq" + str(char),
("Decode Frequency " + str(char)), val)
val.set_validate_callback(_2tone_validate)
frq.set_apply_callback(apply_2tone_freq_pair, freq)
@@ -2913,6 +3199,10 @@ class BTechMobileCommon(chirp_common.CloneModeRadio,
if element.has_apply_callback():
LOG.debug("Using apply callback")
element.run_apply_callback()
+ elif setting == "volume" and self.MODEL == "KT-WP12":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "volume" and self.MODEL == "WP-9900":
+ setattr(obj, setting, int(element.value) - 1)
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
@@ -2948,8 +3238,8 @@ struct {
u8 unknown0:4,
scode:4;
u8 unknown1:2,
- spmute:1,
- unknown2:3,
+ spmute:2,
+ unknown2:2,
optsig:2;
u8 unknown3:3,
scramble:1,
@@ -3315,7 +3605,6 @@ class UV2501_220(BTech):
MODEL = "UV-2501+220"
BANDS = 3
_magic = MSTRING_220
- _id2 = [UV2501_220pp_id, ]
_fileid = [UV2501_220G3_fp,
UV2501_220G2_fp,
UV2501_220_fp,
@@ -3362,6 +3651,11 @@ class KTUV980(BTech):
# Waccom Mini8900, maybe an early version?
+class OTGRadioV1(chirp_common.Alias):
+ VENDOR = 'OTGSTUFF'
+ MODEL = 'OTG Radio v1'
+
+
@directory.register
class KT9800(BTech):
"""QYT KT8900"""
@@ -3375,8 +3669,9 @@ class KT9800(BTech):
KT8900_fp2,
KT8900_fp3,
KT8900_fp4,
- KT8900_fp5]
- _id2 = [KT8900_id, ]
+ KT8900_fp5,
+ KT8900_fp6,
+ KT8900_fp7]
# Clones
ALIASES = [JT6188Mini, SSGT890, ZastoneMP300]
@@ -3395,8 +3690,8 @@ class KT9800R(BTech):
KT8900R_fp1,
KT8900R_fp2,
KT8900R_fp3,
- KT8900R_fp4]
- _id2 = [KT8900R_id, KT8900R_id2]
+ KT8900R_fp4,
+ KT8900R_fp5]
@directory.register
@@ -3423,13 +3718,13 @@ struct {
u8 unknown0:4,
scode:4;
u8 unknown1:2,
- spmute:1,
- unknown2:3,
+ spmute:2,
+ unknown2:2,
optsig:2;
u8 unknown3:3,
scramble:1,
- unknown4:3,
- power:1;
+ unknown4:2,
+ power:2;
u8 unknown5:1,
wide:1,
unknown6:2,
@@ -3443,7 +3738,8 @@ struct {
u8 tmr;
u8 unknown1;
u8 sql;
- u8 unknown2[2];
+ u8 unknown2;
+ u8 mgain2;
u8 tot;
u8 apo;
u8 unknown3;
@@ -3489,9 +3785,10 @@ struct {
u8 rpste;
u8 rptdl;
u8 dtmfg;
- u8 mgain;
+ u8 mgain; // used by db25-g for ponyey
u8 skiptx;
u8 scmode;
+ u8 tmrtx;
} settings;
#seekto 0x0E80;
@@ -3821,7 +4118,8 @@ class KT7900D(BTechColor):
_uhf_range = (400000000, 481000000)
_350_range = (350000000, 371000000)
_magic = MSTRING_KT8900D
- _fileid = [KT7900D_fp, KT7900D_fp1, KT7900D_fp2, QB25_fp, ]
+ _fileid = [KT7900D_fp, KT7900D_fp1, KT7900D_fp2, KT7900D_fp3, KT7900D_fp4,
+ KT7900D_fp5, KT7900D_fp6, KT7900D_fp7, KT7900D_fp8, QB25_fp, ]
# Clones
ALIASES = [SKT8900D, QB25, ]
@@ -3836,7 +4134,65 @@ class KT8900D(BTechColor):
_vhf_range = (136000000, 175000000)
_uhf_range = (400000000, 481000000)
_magic = MSTRING_KT8900D
- _fileid = [KT8900D_fp, KT8900D_fp1]
+ _fileid = [KT8900D_fp3, KT8900D_fp2, KT8900D_fp1, KT8900D_fp]
+
+ # Clones
+ ALIASES = [OTGRadioV1]
+
+
+@directory.register
+class KT5800(BTechColor):
+ """QYT KT5800"""
+ VENDOR = "QYT"
+ MODEL = "KT5800"
+ BANDS = 2
+ LIST_TMR = LIST_TMR15
+ _vhf_range = (136000000, 175000000)
+ _uhf_range = (400000000, 481000000)
+ _magic = MSTRING_KT8900D
+ _fileid = [KT5800_fp, ]
+
+
+@directory.register
+class KT980PLUS(BTechColor):
+ """QYT KT980PLUS"""
+ VENDOR = "QYT"
+ MODEL = "KT980PLUS"
+ BANDS = 2
+ LIST_TMR = LIST_TMR15
+ _vhf_range = (136000000, 175000000)
+ _uhf_range = (400000000, 481000000)
+ _magic = MSTRING_KT8900D
+ _fileid = [KT980PLUS_fp1, KT980PLUS_fp]
+ _power_levels = [chirp_common.PowerLevel("High", watts=75),
+ chirp_common.PowerLevel("Low", watts=55)]
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This model is only ever matched via metadata
+ return False
+
+
+@directory.register
+class DB25G(BTechColor):
+ """Radioddity DB25-G"""
+ VENDOR = "Radioddity"
+ MODEL = "DB25-G"
+ BANDS = 2
+ LIST_TMR = LIST_TMR15
+ _vhf_range = (136000000, 175000000)
+ _uhf_range = (400000000, 481000000)
+ _magic = MSTRING_KT8900D
+ _fileid = [DB25G_fp1, DB25G_fp]
+ _gmrs = True
+ _power_levels = [chirp_common.PowerLevel("High", watts=25),
+ chirp_common.PowerLevel("Mid", watts=15),
+ chirp_common.PowerLevel("Low", watts=5)]
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This model is only ever matched via metadata
+ return False
GMRS_MEM_FORMAT = """
@@ -3849,8 +4205,8 @@ struct {
u8 unknown0:4,
scode:4;
u8 unknown1:2,
- spmute:1,
- unknown2:3,
+ spmute:2,
+ unknown2:2,
optsig:2;
u8 unknown3:3,
scramble:1,
@@ -4057,6 +4413,7 @@ struct {
u8 mgain;
u8 skiptx;
u8 scmode;
+ u8 tmrtx;
} settings;
#seekto 0x3280;
@@ -4193,3 +4550,1079 @@ class GMRS50X1(BTechGMRS):
_upper = 255
_magic = MSTRING_GMRS50X1
_fileid = [GMRS50X1_fp1, GMRS50X1_fp, ]
+ _gmrs = True
+
+
+COLORHT_MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unknown0:4,
+ scode:4;
+ u8 unknown1:2,
+ spmute:2,
+ unknown2:2,
+ optsig:2;
+ u8 unknown3:3,
+ scramble:1,
+ unknown4:3,
+ power:1;
+ u8 unknown5:1,
+ wide:1,
+ unknown6:2,
+ bcl:1,
+ add:1,
+ pttid:2;
+} memory[200];
+
+#seekto 0x0E00;
+struct {
+ u8 tmr;
+ u8 unknownE01;
+ u8 sql;
+ u8 unknownE03[2];
+ u8 tot;
+ u8 save;
+ u8 unknownE07;
+ u8 abr;
+ u8 beep;
+ u8 unknownE0A[4];
+ u8 dsub;
+ u8 dtmfst;
+ u8 screv;
+ u8 unknownE11[3];
+ u8 pttid;
+ u8 unknownE15;
+ u8 pttlt;
+ u8 unknownE17;
+ u8 emctp;
+ u8 emcch;
+ u8 sigbp;
+ u8 unknownE1B;
+ u8 camdf;
+ u8 cbmdf;
+ u8 ccmdf;
+ u8 cdmdf;
+ u8 langua;
+ u8 voice;
+ u8 vox;
+ u8 voxt;
+ u8 sync; // BTech radios use this as the display sync setting
+ // other radios use this as the auto keypad lock setting
+ u8 stfc;
+ u8 mffc;
+ u8 sfafc;
+ u8 sfbfc;
+ u8 sfcfc;
+ u8 sfdfc;
+ u8 subfc;
+ u8 fmfc;
+ u8 sigfc;
+ u8 menufc;
+ u8 txfc;
+ u8 rxfc;
+ u8 unknownE31[5];
+ u8 anil;
+ u8 reps;
+ u8 tmrmr;
+ u8 ste;
+ u8 rpste;
+ u8 rptdl;
+ u8 dtmfg;
+ u8 tmrtx;
+} settings;
+
+#seekto 0x0E80;
+struct {
+ u8 unknown1;
+ u8 vfomr;
+ u8 keylock;
+ u8 unknown2;
+ u8 unknown3:4,
+ vfomren:1,
+ unknown4:1,
+ reseten:1,
+ menuen:1;
+ u8 unknown5[11];
+ u8 dispab;
+ u8 unknown6[2];
+ u8 menu;
+ u8 unknown7[7];
+ u8 vfomra;
+ u8 vfomrb;
+ u8 vfomrc;
+ u8 vfomrd;
+ u8 mrcha;
+ u8 mrchb;
+ u8 mrchc;
+ u8 mrchd;
+} settings2;
+
+struct settings_vfo {
+ u8 freq[8];
+ u8 offset[6];
+ u8 unknown2[2];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 scode;
+ u8 spmute;
+ u8 optsig;
+ u8 scramble;
+ u8 wide;
+ u8 power;
+ u8 shiftd;
+ u8 step;
+ u8 unknown3[4];
+};
+
+#seekto 0x0F00;
+struct {
+ struct settings_vfo a;
+ struct settings_vfo b;
+ struct settings_vfo c;
+ struct settings_vfo d;
+} vfo;
+
+#seekto 0x0FE0;
+struct {
+ char line[16];
+} static_msg;
+
+#seekto 0x1000;
+struct {
+ char name[8];
+ u8 unknown1[8];
+} names[200];
+
+#seekto 0x2400;
+struct {
+ u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
+ u8 group_tone;
+ u8 repeat_tone;
+ u8 unused[13];
+} _5tone_std_settings[15];
+
+#seekto 0x2500;
+struct {
+ u8 frame1[5];
+ u8 frame2[5];
+ u8 frame3[5];
+ u8 standard; // one out of LIST_5TONE_STANDARDS
+} _5tone_codes[15];
+
+#seekto 0x25F0;
+struct {
+ u8 _5tone_delay1; // * 10ms
+ u8 _5tone_delay2; // * 10ms
+ u8 _5tone_delay3; // * 10ms
+ u8 _5tone_first_digit_ext_length;
+ u8 unknown1;
+ u8 unknown2;
+ u8 unknown3;
+ u8 unknown4;
+ u8 decode_standard;
+ u8 unknown5:5,
+ _5tone_decode_call_frame3:1,
+ _5tone_decode_call_frame2:1,
+ _5tone_decode_call_frame1:1;
+ u8 unknown6:5,
+ _5tone_decode_disp_frame3:1,
+ _5tone_decode_disp_frame2:1,
+ _5tone_decode_disp_frame1:1;
+ u8 decode_reset_time; // * 100 + 100ms
+} _5tone_settings;
+
+#seekto 0x2900;
+struct {
+ u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
+} dtmf_codes[15];
+
+#seekto 0x29F0;
+struct {
+ u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
+ u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
+ u8 unknown0[14];
+ u8 inspection[16];
+ u8 monitor[16];
+ u8 alarmcode[16];
+ u8 stun[16];
+ u8 kill[16];
+ u8 revive[16];
+ u8 unknown1[16];
+ u8 unknown2[16];
+ u8 unknown3[16];
+ u8 unknown4[16];
+ u8 unknown5[16];
+ u8 unknown6[16];
+ u8 unknown7[16];
+ u8 masterid[16];
+ u8 viceid[16];
+ u8 unused01:7,
+ mastervice:1;
+ u8 unused02:3,
+ mrevive:1,
+ mkill:1,
+ mstun:1,
+ mmonitor:1,
+ minspection:1;
+ u8 unused03:3,
+ vrevive:1,
+ vkill:1,
+ vstun:1,
+ vmonitor:1,
+ vinspection:1;
+ u8 unused04:6,
+ txdisable:1,
+ rxdisable:1;
+ u8 groupcode;
+ u8 spacecode;
+ u8 delayproctime; // * 100 + 100ms
+ u8 resettime; // * 100 + 100ms
+} dtmf_settings;
+
+#seekto 0x2D00;
+struct {
+ struct {
+ ul16 freq1;
+ u8 unused01[6];
+ ul16 freq2;
+ u8 unused02[6];
+ } _2tone_encode[15];
+ u8 duration_1st_tone; // *10ms
+ u8 duration_2nd_tone; // *10ms
+ u8 duration_gap; // *10ms
+ u8 unused03[13];
+ struct {
+ struct {
+ u8 dec; // one out of LIST_2TONE_DEC
+ u8 response; // one out of LIST_2TONE_RESPONSE
+ u8 alert; // 1-16
+ } decs[4];
+ u8 unused04[4];
+ } _2tone_decode[15];
+ u8 unused05[16];
+
+ struct {
+ ul16 freqA;
+ ul16 freqB;
+ ul16 freqC;
+ ul16 freqD;
+ // unknown what those values mean, but they are
+ // derived from configured frequencies
+ ul16 derived_from_freqA; // 2304000/freqA
+ ul16 derived_from_freqB; // 2304000/freqB
+ ul16 derived_from_freqC; // 2304000/freqC
+ ul16 derived_from_freqD; // 2304000/freqD
+ }freqs[15];
+ u8 reset_time; // * 100 + 100ms - 100-8000ms
+} _2tone;
+
+#seekto 0x3D80;
+struct {
+ u8 vhf_low[3];
+ u8 vhf_high[3];
+ u8 unknown1[4];
+ u8 unknown2[6];
+ u8 vhf2_low[3];
+ u8 vhf2_high[3];
+ u8 unknown3[4];
+ u8 unknown4[6];
+ u8 uhf_low[3];
+ u8 uhf_high[3];
+ u8 unknown5[4];
+ u8 unknown6[6];
+ u8 uhf2_low[3];
+ u8 uhf2_high[3];
+} ranges;
+
+#seekto 0x3F70;
+struct {
+ char fp[6];
+} fingerprint;
+
+"""
+
+
+class QYTColorHT(BTechMobileCommon):
+ """QTY's Color LCD Handheld and alike radios"""
+ COLOR_LCD = True
+ COLOR_LCD3 = True
+ NAME_LENGTH = 8
+ LIST_TMR = LIST_TMR15
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+
+ # Get it
+ self._memobj = bitwise.parse(COLORHT_MEM_FORMAT, self._mmap)
+
+ # load specific parameters from the radio image
+ self.set_options()
+
+ def set_options(self):
+ """This is to read the options from the image and set it in the
+ environment, for now just the limits of the freqs in the VHF/UHF
+ ranges"""
+
+ # setting the correct ranges for each radio type
+ ranges = self._memobj.ranges
+
+ # the normal dual bands
+ vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
+ uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
+
+ # DEBUG
+ LOG.info("Radio ranges: VHF %d to %d" % vhf)
+ LOG.info("Radio ranges: UHF %d to %d" % uhf)
+
+ # the additional bands
+ if self.MODEL in ["KT-8R"]:
+ # 200Mhz band
+ vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
+ LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
+ self._220_range = vhf2
+
+ # 350Mhz band
+ uhf2 = _decode_ranges(ranges.uhf2_low, ranges.uhf2_high)
+ LOG.info("Radio ranges: UHF(350) %d to %d" % uhf2)
+ self._350_range = uhf2
+
+ # set the class with the real data
+ self._vhf_range = vhf
+ self._uhf_range = uhf
+
+
+# real radios
+@directory.register
+class KT8R(QYTColorHT):
+ """QYT KT8R"""
+ VENDOR = "QYT"
+ MODEL = "KT-8R"
+ BANDS = 4
+ LIST_TMR = LIST_TMR16
+ _vhf_range = (136000000, 175000000)
+ _220_range = (200000000, 261000000)
+ _uhf_range = (400000000, 481000000)
+ _350_range = (350000000, 391000000)
+ _magic = MSTRING_KT8R
+ _fileid = [KT8R_fp2, KT8R_fp1, KT8R_fp, ]
+ _power_levels = [chirp_common.PowerLevel("High", watts=5),
+ chirp_common.PowerLevel("Low", watts=1)]
+
+
+COLOR9900_MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unknown0:4,
+ scode:4;
+ u8 unknown1:2,
+ spmute:2,
+ unknown2:2,
+ optsig:2;
+ u8 unknown3:3,
+ scramble:1,
+ unknown4:2,
+ power:2;
+ u8 unknown5:1,
+ wide:1,
+ unknown6:2,
+ bcl:1,
+ add:1,
+ pttid:2;
+} memory[200];
+
+#seekto 0x0E00;
+struct {
+ u8 tmr;
+ u8 unknown1;
+ u8 sql;
+ u8 unknown2[2];
+ u8 tot;
+ u8 volume;
+ u8 unknown3;
+ u8 abr;
+ u8 beep;
+ u8 unknown4[4];
+ u8 dsub;
+ u8 dtmfst;
+ u8 unknown_e10;
+ u8 unknown_e11;
+ u8 screv;
+ u8 unknown_e13;
+ u8 unknown_e14;
+ u8 pttid;
+ u8 pttlt;
+ u8 unknown7;
+ u8 emctp;
+ u8 emcch;
+ u8 sigbp;
+ u8 unknown8;
+ u8 camdf;
+ u8 cbmdf;
+ u8 ccmdf;
+ u8 language;
+ u8 tmrtx;
+ u8 vox;
+ u8 voxt;
+ u8 autolock;
+ u8 asfc;
+ u8 mainfc;
+ u8 a_fc;
+ u8 b_fc;
+ u8 c_fc;
+ u8 subfc;
+ u8 battfc;
+ u8 sigfc;
+ u8 menufc;
+ u8 txfc;
+ u8 rxfc;
+ u8 unknown_e2f;
+ u8 unknown_e30;
+ u8 unknown9[3];
+ u8 anil;
+ u8 reps;
+ u8 tmrmr;
+ u8 ste;
+ u8 rpste;
+ u8 rptdl;
+ u8 dtmfg;
+} settings;
+
+#seekto 0x0E80;
+struct {
+ u8 unknown1;
+ u8 vfomr;
+ u8 keylock;
+ u8 unknown2;
+ u8 unknown3:4,
+ vfomren:1,
+ unknown4:1,
+ reseten:1,
+ menuen:1;
+ u8 unknown5[11];
+ u8 dispab;
+ u8 unknown6[2];
+ u8 menu;
+ u8 unknown7[7];
+ u8 vfomra;
+ u8 vfomrb;
+ u8 vfomrc;
+ u8 vfomrd;
+ u8 mrcha;
+ u8 mrchb;
+ u8 mrchc;
+ u8 mrchd;
+} settings2;
+
+struct settings_vfo {
+ u8 freq[8];
+ u8 offset[6];
+ u8 unknown2[2];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 scode;
+ u8 spmute;
+ u8 optsig;
+ u8 scramble;
+ u8 wide;
+ u8 power;
+ u8 shiftd;
+ u8 step;
+ u8 unknown3[4];
+};
+
+#seekto 0x0F00;
+struct {
+ struct settings_vfo a;
+ struct settings_vfo b;
+ struct settings_vfo c;
+ struct settings_vfo d;
+} vfo;
+
+#seekto 0x0F80;
+struct {
+ char line1[8];
+ char line2[8];
+ char line3[8];
+ char line4[8];
+ char line5[8];
+ char line6[8];
+ char line7[8];
+ char line8[8];
+} poweron_msg;
+
+#seekto 0x0FE0;
+struct {
+ char line[16];
+} static_msg;
+
+#seekto 0x1000;
+struct {
+ char name[7];
+ u8 unknown1[9];
+} names[200];
+
+#seekto 0x2400;
+struct {
+ u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
+ u8 group_tone;
+ u8 repeat_tone;
+ u8 unused[13];
+} _5tone_std_settings[15];
+
+#seekto 0x2500;
+struct {
+ u8 frame1[5];
+ u8 frame2[5];
+ u8 frame3[5];
+ u8 standard; // one out of LIST_5TONE_STANDARDS
+} _5tone_codes[15];
+
+#seekto 0x25F0;
+struct {
+ u8 _5tone_delay1; // * 10ms
+ u8 _5tone_delay2; // * 10ms
+ u8 _5tone_delay3; // * 10ms
+ u8 _5tone_first_digit_ext_length;
+ u8 unknown1;
+ u8 unknown2;
+ u8 unknown3;
+ u8 unknown4;
+ u8 decode_standard;
+ u8 unknown5:5,
+ _5tone_decode_call_frame3:1,
+ _5tone_decode_call_frame2:1,
+ _5tone_decode_call_frame1:1;
+ u8 unknown6:5,
+ _5tone_decode_disp_frame3:1,
+ _5tone_decode_disp_frame2:1,
+ _5tone_decode_disp_frame1:1;
+ u8 decode_reset_time; // * 100 + 100ms
+} _5tone_settings;
+
+#seekto 0x2900;
+struct {
+ u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
+} dtmf_codes[15];
+
+#seekto 0x29F0;
+struct {
+ u8 dtmfspeed_on; //list with 50..2000ms in steps of 10 // 9f0
+ u8 dtmfspeed_off; //list with 50..2000ms in steps of 10 // 9f1
+ u8 unknown0[14]; // 9f2-9ff
+ u8 inspection[16]; // a00-a0f
+ u8 monitor[16]; // a10-a1f
+ u8 alarmcode[16]; // a20-a2f
+ u8 stun[16]; // a30-a3f
+ u8 kill[16]; // a40-a4f
+ u8 revive[16]; // a50-a5f
+ u8 unknown1[16]; // a60-a6f
+ u8 unknown2[16]; // a70-a7f
+ u8 unknown3[16]; // a80-a8f
+ u8 unknown4[16]; // a90-a9f
+ u8 unknown5[16]; // aa0-aaf
+ u8 unknown6[16]; // ab0-abf
+ u8 unknown7[16]; // ac0-acf
+ u8 masterid[16]; // ad0-adf
+ u8 viceid[16]; // ae0-aef
+ u8 unused01:7, // af0
+ mastervice:1;
+ u8 unused02:3, // af1
+ mrevive:1,
+ mkill:1,
+ mstun:1,
+ mmonitor:1,
+ minspection:1;
+ u8 unused03:3, // af2
+ vrevive:1,
+ vkill:1,
+ vstun:1,
+ vmonitor:1,
+ vinspection:1;
+ u8 unused04:6, // af3
+ txdisable:1,
+ rxdisable:1;
+ u8 groupcode; // af4
+ u8 spacecode; // af5
+ u8 delayproctime; // * 100 + 100ms // af6
+ u8 resettime; // * 100 + 100ms // af7
+} dtmf_settings;
+
+#seekto 0x2D00;
+struct {
+ struct {
+ ul16 freq1;
+ u8 unused01[6];
+ ul16 freq2;
+ u8 unused02[6];
+ } _2tone_encode[15];
+ u8 duration_1st_tone; // *10ms
+ u8 duration_2nd_tone; // *10ms
+ u8 duration_gap; // *10ms
+ u8 unused03[13];
+ struct {
+ struct {
+ u8 dec; // one out of LIST_2TONE_DEC
+ u8 response; // one out of LIST_2TONE_RESPONSE
+ u8 alert; // 1-16
+ } decs[4];
+ u8 unused04[4];
+ } _2tone_decode[15];
+ u8 unused05[16];
+
+ struct {
+ ul16 freqA;
+ ul16 freqB;
+ ul16 freqC;
+ ul16 freqD;
+ // unknown what those values mean, but they are
+ // derived from configured frequencies
+ ul16 derived_from_freqA; // 2304000/freqA
+ ul16 derived_from_freqB; // 2304000/freqB
+ ul16 derived_from_freqC; // 2304000/freqC
+ ul16 derived_from_freqD; // 2304000/freqD
+ }freqs[15];
+ u8 reset_time; // * 100 + 100ms - 100-8000ms
+} _2tone;
+
+#seekto 0x3D80;
+struct {
+ u8 vhf_low[3];
+ u8 vhf_high[3];
+ u8 unknown1[4];
+ u8 unknown2[6];
+ u8 vhf2_low[3];
+ u8 vhf2_high[3];
+ u8 unknown3[4];
+ u8 unknown4[6];
+ u8 uhf_low[3];
+ u8 uhf_high[3];
+ u8 unknown5[4];
+ u8 unknown6[6];
+ u8 uhf2_low[3];
+ u8 uhf2_high[3];
+} ranges;
+
+#seekto 0x3F70;
+struct {
+ char fp[6];
+} fingerprint;
+
+"""
+
+
+COLOR20V2_MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unknown0:4,
+ scode:4;
+ u8 unknown1:2,
+ spmute:2,
+ unknown2:2,
+ optsig:2;
+ u8 unknown3:3,
+ scramble:1,
+ unknown4:2,
+ power:2;
+ u8 unknown5:1,
+ wide:1,
+ unknown6:2,
+ bcl:1,
+ add:1,
+ pttid:2;
+} memory[200];
+
+#seekto 0x0E00;
+struct {
+ u8 tmr;
+ u8 unknown1;
+ u8 sql;
+ u8 unknown2;
+ u8 autolock;
+ u8 tot;
+ u8 apo;
+ u8 unknown3;
+ u8 abr;
+ u8 beep;
+ u8 unknown4[4];
+ u8 dtmfst;
+ u8 unknown5[2];
+ u8 screv;
+ u8 unknown6[2];
+ u8 pttid;
+ u8 pttlt;
+ u8 unknown7;
+ u8 emctp;
+ u8 emcch;
+ u8 sigbp;
+ u8 unknown8;
+ u8 camdf;
+ u8 cbmdf;
+ u8 ccmdf;
+ u8 vox;
+ u8 voxt;
+ u8 sync;
+ u8 asfc;
+ u8 mainfc;
+ u8 a_fc;
+ u8 b_fc;
+ u8 c_fc;
+ u8 subfc;
+ u8 battfc;
+ u8 sigfc;
+ u8 menufc;
+ u8 txfc;
+ u8 rxfc;
+ u8 repsw;
+ u8 dsub;
+ u8 unknown9[5];
+ u8 anil;
+ u8 reps;
+ u8 repm;
+ u8 tmrmr;
+ u8 ste;
+ u8 rpste;
+ u8 rptdl;
+ u8 dtmfg;
+ u8 mgain;
+ u8 skiptx;
+ u8 scmode;
+ u8 tmrtx;
+ u8 volume;
+ u8 unknown_10;
+ u8 save;
+} settings;
+
+#seekto 0x0E80;
+struct {
+ u8 unknown1;
+ u8 vfomr;
+ u8 keylock;
+ u8 unknown2;
+ u8 unknown3:4,
+ vfomren:1,
+ unknown4:1,
+ reseten:1,
+ menuen:1;
+ u8 unknown5[11];
+ u8 dispab;
+ u8 unknown6[2];
+ u8 menu;
+ u8 unknown7[7];
+ u8 vfomra;
+ u8 vfomrb;
+ u8 vfomrc;
+ u8 vfomrd;
+ u8 mrcha;
+ u8 mrchb;
+ u8 mrchc;
+ u8 mrchd;
+} settings2;
+
+struct settings_vfo {
+ u8 freq[8];
+ u8 offset[6];
+ u8 unknown2[2];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 scode;
+ u8 spmute;
+ u8 optsig;
+ u8 scramble;
+ u8 wide;
+ u8 power;
+ u8 shiftd;
+ u8 step;
+ u8 unknown3[4];
+};
+
+#seekto 0x0F00;
+struct {
+ struct settings_vfo a;
+ struct settings_vfo b;
+ struct settings_vfo c;
+ struct settings_vfo d;
+} vfo;
+
+#seekto 0x0F80;
+struct {
+ char line1[8];
+ char line2[8];
+ char line3[8];
+ char line4[8];
+ char line5[8];
+ char line6[8];
+ char line7[8];
+ char line8[8];
+} poweron_msg;
+
+#seekto 0x0FE0;
+struct {
+ char line[16];
+} static_msg;
+
+#seekto 0x1000;
+struct {
+ char name[7];
+ u8 unknown1[9];
+} names[200];
+
+#seekto 0x2400;
+struct {
+ u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
+ u8 group_tone;
+ u8 repeat_tone;
+ u8 unused[13];
+} _5tone_std_settings[15];
+
+#seekto 0x2500;
+struct {
+ u8 frame1[5];
+ u8 frame2[5];
+ u8 frame3[5];
+ u8 standard; // one out of LIST_5TONE_STANDARDS
+} _5tone_codes[15];
+
+#seekto 0x25F0;
+struct {
+ u8 _5tone_delay1; // * 10ms
+ u8 _5tone_delay2; // * 10ms
+ u8 _5tone_delay3; // * 10ms
+ u8 _5tone_first_digit_ext_length;
+ u8 unknown1;
+ u8 unknown2;
+ u8 unknown3;
+ u8 unknown4;
+ u8 decode_standard;
+ u8 unknown5:5,
+ _5tone_decode_call_frame3:1,
+ _5tone_decode_call_frame2:1,
+ _5tone_decode_call_frame1:1;
+ u8 unknown6:5,
+ _5tone_decode_disp_frame3:1,
+ _5tone_decode_disp_frame2:1,
+ _5tone_decode_disp_frame1:1;
+ u8 decode_reset_time; // * 100 + 100ms
+} _5tone_settings;
+
+#seekto 0x2900;
+struct {
+ u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
+} dtmf_codes[15];
+
+#seekto 0x29F0;
+struct {
+ u8 dtmfspeed_on; //list with 50..2000ms in steps of 10 // 9f0
+ u8 dtmfspeed_off; //list with 50..2000ms in steps of 10 // 9f1
+ u8 unknown0[14]; // 9f2-9ff
+ u8 inspection[16]; // a00-a0f
+ u8 monitor[16]; // a10-a1f
+ u8 alarmcode[16]; // a20-a2f
+ u8 stun[16]; // a30-a3f
+ u8 kill[16]; // a40-a4f
+ u8 revive[16]; // a50-a5f
+ u8 unknown1[16]; // a60-a6f
+ u8 unknown2[16]; // a70-a7f
+ u8 unknown3[16]; // a80-a8f
+ u8 unknown4[16]; // a90-a9f
+ u8 unknown5[16]; // aa0-aaf
+ u8 unknown6[16]; // ab0-abf
+ u8 unknown7[16]; // ac0-acf
+ u8 masterid[16]; // ad0-adf
+ u8 viceid[16]; // ae0-aef
+ u8 unused01:7, // af0
+ mastervice:1;
+ u8 unused02:3, // af1
+ mrevive:1,
+ mkill:1,
+ mstun:1,
+ mmonitor:1,
+ minspection:1;
+ u8 unused03:3, // af2
+ vrevive:1,
+ vkill:1,
+ vstun:1,
+ vmonitor:1,
+ vinspection:1;
+ u8 unused04:6, // af3
+ txdisable:1,
+ rxdisable:1;
+ u8 groupcode; // af4
+ u8 spacecode; // af5
+ u8 delayproctime; // * 100 + 100ms // af6
+ u8 resettime; // * 100 + 100ms // af7
+} dtmf_settings;
+
+#seekto 0x2D00;
+struct {
+ struct {
+ ul16 freq1;
+ u8 unused01[6];
+ ul16 freq2;
+ u8 unused02[6];
+ } _2tone_encode[15];
+ u8 duration_1st_tone; // *10ms
+ u8 duration_2nd_tone; // *10ms
+ u8 duration_gap; // *10ms
+ u8 unused03[13];
+ struct {
+ struct {
+ u8 dec; // one out of LIST_2TONE_DEC
+ u8 response; // one out of LIST_2TONE_RESPONSE
+ u8 alert; // 1-16
+ } decs[4];
+ u8 unused04[4];
+ } _2tone_decode[15];
+ u8 unused05[16];
+
+ struct {
+ ul16 freqA;
+ ul16 freqB;
+ ul16 freqC;
+ ul16 freqD;
+ // unknown what those values mean, but they are
+ // derived from configured frequencies
+ ul16 derived_from_freqA; // 2304000/freqA
+ ul16 derived_from_freqB; // 2304000/freqB
+ ul16 derived_from_freqC; // 2304000/freqC
+ ul16 derived_from_freqD; // 2304000/freqD
+ }freqs[15];
+ u8 reset_time; // * 100 + 100ms - 100-8000ms
+} _2tone;
+
+#seekto 0x3D80;
+struct {
+ u8 vhf_low[3];
+ u8 vhf_high[3];
+ u8 unknown1[4];
+ u8 unknown2[6];
+ u8 vhf2_low[3];
+ u8 vhf2_high[3];
+ u8 unknown3[4];
+ u8 unknown4[6];
+ u8 uhf_low[3];
+ u8 uhf_high[3];
+ u8 unknown5[4];
+ u8 unknown6[6];
+ u8 uhf2_low[3];
+ u8 uhf2_high[3];
+} ranges;
+
+#seekto 0x3F70;
+struct {
+ char fp[6];
+} fingerprint;
+
+"""
+
+
+class BTechColorWP(BTechMobileCommon):
+ """BTECH's Color WP Mobile and alike radios"""
+ COLOR_LCD = True
+ COLOR_LCD4 = True
+ NAME_LENGTH = 7
+ LIST_TMR = LIST_TMR7
+
+ def set_options(self):
+ """This is to read the options from the image and set it in the
+ environment, for now just the limits of the freqs in the VHF/UHF
+ ranges"""
+
+ # setting the correct ranges for each radio type
+ ranges = self._memobj.ranges
+
+ # the normal dual bands
+ vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
+ uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
+
+ # DEBUG
+ LOG.info("Radio ranges: VHF %d to %d" % vhf)
+ LOG.info("Radio ranges: UHF %d to %d" % uhf)
+
+ # set the class with the real data
+ self._vhf_range = vhf
+ self._uhf_range = uhf
+
+
+# real radios
+@directory.register
+class KTWP12(BTechColorWP):
+ """QYT KT-WP12"""
+ VENDOR = "QYT"
+ MODEL = "KT-WP12"
+ BANDS = 2
+ UPLOAD_MEM_SIZE = 0X3100
+ _power_levels = [chirp_common.PowerLevel("High", watts=25),
+ chirp_common.PowerLevel("Low", watts=5)]
+ _upper = 199
+ _magic = MSTRING_KTWP12
+ _fileid = [KTWP12_fp, ]
+ _gmrs = False
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+
+ # Get it
+ self._memobj = bitwise.parse(COLOR9900_MEM_FORMAT, self._mmap)
+
+ # load specific parameters from the radio image
+ self.set_options()
+
+
+@directory.register
+class WP9900(BTechColorWP):
+ """Anysecu WP-9900"""
+ VENDOR = "Anysecu"
+ MODEL = "WP-9900"
+ BANDS = 2
+ UPLOAD_MEM_SIZE = 0X3100
+ _power_levels = [chirp_common.PowerLevel("High", watts=25),
+ chirp_common.PowerLevel("Low", watts=5)]
+ _upper = 199
+ _magic = MSTRING_KTWP12
+ _fileid = [WP9900_fp, ]
+ _gmrs = False
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+
+ # Get it
+ self._memobj = bitwise.parse(COLOR9900_MEM_FORMAT, self._mmap)
+
+ # load specific parameters from the radio image
+ self.set_options()
+
+
+@directory.register
+class GMRS20V2(BTechColorWP):
+ """Baofeng Tech GMRS-20V2"""
+ MODEL = "GMRS-20V2"
+ BANDS = 2
+ UPLOAD_MEM_SIZE = 0X3100
+ _power_levels = [chirp_common.PowerLevel("High", watts=20),
+ chirp_common.PowerLevel("", watts=6),
+ chirp_common.PowerLevel("Low", watts=5)]
+ _upper = 199
+ _magic = MSTRING_GMRS20V2
+ _fileid = [GMRS20V2_fp2, GMRS20V2_fp1, GMRS20V2_fp, ]
+ _gmrs = True
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+
+ # Get it
+ self._memobj = bitwise.parse(COLOR20V2_MEM_FORMAT, self._mmap)
+
+ # load specific parameters from the radio image
+ self.set_options()
diff --git a/chirp/drivers/fake.py b/chirp/drivers/fake.py
new file mode 100644
index 0000000..e03eea0
--- /dev/null
+++ b/chirp/drivers/fake.py
@@ -0,0 +1,100 @@
+import logging
+import time
+
+from chirp import chirp_common
+from chirp import directory
+from chirp import errors
+from chirp import settings
+
+LOG = logging.getLogger(__name__)
+
+
+class FakeLiveRadio(chirp_common.LiveRadio):
+ VENDOR = 'CHIRP'
+ MODEL = 'Fake Live Radio'
+
+ def __init__(self, *a, **k):
+ super().__init__(*a, **k)
+ self.settings = {'knob': 5}
+ self.memories = []
+ for i in range (1, 11):
+ m = chirp_common.Memory(i, empty=i > 5, name='channel %i' % i)
+ m.freq = 146520000
+ self.memories.append(m)
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.memory_bounds = (1, 10)
+ rf.has_settings = True
+ return rf
+
+ def get_memory(self, number):
+ return self.memories[number - 1]
+
+ def set_memory(self, mem):
+ LOG.info('Set memory %s' % mem)
+ self.memories[mem.number - 1] = mem
+
+ def get_settings(self):
+ g = settings.RadioSettingGroup('top', 'Some Settings')
+ g.append(
+ settings.RadioSetting(
+ 'knob', 'A knob',
+ settings.RadioSettingValueInteger(0, 10,
+ self.settings['knob'])))
+ return settings.RadioSettings(g)
+
+ def set_settings(self, rs):
+ for e in rs:
+ if isinstance(e, settings.RadioSetting):
+ self.settings[e.name] = e.value
+ else:
+ self.set_settings(e)
+
+
+class FakeLiveSlowRadio(FakeLiveRadio):
+ VARIANT = 'Slow'
+
+ def get_memory(self, number):
+ time.sleep(0.5)
+ return super().get_memory(number)
+
+ def set_memory(self, mem):
+ time.sleep(5)
+ return super().set_memory(mem)
+
+ def get_settings(self):
+ time.sleep(1)
+ return super().get_settings()
+
+ def set_settings(self, settings):
+ time.sleep(2)
+ return super().set_settings(settings)
+
+
+class FakeLiveRadioWithErrors(FakeLiveRadio):
+ VARIANT = 'Errors'
+
+ def __init__(self, *a, **k):
+ super().__init__(*a, **k)
+ self.memories[2] = errors.RadioError
+ self.memories[3] = Exception
+
+ def get_memory(self, number):
+ m = super().get_memory(number)
+ if isinstance(m, type):
+ raise m('Error')
+ else:
+ return m
+
+ def set_memory(self, mem):
+ if mem.freq < 145000000:
+ raise errors.RadioError('Out of range')
+ else:
+ return super().set_memory(mem)
+
+
+def register_fakes():
+ directory.register(FakeLiveRadio)
+ directory.register(FakeLiveSlowRadio)
+ directory.register(FakeLiveRadioWithErrors)
diff --git a/chirp/drivers/fd268.py b/chirp/drivers/fd268.py
index 8d9128b..7d4f726 100644
--- a/chirp/drivers/fd268.py
+++ b/chirp/drivers/fd268.py
@@ -221,7 +221,7 @@ def do_program(radio):
#
# Even FDX-288 software appears to match the model by any other
# mean, so I detected on a few images that the 3 first bytes are
- # unique to each radio model, so for now we use that method untill
+ # unique to each radio model, so for now we use that method until
# proven otherwise
# ###################################################################
@@ -297,7 +297,7 @@ class FeidaxinFD2x8yRadio(chirp_common.CloneModeRadio):
_memsize = MEM_SIZE
_upper = 99
_VFO_DEFAULT = 0
- _IDENT = ""
+ _IDENT = b""
_active_ch = ACTIVE_CH
@classmethod
@@ -353,7 +353,7 @@ class FeidaxinFD2x8yRadio(chirp_common.CloneModeRadio):
"DTCS->Tone",
"->Tone",
"DTCS->DTCS"]
- # Power levels are golbal and no per channel, so disabled
+ # Power levels are global and no per channel, so disabled
# rf.valid_power_levels = POWER_LEVELS
# this radio has no skips
rf.valid_skips = []
@@ -589,7 +589,7 @@ class FeidaxinFD2x8yRadio(chirp_common.CloneModeRadio):
else:
vfo = int(_mem.vfo.vrx_freq) * 10
- # frecuency apply_callback
+ # frequency apply_callback
def apply_freq(setting, obj):
"""Setting is the UI returned value, obj is the memmap object"""
value = chirp_common.parse_freq(str(setting.value))
@@ -790,11 +790,11 @@ class FeidaxinFD2x8yRadio(chirp_common.CloneModeRadio):
obj = getattr(_mem, sett)
setattr(obj, name, element.value)
- except AttributeError, e:
+ except AttributeError as e:
m = "Setting %s is not in this setting block" % name
LOG.debug(m)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -827,7 +827,7 @@ class FD268ARadio(FeidaxinFD2x8yRadio):
MODEL = "FD-268A"
_range = (136000000, 174000000)
_VFO_DEFAULT = 145000000
- _IDENT = "\xFF\xEE\x46\xFF"
+ _IDENT = b"\xFF\xEE\x46\xFF"
@directory.register
@@ -836,13 +836,13 @@ class FD268BRadio(FeidaxinFD2x8yRadio):
MODEL = "FD-268B"
_range = (400000000, 470000000)
_VFO_DEFAULT = 439000000
- _IDENT = "\xFF\xEE\x47\xFF"
+ _IDENT = b"\xFF\xEE\x47\xFF"
# #####################################################################
# FD-288 Family: the only difference from this family to the FD-268's
# are the ANI settings
-# Tested hacking the FD-268A memmory
+# Tested hacking the FD-268A memory
@directory.register
@@ -851,7 +851,7 @@ class FD288ARadio(FeidaxinFD2x8yRadio):
MODEL = "FD-288A"
_range = (136000000, 174000000)
_VFO_DEFAULT = 145000000
- _IDENT = "\xFF\xEE\x4B\xFF"
+ _IDENT = b"\xFF\xEE\x4B\xFF"
@directory.register
@@ -860,11 +860,11 @@ class FD288BRadio(FeidaxinFD2x8yRadio):
MODEL = "FD-288B"
_range = (400000000, 470000000)
_VFO_DEFAULT = 439000000
- _IDENT = "\xFF\xEE\x4C\xFF"
+ _IDENT = b"\xFF\xEE\x4C\xFF"
# #####################################################################
-# The following radios was tested hacking the FD-268A memmory with
+# The following radios was tested hacking the FD-268A memory with
# the software and found to be clones of FD-268 ones
# please report any problems to driver author (see head of this file)
@@ -875,7 +875,7 @@ class FD150ARadio(FeidaxinFD2x8yRadio):
MODEL = "FD-150A"
_range = (136000000, 174000000)
_VFO_DEFAULT = 145000000
- _IDENT = "\xFF\xEE\x45\xFF"
+ _IDENT = b"\xFF\xEE\x45\xFF"
@directory.register
@@ -884,7 +884,7 @@ class FD160ARadio(FeidaxinFD2x8yRadio):
MODEL = "FD-160A"
_range = (136000000, 174000000)
_VFO_DEFAULT = 145000000
- _IDENT = "\xFF\xEE\x48\xFF"
+ _IDENT = b"\xFF\xEE\x48\xFF"
@directory.register
@@ -893,7 +893,7 @@ class FD450ARadio(FeidaxinFD2x8yRadio):
MODEL = "FD-450A"
_range = (400000000, 470000000)
_VFO_DEFAULT = 439000000
- _IDENT = "\xFF\xEE\x44\xFF"
+ _IDENT = b"\xFF\xEE\x44\xFF"
@directory.register
@@ -902,7 +902,7 @@ class FD460ARadio(FeidaxinFD2x8yRadio):
MODEL = "FD-460A"
_range = (400000000, 470000000)
_VFO_DEFAULT = 439000000
- _IDENT = "\xFF\xEE\x4A\xFF"
+ _IDENT = b"\xFF\xEE\x4A\xFF"
@directory.register
@@ -911,4 +911,4 @@ class FD460UHRadio(FeidaxinFD2x8yRadio):
MODEL = "FD-460UH"
_range = (400000000, 480000000)
_VFO_DEFAULT = 439000000
- _IDENT = "\xFF\xF4\x44\xFF"
+ _IDENT = b"\xFF\xF4\x44\xFF"
diff --git a/chirp/drivers/ft1500m.py b/chirp/drivers/ft1500m.py
index 16778f4..3f12ff0 100644
--- a/chirp/drivers/ft1500m.py
+++ b/chirp/drivers/ft1500m.py
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# FT-1500M Clone Proceedure
+# FT-1500M Clone Procedure
# 1. Turn radio off.
# 2. Connect cable to mic jack.
# 3. Press and hold in the [MHz],[LOW] and [D/MR] keys
diff --git a/chirp/drivers/ft1802.py b/chirp/drivers/ft1802.py
index 952a23c..bad0863 100644
--- a/chirp/drivers/ft1802.py
+++ b/chirp/drivers/ft1802.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# FT-1802 Clone Proceedure
+# FT-1802 Clone Procedure
# 1. Turn radio off.
# 2. Connect cable to mic jack.
# 3. Press and hold in the [LOW(A/N)] key while turning the radio on.
diff --git a/chirp/drivers/ft1d.py b/chirp/drivers/ft1d.py
index 06a20ed..9f325e6 100644
--- a/chirp/drivers/ft1d.py
+++ b/chirp/drivers/ft1d.py
@@ -338,7 +338,7 @@ struct {
char dst_callsign[9];
char path[30];
u16 flags;
- u8 seperator;
+ u8 separator;
char body[%d];
} aprs_beacon_pkt[%d];
diff --git a/chirp/drivers/ft2800.py b/chirp/drivers/ft2800.py
index 9030e96..28cabf7 100644
--- a/chirp/drivers/ft2800.py
+++ b/chirp/drivers/ft2800.py
@@ -18,7 +18,7 @@ import os
import logging
from chirp import util, memmap, chirp_common, bitwise, directory, errors
-from yaesu_clone import YaesuCloneModeRadio
+from chirp.drivers.yaesu_clone import YaesuCloneModeRadio
LOG = logging.getLogger(__name__)
@@ -101,7 +101,7 @@ def _upload(radio):
raise Exception("Radio did not ack ID")
block = 0
- while block < (radio.get_memsize() / 32):
+ while block < (radio.get_memsize() // 32):
data = "\x0C\x03\x00\x00" + chr(block)
data += radio.get_mmap()[block*32:(block+1)*32]
cs = 0
@@ -201,7 +201,7 @@ class FT2800Radio(YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Downloaded in %.2f sec" % (time.time() - start))
self.process_mmap()
@@ -214,7 +214,7 @@ class FT2800Radio(YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Uploaded in %.2f sec" % (time.time() - start))
@@ -253,12 +253,12 @@ class FT2800Radio(YaesuCloneModeRadio):
_nam = self._memobj.names[mem.number]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
if _mem.get_raw()[0] == "\xFF":
- # Emtpy -> Non-empty, so initialize
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ # Empty -> Non-empty, so initialize
+ _mem.set_raw("\x00" * (_mem.size() // 8))
_mem.freq = mem.freq / 10
_mem.offset = mem.offset / 100000
diff --git a/chirp/drivers/ft2900.py b/chirp/drivers/ft2900.py
index a7ad33d..3b34c46 100644
--- a/chirp/drivers/ft2900.py
+++ b/chirp/drivers/ft2900.py
@@ -395,7 +395,7 @@ def _encode_name(mem):
def _wipe_memory(mem):
- mem.set_raw("\xff" * (mem.size() / 8))
+ mem.set_raw("\xff" * (mem.size() // 8))
class FT2900Bank(chirp_common.NamedBank):
@@ -537,7 +537,7 @@ class FT2900Radio(YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Downloaded in %.2f sec" % (time.time() - start))
self.process_mmap()
@@ -549,7 +549,7 @@ class FT2900Radio(YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Uploaded in %.2f sec" % (time.time() - start))
@@ -1210,7 +1210,7 @@ class FT2900Radio(YaesuCloneModeRadio):
setattr(_settings, name, value)
LOG.debug("Setting %s: %s" % (name, value))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -1254,3 +1254,18 @@ class FT2900ERadio(FT2900Radio):
MODEL = "FT-2900E/1900E"
VARIANT = "E"
IDBLOCK = "\x56\x43\x32\x33\x00\x02\x41\x02\x01\x01"
+
+
+# This class is for the TX Modified FT-1900/FT-2900 (MARS/CAP Mod).
+# Enabling out of band TX changes the header received by CHIRP
+@directory.register
+class FT2900ModRadio(FT2900Radio):
+
+ """Yaesu FT-2900Mod"""
+ MODEL = "FT-2900R/1900R(TXMod)"
+ VARIANT = "Opened Xmit"
+ IDBLOCK = "\x56\x43\x32\x33\x00\x02\xc7\x01\x01\x01"
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return False
diff --git a/chirp/drivers/ft2d.py b/chirp/drivers/ft2d.py
index 6c15f16..1bbc000 100644
--- a/chirp/drivers/ft2d.py
+++ b/chirp/drivers/ft2d.py
@@ -152,7 +152,7 @@ class FT2D(ft1d.FT1Radio):
@directory.register
class FT2Dv2(FT2D):
- """Yaesu FT-2D v2 firwmare"""
+ """Yaesu FT-2D v2 firmware"""
VARIANT = "Rv2"
_model = "AH60G"
diff --git a/chirp/drivers/ft4.py b/chirp/drivers/ft4.py
index 0b7f319..b625347 100644
--- a/chirp/drivers/ft4.py
+++ b/chirp/drivers/ft4.py
@@ -469,12 +469,25 @@ class YaesuSC35GenericBankModel(chirp_common.BankModel):
# the values in these lists must also be in the canonical UI list
# we can re-arrange the order, and we don't need to have all
# the values, but we cannot add our own values here.
-DUPLEX = ["+", "", "-", "", "off", "", "split"] # (0,2,4,5)= (+,-,0, auto)
-# the radio implements duplex "auto" as 5. we map to "" It appears to be
-# a convienience function in the radio that affects the offset, but I do not
-# understand it.
-SKIPS = ["", "S"]
+DUPLEX = ["+", "", "-", "", "off", "", "split"] # (0,2,4,5) = (+, -, 0, auto)
+# The radio implements duplex "auto" as 5. We map to "". It is a convenience
+# function in the radio that affects the offset, which sets the duplex value
+# according to the frequency in use. Yaesu doesn't entirely adhere to the band
+# plans; but worse, they save the value 'auto' instead of + or -. Why Yaesu
+# is doing such a thing is beyond me. [AE6YN]
+DUPLEX_AUTO_US = [
+ [145100000, 145495000, 2],
+ [146000000, 146395000, 0],
+ [146600000, 146995000, 2],
+ [147000000, 147395000, 0],
+ [147600000, 147995000, 2]]
+# (There are no automatic duplex values in IARU-2 70CM.)
+DUPLEX_AUTO_EU = [
+ [145600000, 145800000, 2],
+ [438200000, 439425000, 2]]
+
+SKIPS = ["S", ""]
POWER_LEVELS = [
chirp_common.PowerLevel("High", watts=5.0), # high must be first (0)
@@ -558,7 +571,7 @@ CHARSET = CW_ID_CHARS + "abcdefghijklmnopqrstuvwxyz*+-/@"
PMSNAMES = ["%s%02d" % (c, i) for i in range(1, 11) for c in ('L', 'U')]
# Four separate arrays of special channel mems.
-# Each special has unique constrants: band, name yes/no, and pms L/U
+# Each special has unique constraints: band, name yes/no, and pms L/U
# The FT-65 class replaces the "prog" entry in this list.
# The name field must be the name of a slot array in MEM_FORMAT
SPECIALS_FT4 = [
@@ -722,8 +735,8 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
# callback for setting byte arrays: DTMF[0-9], passwd, and CW_ID
def apply_str_to_bytearray(self, element, obj):
lng = len(obj)
- strng = (element.value.get_value() + " ")[:lng]
- bytes = bytearray(strng, "ascii")
+ string = (element.value.get_value() + " ")[:lng]
+ bytes = bytearray(string, "ascii")
for x in range(0, lng): # memobj cannot iterate, so byte-by-byte
obj[x] = bytes[x]
return
@@ -807,7 +820,7 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
("apo", "Automatic Power Off",
["OFF"] + ["%0.1f" % (x * 0.5) for x in range(1, 24 + 1)]),
("bclo", "Busy Channel Lock-Out", ["OFF", "ON"]),
- ("beep", "Enable the Beeper", ["OFF", "KEY", "KEY+SC"]),
+ ("beep", "Enable the Beeper", ["KEY+SC", "KEY", "OFF"]),
("bsy_led", "Busy LED", ["ON", "OFF"]),
("edg_beep", "Band Edge Beeper", ["OFF", "ON"]),
("vox", "VOX", ["OFF", "ON"]),
@@ -1047,6 +1060,17 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
name += chr(y)
return name.rstrip()
+ def get_duplex(freq): # auto duplex to real duplex
+ """
+ Select the duplex direction if duplex == 'auto'.
+ 0 is +, 2 is -, and 4 is none.
+ """
+ return_value = 4 # off, if not in auto range
+ for x in self.DUPLEX_AUTO:
+ if freq in range(x[0], x[1]):
+ return_value = x[2]
+ return return_value
+
mem = chirp_common.Memory()
_mem, ndx, num, regtype, sname = self.slotloc(memref)
mem.number = num
@@ -1081,12 +1105,14 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
else:
mem.freq = int(_mem.freq) * 10
txfreq = int(self._memobj.txfreqs[ndx].freq) * 10
- if (txfreq != 0) and (txfreq != mem.freq):
- mem.duplex = "split"
+ if _mem.duplex == 5: # auto offset
+ mem.duplex = DUPLEX[get_duplex(mem.freq)]
+ else:
+ mem.duplex = DUPLEX[_mem.duplex]
+ if _mem.duplex == 6: # split: offset is tx frequency
mem.offset = txfreq
else:
mem.offset = int(_mem.offset) * self.freq_offset_scale
- mem.duplex = DUPLEX[_mem.duplex]
self.decode_sql(mem, _mem)
mem.power = POWER_LEVELS[2 - _mem.tx_pwr]
mem.mode = ["FM", "NFM"][_mem.tx_width]
@@ -1137,7 +1163,6 @@ class YaesuSC35GenericRadio(chirp_common.CloneModeRadio,
self._memobj.names[ndx].chrs = bytearray(nametrim, "ascii")
if mem.duplex == "split":
txfreq = mem.offset / 10
- duplex = "off" # radio ignores when tx != rx
self._memobj.txfreqs[num-1].freq = txfreq
_mem.duplex = DUPLEX.index(duplex)
if regtype in ["vfo", "home"]:
@@ -1210,6 +1235,7 @@ class YaesuFT4XRRadio(YaesuFT4GenericRadio):
MODEL = "FT-4XR"
id_str = b'IFT-35R\x00\x00V100\x00\x00'
valid_bands = VALID_BANDS_DUAL
+ DUPLEX_AUTO = DUPLEX_AUTO_US
legal_steps = US_LEGAL_STEPS
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_DUALBAND
@@ -1222,6 +1248,7 @@ class YaesuFT4XERadio(YaesuFT4GenericRadio):
MODEL = "FT-4XE"
id_str = b'IFT-35R\x00\x00V100\x00\x00'
valid_bands = VALID_BANDS_DUAL
+ DUPLEX_AUTO = DUPLEX_AUTO_EU
legal_steps = STEP_CODE
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_DUALBAND
@@ -1234,6 +1261,7 @@ class YaesuFT4VRRadio(YaesuFT4GenericRadio):
MODEL = "FT-4VR"
id_str = b'IFT-15R\x00\x00V100\x00\x00'
valid_bands = VALID_BANDS_VHF
+ DUPLEX_AUTO = DUPLEX_AUTO_US
legal_steps = US_LEGAL_STEPS
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_MONO_VHF
@@ -1247,6 +1275,7 @@ class YaesuFT4VRRadio(YaesuFT4GenericRadio):
# MODEL = "FT-4VE"
# id_str = b'IFT-15R\x00\x00V100\x00\x00'
# valid_bands = VALID_BANDS_VHF
+# DUPLEX_AUTO = DUPLEX_AUTO_EU
# legal_steps = STEP_CODE
# BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_MONO_VHF
@@ -1259,7 +1288,8 @@ class YaesuFT65RRadio(YaesuFT65GenericRadio):
MODEL = "FT-65R"
id_str = b'IH-420\x00\x00\x00V100\x00\x00'
valid_bands = VALID_BANDS_DUAL
- legal_steps = US_LEGAL_STEPS
+ DUPLEX_AUTO = DUPLEX_AUTO_US
+ legal_steps = STEP_CODE
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_DUALBAND
@@ -1271,6 +1301,7 @@ class YaesuFT65ERadio(YaesuFT65GenericRadio):
MODEL = "FT-65E"
id_str = b'IH-420\x00\x00\x00V100\x00\x00'
valid_bands = VALID_BANDS_DUAL
+ DUPLEX_AUTO = DUPLEX_AUTO_EU
legal_steps = STEP_CODE
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_DUALBAND
@@ -1283,6 +1314,7 @@ class YaesuFT25RRadio(YaesuFT65GenericRadio):
MODEL = "FT-25R"
id_str = b'IFT-25R\x00\x00V100\x00\x00'
valid_bands = VALID_BANDS_VHF
+ DUPLEX_AUTO = DUPLEX_AUTO_US
legal_steps = US_LEGAL_STEPS
BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_MONO_VHF
@@ -1296,5 +1328,6 @@ class YaesuFT25RRadio(YaesuFT65GenericRadio):
# MODEL = "FT-25E"
# id_str = b'IFT-25R\x00\x00V100\x00\x00'
# valid_bands = VALID_BANDS_VHF
+# DUPLEX_AUTO = DUPLEX_AUTO_EU
# legal_steps = STEP_CODE
# BAND_ASSIGNMENTS = BAND_ASSIGNMENTS_MONO_VHF
diff --git a/chirp/drivers/ft450d.py b/chirp/drivers/ft450d.py
index 6664f77..e5a1ee9 100644
--- a/chirp/drivers/ft450d.py
+++ b/chirp/drivers/ft450d.py
@@ -1,4 +1,5 @@
# Copyright 2018 by Rick DeWitt (aa0rd@yahoo.com>
+# Bug fix for issue #8183, invalid APO Off value
# Thanks to Filippi Marco <iz3gme.marco@gmail.com> for Yaesu processes
#
# This program is free software: you can redistribute it and/or modify
@@ -288,7 +289,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
#seekto 0x3C3;
struct mem_struct memory[500];
- struct mem_struct pms[4]; // Programed Scan limits @ x387F
+ struct mem_struct pms[4]; // Programmed Scan limits @ x387F
#seekto 0x3906;
struct {
@@ -377,7 +378,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
50m HOME memories and all the A and B VFO memories.
There are VFO memories for the last frequency dialed in
each band. The last mem-tune config is also stored.
- These Special Channels allow limited field editting.
+ These Special Channels allow limited field editing.
This driver also populates the 'Other' tab in the channel
memory Properties window. This tab contains values for
those channel memory settings that don't fall under the
@@ -553,7 +554,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
if isinstance(number, str):
return self._get_special(number)
elif number < 0:
- # I can't stop delete operation from loosing extd_number but
+ # I can't stop delete operation from losing extd_number but
# I know how to get it back
return self._get_special(self.SPECIAL_MEMORIES_REV[number])
else:
@@ -920,7 +921,7 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
for setting in mem.extra:
if setting.get_name() == "notch_pos":
- vx = 0 # Overide list string with signed value
+ vx = 0 # Override list string with signed value
stx = str(setting.value)
if stx == "<-":
vx = -13
@@ -1007,9 +1008,9 @@ class FT450DRadio(yaesu_clone.YaesuCloneModeRadio):
RadioSettingValueBoolean(_settings.ext_mnu))
rs.set_doc("Enables access to extended settings in the radio")
tab.append(rs)
-
+ # Issue #8183 bugfix
rs = RadioSetting("apo", "APO time (Hrs)",
- RadioSettingValueInteger(1, 12, _settings.apo))
+ RadioSettingValueInteger(0, 12, _settings.apo))
tab.append(rs)
options = ["%i" % i for i in range(0, 21)]
diff --git a/chirp/drivers/ft50.py b/chirp/drivers/ft50.py
index 9f28110..ef86ca2 100644
--- a/chirp/drivers/ft50.py
+++ b/chirp/drivers/ft50.py
@@ -162,7 +162,7 @@ TONES = list(chirp_common.OLD_TONES)
# the = displays as an underscored dash on radio
# the first ? is an uppercase delta - \xA7
# the second ? is an uppercase gamma - \xD1
-# the thrid ? is an uppercase sigma - \xCF
+# the third ? is an uppercase sigma - \xCF
NUMERIC_CHARSET = list("0123456789")
CHARSET = [str(x) for x in range(0, 10)] + \
[chr(x) for x in range(ord("A"), ord("Z")+1)] + \
@@ -218,7 +218,7 @@ class FT50Radio(yaesu_clone.YaesuCloneModeRadio):
rf.valid_characters = "".join(CHARSET)
rf.valid_name_length = 4
rf.valid_modes = MODES
- # Specials not yet implementd
+ # Specials not yet implemented
# rf.valid_special_chans = SPECIALS
rf.valid_bands = [(76000000, 200000000),
(300000000, 540000000),
@@ -586,7 +586,7 @@ class FT50Radio(yaesu_clone.YaesuCloneModeRadio):
def _clone_out(radio):
try:
return __clone_out(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
diff --git a/chirp/drivers/ft60.py b/chirp/drivers/ft60.py
index 3c00d84..7c2cfd7 100644
--- a/chirp/drivers/ft60.py
+++ b/chirp/drivers/ft60.py
@@ -286,7 +286,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.0),
STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0]
SKIPS = ["", "S", "P"]
DTMF_CHARS = list("0123456789ABCD*#")
-CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ [?]^__|`?$%&-()*+,-,/|;/=>?@"
+CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ !`o$%&'()*+,-./|;/=>?@[u]^_"
SPECIALS = ["%s%d" % (c, i + 1) for i in range(0, 50) for c in ('L', 'U')]
@@ -345,7 +345,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
BAUD_RATE = 9600
VENDOR = "Yaesu"
MODEL = "FT-60"
- _model = "AH017"
+ _model = b"AH017"
_memsize = 28617
@@ -403,7 +403,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
self.check_checksums()
@@ -414,7 +414,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
@@ -627,7 +627,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
# RXSAVE
opts = ["OFF", "200 MS", "300 MS", "500 MS", "1 S", "2 S"]
power.append(RadioSetting(
- "rxsave", "Receive Mode Batery Savery Interval",
+ "rxsave", "Receive Mode Battery Savery Interval",
RadioSettingValueList(opts, opts[_settings.rxsave])))
# S.SRCH
@@ -716,7 +716,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio):
setattr(_settings, name, value)
LOG.debug("Setting %s: %s" % (name, value))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft70.py b/chirp/drivers/ft70.py
index 20d1000..3db601f 100644
--- a/chirp/drivers/ft70.py
+++ b/chirp/drivers/ft70.py
@@ -1,1191 +1,1191 @@
-# Copyright 2010 Dan Smith <dsmith@danplanet.com>
-# Copyright 2017 Nicolas Pike <nick@zbm2.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import logging
-
-from chirp.drivers import yaesu_clone
-from chirp import chirp_common, directory, bitwise
-from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \
- RadioSettingValueInteger, RadioSettingValueString, \
- RadioSettingValueList, RadioSettingValueBoolean, \
- InvalidValueError
-from textwrap import dedent
-import string
-LOG = logging.getLogger(__name__)
-
-# Testing
-
-# 37 PAG.ABK Turn the pager answer back Function ON/OFF
-# 38 PAG.CDR Specify a personal code (receive)
-# 39 PAG.CDT Specify a personal code (transmit)
-# 47 RX.MOD Select the receive mode. Auto FM AM
-
-MEM_SETTINGS_FORMAT = """
-
-// FT-70DE New Model #5329
-//
-// Communications Mode ? AMS,FM DN,DW TX vs RX?
-// Mode not currently correctly stored in memories ? - ALL show as FM in memories
-// SKIP test/where stored
-// Check storage of steps
-// Pager settings ?
-// Triple check/ understand _memsize and _block_lengths
-// Bank name label name size display 6 store 16? padded with 0xFF same for MYCALL and message
-// CHIRP mode DIG not supported - is there a CHIRP Fusion mode? Auto?
-// Check character set
-// Supported Modes ?
-// Supported Bands ?
-// rf.has_dtcs_polarity = False - think radio supports DTCS polarity
-// rf.memory_bounds = (1, 900) - should this be 0? as zero displays as blank
-// RPT offsets (stored per band) not included.
-// 59 Display radio firmware version info and Radio ID?
-// Front Panel settings power etc?
-// Banks and VFO?
-
-// Features Required
-// Default AMS and Memory name (in mem extras) to enabled.
-
-// Bugs
-// MYCALL and Opening Message errors if not 10 characters
-// Values greater than one sometimes stored as whole bytes, these need to be refactored into bit fields
-// to prevent accidental overwriting of adjacent values
-// Bank Name length not checked on gui input - but first 6 characters are saved correctly.
-// Extended characters entered as bank names on radio are corrupted in Chirp
-
-// Missing
-// 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL - NOT FOUND
-// 49 SCM.WTH Set the memory scan frequency range. ALL / BAND - NOT FOUND
-
-// Radio Questions
-// Temp unit C/F not saved by radio, always goes back to C ?
-// 44 RF SQL Adjusts the RF Squelch threshold level. OFF / S1 - S9? Default is OFF - Based on RF strength - for AM? How
-// is this different from F, Monitor, Dial Squelch?
-// Password setting on radio allows letters (DTMF), but letters cannot be entered at the radio's password prompt?
-// 49 SCM.WTH Set the memory scan frequency range. ALL / BAND Defaults to ALL Not Band as stated in the manual.
-
- #seekto 0x049a;
- struct {
- u8 unknown0:4,
- squelch:4; // Squelch F, Monitor, Dial Adjust the Squelch level
- } squelch_settings;
-
- #seekto 0x04ba;
- struct {
- u8 unknown:3,
- scan_resume:5; // 52 SCN.RSM Configure the scan stop mode settings. 2.0 S - 5.0 S - 10.0 S / BUSY / HOLD
- u8 unknown1:3,
- dw_resume_interval:5; // 22 DW RSM Configure the scan stop mode settings for Dual Receive. 2.0S-10.0S/BUSY/HOLD
- u8 unknown2;
- u8 unknown3:3,
- apo:5; // 02 APO Set the length of time until the transceiver turns off automatically.
- u8 unknown4:6,
- gm_ring:2; // 24 GM RNG Select the beep option while receiving digital GM info. OFF/IN RNG/ALWAYS
- u8 temp_cf; // Placeholder as not found
- u8 unknown5;
- } first_settings;
-
- #seekto 0x04ed;
- struct {
- u8 unknown1:1,
- unknown2:1,
- unknown3:1,
- unknown4:1,
- unknown5:1,
- unknown6:1,
- unknown7:1,
- unknown8:1;
- } test_bit_field;
-
- #seekto 0x04c0;
- struct {
- u8 unknown1:5,
- beep_level:3; // 05 BEP.LVL Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
- u8 unknown2:6,
- beep_select:2; // 04 BEEP Sets the beep sound function OFF / KEY+SC / KEY
- } beep_settings;
-
- #seekto 0x04ce;
- struct {
- u8 lcd_dimmer; // 14 DIMMER LCD Dimmer
- u8 dtmf_delay; // 18 DT DLY DTMF delay
- u8 unknown0[3];
- u8 unknown1:4,
- unknown1:4;
- u8 lamp; // 28 LAMP Set the duration time of the backlight and keys to be lit
- u8 lock; // 30 LOCK Configure the lock mode setting. KEY/DIAL/K+D/PTT/K+P/D+P/ALL
- u8 unknown2_1;
- u8 mic_gain; // 31 MCGAIN Adjust the microphone gain level
- u8 unknown2_3;
- u8 dw_interval; // 21 DW INT Set the priority memory ch mon int during Dual RX 0.1S-5.0S-10.0S
- u8 ptt_delay; // 42 PTT.DLY Set the PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS
- u8 rx_save; // 48 RX.SAVE Set the battery save time. OFF / 0.2 S - 60.0 S
- u8 scan_restart; // 53 SCN.STR Set the scanning restart time. 0.1 S - 2.0 S - 10.0 S
- u8 unknown2_5;
- u8 unknown2_6;
- u8 unknown4[5];
- u8 tot; // 56 TOT Set the transmission timeout timer
- u8 unknown5[3]; // 26
- u8 vfo_mode:1, // 60 VFO.MOD Set freq setting range in the VFO mode by DIAL knob. ALL / BAND
- unknown7:1,
- scan_lamp:1, // 51 SCN.LMP Set the scan lamp ON or OFF when scanning stops On/Off
- unknown8:1,
- ars:1, // 45 RPT.ARS Turn the ARS function on/off.
- dtmf_speed:1, // 20 DT SPD Set DTMF speed
- unknown8:1,
- dtmf_mode:1; // DTMF Mode set from front panel
- u8 busy_led:1, // Not Supported ?
- unknown8_2:1,
- unknown8_3:1,
- bclo:1, // 03 BCLO Turns the busy channel lockout function on/off.
- beep_edge:1, // 06 BEP.Edg Sets the beep sound ON or OFF when a band edge is encountered.
- unknown8_6:1,
- unknown8_7:1,
- unknown8_8:1; // 28
- u8 unknown9_1:1,
- unknown9_2:1,
- unknown9_3:1,
- unknown9_4:1,
- unknown9_5:1,
- password:1, // Placeholder location
- home_rev:1, // 26 HOME/REV Select the function of the [HOME/REV] key.
- moni:1; // 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
- u8 gm_interval:4, // 30 // 25 GM INT Set tx interval of digital GM information. OFF / NORMAL / LONG
- unknown10:4;
- u8 unknown11;
- u8 unknown12:1,
- unknown12_2:1,
- unknown12_3:1,
- unknown12_4:1,
- home_vfo:1, // 27 HOME->VFO Turn transfer VFO to the Home channel ON or OFF.
- unknown12_6:1,
- unknown12_7:1,
- dw_rt:1; // 32 // 23 DW RVT Turn "Priority Channel Revert" feature ON or OFF during Dual Rx.
- u8 unknown33;
- u8 unknown34;
- u8 unknown35;
- u8 unknown36;
- u8 unknown37;
- u8 unknown38;
- u8 unknown39;
- u8 unknown40;
- u8 unknown41;
- u8 unknown42;
- u8 unknown43;
- u8 unknown44;
- u8 unknown45;
- u8 prog_key1; // P1 Set Mode Items to the Programmable Key
- u8 prog_key2; // P2 Set Mode Items to the Programmable Key
- u8 unknown48;
- u8 unknown49;
- u8 unknown50;
- } scan_settings;
-
- #seekto 0x064b;
- struct {
- u8 unknown1:1,
- unknown2:1,
- unknown3:1,
- unknown4:1,
- vfo_scan_width:1, // Placeholder as not found - 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL
- memory_scan_width:1, // Placeholder as not found - 49 SCM.WTH Set the memory scan frequency range. ALL / BAND
- unknown7:1,
- unknown8:1;
- } scan_settings_1;
-
- #seekto 0x06B6;
- struct {
- u8 unknown1:3,
- volume:5; // # VOL and Dial Adjust the volume level
- } scan_settings_2;
-
- #seekto 0x0690; // Memory or VFO Settings Map?
- struct {
- u8 unknown[48]; // Array cannot be 64 elements!
- u8 unknown1[16]; // Exception: Not implemented for chirp.bitwise.structDataElement
- } vfo_info_1;
-
- #seekto 0x0710; // Backup Memory or VFO Settings Map?
- struct {
- u8 unknown[48];
- u8 unknown1[16];
- } vfo_backup_info_1;
-
- #seekto 0x047e;
- struct {
- u8 unknown1;
- u8 flag;
- u16 unknown2;
- struct {
- char padded_string[6]; // 36 OPN.MSG Select MSG then key vm to edit it
- } message;
- } opening_message; // 36 OPN.MSG Select the Opening Message when transceiver is ON. OFF/MSG/DC
-
- #seekto 0x094a; // DTMF Memories
- struct {
- u8 memory[16];
- } dtmf[10];
-
- #seekto 0x154a;
- struct {
- u16 channel[100];
- } bank_members[24];
-
- #seekto 0x54a;
- struct {
- u16 in_use;
- } bank_used[24];
-
- #seekto 0x0EFE;
- struct {
- u8 unknown[2];
- u8 name[6];
- u8 unknown1[10];
- } bank_info[24];
-
- #seekto 0xCF30;
- struct {
- u8 unknown0;
- u8 unknown1;
- u8 unknown2;
- u8 unknown3;
- u8 unknown4;
- u8 unknown5;
- u8 unknown6;
- u8 digital_popup; // 15 DIG.POP Call sign display pop up time
- } digital_settings_more;
-
- #seekto 0xCF7C;
- struct {
- u8 unknown0:6,
- ams_tx_mode:2; // AMS TX Mode Short Press AMS button AMS TX Mode
- u8 unknown1;
- u8 unknown2:7,
- standby_beep:1; // 07 BEP.STB Standby Beep in the digital C4FM mode. On/Off
- u8 unknown3;
- u8 unknown4:6,
- gm_ring:2; // 24 GM RNG Select beep option while rx digital GM info. OFF/IN RNG/ALWAYS
- u8 unknown5;
- u8 rx_dg_id; // RX DG-ID Long Press Mode Key, Mode Key to select, Dial
- u8 tx_dg_id; // TX DG-ID Long Press Mode Key, Dial
- u8 unknown6:7,
- vw_mode:1; // 16 DIG VW Turn the VW mode selection ON or OFF
- u8 unknown7;
- } digital_settings;
-
- // ^^^ All above referenced U8's have been refactored to minimum number of bits.
-
- """
-
-MEM_FORMAT = """
- #seekto 0x2D4A;
- struct { // 32 Bytes per memory entry
- u8 display_tag:1, // 0 Display Freq, 1 Display Name
- unknown0:1, // Mode if AMS not selected????????
- deviation:1, // 0 Full deviation (Wide), 1 Half deviation (Narrow)
- clock_shift:1, // 0 None, 1 CPU clock shifted
- unknown1:4; // 1
- u8 mode:2, // FM,AM,WFM only? - check
- duplex:2, // Works
- tune_step:4; // Works - check all steps? 7 = Auto // 1
- bbcd freq[3]; // Works // 3
- u8 power:2, // Works
- unknown2:1, // 0 FM, 1 Digital - If AMS off
- ams:1, // 0 AMS off, 1 AMS on ?
- tone_mode:4; // Works // 1
- u8 charsetbits[2]; // 2
- char label[6]; // Works - Can only input 6 on screen // 6
- char unknown7[10]; // Rest of label ??? // 10
- bbcd offset[3]; // Works // 3
- u8 unknown5:2,
- tone:6; // Works // 1
- u8 unknown6:1,
- dcs:7; // Works // 1
- u8 unknown9;
- u8 ams_on_dn_vw_fm:2, // AMS DN, AMS VW, AMS FM
- unknown8_3:1,
- unknown8_4:1,
- unknown8_5:1,
- unknown8_6:1,
- unknown8_7:1,
- unknown8_8:1;
- u8 unknown10;
- } memory[%d]; // DN, VW, FM, AM
- // AMS DN, AMS VW, AMS FM
-
- #seekto 0x280A;
- struct {
- u8 nosubvfo:1,
- unknown:3,
- pskip:1, // PSkip (Select?)
- skip:1, // Skip memory during scan
- used:1, // Memory used
- valid:1; // Aways 1?
- } flag[%d];
- """
-
-MEM_CALLSIGN_FORMAT = """
-#seekto 0x0ced0;
- struct {
- char callsign[10]; // 63 MYCALL Set the call sign. (up to 10 characters)
- u16 charset; // character set ID
- } my_call;
- """
-
-MEM_CHECKSUM_FORMAT = """
- #seekto 0xFECA;
- u8 checksum;
- """
-
-TMODES = ["", "Tone", "TSQL", "DTCS"]
-DUPLEX = ["", "-", "+", "split"]
-
-MODES = ["FM", "AM"]
-
-STEPS = [0, 5, 6.25, 10, 12.5, 15, 20, 25, 50, 100] # 0 = auto
-RFSQUELCH = ["OFF", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8"]
-
-SKIPS = ["", "S", "P"]
-FT70_DTMF_CHARS = list("0123456789ABCDEF-")
-
-CHARSET = ["%i" % int(x) for x in range(0, 10)] + \
- [chr(x) for x in range(ord("A"), ord("Z") + 1)] + \
- [" ", ] + \
- [chr(x) for x in range(ord("a"), ord("z") + 1)] + \
- list(".,:;*#_-/&()@!?^ ") + list("\x00" * 100)
-
-POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00),
- chirp_common.PowerLevel("Mid", watts=2.00),
- chirp_common.PowerLevel("Low", watts=.50)]
-
-
-class FT70Bank(chirp_common.NamedBank):
- """A FT70 bank"""
-
- def get_name(self):
- _bank = self._model._radio._memobj.bank_info[self.index]
- name = ""
- for i in _bank.name:
- if i == 0xff:
- break
- name += chr(i & 0xFF)
- return name.rstrip()
-
- def set_name(self, name):
- _bank = self._model._radio._memobj.bank_info[self.index]
- _bank.name = [ord(x) for x in name.ljust(6, chr(0xFF))[:6]]
-
-
-class FT70BankModel(chirp_common.BankModel):
- """A FT70 bank model"""
-
- def __init__(self, radio, name='Banks'):
- super(FT70BankModel, self).__init__(radio, name)
-
- _banks = self._radio._memobj.bank_info
- self._bank_mappings = []
- for index, _bank in enumerate(_banks):
- bank = FT70Bank(self, "%i" % index, "BANK-%i" % index)
- bank.index = index
- self._bank_mappings.append(bank)
-
- def get_num_mappings(self):
- return len(self._bank_mappings)
-
- def get_mappings(self):
- return self._bank_mappings
-
- def _channel_numbers_in_bank(self, bank):
- _bank_used = self._radio._memobj.bank_used[bank.index]
- if _bank_used.in_use == 0xFFFF:
- return set()
-
- _members = self._radio._memobj.bank_members[bank.index]
- return set([int(ch) + 1 for ch in _members.channel if ch != 0xFFFF])
-
- def _update_bank_with_channel_numbers(self, bank, channels_in_bank):
- _members = self._radio._memobj.bank_members[bank.index]
- if len(channels_in_bank) > len(_members.channel):
- raise Exception("Too many entries in bank %d" % bank.index)
-
- empty = 0
- for index, channel_number in enumerate(sorted(channels_in_bank)):
- _members.channel[index] = channel_number - 1
- empty = index + 1
- for index in range(empty, len(_members.channel)):
- _members.channel[index] = 0xFFFF
-
- def add_memory_to_mapping(self, memory, bank):
- channels_in_bank = self._channel_numbers_in_bank(bank)
- channels_in_bank.add(memory.number)
- self._update_bank_with_channel_numbers(bank, channels_in_bank)
-
- _bank_used = self._radio._memobj.bank_used[bank.index]
- _bank_used.in_use = 0x06
-
- def remove_memory_from_mapping(self, memory, bank):
- channels_in_bank = self._channel_numbers_in_bank(bank)
- try:
- channels_in_bank.remove(memory.number)
- except KeyError:
- raise Exception("Memory %i is not in bank %s. Cannot remove" %
- (memory.number, bank))
- self._update_bank_with_channel_numbers(bank, channels_in_bank)
-
- if not channels_in_bank:
- _bank_used = self._radio._memobj.bank_used[bank.index]
- _bank_used.in_use = 0xFFFF
-
- def get_mapping_memories(self, bank):
- memories = []
- for channel in self._channel_numbers_in_bank(bank):
- memories.append(self._radio.get_memory(channel))
-
- return memories
-
- def get_memory_mappings(self, memory):
- banks = []
- for bank in self.get_mappings():
- if memory.number in self._channel_numbers_in_bank(bank):
- banks.append(bank)
-
- return banks
-
-
-@directory.register
-class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
- """Yaesu FT-70DE"""
- BAUD_RATE = 38400
- VENDOR = "Yaesu"
- MODEL = "FT-70D"
-
- _model = "AH51G"
-
- _memsize = 65227 # 65227 read from dump
- _block_lengths = [10, 65217]
- _block_size = 32
- _mem_params = (900, # size of memories array
- 900, # size of flags array
- )
-
- _has_vibrate = False
- _has_af_dual = True
-
- _BEEP_SELECT = ("Off", "Key+Scan", "Key")
- _OPENING_MESSAGE = ("Off", "DC", "Message")
- _MIC_GAIN = ("Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7", "Level 8", "Level 9")
- _AMS_TX_MODE = ("TX Auto", "TX DIGITAL", "TX FM")
- _VW_MODE = ("On", "Off")
- _DIG_POP_UP = ("Off", "2sec", "4sec", "6sec", "8sec", "10sec", "20sec", "30sec", "60sec", "Continuous")
- _STANDBY_BEEP = ("On", "Off")
- _SCAN_RESUME = ["%.1fs" % (0.5 * x) for x in range(4, 21)] + \
- ["Busy", "Hold"]
- _SCAN_RESTART = ["%.1fs" % (0.1 * x) for x in range(1, 10)] + \
- ["%.1fs" % (0.5 * x) for x in range(2, 21)]
- _LAMP_KEY = ["Key %d sec" % x
- for x in range(2, 11)] + ["Continuous", "OFF"]
- _LCD_DIMMER = ["Level %d" % x for x in range(1, 7)]
- _TOT_TIME = ["Off"] + ["%.1f min" % (0.5 * x) for x in range(1, 21)]
- _OFF_ON = ("Off", "On")
- _ON_OFF = ("On", "Off")
- _DTMF_MODE = ("Manual", "Auto")
- _DTMF_SPEED = ("50ms", "100ms")
- _DTMF_DELAY = ("50ms", "250ms", "450ms", "750ms", "1000ms")
- _TEMP_CF = ("Centigrade", "Fahrenheit")
- _APO_SELECT = ("Off", "0.5H", "1.0H", "1.5H", "2.0H", "2.5H", "3.0H", "3.5H", "4.0H", "4.5H", "5.0H",
- "5.5H", "6.0H", "6.5H", "7.0H", "7.5H", "8.0H", "8.5H", "9.0H", "9.5H", "10.0H", "10.5H",
- "11.0H", "11.5H", "12.0H")
- _MONI_TCALL = ("Monitor", "Tone-CALL")
- _HOME_REV = ("Home", "Reverse")
- _LOCK = ("KEY", "DIAL", "Key+Dial", "PTT", "Key+PTT", "Dial+PTT", "ALL")
- _PTT_DELAY = ("Off", "20 MS", "50 MS", "100 MS", "200 MS")
- _BEEP_LEVEL = ("Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7")
- _SET_MODE = ("Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7")
- _RX_SAVE = ("OFF", "0.2s", ".3s", ".4s", ".5s", ".6s", ".7s", ".8s", ".9s", "1.0s", "1.5s",
- "2.0s", "2.5s", "3.0s", "3.5s", "4.0s", "4.5s", "5.0s", "5.5s", "6.0s", "6.5s", "7.0s",
- "7.5s", "8.0s", "8.5s", "9.0s", "10.0s", "15s", "20s", "25s", "30s", "35s", "40s", "45s", "50s", "55s",
- "60s")
- _VFO_MODE = ("ALL", "BAND")
- _VFO_SCAN_MODE = ("BAND", "ALL")
- _MEMORY_SCAN_MODE = ("BAND", "ALL")
-
- _VOLUME = ["Level %d" % x for x in range(0, 32)]
- _SQUELCH = ["Level %d" % x for x in range(0, 16)]
-
- _DG_ID = ["%d" % x for x in range(0, 100)]
- _GM_RING = ("OFF", "IN RING", "AlWAYS")
- _GM_INTERVAL = ("LONG", "NORMAL", "OFF")
-
- _MYCALL_CHR_SET = list(string.uppercase) + list(string.digits) + ['-','/' ]
-
- @classmethod
- def get_prompts(cls):
- rp = chirp_common.RadioPrompts()
-
- rp.pre_download = _(dedent("""\
- 1. Turn radio on.
- 2. Connect cable to DATA terminal.
- 3. Unclip battery.
- 4. Press and hold in the [AMS] key and power key while clipping the battery back in
- ("ADMS" will appear on the display).
- 5. <b>After clicking OK</b>, press the [BAND] key."""
- ))
- rp.pre_upload = _(dedent("""\
- 1. Turn radio on.
- 2. Connect cable to DATA terminal.
- 3. Unclip battery.
- 4. Press and hold in the [AMS] key and power key while clipping the battery back in
- ("ADMS" will appear on the display).
- 5. Press the [MODE] key ("-WAIT-" will appear on the LCD). <b>Then click OK</b>"""))
- return rp
-
- def process_mmap(self):
-
- mem_format = MEM_SETTINGS_FORMAT + MEM_FORMAT + MEM_CALLSIGN_FORMAT + MEM_CHECKSUM_FORMAT
-
- self._memobj = bitwise.parse(mem_format % self._mem_params, self._mmap)
-
- def get_features(self):
- rf = chirp_common.RadioFeatures()
- rf.has_dtcs_polarity = False
- rf.valid_modes = list(MODES)
- rf.valid_tmodes = list(TMODES)
- rf.valid_duplexes = list(DUPLEX)
- rf.valid_tuning_steps = list(STEPS)
- rf.valid_bands = [(500000, 999900000)]
- rf.valid_skips = SKIPS
- rf.valid_power_levels = POWER_LEVELS
- rf.valid_characters = "".join(CHARSET)
- rf.valid_name_length = 6
- rf.memory_bounds = (1, 900)
- rf.can_odd_split = True
- rf.has_ctone = False
- rf.has_bank_names = True
- rf.has_settings = True
- return rf
-
- def get_raw_memory(self, number):
- return "\n".join([repr(self._memobj.memory[number - 1]),
- repr(self._memobj.flag[number - 1])])
-
- def _checksums(self):
- return [yaesu_clone.YaesuChecksum(0x0000, 0xFEC9)] # The whole file -2 bytes
-
- @staticmethod
- def _add_ff_pad(val, length):
- return val.ljust(length, "\xFF")[:length]
-
- @classmethod
- def _strip_ff_pads(cls, messages):
- result = []
- for msg_text in messages:
- result.append(str(msg_text).rstrip("\xFF"))
- return result
-
- def get_memory(self, number):
- flag = self._memobj.flag[number - 1]
- _mem = self._memobj.memory[number - 1]
-
- mem = chirp_common.Memory()
- mem.number = number
- if not flag.used:
- mem.empty = True
- if not flag.valid:
- mem.empty = True
- return mem
- mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) * 1000)
- mem.offset = int(_mem.offset) * 1000
- mem.rtone = mem.ctone = chirp_common.TONES[_mem.tone]
- self._get_tmode(mem, _mem)
- mem.duplex = DUPLEX[_mem.duplex]
- if mem.duplex == "split":
- mem.offset = chirp_common.fix_rounded_step(mem.offset)
- mem.mode = self._decode_mode(_mem)
- mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs]
- mem.tuning_step = STEPS[_mem.tune_step]
- mem.power = self._decode_power_level(_mem)
- mem.skip = flag.pskip and "P" or flag.skip and "S" or ""
- mem.name = self._decode_label(_mem)
-
- return mem
-
- def _decode_label(self, mem):
- return str(mem.label).rstrip("\xFF")
-
- def _encode_label(self, mem):
- return self._add_ff_pad(mem.name.rstrip(), 6)
-
- def _encode_charsetbits(self, mem):
- # We only speak english here in chirpville
- return [0x00, 0x00]
-
- def _decode_power_level(self, mem): # 3 High 2 Mid 1 Low
- return POWER_LEVELS[3 - mem.power]
-
- def _encode_power_level(self, mem):
- return 3 - POWER_LEVELS.index(mem.power)
-
- def _decode_mode(self, mem):
- return MODES[mem.mode]
-
- def _encode_mode(self, mem):
- return MODES.index(mem.mode)
-
- def _get_tmode(self, mem, _mem):
- mem.tmode = TMODES[_mem.tone_mode]
-
- def _set_tmode(self, _mem, mem):
- _mem.tone_mode = TMODES.index(mem.tmode)
-
- def _set_mode(self, _mem, mem):
- _mem.mode = self._encode_mode(mem)
-
- def _debank(self, mem):
- bm = self.get_bank_model()
- for bank in bm.get_memory_mappings(mem):
- bm.remove_memory_from_mapping(mem, bank)
-
- def set_memory(self, mem):
- _mem = self._memobj.memory[mem.number - 1]
- flag = self._memobj.flag[mem.number - 1]
-
- self._debank(mem)
-
- if not mem.empty and not flag.valid:
- self._wipe_memory(_mem)
-
- if mem.empty and flag.valid and not flag.used:
- flag.valid = False
- return
- flag.used = not mem.empty
- flag.valid = flag.used
-
- if mem.empty:
- return
-
- if mem.freq < 30000000 or \
- (mem.freq > 88000000 and mem.freq < 108000000) or \
- mem.freq > 580000000:
- flag.nosubvfo = True # Masked from VFO B
- else:
- flag.nosubvfo = False # Available in both VFOs
-
- _mem.freq = int(mem.freq / 1000)
- _mem.offset = int(mem.offset / 1000)
- _mem.tone = chirp_common.TONES.index(mem.rtone)
- self._set_tmode(_mem, mem)
- _mem.duplex = DUPLEX.index(mem.duplex)
- self._set_mode(_mem, mem)
- _mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs)
- _mem.tune_step = STEPS.index(mem.tuning_step)
-
- if mem.power:
- _mem.power = self._encode_power_level(mem)
- else:
- _mem.power = 3 # Set 3 - High power as the default
-
- _mem.label = self._encode_label(mem)
- charsetbits = self._encode_charsetbits(mem)
- _mem.charsetbits[0], _mem.charsetbits[1] = charsetbits
-
- flag.skip = mem.skip == "S"
- flag.pskip = mem.skip == "P"
-
- _mem.display_tag = 1 # Always Display Memory Name (For the moment..)
-
- @classmethod
- def _wipe_memory(cls, mem):
- mem.set_raw("\x00" * (mem.size() / 8))
- mem.unknown1 = 0x05
-
- def get_bank_model(self):
- return FT70BankModel(self)
-
- def _get_dtmf_settings(self):
- menu = RadioSettingGroup("dtmf_settings", "DTMF")
- dtmf = self._memobj.scan_settings
-
- val = RadioSettingValueList(
- self._DTMF_MODE,
- self._DTMF_MODE[dtmf.dtmf_mode])
- rs = RadioSetting("scan_settings.dtmf_mode", "DTMF Mode", val)
- menu.append(rs)
-
- val = RadioSettingValueList(
- self._DTMF_DELAY,
- self._DTMF_DELAY[dtmf.dtmf_delay])
- rs = RadioSetting(
- "scan_settings.dtmf_delay", "DTMF Delay", val)
- menu.append(rs)
-
- val = RadioSettingValueList(
- self._DTMF_SPEED,
- self._DTMF_SPEED[dtmf.dtmf_speed])
- rs = RadioSetting(
- "scan_settings.dtmf_speed", "DTMF Speed", val)
- menu.append(rs)
-
- for i in range(10):
-
- name = "dtmf_%02d" % (i + 1)
- if i == 9:
- name = "dtmf_%02d" % 0
-
- dtmfsetting = self._memobj.dtmf[i]
- dtmfstr = ""
- for c in dtmfsetting.memory:
- if c == 0xFF:
- break
- if c < len(FT70_DTMF_CHARS):
- dtmfstr += FT70_DTMF_CHARS[c]
- dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
- dtmfentry.set_charset(
- FT70_DTMF_CHARS + list("abcdef ")) # Allow input in lowercase, space ? validation fails otherwise
- rs = RadioSetting(name, name.upper(), dtmfentry)
- rs.set_apply_callback(self.apply_dtmf, i)
- menu.append(rs)
-
- return menu
-
- def _get_display_settings(self):
- menu = RadioSettingGroup("display_settings", "Display")
- scan_settings = self._memobj.scan_settings
-
- val = RadioSettingValueList(
- self._LAMP_KEY,
- self._LAMP_KEY[scan_settings.lamp])
- rs = RadioSetting("scan_settings.lamp", "Lamp", val)
- menu.append(rs)
-
- val = RadioSettingValueList(
- self._LCD_DIMMER,
- self._LCD_DIMMER[scan_settings.lcd_dimmer])
- rs = RadioSetting("scan_settings.lcd_dimmer", "LCD Dimmer", val)
- menu.append(rs)
-
- opening_message = self._memobj.opening_message
- val = RadioSettingValueList(
- self._OPENING_MESSAGE,
- self._OPENING_MESSAGE[opening_message.flag])
- rs = RadioSetting("opening_message.flag", "Opening Msg Mode", val)
- menu.append(rs)
-
- return menu
-
- def _get_config_settings(self):
- menu = RadioSettingGroup("config_settings", "Config")
- scan_settings = self._memobj.scan_settings
-
- # 02 APO Set the length of time until the transceiver turns off automatically.
-
- first_settings = self._memobj.first_settings
- val = RadioSettingValueList(
- self._APO_SELECT,
- self._APO_SELECT[first_settings.apo])
- rs = RadioSetting("first_settings.apo", "APO", val)
- menu.append(rs)
-
- # 03 BCLO Turns the busy channel lockout function on/off.
-
- val = RadioSettingValueList(
- self._OFF_ON,
- self._OFF_ON[scan_settings.bclo])
- rs = RadioSetting("scan_settings.bclo", "Busy Channel Lockout", val)
- menu.append(rs)
-
- # 04 BEEP Sets the beep sound function.
-
- beep_settings = self._memobj.beep_settings
- val = RadioSettingValueList(
- self._BEEP_SELECT,
- self._BEEP_SELECT[beep_settings.beep_select])
- rs = RadioSetting("beep_settings.beep_select", "Beep", val)
- menu.append(rs)
-
- # 05 BEP.LVL Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
-
- val = RadioSettingValueList(
- self._BEEP_LEVEL,
- self._BEEP_LEVEL[beep_settings.beep_level])
- rs = RadioSetting("beep_settings", "Beep Level", val)
- menu.append(rs)
-
- # 06 BEP.Edg Sets the beep sound ON or OFF when a band edge is encountered.
-
- val = RadioSettingValueList(
- self._OFF_ON,
- self._OFF_ON[scan_settings.beep_edge])
- rs = RadioSetting("scan_settings.beep_edge", "Beep Band Edge", val)
- menu.append(rs)
-
- # 10 Bsy.LED Turn the MODE/STATUS Indicator ON or OFF while receiving signals.
-
- val = RadioSettingValueList(
- self._ON_OFF,
- self._ON_OFF[scan_settings.busy_led])
- rs = RadioSetting("scan_settings.busy_led", "Busy LED", val)
- menu.append(rs)
-
- # 26 HOME/REV Select the function of the [HOME/REV] key.
-
- val = RadioSettingValueList(
- self._HOME_REV,
- self._HOME_REV[scan_settings.home_rev])
- rs = RadioSetting("scan_settings.home_rev", "HOME/REV", val)
- menu.append(rs)
-
- # 27 HOME->VFO Turn transfer VFO to the Home channel ON or OFF.
-
- val = RadioSettingValueList(
- self._OFF_ON,
- self._OFF_ON[scan_settings.home_vfo])
- rs = RadioSetting("scan_settings.home_vfo", "Home->VFO", val)
- menu.append(rs)
-
- # 30 LOCK Configure the lock mode setting. KEY / DIAL / K+D / PTT / K+P / D+P / ALL
-
- val = RadioSettingValueList(
- self._LOCK,
- self._LOCK[scan_settings.lock])
- rs = RadioSetting("scan_settings.lock", "Lock Mode", val)
- menu.append(rs)
-
- # 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
-
- val = RadioSettingValueList(
- self._MONI_TCALL,
- self._MONI_TCALL[scan_settings.moni])
- rs = RadioSetting("scan_settings.moni", "MONI/T-CALL", val)
- menu.append(rs)
-
- # 42 PTT.DLY Set the PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS
-
- val = RadioSettingValueList(
- self._PTT_DELAY,
- self._PTT_DELAY[scan_settings.ptt_delay])
- rs = RadioSetting("scan_settings.ptt_delay", "PTT Delay", val)
- menu.append(rs)
-
- # 45 RPT.ARS Turn the ARS function on/off.
-
- val = RadioSettingValueList(
- self._OFF_ON,
- self._OFF_ON[scan_settings.ars])
- rs = RadioSetting("scan_settings.ars", "ARS", val)
- menu.append(rs)
-
- # 48 RX.SAVE Set the battery save time. OFF / 0.2 S - 60.0 S
-
- val = RadioSettingValueList(
- self._RX_SAVE,
- self._RX_SAVE[scan_settings.rx_save])
- rs = RadioSetting("scan_settings.rx_save", "RX SAVE", val)
- menu.append(rs)
-
- # 60 VFO.MOD Set the frequency setting range in the VFO mode by DIAL knob. ALL / BAND
-
- val = RadioSettingValueList(
- self._VFO_MODE,
- self._VFO_MODE[scan_settings.vfo_mode])
- rs = RadioSetting("scan_settings.vfo_mode", "VFO MODE", val)
- menu.append(rs)
-
- # 56 TOT Set the timeout timer.
-
- val = RadioSettingValueList(
- self._TOT_TIME,
- self._TOT_TIME[scan_settings.tot])
- rs = RadioSetting("scan_settings.tot", "Transmit Timeout (TOT)", val)
- menu.append(rs)
-
- # 31 MCGAIN Adjust the microphone gain level
-
- val = RadioSettingValueList(
- self._MIC_GAIN,
- self._MIC_GAIN[scan_settings.mic_gain])
- rs = RadioSetting("scan_settings.mic_gain", "Mic Gain", val)
- menu.append(rs)
-
- # VOLUME Adjust the volume level
-
- scan_settings_2 = self._memobj.scan_settings_2
- val = RadioSettingValueList(
- self._VOLUME,
- self._VOLUME[scan_settings_2.volume])
- rs = RadioSetting("scan_settings_2.volume", "Volume", val)
- menu.append(rs)
-
- # Squelch F key, Hold Monitor, Dial to adjust squelch level
-
- squelch_settings = self._memobj.squelch_settings
- val = RadioSettingValueList(
- self._SQUELCH,
- self._SQUELCH[squelch_settings.squelch])
- rs = RadioSetting("squelch_settings.squelch", "Squelch", val)
- menu.append(rs)
-
- return menu
-
- def _get_digital_settings(self):
- menu = RadioSettingGroup("digital_settings", "Digital")
-
- # MYCALL
- mycall = self._memobj.my_call
- mycallstr = str(mycall.callsign).rstrip("\xFF")
-
- mycallentry = RadioSettingValueString(0, 10, mycallstr, False, charset=self._MYCALL_CHR_SET)
- rs = RadioSetting('mycall.callsign', 'MYCALL', mycallentry)
- rs.set_apply_callback(self.apply_mycall, mycall)
- menu.append(rs)
-
- # Short Press AMS button AMS TX Mode
-
- digital_settings = self._memobj.digital_settings
- val = RadioSettingValueList(
- self._AMS_TX_MODE,
- self._AMS_TX_MODE[digital_settings.ams_tx_mode])
- rs = RadioSetting("digital_settings.ams_tx_mode", "AMS TX Mode", val)
- menu.append(rs)
-
- # 16 DIG VW Turn the VW mode selection ON or OFF.
-
- val = RadioSettingValueList(
- self._VW_MODE,
- self._VW_MODE[digital_settings.vw_mode])
- rs = RadioSetting("digital_settings.vw_mode", "VW Mode", val)
- menu.append(rs)
-
- # TX DG-ID Long Press Mode Key, Dial
-
- val = RadioSettingValueList(
- self._DG_ID,
- self._DG_ID[digital_settings.tx_dg_id])
- rs = RadioSetting("digital_settings.tx_dg_id", "TX DG-ID", val)
- menu.append(rs)
-
- # RX DG-ID Long Press Mode Key, Mode Key to select, Dial
-
- val = RadioSettingValueList(
- self._DG_ID,
- self._DG_ID[digital_settings.rx_dg_id])
- rs = RadioSetting("digital_settings.rx_dg_id", "RX DG-ID", val)
- menu.append(rs)
-
- # 15 DIG.POP Call sign display pop up time
-
- # 00 OFF 00
- # 0A 2s 10
- # 0B 4s 11
- # 0C 6s 12
- # 0D 8s 13
- # 0E 10s 14
- # 0F 20s 15
- # 10 30s 16
- # 11 60s 17
- # 12 CONT 18
-
- digital_settings_more = self._memobj.digital_settings_more
-
- val = RadioSettingValueList(
- self._DIG_POP_UP,
- self._DIG_POP_UP[
- 0 if digital_settings_more.digital_popup == 0 else digital_settings_more.digital_popup - 9])
-
- rs = RadioSetting("digital_settings_more.digital_popup", "Digital Popup", val)
- rs.set_apply_callback(self.apply_digital_popup, digital_settings_more)
- menu.append(rs)
-
- # 07 BEP.STB Standby Beep in the digital C4FM mode. On/Off
-
- val = RadioSettingValueList(
- self._STANDBY_BEEP,
- self._STANDBY_BEEP[digital_settings.standby_beep])
- rs = RadioSetting("digital_settings.standby_beep", "Standby Beep", val)
- menu.append(rs)
-
- return menu
-
- def _get_gm_settings(self):
- menu = RadioSettingGroup("first_settings", "Group Monitor")
-
- # 24 GM RNG Select the beep option while receiving digital GM information. OFF / IN RNG /ALWAYS
-
- first_settings = self._memobj.first_settings
- val = RadioSettingValueList(
- self._GM_RING,
- self._GM_RING[first_settings.gm_ring])
- rs = RadioSetting("first_settings.gm_ring", "GM Ring", val)
- menu.append(rs)
-
- # 25 GM INT Set the transmission interval of digital GM information. OFF / NORMAL / LONG
-
- scan_settings = self._memobj.scan_settings
- val = RadioSettingValueList(
- self._GM_INTERVAL,
- self._GM_INTERVAL[scan_settings.gm_interval])
- rs = RadioSetting("scan_settings.gm_interval", "GM Interval", val)
- menu.append(rs)
-
- return menu
-
- def _get_scan_settings(self):
- menu = RadioSettingGroup("scan_settings", "Scan")
- scan_settings = self._memobj.scan_settings
-
- # 23 DW RVT Turn the "Priority Channel Revert" feature ON or OFF during Dual Receive.
-
- val = RadioSettingValueList(
- self._OFF_ON,
- self._OFF_ON[scan_settings.dw_rt])
- rs = RadioSetting("scan_settings.dw_rt", "Dual Watch Priority Channel Revert", val)
- menu.append(rs)
-
- # 21 DW INT Set the priority memory channel monitoring interval during Dual Receive. 0.1S - 5.0S - 10.0S
-
- val = RadioSettingValueList(
- self._SCAN_RESTART,
- self._SCAN_RESTART[scan_settings.dw_interval])
- rs = RadioSetting("scan_settings.dw_interval", "Dual Watch Interval", val)
- menu.append(rs)
-
- # 22 DW RSM Configure the scan stop mode settings for Dual Receive. 2.0S - 10.0 S / BUSY / HOLD
-
- first_settings = self._memobj.first_settings
- val = RadioSettingValueList(
- self._SCAN_RESUME,
- self._SCAN_RESUME[first_settings.dw_resume_interval])
- rs = RadioSetting("first_settings.dw_resume_interval", "Dual Watch Resume Interval", val)
- menu.append(rs)
-
- # 51 SCN.LMP Set the scan lamp ON or OFF when scanning stops. OFF / ON
-
- val = RadioSettingValueList(
- self._OFF_ON,
- self._OFF_ON[scan_settings.scan_lamp])
- rs = RadioSetting("scan_settings.scan_lamp", "Scan Lamp", val)
- menu.append(rs)
-
- # 53 SCN.STR Set the scanning restart time. 0.1 S - 2.0 S - 10.0 S
-
- val = RadioSettingValueList(
- self._SCAN_RESTART,
- self._SCAN_RESTART[scan_settings.scan_restart])
- rs = RadioSetting("scan_settings.scan_restart", "Scan Restart", val)
- menu.append(rs)
-
- # Scan Width Section
-
- # 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL - NOT FOUND!
-
- # Scan Resume Section
-
- # 52 SCN.RSM Configure the scan stop mode settings. 2.0 S - 5.0 S - 10.0 S / BUSY / HOLD
-
- first_settings = self._memobj.first_settings
- val = RadioSettingValueList(
- self._SCAN_RESUME,
- self._SCAN_RESUME[first_settings.scan_resume])
- rs = RadioSetting("first_settings.scan_resume", "Scan Resume", val)
- menu.append(rs)
-
- return menu
-
- def _get_settings(self):
- top = RadioSettings(
- self._get_config_settings(),
- self._get_digital_settings(),
- self._get_display_settings(),
- self._get_dtmf_settings(),
- self._get_gm_settings(),
- self._get_scan_settings()
- )
- return top
-
- def get_settings(self):
- try:
- return self._get_settings()
- except:
- import traceback
- LOG.error("Failed to parse settings: %s", traceback.format_exc())
- return None
-
- @classmethod
- def apply_ff_padded_string(cls, setting, obj):
- setattr(obj, "padded_string", cls._add_ff_pad(setting.value.get_value().rstrip(), 6))
-
- def set_settings(self, settings):
- _mem = self._memobj
- for element in settings:
- if not isinstance(element, RadioSetting):
- self.set_settings(element)
- continue
- if not element.changed():
- continue
- try:
- if element.has_apply_callback():
- LOG.debug("Using apply callback")
- try:
- element.run_apply_callback()
- except NotImplementedError as e:
- LOG.error(e)
- continue
-
- # Find the object containing setting.
- obj = _mem
- bits = element.get_name().split(".")
- setting = bits[-1]
- for name in bits[:-1]:
- if name.endswith("]"):
- name, index = name.split("[")
- index = int(index[:-1])
- obj = getattr(obj, name)[index]
- else:
- obj = getattr(obj, name)
-
- try:
- old_val = getattr(obj, setting)
- LOG.debug("Setting %s(%r) <= %s" % (
- element.get_name(), old_val, element.value))
- setattr(obj, setting, element.value)
- except AttributeError as e:
- LOG.error("Setting %s is not in the memory map: %s" %
- (element.get_name(), e))
- except Exception, e:
- LOG.debug(element.get_name())
- raise
-
- def apply_volume(cls, setting, vfo):
- val = setting.value.get_value()
- cls._memobj.vfo_info[(vfo * 2)].volume = val
- cls._memobj.vfo_info[(vfo * 2) + 1].volume = val
-
- def apply_dtmf(cls, setting, i):
- rawval = setting.value.get_value().upper().rstrip()
- val = [FT70_DTMF_CHARS.index(x) for x in rawval]
- for x in range(len(val), 16):
- val.append(0xFF)
- cls._memobj.dtmf[i].memory = val
-
- def apply_digital_popup(cls, setting, obj):
- rawval = setting.value.get_value()
- val = 0 if cls._DIG_POP_UP.index(rawval) == 0 else cls._DIG_POP_UP.index(rawval) + 9
- obj.digital_popup = val
-
- def apply_mycall(cls, setting, obj):
- cs = setting.value.get_value()
- if cs[0] in ('-', '/'):
- raise InvalidValueError("First character of call sign can't be - or /: {0:s}".format(cs))
- else:
- obj.callsign = cls._add_ff_pad(cs.rstrip(), 10)
+# Copyright 2010 Dan Smith <dsmith@danplanet.com>
+# Copyright 2017 Nicolas Pike <nick@zbm2.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from chirp.drivers import yaesu_clone
+from chirp import chirp_common, directory, bitwise
+from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \
+ RadioSettingValueInteger, RadioSettingValueString, \
+ RadioSettingValueList, RadioSettingValueBoolean, \
+ InvalidValueError
+from textwrap import dedent
+import string
+LOG = logging.getLogger(__name__)
+
+# Testing
+
+# 37 PAG.ABK Turn the pager answer back Function ON/OFF
+# 38 PAG.CDR Specify a personal code (receive)
+# 39 PAG.CDT Specify a personal code (transmit)
+# 47 RX.MOD Select the receive mode. Auto FM AM
+
+MEM_SETTINGS_FORMAT = """
+
+// FT-70DE New Model #5329
+//
+// Communications Mode ? AMS,FM DN,DW TX vs RX?
+// Mode not currently correctly stored in memories ? - ALL show as FM in memories
+// SKIP test/where stored
+// Check storage of steps
+// Pager settings ?
+// Triple check/ understand _memsize and _block_lengths
+// Bank name label name size display 6 store 16? padded with 0xFF same for MYCALL and message
+// CHIRP mode DIG not supported - is there a CHIRP Fusion mode? Auto?
+// Check character set
+// Supported Modes ?
+// Supported Bands ?
+// rf.has_dtcs_polarity = False - think radio supports DTCS polarity
+// rf.memory_bounds = (1, 900) - should this be 0? as zero displays as blank
+// RPT offsets (stored per band) not included.
+// 59 Display radio firmware version info and Radio ID?
+// Front Panel settings power etc?
+// Banks and VFO?
+
+// Features Required
+// Default AMS and Memory name (in mem extras) to enabled.
+
+// Bugs
+// MYCALL and Opening Message errors if not 10 characters
+// Values greater than one sometimes stored as whole bytes, these need to be refactored into bit fields
+// to prevent accidental overwriting of adjacent values
+// Bank Name length not checked on gui input - but first 6 characters are saved correctly.
+// Extended characters entered as bank names on radio are corrupted in Chirp
+
+// Missing
+// 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL - NOT FOUND
+// 49 SCM.WTH Set the memory scan frequency range. ALL / BAND - NOT FOUND
+
+// Radio Questions
+// Temp unit C/F not saved by radio, always goes back to C ?
+// 44 RF SQL Adjusts the RF Squelch threshold level. OFF / S1 - S9? Default is OFF - Based on RF strength - for AM? How
+// is this different from F, Monitor, Dial Squelch?
+// Password setting on radio allows letters (DTMF), but letters cannot be entered at the radio's password prompt?
+// 49 SCM.WTH Set the memory scan frequency range. ALL / BAND Defaults to ALL Not Band as stated in the manual.
+
+ #seekto 0x049a;
+ struct {
+ u8 unknown0:4,
+ squelch:4; // Squelch F, Monitor, Dial Adjust the Squelch level
+ } squelch_settings;
+
+ #seekto 0x04ba;
+ struct {
+ u8 unknown:3,
+ scan_resume:5; // 52 SCN.RSM Configure the scan stop mode settings. 2.0 S - 5.0 S - 10.0 S / BUSY / HOLD
+ u8 unknown1:3,
+ dw_resume_interval:5; // 22 DW RSM Configure the scan stop mode settings for Dual Receive. 2.0S-10.0S/BUSY/HOLD
+ u8 unknown2;
+ u8 unknown3:3,
+ apo:5; // 02 APO Set the length of time until the transceiver turns off automatically.
+ u8 unknown4:6,
+ gm_ring:2; // 24 GM RNG Select the beep option while receiving digital GM info. OFF/IN RNG/ALWAYS
+ u8 temp_cf; // Placeholder as not found
+ u8 unknown5;
+ } first_settings;
+
+ #seekto 0x04ed;
+ struct {
+ u8 unknown1:1,
+ unknown2:1,
+ unknown3:1,
+ unknown4:1,
+ unknown5:1,
+ unknown6:1,
+ unknown7:1,
+ unknown8:1;
+ } test_bit_field;
+
+ #seekto 0x04c0;
+ struct {
+ u8 unknown1:5,
+ beep_level:3; // 05 BEP.LVL Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
+ u8 unknown2:6,
+ beep_select:2; // 04 BEEP Sets the beep sound function OFF / KEY+SC / KEY
+ } beep_settings;
+
+ #seekto 0x04ce;
+ struct {
+ u8 lcd_dimmer; // 14 DIMMER LCD Dimmer
+ u8 dtmf_delay; // 18 DT DLY DTMF delay
+ u8 unknown0[3];
+ u8 unknown1:4,
+ unknown1:4;
+ u8 lamp; // 28 LAMP Set the duration time of the backlight and keys to be lit
+ u8 lock; // 30 LOCK Configure the lock mode setting. KEY/DIAL/K+D/PTT/K+P/D+P/ALL
+ u8 unknown2_1;
+ u8 mic_gain; // 31 MCGAIN Adjust the microphone gain level
+ u8 unknown2_3;
+ u8 dw_interval; // 21 DW INT Set the priority memory ch mon int during Dual RX 0.1S-5.0S-10.0S
+ u8 ptt_delay; // 42 PTT.DLY Set the PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS
+ u8 rx_save; // 48 RX.SAVE Set the battery save time. OFF / 0.2 S - 60.0 S
+ u8 scan_restart; // 53 SCN.STR Set the scanning restart time. 0.1 S - 2.0 S - 10.0 S
+ u8 unknown2_5;
+ u8 unknown2_6;
+ u8 unknown4[5];
+ u8 tot; // 56 TOT Set the transmission timeout timer
+ u8 unknown5[3]; // 26
+ u8 vfo_mode:1, // 60 VFO.MOD Set freq setting range in the VFO mode by DIAL knob. ALL / BAND
+ unknown7:1,
+ scan_lamp:1, // 51 SCN.LMP Set the scan lamp ON or OFF when scanning stops On/Off
+ unknown8:1,
+ ars:1, // 45 RPT.ARS Turn the ARS function on/off.
+ dtmf_speed:1, // 20 DT SPD Set DTMF speed
+ unknown8:1,
+ dtmf_mode:1; // DTMF Mode set from front panel
+ u8 busy_led:1, // Not Supported ?
+ unknown8_2:1,
+ unknown8_3:1,
+ bclo:1, // 03 BCLO Turns the busy channel lockout function on/off.
+ beep_edge:1, // 06 BEP.Edg Sets the beep sound ON or OFF when a band edge is encountered.
+ unknown8_6:1,
+ unknown8_7:1,
+ unknown8_8:1; // 28
+ u8 unknown9_1:1,
+ unknown9_2:1,
+ unknown9_3:1,
+ unknown9_4:1,
+ unknown9_5:1,
+ password:1, // Placeholder location
+ home_rev:1, // 26 HOME/REV Select the function of the [HOME/REV] key.
+ moni:1; // 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
+ u8 gm_interval:4, // 30 // 25 GM INT Set tx interval of digital GM information. OFF / NORMAL / LONG
+ unknown10:4;
+ u8 unknown11;
+ u8 unknown12:1,
+ unknown12_2:1,
+ unknown12_3:1,
+ unknown12_4:1,
+ home_vfo:1, // 27 HOME->VFO Turn transfer VFO to the Home channel ON or OFF.
+ unknown12_6:1,
+ unknown12_7:1,
+ dw_rt:1; // 32 // 23 DW RVT Turn "Priority Channel Revert" feature ON or OFF during Dual Rx.
+ u8 unknown33;
+ u8 unknown34;
+ u8 unknown35;
+ u8 unknown36;
+ u8 unknown37;
+ u8 unknown38;
+ u8 unknown39;
+ u8 unknown40;
+ u8 unknown41;
+ u8 unknown42;
+ u8 unknown43;
+ u8 unknown44;
+ u8 unknown45;
+ u8 prog_key1; // P1 Set Mode Items to the Programmable Key
+ u8 prog_key2; // P2 Set Mode Items to the Programmable Key
+ u8 unknown48;
+ u8 unknown49;
+ u8 unknown50;
+ } scan_settings;
+
+ #seekto 0x064b;
+ struct {
+ u8 unknown1:1,
+ unknown2:1,
+ unknown3:1,
+ unknown4:1,
+ vfo_scan_width:1, // Placeholder as not found - 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL
+ memory_scan_width:1, // Placeholder as not found - 49 SCM.WTH Set the memory scan frequency range. ALL / BAND
+ unknown7:1,
+ unknown8:1;
+ } scan_settings_1;
+
+ #seekto 0x06B6;
+ struct {
+ u8 unknown1:3,
+ volume:5; // # VOL and Dial Adjust the volume level
+ } scan_settings_2;
+
+ #seekto 0x0690; // Memory or VFO Settings Map?
+ struct {
+ u8 unknown[48]; // Array cannot be 64 elements!
+ u8 unknown1[16]; // Exception: Not implemented for chirp.bitwise.structDataElement
+ } vfo_info_1;
+
+ #seekto 0x0710; // Backup Memory or VFO Settings Map?
+ struct {
+ u8 unknown[48];
+ u8 unknown1[16];
+ } vfo_backup_info_1;
+
+ #seekto 0x047e;
+ struct {
+ u8 unknown1;
+ u8 flag;
+ u16 unknown2;
+ struct {
+ char padded_string[6]; // 36 OPN.MSG Select MSG then key vm to edit it
+ } message;
+ } opening_message; // 36 OPN.MSG Select the Opening Message when transceiver is ON. OFF/MSG/DC
+
+ #seekto 0x094a; // DTMF Memories
+ struct {
+ u8 memory[16];
+ } dtmf[10];
+
+ #seekto 0x154a;
+ struct {
+ u16 channel[100];
+ } bank_members[24];
+
+ #seekto 0x54a;
+ struct {
+ u16 in_use;
+ } bank_used[24];
+
+ #seekto 0x0EFE;
+ struct {
+ u8 unknown[2];
+ u8 name[6];
+ u8 unknown1[10];
+ } bank_info[24];
+
+ #seekto 0xCF30;
+ struct {
+ u8 unknown0;
+ u8 unknown1;
+ u8 unknown2;
+ u8 unknown3;
+ u8 unknown4;
+ u8 unknown5;
+ u8 unknown6;
+ u8 digital_popup; // 15 DIG.POP Call sign display pop up time
+ } digital_settings_more;
+
+ #seekto 0xCF7C;
+ struct {
+ u8 unknown0:6,
+ ams_tx_mode:2; // AMS TX Mode Short Press AMS button AMS TX Mode
+ u8 unknown1;
+ u8 unknown2:7,
+ standby_beep:1; // 07 BEP.STB Standby Beep in the digital C4FM mode. On/Off
+ u8 unknown3;
+ u8 unknown4:6,
+ gm_ring:2; // 24 GM RNG Select beep option while rx digital GM info. OFF/IN RNG/ALWAYS
+ u8 unknown5;
+ u8 rx_dg_id; // RX DG-ID Long Press Mode Key, Mode Key to select, Dial
+ u8 tx_dg_id; // TX DG-ID Long Press Mode Key, Dial
+ u8 unknown6:7,
+ vw_mode:1; // 16 DIG VW Turn the VW mode selection ON or OFF
+ u8 unknown7;
+ } digital_settings;
+
+ // ^^^ All above referenced U8's have been refactored to minimum number of bits.
+
+ """
+
+MEM_FORMAT = """
+ #seekto 0x2D4A;
+ struct { // 32 Bytes per memory entry
+ u8 display_tag:1, // 0 Display Freq, 1 Display Name
+ unknown0:1, // Mode if AMS not selected????????
+ deviation:1, // 0 Full deviation (Wide), 1 Half deviation (Narrow)
+ clock_shift:1, // 0 None, 1 CPU clock shifted
+ unknown1:4; // 1
+ u8 mode:2, // FM,AM,WFM only? - check
+ duplex:2, // Works
+ tune_step:4; // Works - check all steps? 7 = Auto // 1
+ bbcd freq[3]; // Works // 3
+ u8 power:2, // Works
+ unknown2:1, // 0 FM, 1 Digital - If AMS off
+ ams:1, // 0 AMS off, 1 AMS on ?
+ tone_mode:4; // Works // 1
+ u8 charsetbits[2]; // 2
+ char label[6]; // Works - Can only input 6 on screen // 6
+ char unknown7[10]; // Rest of label ??? // 10
+ bbcd offset[3]; // Works // 3
+ u8 unknown5:2,
+ tone:6; // Works // 1
+ u8 unknown6:1,
+ dcs:7; // Works // 1
+ u8 unknown9;
+ u8 ams_on_dn_vw_fm:2, // AMS DN, AMS VW, AMS FM
+ unknown8_3:1,
+ unknown8_4:1,
+ unknown8_5:1,
+ unknown8_6:1,
+ unknown8_7:1,
+ unknown8_8:1;
+ u8 unknown10;
+ } memory[%d]; // DN, VW, FM, AM
+ // AMS DN, AMS VW, AMS FM
+
+ #seekto 0x280A;
+ struct {
+ u8 nosubvfo:1,
+ unknown:3,
+ pskip:1, // PSkip (Select?)
+ skip:1, // Skip memory during scan
+ used:1, // Memory used
+ valid:1; // Always 1?
+ } flag[%d];
+ """
+
+MEM_CALLSIGN_FORMAT = """
+#seekto 0x0ced0;
+ struct {
+ char callsign[10]; // 63 MYCALL Set the call sign. (up to 10 characters)
+ u16 charset; // character set ID
+ } my_call;
+ """
+
+MEM_CHECKSUM_FORMAT = """
+ #seekto 0xFECA;
+ u8 checksum;
+ """
+
+TMODES = ["", "Tone", "TSQL", "DTCS"]
+DUPLEX = ["", "-", "+", "split"]
+
+MODES = ["FM", "AM"]
+
+STEPS = [0, 5, 6.25, 10, 12.5, 15, 20, 25, 50, 100] # 0 = auto
+RFSQUELCH = ["OFF", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8"]
+
+SKIPS = ["", "S", "P"]
+FT70_DTMF_CHARS = list("0123456789ABCDEF-")
+
+CHARSET = ["%i" % int(x) for x in range(0, 10)] + \
+ [chr(x) for x in range(ord("A"), ord("Z") + 1)] + \
+ [" ", ] + \
+ [chr(x) for x in range(ord("a"), ord("z") + 1)] + \
+ list(".,:;*#_-/&()@!?^ ") + list("\x00" * 100)
+
+POWER_LEVELS = [chirp_common.PowerLevel("Hi", watts=5.00),
+ chirp_common.PowerLevel("Mid", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=.50)]
+
+
+class FT70Bank(chirp_common.NamedBank):
+ """A FT70 bank"""
+
+ def get_name(self):
+ _bank = self._model._radio._memobj.bank_info[self.index]
+ name = ""
+ for i in _bank.name:
+ if i == 0xff:
+ break
+ name += chr(i & 0xFF)
+ return name.rstrip()
+
+ def set_name(self, name):
+ _bank = self._model._radio._memobj.bank_info[self.index]
+ _bank.name = [ord(x) for x in name.ljust(6, chr(0xFF))[:6]]
+
+
+class FT70BankModel(chirp_common.BankModel):
+ """A FT70 bank model"""
+
+ def __init__(self, radio, name='Banks'):
+ super(FT70BankModel, self).__init__(radio, name)
+
+ _banks = self._radio._memobj.bank_info
+ self._bank_mappings = []
+ for index, _bank in enumerate(_banks):
+ bank = FT70Bank(self, "%i" % index, "BANK-%i" % index)
+ bank.index = index
+ self._bank_mappings.append(bank)
+
+ def get_num_mappings(self):
+ return len(self._bank_mappings)
+
+ def get_mappings(self):
+ return self._bank_mappings
+
+ def _channel_numbers_in_bank(self, bank):
+ _bank_used = self._radio._memobj.bank_used[bank.index]
+ if _bank_used.in_use == 0xFFFF:
+ return set()
+
+ _members = self._radio._memobj.bank_members[bank.index]
+ return set([int(ch) + 1 for ch in _members.channel if ch != 0xFFFF])
+
+ def _update_bank_with_channel_numbers(self, bank, channels_in_bank):
+ _members = self._radio._memobj.bank_members[bank.index]
+ if len(channels_in_bank) > len(_members.channel):
+ raise Exception("Too many entries in bank %d" % bank.index)
+
+ empty = 0
+ for index, channel_number in enumerate(sorted(channels_in_bank)):
+ _members.channel[index] = channel_number - 1
+ empty = index + 1
+ for index in range(empty, len(_members.channel)):
+ _members.channel[index] = 0xFFFF
+
+ def add_memory_to_mapping(self, memory, bank):
+ channels_in_bank = self._channel_numbers_in_bank(bank)
+ channels_in_bank.add(memory.number)
+ self._update_bank_with_channel_numbers(bank, channels_in_bank)
+
+ _bank_used = self._radio._memobj.bank_used[bank.index]
+ _bank_used.in_use = 0x06
+
+ def remove_memory_from_mapping(self, memory, bank):
+ channels_in_bank = self._channel_numbers_in_bank(bank)
+ try:
+ channels_in_bank.remove(memory.number)
+ except KeyError:
+ raise Exception("Memory %i is not in bank %s. Cannot remove" %
+ (memory.number, bank))
+ self._update_bank_with_channel_numbers(bank, channels_in_bank)
+
+ if not channels_in_bank:
+ _bank_used = self._radio._memobj.bank_used[bank.index]
+ _bank_used.in_use = 0xFFFF
+
+ def get_mapping_memories(self, bank):
+ memories = []
+ for channel in self._channel_numbers_in_bank(bank):
+ memories.append(self._radio.get_memory(channel))
+
+ return memories
+
+ def get_memory_mappings(self, memory):
+ banks = []
+ for bank in self.get_mappings():
+ if memory.number in self._channel_numbers_in_bank(bank):
+ banks.append(bank)
+
+ return banks
+
+
+@directory.register
+class FT70Radio(yaesu_clone.YaesuCloneModeRadio):
+ """Yaesu FT-70DE"""
+ BAUD_RATE = 38400
+ VENDOR = "Yaesu"
+ MODEL = "FT-70D"
+
+ _model = "AH51G"
+
+ _memsize = 65227 # 65227 read from dump
+ _block_lengths = [10, 65217]
+ _block_size = 32
+ _mem_params = (900, # size of memories array
+ 900, # size of flags array
+ )
+
+ _has_vibrate = False
+ _has_af_dual = True
+
+ _BEEP_SELECT = ("Off", "Key+Scan", "Key")
+ _OPENING_MESSAGE = ("Off", "DC", "Message")
+ _MIC_GAIN = ("Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7", "Level 8", "Level 9")
+ _AMS_TX_MODE = ("TX Auto", "TX DIGITAL", "TX FM")
+ _VW_MODE = ("On", "Off")
+ _DIG_POP_UP = ("Off", "2sec", "4sec", "6sec", "8sec", "10sec", "20sec", "30sec", "60sec", "Continuous")
+ _STANDBY_BEEP = ("On", "Off")
+ _SCAN_RESUME = ["%.1fs" % (0.5 * x) for x in range(4, 21)] + \
+ ["Busy", "Hold"]
+ _SCAN_RESTART = ["%.1fs" % (0.1 * x) for x in range(1, 10)] + \
+ ["%.1fs" % (0.5 * x) for x in range(2, 21)]
+ _LAMP_KEY = ["Key %d sec" % x
+ for x in range(2, 11)] + ["Continuous", "OFF"]
+ _LCD_DIMMER = ["Level %d" % x for x in range(1, 7)]
+ _TOT_TIME = ["Off"] + ["%.1f min" % (0.5 * x) for x in range(1, 21)]
+ _OFF_ON = ("Off", "On")
+ _ON_OFF = ("On", "Off")
+ _DTMF_MODE = ("Manual", "Auto")
+ _DTMF_SPEED = ("50ms", "100ms")
+ _DTMF_DELAY = ("50ms", "250ms", "450ms", "750ms", "1000ms")
+ _TEMP_CF = ("Centigrade", "Fahrenheit")
+ _APO_SELECT = ("Off", "0.5H", "1.0H", "1.5H", "2.0H", "2.5H", "3.0H", "3.5H", "4.0H", "4.5H", "5.0H",
+ "5.5H", "6.0H", "6.5H", "7.0H", "7.5H", "8.0H", "8.5H", "9.0H", "9.5H", "10.0H", "10.5H",
+ "11.0H", "11.5H", "12.0H")
+ _MONI_TCALL = ("Monitor", "Tone-CALL")
+ _HOME_REV = ("Home", "Reverse")
+ _LOCK = ("KEY", "DIAL", "Key+Dial", "PTT", "Key+PTT", "Dial+PTT", "ALL")
+ _PTT_DELAY = ("Off", "20 MS", "50 MS", "100 MS", "200 MS")
+ _BEEP_LEVEL = ("Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7")
+ _SET_MODE = ("Level 1", "Level 2", "Level 3", "Level 4", "Level 5", "Level 6", "Level 7")
+ _RX_SAVE = ("OFF", "0.2s", ".3s", ".4s", ".5s", ".6s", ".7s", ".8s", ".9s", "1.0s", "1.5s",
+ "2.0s", "2.5s", "3.0s", "3.5s", "4.0s", "4.5s", "5.0s", "5.5s", "6.0s", "6.5s", "7.0s",
+ "7.5s", "8.0s", "8.5s", "9.0s", "10.0s", "15s", "20s", "25s", "30s", "35s", "40s", "45s", "50s", "55s",
+ "60s")
+ _VFO_MODE = ("ALL", "BAND")
+ _VFO_SCAN_MODE = ("BAND", "ALL")
+ _MEMORY_SCAN_MODE = ("BAND", "ALL")
+
+ _VOLUME = ["Level %d" % x for x in range(0, 32)]
+ _SQUELCH = ["Level %d" % x for x in range(0, 16)]
+
+ _DG_ID = ["%d" % x for x in range(0, 100)]
+ _GM_RING = ("OFF", "IN RING", "AlWAYS")
+ _GM_INTERVAL = ("LONG", "NORMAL", "OFF")
+
+ _MYCALL_CHR_SET = list(string.ascii_uppercase) + list(string.digits) + ['-','/' ]
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+
+ rp.pre_download = _(dedent("""\
+ 1. Turn radio on.
+ 2. Connect cable to DATA terminal.
+ 3. Unclip battery.
+ 4. Press and hold in the [AMS] key and power key while clipping the battery back in
+ ("ADMS" will appear on the display).
+ 5. <b>After clicking OK</b>, press the [BAND] key."""
+ ))
+ rp.pre_upload = _(dedent("""\
+ 1. Turn radio on.
+ 2. Connect cable to DATA terminal.
+ 3. Unclip battery.
+ 4. Press and hold in the [AMS] key and power key while clipping the battery back in
+ ("ADMS" will appear on the display).
+ 5. Press the [MODE] key ("-WAIT-" will appear on the LCD). <b>Then click OK</b>"""))
+ return rp
+
+ def process_mmap(self):
+
+ mem_format = MEM_SETTINGS_FORMAT + MEM_FORMAT + MEM_CALLSIGN_FORMAT + MEM_CHECKSUM_FORMAT
+
+ self._memobj = bitwise.parse(mem_format % self._mem_params, self._mmap)
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_dtcs_polarity = False
+ rf.valid_modes = list(MODES)
+ rf.valid_tmodes = list(TMODES)
+ rf.valid_duplexes = list(DUPLEX)
+ rf.valid_tuning_steps = list(STEPS)
+ rf.valid_bands = [(500000, 999900000)]
+ rf.valid_skips = SKIPS
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_characters = "".join(CHARSET)
+ rf.valid_name_length = 6
+ rf.memory_bounds = (1, 900)
+ rf.can_odd_split = True
+ rf.has_ctone = False
+ rf.has_bank_names = True
+ rf.has_settings = True
+ return rf
+
+ def get_raw_memory(self, number):
+ return "\n".join([repr(self._memobj.memory[number - 1]),
+ repr(self._memobj.flag[number - 1])])
+
+ def _checksums(self):
+ return [yaesu_clone.YaesuChecksum(0x0000, 0xFEC9)] # The whole file -2 bytes
+
+ @staticmethod
+ def _add_ff_pad(val, length):
+ return val.ljust(length, "\xFF")[:length]
+
+ @classmethod
+ def _strip_ff_pads(cls, messages):
+ result = []
+ for msg_text in messages:
+ result.append(str(msg_text).rstrip("\xFF"))
+ return result
+
+ def get_memory(self, number):
+ flag = self._memobj.flag[number - 1]
+ _mem = self._memobj.memory[number - 1]
+
+ mem = chirp_common.Memory()
+ mem.number = number
+ if not flag.used:
+ mem.empty = True
+ if not flag.valid:
+ mem.empty = True
+ return mem
+ mem.freq = chirp_common.fix_rounded_step(int(_mem.freq) * 1000)
+ mem.offset = int(_mem.offset) * 1000
+ mem.rtone = mem.ctone = chirp_common.TONES[_mem.tone]
+ self._get_tmode(mem, _mem)
+ mem.duplex = DUPLEX[_mem.duplex]
+ if mem.duplex == "split":
+ mem.offset = chirp_common.fix_rounded_step(mem.offset)
+ mem.mode = self._decode_mode(_mem)
+ mem.dtcs = chirp_common.DTCS_CODES[_mem.dcs]
+ mem.tuning_step = STEPS[_mem.tune_step]
+ mem.power = self._decode_power_level(_mem)
+ mem.skip = flag.pskip and "P" or flag.skip and "S" or ""
+ mem.name = self._decode_label(_mem)
+
+ return mem
+
+ def _decode_label(self, mem):
+ return str(mem.label).rstrip("\xFF")
+
+ def _encode_label(self, mem):
+ return self._add_ff_pad(mem.name.rstrip(), 6)
+
+ def _encode_charsetbits(self, mem):
+ # We only speak english here in chirpville
+ return [0x00, 0x00]
+
+ def _decode_power_level(self, mem): # 3 High 2 Mid 1 Low
+ return POWER_LEVELS[3 - mem.power]
+
+ def _encode_power_level(self, mem):
+ return 3 - POWER_LEVELS.index(mem.power)
+
+ def _decode_mode(self, mem):
+ return MODES[mem.mode]
+
+ def _encode_mode(self, mem):
+ return MODES.index(mem.mode)
+
+ def _get_tmode(self, mem, _mem):
+ mem.tmode = TMODES[_mem.tone_mode]
+
+ def _set_tmode(self, _mem, mem):
+ _mem.tone_mode = TMODES.index(mem.tmode)
+
+ def _set_mode(self, _mem, mem):
+ _mem.mode = self._encode_mode(mem)
+
+ def _debank(self, mem):
+ bm = self.get_bank_model()
+ for bank in bm.get_memory_mappings(mem):
+ bm.remove_memory_from_mapping(mem, bank)
+
+ def set_memory(self, mem):
+ _mem = self._memobj.memory[mem.number - 1]
+ flag = self._memobj.flag[mem.number - 1]
+
+ self._debank(mem)
+
+ if not mem.empty and not flag.valid:
+ self._wipe_memory(_mem)
+
+ if mem.empty and flag.valid and not flag.used:
+ flag.valid = False
+ return
+ flag.used = not mem.empty
+ flag.valid = flag.used
+
+ if mem.empty:
+ return
+
+ if mem.freq < 30000000 or \
+ (mem.freq > 88000000 and mem.freq < 108000000) or \
+ mem.freq > 580000000:
+ flag.nosubvfo = True # Masked from VFO B
+ else:
+ flag.nosubvfo = False # Available in both VFOs
+
+ _mem.freq = int(mem.freq / 1000)
+ _mem.offset = int(mem.offset / 1000)
+ _mem.tone = chirp_common.TONES.index(mem.rtone)
+ self._set_tmode(_mem, mem)
+ _mem.duplex = DUPLEX.index(mem.duplex)
+ self._set_mode(_mem, mem)
+ _mem.dcs = chirp_common.DTCS_CODES.index(mem.dtcs)
+ _mem.tune_step = STEPS.index(mem.tuning_step)
+
+ if mem.power:
+ _mem.power = self._encode_power_level(mem)
+ else:
+ _mem.power = 3 # Set 3 - High power as the default
+
+ _mem.label = self._encode_label(mem)
+ charsetbits = self._encode_charsetbits(mem)
+ _mem.charsetbits[0], _mem.charsetbits[1] = charsetbits
+
+ flag.skip = mem.skip == "S"
+ flag.pskip = mem.skip == "P"
+
+ _mem.display_tag = 1 # Always Display Memory Name (For the moment..)
+
+ @classmethod
+ def _wipe_memory(cls, mem):
+ mem.set_raw("\x00" * (mem.size() // 8))
+ mem.unknown1 = 0x05
+
+ def get_bank_model(self):
+ return FT70BankModel(self)
+
+ def _get_dtmf_settings(self):
+ menu = RadioSettingGroup("dtmf_settings", "DTMF")
+ dtmf = self._memobj.scan_settings
+
+ val = RadioSettingValueList(
+ self._DTMF_MODE,
+ self._DTMF_MODE[dtmf.dtmf_mode])
+ rs = RadioSetting("scan_settings.dtmf_mode", "DTMF Mode", val)
+ menu.append(rs)
+
+ val = RadioSettingValueList(
+ self._DTMF_DELAY,
+ self._DTMF_DELAY[dtmf.dtmf_delay])
+ rs = RadioSetting(
+ "scan_settings.dtmf_delay", "DTMF Delay", val)
+ menu.append(rs)
+
+ val = RadioSettingValueList(
+ self._DTMF_SPEED,
+ self._DTMF_SPEED[dtmf.dtmf_speed])
+ rs = RadioSetting(
+ "scan_settings.dtmf_speed", "DTMF Speed", val)
+ menu.append(rs)
+
+ for i in range(10):
+
+ name = "dtmf_%02d" % (i + 1)
+ if i == 9:
+ name = "dtmf_%02d" % 0
+
+ dtmfsetting = self._memobj.dtmf[i]
+ dtmfstr = ""
+ for c in dtmfsetting.memory:
+ if c == 0xFF:
+ break
+ if c < len(FT70_DTMF_CHARS):
+ dtmfstr += FT70_DTMF_CHARS[c]
+ dtmfentry = RadioSettingValueString(0, 16, dtmfstr)
+ dtmfentry.set_charset(
+ FT70_DTMF_CHARS + list("abcdef ")) # Allow input in lowercase, space ? validation fails otherwise
+ rs = RadioSetting(name, name.upper(), dtmfentry)
+ rs.set_apply_callback(self.apply_dtmf, i)
+ menu.append(rs)
+
+ return menu
+
+ def _get_display_settings(self):
+ menu = RadioSettingGroup("display_settings", "Display")
+ scan_settings = self._memobj.scan_settings
+
+ val = RadioSettingValueList(
+ self._LAMP_KEY,
+ self._LAMP_KEY[scan_settings.lamp])
+ rs = RadioSetting("scan_settings.lamp", "Lamp", val)
+ menu.append(rs)
+
+ val = RadioSettingValueList(
+ self._LCD_DIMMER,
+ self._LCD_DIMMER[scan_settings.lcd_dimmer])
+ rs = RadioSetting("scan_settings.lcd_dimmer", "LCD Dimmer", val)
+ menu.append(rs)
+
+ opening_message = self._memobj.opening_message
+ val = RadioSettingValueList(
+ self._OPENING_MESSAGE,
+ self._OPENING_MESSAGE[opening_message.flag])
+ rs = RadioSetting("opening_message.flag", "Opening Msg Mode", val)
+ menu.append(rs)
+
+ return menu
+
+ def _get_config_settings(self):
+ menu = RadioSettingGroup("config_settings", "Config")
+ scan_settings = self._memobj.scan_settings
+
+ # 02 APO Set the length of time until the transceiver turns off automatically.
+
+ first_settings = self._memobj.first_settings
+ val = RadioSettingValueList(
+ self._APO_SELECT,
+ self._APO_SELECT[first_settings.apo])
+ rs = RadioSetting("first_settings.apo", "APO", val)
+ menu.append(rs)
+
+ # 03 BCLO Turns the busy channel lockout function on/off.
+
+ val = RadioSettingValueList(
+ self._OFF_ON,
+ self._OFF_ON[scan_settings.bclo])
+ rs = RadioSetting("scan_settings.bclo", "Busy Channel Lockout", val)
+ menu.append(rs)
+
+ # 04 BEEP Sets the beep sound function.
+
+ beep_settings = self._memobj.beep_settings
+ val = RadioSettingValueList(
+ self._BEEP_SELECT,
+ self._BEEP_SELECT[beep_settings.beep_select])
+ rs = RadioSetting("beep_settings.beep_select", "Beep", val)
+ menu.append(rs)
+
+ # 05 BEP.LVL Beep volume setting LEVEL1 - LEVEL4 - LEVEL7
+
+ val = RadioSettingValueList(
+ self._BEEP_LEVEL,
+ self._BEEP_LEVEL[beep_settings.beep_level])
+ rs = RadioSetting("beep_settings", "Beep Level", val)
+ menu.append(rs)
+
+ # 06 BEP.Edg Sets the beep sound ON or OFF when a band edge is encountered.
+
+ val = RadioSettingValueList(
+ self._OFF_ON,
+ self._OFF_ON[scan_settings.beep_edge])
+ rs = RadioSetting("scan_settings.beep_edge", "Beep Band Edge", val)
+ menu.append(rs)
+
+ # 10 Bsy.LED Turn the MODE/STATUS Indicator ON or OFF while receiving signals.
+
+ val = RadioSettingValueList(
+ self._ON_OFF,
+ self._ON_OFF[scan_settings.busy_led])
+ rs = RadioSetting("scan_settings.busy_led", "Busy LED", val)
+ menu.append(rs)
+
+ # 26 HOME/REV Select the function of the [HOME/REV] key.
+
+ val = RadioSettingValueList(
+ self._HOME_REV,
+ self._HOME_REV[scan_settings.home_rev])
+ rs = RadioSetting("scan_settings.home_rev", "HOME/REV", val)
+ menu.append(rs)
+
+ # 27 HOME->VFO Turn transfer VFO to the Home channel ON or OFF.
+
+ val = RadioSettingValueList(
+ self._OFF_ON,
+ self._OFF_ON[scan_settings.home_vfo])
+ rs = RadioSetting("scan_settings.home_vfo", "Home->VFO", val)
+ menu.append(rs)
+
+ # 30 LOCK Configure the lock mode setting. KEY / DIAL / K+D / PTT / K+P / D+P / ALL
+
+ val = RadioSettingValueList(
+ self._LOCK,
+ self._LOCK[scan_settings.lock])
+ rs = RadioSetting("scan_settings.lock", "Lock Mode", val)
+ menu.append(rs)
+
+ # 32 Mon/T-Call Select the function of the [MONI/T-CALL] switch.
+
+ val = RadioSettingValueList(
+ self._MONI_TCALL,
+ self._MONI_TCALL[scan_settings.moni])
+ rs = RadioSetting("scan_settings.moni", "MONI/T-CALL", val)
+ menu.append(rs)
+
+ # 42 PTT.DLY Set the PTT delay time. OFF / 20 MS / 50 MS / 100 MS / 200 MS
+
+ val = RadioSettingValueList(
+ self._PTT_DELAY,
+ self._PTT_DELAY[scan_settings.ptt_delay])
+ rs = RadioSetting("scan_settings.ptt_delay", "PTT Delay", val)
+ menu.append(rs)
+
+ # 45 RPT.ARS Turn the ARS function on/off.
+
+ val = RadioSettingValueList(
+ self._OFF_ON,
+ self._OFF_ON[scan_settings.ars])
+ rs = RadioSetting("scan_settings.ars", "ARS", val)
+ menu.append(rs)
+
+ # 48 RX.SAVE Set the battery save time. OFF / 0.2 S - 60.0 S
+
+ val = RadioSettingValueList(
+ self._RX_SAVE,
+ self._RX_SAVE[scan_settings.rx_save])
+ rs = RadioSetting("scan_settings.rx_save", "RX SAVE", val)
+ menu.append(rs)
+
+ # 60 VFO.MOD Set the frequency setting range in the VFO mode by DIAL knob. ALL / BAND
+
+ val = RadioSettingValueList(
+ self._VFO_MODE,
+ self._VFO_MODE[scan_settings.vfo_mode])
+ rs = RadioSetting("scan_settings.vfo_mode", "VFO MODE", val)
+ menu.append(rs)
+
+ # 56 TOT Set the timeout timer.
+
+ val = RadioSettingValueList(
+ self._TOT_TIME,
+ self._TOT_TIME[scan_settings.tot])
+ rs = RadioSetting("scan_settings.tot", "Transmit Timeout (TOT)", val)
+ menu.append(rs)
+
+ # 31 MCGAIN Adjust the microphone gain level
+
+ val = RadioSettingValueList(
+ self._MIC_GAIN,
+ self._MIC_GAIN[scan_settings.mic_gain])
+ rs = RadioSetting("scan_settings.mic_gain", "Mic Gain", val)
+ menu.append(rs)
+
+ # VOLUME Adjust the volume level
+
+ scan_settings_2 = self._memobj.scan_settings_2
+ val = RadioSettingValueList(
+ self._VOLUME,
+ self._VOLUME[scan_settings_2.volume])
+ rs = RadioSetting("scan_settings_2.volume", "Volume", val)
+ menu.append(rs)
+
+ # Squelch F key, Hold Monitor, Dial to adjust squelch level
+
+ squelch_settings = self._memobj.squelch_settings
+ val = RadioSettingValueList(
+ self._SQUELCH,
+ self._SQUELCH[squelch_settings.squelch])
+ rs = RadioSetting("squelch_settings.squelch", "Squelch", val)
+ menu.append(rs)
+
+ return menu
+
+ def _get_digital_settings(self):
+ menu = RadioSettingGroup("digital_settings", "Digital")
+
+ # MYCALL
+ mycall = self._memobj.my_call
+ mycallstr = str(mycall.callsign).rstrip("\xFF")
+
+ mycallentry = RadioSettingValueString(0, 10, mycallstr, False, charset=self._MYCALL_CHR_SET)
+ rs = RadioSetting('mycall.callsign', 'MYCALL', mycallentry)
+ rs.set_apply_callback(self.apply_mycall, mycall)
+ menu.append(rs)
+
+ # Short Press AMS button AMS TX Mode
+
+ digital_settings = self._memobj.digital_settings
+ val = RadioSettingValueList(
+ self._AMS_TX_MODE,
+ self._AMS_TX_MODE[digital_settings.ams_tx_mode])
+ rs = RadioSetting("digital_settings.ams_tx_mode", "AMS TX Mode", val)
+ menu.append(rs)
+
+ # 16 DIG VW Turn the VW mode selection ON or OFF.
+
+ val = RadioSettingValueList(
+ self._VW_MODE,
+ self._VW_MODE[digital_settings.vw_mode])
+ rs = RadioSetting("digital_settings.vw_mode", "VW Mode", val)
+ menu.append(rs)
+
+ # TX DG-ID Long Press Mode Key, Dial
+
+ val = RadioSettingValueList(
+ self._DG_ID,
+ self._DG_ID[digital_settings.tx_dg_id])
+ rs = RadioSetting("digital_settings.tx_dg_id", "TX DG-ID", val)
+ menu.append(rs)
+
+ # RX DG-ID Long Press Mode Key, Mode Key to select, Dial
+
+ val = RadioSettingValueList(
+ self._DG_ID,
+ self._DG_ID[digital_settings.rx_dg_id])
+ rs = RadioSetting("digital_settings.rx_dg_id", "RX DG-ID", val)
+ menu.append(rs)
+
+ # 15 DIG.POP Call sign display pop up time
+
+ # 00 OFF 00
+ # 0A 2s 10
+ # 0B 4s 11
+ # 0C 6s 12
+ # 0D 8s 13
+ # 0E 10s 14
+ # 0F 20s 15
+ # 10 30s 16
+ # 11 60s 17
+ # 12 CONT 18
+
+ digital_settings_more = self._memobj.digital_settings_more
+
+ val = RadioSettingValueList(
+ self._DIG_POP_UP,
+ self._DIG_POP_UP[
+ 0 if digital_settings_more.digital_popup == 0 else digital_settings_more.digital_popup - 9])
+
+ rs = RadioSetting("digital_settings_more.digital_popup", "Digital Popup", val)
+ rs.set_apply_callback(self.apply_digital_popup, digital_settings_more)
+ menu.append(rs)
+
+ # 07 BEP.STB Standby Beep in the digital C4FM mode. On/Off
+
+ val = RadioSettingValueList(
+ self._STANDBY_BEEP,
+ self._STANDBY_BEEP[digital_settings.standby_beep])
+ rs = RadioSetting("digital_settings.standby_beep", "Standby Beep", val)
+ menu.append(rs)
+
+ return menu
+
+ def _get_gm_settings(self):
+ menu = RadioSettingGroup("first_settings", "Group Monitor")
+
+ # 24 GM RNG Select the beep option while receiving digital GM information. OFF / IN RNG /ALWAYS
+
+ first_settings = self._memobj.first_settings
+ val = RadioSettingValueList(
+ self._GM_RING,
+ self._GM_RING[first_settings.gm_ring])
+ rs = RadioSetting("first_settings.gm_ring", "GM Ring", val)
+ menu.append(rs)
+
+ # 25 GM INT Set the transmission interval of digital GM information. OFF / NORMAL / LONG
+
+ scan_settings = self._memobj.scan_settings
+ val = RadioSettingValueList(
+ self._GM_INTERVAL,
+ self._GM_INTERVAL[scan_settings.gm_interval])
+ rs = RadioSetting("scan_settings.gm_interval", "GM Interval", val)
+ menu.append(rs)
+
+ return menu
+
+ def _get_scan_settings(self):
+ menu = RadioSettingGroup("scan_settings", "Scan")
+ scan_settings = self._memobj.scan_settings
+
+ # 23 DW RVT Turn the "Priority Channel Revert" feature ON or OFF during Dual Receive.
+
+ val = RadioSettingValueList(
+ self._OFF_ON,
+ self._OFF_ON[scan_settings.dw_rt])
+ rs = RadioSetting("scan_settings.dw_rt", "Dual Watch Priority Channel Revert", val)
+ menu.append(rs)
+
+ # 21 DW INT Set the priority memory channel monitoring interval during Dual Receive. 0.1S - 5.0S - 10.0S
+
+ val = RadioSettingValueList(
+ self._SCAN_RESTART,
+ self._SCAN_RESTART[scan_settings.dw_interval])
+ rs = RadioSetting("scan_settings.dw_interval", "Dual Watch Interval", val)
+ menu.append(rs)
+
+ # 22 DW RSM Configure the scan stop mode settings for Dual Receive. 2.0S - 10.0 S / BUSY / HOLD
+
+ first_settings = self._memobj.first_settings
+ val = RadioSettingValueList(
+ self._SCAN_RESUME,
+ self._SCAN_RESUME[first_settings.dw_resume_interval])
+ rs = RadioSetting("first_settings.dw_resume_interval", "Dual Watch Resume Interval", val)
+ menu.append(rs)
+
+ # 51 SCN.LMP Set the scan lamp ON or OFF when scanning stops. OFF / ON
+
+ val = RadioSettingValueList(
+ self._OFF_ON,
+ self._OFF_ON[scan_settings.scan_lamp])
+ rs = RadioSetting("scan_settings.scan_lamp", "Scan Lamp", val)
+ menu.append(rs)
+
+ # 53 SCN.STR Set the scanning restart time. 0.1 S - 2.0 S - 10.0 S
+
+ val = RadioSettingValueList(
+ self._SCAN_RESTART,
+ self._SCAN_RESTART[scan_settings.scan_restart])
+ rs = RadioSetting("scan_settings.scan_restart", "Scan Restart", val)
+ menu.append(rs)
+
+ # Scan Width Section
+
+ # 50 SCV.WTH Set the VFO scan frequency range. BAND / ALL - NOT FOUND!
+
+ # Scan Resume Section
+
+ # 52 SCN.RSM Configure the scan stop mode settings. 2.0 S - 5.0 S - 10.0 S / BUSY / HOLD
+
+ first_settings = self._memobj.first_settings
+ val = RadioSettingValueList(
+ self._SCAN_RESUME,
+ self._SCAN_RESUME[first_settings.scan_resume])
+ rs = RadioSetting("first_settings.scan_resume", "Scan Resume", val)
+ menu.append(rs)
+
+ return menu
+
+ def _get_settings(self):
+ top = RadioSettings(
+ self._get_config_settings(),
+ self._get_digital_settings(),
+ self._get_display_settings(),
+ self._get_dtmf_settings(),
+ self._get_gm_settings(),
+ self._get_scan_settings()
+ )
+ return top
+
+ def get_settings(self):
+ try:
+ return self._get_settings()
+ except:
+ import traceback
+ LOG.error("Failed to parse settings: %s", traceback.format_exc())
+ return None
+
+ @classmethod
+ def apply_ff_padded_string(cls, setting, obj):
+ setattr(obj, "padded_string", cls._add_ff_pad(setting.value.get_value().rstrip(), 6))
+
+ def set_settings(self, settings):
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ if not element.changed():
+ continue
+ try:
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ try:
+ element.run_apply_callback()
+ except NotImplementedError as e:
+ LOG.error(e)
+ continue
+
+ # Find the object containing setting.
+ obj = _mem
+ bits = element.get_name().split(".")
+ setting = bits[-1]
+ for name in bits[:-1]:
+ if name.endswith("]"):
+ name, index = name.split("[")
+ index = int(index[:-1])
+ obj = getattr(obj, name)[index]
+ else:
+ obj = getattr(obj, name)
+
+ try:
+ old_val = getattr(obj, setting)
+ LOG.debug("Setting %s(%r) <= %s" % (
+ element.get_name(), old_val, element.value))
+ setattr(obj, setting, element.value)
+ except AttributeError as e:
+ LOG.error("Setting %s is not in the memory map: %s" %
+ (element.get_name(), e))
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ def apply_volume(cls, setting, vfo):
+ val = setting.value.get_value()
+ cls._memobj.vfo_info[(vfo * 2)].volume = val
+ cls._memobj.vfo_info[(vfo * 2) + 1].volume = val
+
+ def apply_dtmf(cls, setting, i):
+ rawval = setting.value.get_value().upper().rstrip()
+ val = [FT70_DTMF_CHARS.index(x) for x in rawval]
+ for x in range(len(val), 16):
+ val.append(0xFF)
+ cls._memobj.dtmf[i].memory = val
+
+ def apply_digital_popup(cls, setting, obj):
+ rawval = setting.value.get_value()
+ val = 0 if cls._DIG_POP_UP.index(rawval) == 0 else cls._DIG_POP_UP.index(rawval) + 9
+ obj.digital_popup = val
+
+ def apply_mycall(cls, setting, obj):
+ cs = setting.value.get_value()
+ if cs[0] in ('-', '/'):
+ raise InvalidValueError("First character of call sign can't be - or /: {0:s}".format(cs))
+ else:
+ obj.callsign = cls._add_ff_pad(cs.rstrip(), 10)
diff --git a/chirp/drivers/ft7100.py b/chirp/drivers/ft7100.py
index ca51367..5b4bb73 100644
--- a/chirp/drivers/ft7100.py
+++ b/chirp/drivers/ft7100.py
@@ -568,7 +568,7 @@ class FT7100Radio(YaesuCloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Downloaded in %.2f sec", (time.time() - start))
self.process_mmap()
@@ -580,7 +580,7 @@ class FT7100Radio(YaesuCloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
LOG.info("Uploaded in %.2f sec", (time.time() - start))
@@ -1091,7 +1091,7 @@ class FT7100Radio(YaesuCloneModeRadio):
setattr(_overlay, name, value)
LOG.debug("Setting %s: %s", name, value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ft7800.py b/chirp/drivers/ft7800.py
index c9d706c..fd26b29 100644
--- a/chirp/drivers/ft7800.py
+++ b/chirp/drivers/ft7800.py
@@ -30,7 +30,7 @@ from collections import defaultdict
LOG = logging.getLogger(__name__)
-ACK = 0x06
+ACK = b'\x06'
MEM_FORMAT = """
#seekto 0x002A;
@@ -184,7 +184,7 @@ def _download(radio):
raise Exception("Failed to read header (%i)" % len(chunk))
data += chunk
- _send(radio.pipe, bytes([ACK]))
+ _send(radio.pipe, ACK)
for i in range(0, radio._block_lengths[1], radio._block_size):
chunk = radio.pipe.read(radio._block_size)
@@ -201,7 +201,7 @@ def _download(radio):
radio.status_fn(status)
data += radio.pipe.read(1)
- _send(radio.pipe, bytes([ACK]))
+ _send(radio.pipe, ACK)
return memmap.MemoryMapBytes(data)
@@ -1010,7 +1010,7 @@ class FT8900Radio(FT8800Radio):
_mem.skip = SKIPS.index(mem.skip)
def get_memory(self, number):
- mem = FT8800Radio.get_memory(self, number)
+ mem = super().get_memory(number)
_mem = self._memobj.memory[number - 1]
diff --git a/chirp/drivers/ft8100.py b/chirp/drivers/ft8100.py
index 1d238c3..9276224 100644
--- a/chirp/drivers/ft8100.py
+++ b/chirp/drivers/ft8100.py
@@ -175,7 +175,7 @@ class FT8100Radio(yaesu_clone.YaesuCloneModeRadio):
if _mem.duplex == DUPLEX.index("split"):
tx_freq = int(_mem.offset) * 1000
- print self.VARIANT, number, tx_freq, mem.freq
+ print(self.VARIANT, number, tx_freq, mem.freq)
mem.offset = tx_freq - mem.freq
else:
mem.offset = int(_mem.offset) * 1000
@@ -189,7 +189,7 @@ class FT8100Radio(yaesu_clone.YaesuCloneModeRadio):
if not self._memobj.enables[byte] & bit and number != 1:
mem.empty = True
- print 'R', self.VARIANT, number, _mem.baud9600
+ print('R', self.VARIANT, number, _mem.baud9600)
return mem
@@ -270,7 +270,7 @@ class FT8100RadioUHF(FT8100Radio):
def _clone_out(radio):
try:
return __clone_out(radio)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
@@ -291,7 +291,7 @@ def __clone_out(radio):
pos = 0
for block in radio._block_lengths:
if os.getenv("CHIRP_DEBUG"):
- print "\nSending %i-%i" % (pos, pos + block)
+ print("\nSending %i-%i" % (pos, pos + block))
out = radio.get_mmap()[pos:pos + block]
# need to chew byte-by-byte here or else we lose the ACK...not sure why
@@ -309,6 +309,6 @@ def __clone_out(radio):
pos += block
- print "Clone completed in %i seconds" % (time.time() - start)
+ print("Clone completed in %i seconds" % (time.time() - start))
return True
diff --git a/chirp/drivers/ft817.py b/chirp/drivers/ft817.py
index 39fb1b6..d3bc077 100644
--- a/chirp/drivers/ft817.py
+++ b/chirp/drivers/ft817.py
@@ -483,7 +483,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
if isinstance(number, str):
return self._get_special(number)
elif number < 0:
- # I can't stop delete operation from loosing extd_number but
+ # I can't stop delete operation from losing extd_number but
# I know how to get it back
return self._get_special(self.SPECIAL_MEMORIES_REV[number])
else:
@@ -780,7 +780,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio):
rs = RadioSetting("ars_430", "430 ARS",
RadioSettingValueBoolean(_settings.ars_430))
basic.append(rs)
- rs = RadioSetting("pkt9600_mic", "Paket 9600 mic level",
+ rs = RadioSetting("pkt9600_mic", "Packet 9600 mic level",
RadioSettingValueInteger(0, 100,
_settings.pkt9600_mic))
packet.append(rs)
@@ -1125,7 +1125,7 @@ class FT817NDRadio(FT817Radio):
class FT817NDUSRadio(FT817Radio):
"""Yaesu FT-817ND (US version)"""
- # seems that radios configured for 5MHz operations send one paket
+ # seems that radios configured for 5MHz operations send one packet
# more than others so we have to distinguish sub models
MODEL = "FT-817ND (US)"
@@ -1192,7 +1192,7 @@ class FT817NDUSRadio(FT817Radio):
elif (number < 0 and
self.SPECIAL_MEMORIES_REV[number] in
list(self.SPECIAL_60M.keys())):
- # I can't stop delete operation from loosing extd_number but
+ # I can't stop delete operation from losing extd_number but
# I know how to get it back
return self._get_special_60m(self.SPECIAL_MEMORIES_REV[number])
else:
diff --git a/chirp/drivers/ft818.py b/chirp/drivers/ft818.py
index c7a0a32..6b77394 100755
--- a/chirp/drivers/ft818.py
+++ b/chirp/drivers/ft818.py
@@ -320,7 +320,7 @@ class FT818NDUSRadio(FT818Radio):
return self._get_special_60m(number)
elif number < 0 and \
self.SPECIAL_MEMORIES_REV[number] in self.SPECIAL_60M.keys():
- # I can't stop delete operation from loosing extd_number but
+ # I can't stop delete operation from losing extd_number but
# I know how to get it back
return self._get_special_60m(self.SPECIAL_MEMORIES_REV[number])
else:
diff --git a/chirp/drivers/ft857.py b/chirp/drivers/ft857.py
index a58c52b..045a9a8 100644
--- a/chirp/drivers/ft857.py
+++ b/chirp/drivers/ft857.py
@@ -484,7 +484,7 @@ class FT857Radio(ft817.FT817Radio):
elif mem.tmode == "TSQL":
mem.rtone = mem.ctone = chirp_common.TONES[_mem.tone]
elif mem.tmode == "DTCS Enc": # UI does not support it yet but
- # this code has alreay been tested
+ # this code has already been tested
mem.dtcs = mem.rx_dtcs = chirp_common.DTCS_CODES[_mem.dcs]
elif mem.tmode == "DTCS":
mem.dtcs = mem.rx_dtcs = chirp_common.DTCS_CODES[_mem.dcs]
@@ -511,7 +511,7 @@ class FT857Radio(ft817.FT817Radio):
elif mem.tmode == "TSQL":
_mem.tone = _mem.rxtone = chirp_common.TONES.index(mem.ctone)
elif mem.tmode == "DTCS Enc": # UI does not support it yet but
- # this code has alreay been tested
+ # this code has already been tested
_mem.dcs = _mem.rxdcs = chirp_common.DTCS_CODES.index(mem.dtcs)
elif mem.tmode == "DTCS":
_mem.dcs = _mem.rxdcs = chirp_common.DTCS_CODES.index(mem.rx_dtcs)
@@ -1109,7 +1109,7 @@ class FT857Radio(ft817.FT817Radio):
@directory.register
class FT857USRadio(FT857Radio):
"""Yaesu FT857/897 (US version)"""
- # seems that radios configured for 5MHz operations send one paket more
+ # seems that radios configured for 5MHz operations send one packet more
# than others so we have to distinguish sub models
MODEL = "FT-857/897 (US)"
@@ -1180,7 +1180,7 @@ class FT857USRadio(FT857Radio):
elif number < 0 and (
self.SPECIAL_MEMORIES_REV[number] in
list(self.SPECIAL_60M.keys())):
- # I can't stop delete operation from loosing extd_number but
+ # I can't stop delete operation from losing extd_number but
# I know how to get it back
return self._get_special_60m(self.SPECIAL_MEMORIES_REV[number])
else:
diff --git a/chirp/drivers/ft90.py b/chirp/drivers/ft90.py
index cc22a14..f452983 100644
--- a/chirp/drivers/ft90.py
+++ b/chirp/drivers/ft90.py
@@ -52,7 +52,8 @@ FT90_POWER_LEVELS_UHF = [chirp_common.PowerLevel("Hi", watts=35),
chirp_common.PowerLevel("Low", watts=5)]
FT90_DUPLEX = ["", "-", "+", "split"]
-FT90_CWID_CHARS = list(string.digits) + list(string.uppercase) + list(" ")
+FT90_CWID_CHARS = list(string.digits) + list(string.ascii_uppercase) \
+ + list(" ")
FT90_DTMF_CHARS = list("0123456789ABCD*#")
FT90_SPECIAL = ["vfo_vhf", "home_vhf", "vfo_uhf", "home_uhf",
"pms_1L", "pms_1U", "pms_2L", "pms_2U"]
@@ -332,7 +333,7 @@ struct {
self._mmap = self._clone_in()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
trace = traceback.format_exc()
raise errors.RadioError(
"Failed to communicate with radio: %s" % trace)
@@ -343,7 +344,7 @@ struct {
self._clone_out()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
trace = traceback.format_exc()
raise errors.RadioError(
"Failed to communicate with radio: %s" % trace)
@@ -559,13 +560,13 @@ struct {
rs = RadioSetting("cwid", "CWID", cwid)
basic.append(rs)
- options = ["OFF"] + map(str, range(1, 12+1))
+ options = ["OFF"] + [str(x) for x in (range(1, 12+1))]
rs = RadioSetting(
"apo", "APO time (hrs)",
RadioSettingValueList(options, options[_settings.apo]))
basic.append(rs)
- options = ["Off"] + map(str, range(1, 60+1))
+ options = ["Off"] + [str(x) for x in (range(1, 60+1))]
rs = RadioSetting(
"tot", "Time Out Timer (mins)",
RadioSettingValueList(options, options[_settings.tot]))
@@ -600,7 +601,7 @@ struct {
RadioSettingValueList(keyopts, keyopts[_settings.key_acc]))
keymaps.append(rs)
- options = map(str, range(0, 12+1))
+ options = [str(x) for x in range(0, 12+1)]
rs = RadioSetting(
"lcdcontrast", "LCD Contrast",
RadioSettingValueList(options, options[_settings.lcdcontrast]))
@@ -630,15 +631,15 @@ struct {
RadioSettingValueList(options, options[_settings.dtmftxdelay]))
autodial.append(rs)
- options = map(str, range(1, 8 + 1))
+ options = [str(x) for x in range(1, 8 + 1)]
rs = RadioSetting(
"dtmf_active", "DTMF Active",
RadioSettingValueList(options, options[_settings.dtmf_active]))
autodial.append(rs)
# setup 8 dtmf autodial entries
- for i in map(str, range(1, 9)):
- objname = "dtmf" + i
+ for i in range(1, 9):
+ objname = "dtmf" + str(i)
dtmfsetting = getattr(_settings, objname)
dtmflen = getattr(_settings, objname + "_len")
dtmfstr = self._bbcd2dtmf(dtmfsetting, dtmflen)
@@ -670,6 +671,6 @@ struct {
newval = self._dtmf2bbcd(newval)
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ftlx011.py b/chirp/drivers/ftlx011.py
new file mode 100644
index 0000000..2cf43ba
--- /dev/null
+++ b/chirp/drivers/ftlx011.py
@@ -0,0 +1,798 @@
+# Copyright 2019 Pavel Milanes, CO7WT <pavelmc@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import struct
+import os
+import logging
+import time
+
+from time import sleep
+from chirp import chirp_common, directory, memmap, errors, util, bitwise
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
+from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+### SAMPLE MEM DUMP as sent from the radios
+
+# FTL-1011
+#0x000000 52 f0 16 90 04 08 38 c0 00 00 00 01 00 00 00 ff |R.....8.........|
+#0x000010 20 f1 00 20 00 00 00 20 04 47 25 04 47 25 00 00 | .. ... .G%.G%..|
+
+# FTL-2011
+#0x000000: 50 90 21 40 04 80 fc 40 00 00 00 01 00 00 00 ff |P.!@...@........|
+#0x000010: 20 f1 00 0b 00 00 00 0b 14 51 70 14 45 70 00 00 |.........Qp.Ep..|
+
+
+MEM_FORMAT = """
+#seekto 0x000;
+u8 rid; // Radio Identification
+
+struct {
+u8 scan_time:4, // Scan timer per channel: 0-15 (5-80msec in 5msec steps)
+ unknownA:4;
+bbcd if[2]; // Radio internal IF, depending on model (16.90, 21.40, 45.10, 47.90)
+u8 chcount; // how many channels are programmed
+u8 scan_resume:1, // Scan sesume: 0 = 0.5 seconds, 1 = Carrier
+ priority_during_scan:1, // Priority during scan: 0 = enabled, 1 = disabled
+ priority_speed:1, // Priority speed: 0 = slow, 1 = fast
+ monitor:1, // Monitor: 0 = enabled, 1 = disabled
+ off_hook:1, // Off hook: 0 = enabled, 1 = disabled
+ home_channel:1, // Home Channel: 0 = Scan Start ch, 1 = Priority 1ch
+ talk_back:1, // Talk Back: 0 = enabled, 1 = disabled
+ tx_carrier_delay:1; // TX carrier delay: 1 = enabled, 0 = disabled
+u8 tot:4, // Time out timer: 16 values (0.0-7.5 in 0.5s step)
+ tot_resume:2, // Time out timer resume: 3, 2, 1, 0 => 0s, 6s, 20s, 60s
+ unknownB:2;
+u8 a_key:2, // A key function: resume: 0-3: Talkaround, High/Low, Call, Accessory
+ unknownB:6;
+u8 pch1; // Priority channel 1
+u8 pch2; // Priority channel 1
+} settings;
+
+#seekto 0x010;
+struct {
+ u8 notx:1, // 0 = Tx possible, 1 = Tx disabled
+ empty:1, // 0 = channel enabled, 1 = channed empty
+ tot:1, // 0 = tot disabled, 1 = tot enabled
+ power:1, // 0 = high, 1 = low
+ bclo_cw:1, // 0 = disabled, 1 = Busy Channel Lock out by carrier
+ bclo_tone:1, // 0 = disabled, 1 = Busy Channel Lock out by tone (set rx tone)
+ skip:1, // 0 = scan enabled, 1 = skip on scanning
+ unknownA0:1;
+ u8 chname;
+ u8 rx_tone[2]; // empty value is \x00\x0B / disabled is \x00\x00
+ u8 unknown4;
+ u8 unknown5;
+ u8 tx_tone[2]; // empty value is \x00\x0B / disabled is \x00\x00
+ bbcd rx_freq[3]; // RX freq
+ bbcd tx_freq[3]; // TX freq
+ u8 unknownA[2];
+} memory[24];
+
+#seekto 0x0190;
+char filename[11];
+
+#seekto 0x19C;
+u8 checksum;
+"""
+
+MEM_SIZE = 0x019C
+POWER_LEVELS = [chirp_common.PowerLevel("High", watts=50),
+ chirp_common.PowerLevel("Low", watts=5)]
+DTCS_CODES = chirp_common.DTCS_CODES
+SKIP_VALUES = ["", "S"]
+LIST_BCL = ["OFF", "Carrier", "Tone"]
+LIST_SCAN_RESUME = ["0.5 seconds", "Carrier drop"]
+LIST_SCAN_TIME = ["%smsecs" % x for x in range(5, 85, 5)]
+LIST_SCAN_P_SPEED = ["Slow", "Fast"]
+LIST_HOME_CHANNEL = ["Scan Start ch", "Priority 1ch"]
+LIST_TOT = ["Off"] + ["%.1f s" % (x/10.0) for x in range(5, 80, 5)]
+# 3, 2, 1, 0 => 0s, 6s, 20s, 60s
+LIST_TOT_RESUME = ["60s","20s","6s","0s"]
+LIST_A_KEY = ["Talkaround", "High/Low", "Call", "Accessory"]
+LIST_PCH = [] # dynamic, as depends on channel list.
+# make a copy of the tones, is not funny to work with this directly
+TONES = list(chirp_common.TONES)
+# this old radios has not the full tone ranges in CST
+invalid_tones = (
+ 69.3,
+ 159.8,
+ 165.5,
+ 171.3,
+ 177.3,
+ 183.5,
+ 189.9,
+ 196.6,
+ 199.5,
+ 206.5,
+ 229.1,
+ 245.1)
+
+# remove invalid tones
+for tone in invalid_tones:
+ try:
+ TONES.remove(tone)
+ except:
+ pass
+
+
+def _set_serial(radio):
+ """Set the serial protocol settings"""
+ radio.pipe.timeout = 10
+ radio.pipe.parity = "N"
+ radio.pipe.baudrate = 9600
+
+
+def _checksum(data):
+ """the radio block checksum algorithm"""
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+
+ return cs % 256
+
+
+def _update_cs(radio):
+ """Update the checksum on the mmap"""
+ payload = str(radio.get_mmap())[:-1]
+ cs = _checksum(payload)
+ radio._mmap[MEM_SIZE - 1] = cs
+
+
+def _do_download(radio):
+ """ The download function """
+ # Get the whole 413 bytes (0x019D) bytes one at a time with plenty of time
+ # to get to the user's pace
+
+ # set serial discipline
+ _set_serial(radio)
+
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = MEM_SIZE
+ status.msg = " Press A to clone. "
+ radio.status_fn(status)
+
+ data = ""
+ for i in range(0, MEM_SIZE):
+ a = radio.pipe.read(1)
+ if len(a) == 0:
+ # error, no received data
+ if len(data) != 0:
+ # received some data, not the complete stream
+ msg = "Just %02i bytes of the %02i received, try again." % \
+ (len(data), MEM_SIZE)
+ else:
+ # timeout, please retry
+ msg = "No data received, try again."
+
+ raise errors.RadioError(msg)
+
+ data += a
+ # UI Update
+ status.cur = len(data)
+ radio.status_fn(status)
+
+ if len(data) != MEM_SIZE:
+ msg = "Incomplete data, we need %02i but got %02i bytes." % \
+ (MEM_SIZE, len(data))
+ raise errors.RadioError(msg)
+
+ if ord(data[-1]) != _checksum(data[:-1]):
+ msg = "Bad checksum, please try again."
+ raise errors.RadioError(msg)
+
+ return data
+
+
+def _do_upload(radio):
+ """The upload function"""
+ # set serial discipline
+ _set_serial(radio)
+
+ # UI progress
+ status = chirp_common.Status()
+
+ # 10 seconds timeout
+ status.cur = 0
+ status.max = 100
+ status.msg = " Quick, press MON on the radio to start. "
+ radio.status_fn(status)
+
+ for byte in range(0,100):
+ status.cur = byte
+ radio.status_fn(status)
+ time.sleep(0.1)
+
+
+ # real upload if user don't cancel the timeout
+ status.cur = 0
+ status.max = MEM_SIZE
+ status.msg = " Cloning to radio... "
+ radio.status_fn(status)
+
+ # send data
+ data = str(radio.get_mmap())
+
+ # this radio has a trick, the EEPROM is an ancient SPI one, so it needs
+ # some time to write, so we send every byte and then allow
+ # a 0.01 seg to complete the write from the MCU to the SPI EEPROM
+ c = 0
+ for byte in data:
+ radio.pipe.write(byte)
+ time.sleep(0.01)
+
+ # UI Update
+ status.cur = c
+ radio.status_fn(status)
+
+ # counter
+ c = c + 1
+
+
+def _model_match(cls, data):
+ """Use a experimental guess to determine if the radio you just
+ downloaded or the img you opened is for this model"""
+
+ # It's hard to tell when this radio is really this radio.
+ # I use the first byte, that appears to be the ID and the IF settings
+
+ LOG.debug("Drivers's ID string:")
+ LOG.debug(cls.finger)
+ LOG.debug("Radio's ID string:")
+ LOG.debug(util.hexprint(data[0:4]))
+
+ radiod = [data[0], data[2:4]]
+ if cls.finger == radiod:
+ return True
+ else:
+ return False
+
+
+def bcd_to_int(data):
+ """Convert an array of bcdDataElement like \x12
+ into an int like 12"""
+ value = 0
+ a = (data & 0xF0) >> 4
+ b = data & 0x0F
+ value = (a * 10) + b
+ return value
+
+
+def int_to_bcd(data):
+ """Convert a int like 94 to 0x94"""
+ data, lsb = divmod(data, 10)
+ data, msb = divmod(data, 10)
+ res = (msb << 4) + lsb
+ return res
+
+
+class ftlx011(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
+ """Vertex FTL1011/2011/7011 4/8/12/24 channels"""
+ VENDOR = "Vertex Standard"
+ _memsize = MEM_SIZE
+ _upper = 0
+ _range = []
+ finger = [] # two elements rid & IF
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = \
+ ('This is a experimental driver, use it on your own risk.\n'
+ '\n'
+ 'This driver is just for the 4/12/24 channels variants of '
+ 'these radios, 99 channel variants are not supported yet.\n'
+ '\n'
+ 'The 99 channel versions appears to use another mem layout.\n'
+ )
+ rp.pre_download = _(dedent("""\
+ Please follow this steps carefully:
+
+ 1 - Turn on your radio
+ 2 - Connect the interface cable to your radio.
+ 3 - Click the button on this window to start download
+ (Radio will beep and led will flash)
+ 4 - Then press the "A" button in your radio to start cloning.
+ (At the end radio will beep)
+ """))
+ rp.pre_upload = _(dedent("""\
+ Please follow this steps carefully:
+
+ 1 - Turn on your radio
+ 2 - Connect the interface cable to your radio
+ 3 - Click the button on this window to start download
+ (you may see another dialog, click ok)
+ 4 - Radio will beep and led will flash
+ 5 - You will get a 10 seconds timeout to press "MON" before
+ data upload start
+ 6 - If all goes right radio will beep at end.
+
+ After cloning remove the cable and power cycle your radio to
+ get into normal mode.
+ """))
+ return rp
+
+ def get_features(self):
+ """Return information about this radio's features"""
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_tuning_step = False
+ rf.has_name = False
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_dtcs = True
+ rf.has_rx_dtcs = True
+ rf.has_dtcs_polarity = False
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.valid_duplexes = ["", "-", "+", "off"]
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = [
+ "Tone->Tone",
+ "DTCS->DTCS",
+ "DTCS->",
+ "->DTCS"]
+ rf.valid_dtcs_codes = DTCS_CODES
+ rf.valid_skips = SKIP_VALUES
+ rf.valid_modes = ["FM"]
+ rf.valid_power_levels = POWER_LEVELS
+ #rf.valid_tuning_steps = [5.0]
+ rf.valid_bands = [self._range]
+ rf.memory_bounds = (1, self._upper)
+ return rf
+
+ def sync_in(self):
+ """Do a download of the radio eeprom"""
+ try:
+ data = _do_download(self)
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio:\n %s" % e)
+
+ # match model
+ if _model_match(self, data) is False:
+ raise errors.RadioError("Incorrect radio model")
+
+ self._mmap = memmap.MemoryMap(data)
+ self.process_mmap()
+
+ # set the channel count from the radio eeprom
+ self._upper = int(ord(data[4]))
+
+ def sync_out(self):
+ """Do an upload to the radio eeprom"""
+ # update checksum
+ _update_cs(self)
+
+ # sanity check, match model
+ data = str(self.get_mmap())
+ if len(data) != MEM_SIZE:
+ raise errors.RadioError("Wrong radio image? Size miss match.")
+
+ if _model_match(self, data) is False:
+ raise errors.RadioError("Wrong image? Fingerprint miss match")
+
+ try:
+ _do_upload(self)
+ except Exception as e:
+ msg = "Failed to communicate with radio:\n%s" % e
+ raise errors.RadioError(msg)
+
+ def process_mmap(self):
+ """Process the memory object"""
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def get_raw_memory(self, number):
+ """Return a raw representation of the memory object"""
+ return repr(self._memobj.memory[number])
+
+ def _decode_tone(self, mem, rx=True):
+ """Parse the tone data to decode from mem tones are encodded like this
+ CTCS: mapped [0x80...0xa5] = [67.0...250.3]
+ DTCS: mixed [0x88, 0x23] last is BCD and first is the 100 power - 88
+
+ It return: ((''|DTCS|Tone), Value (None|###), None)"""
+ mode = ""
+ tone = None
+
+ # get the tone depending of rx or tx
+ if rx:
+ t = mem.rx_tone
+ else:
+ t = mem.tx_tone
+
+ tMSB = t[0]
+ tLSB = t[1]
+
+ # no tone at all
+ if (tMSB == 0 and tLSB < 128):
+ return ('', None, None)
+
+ # extract the tone info
+ if tMSB == 0x00:
+ # CTCS
+ mode = "Tone"
+ try:
+ tone = TONES[tLSB - 128]
+ except IndexError:
+ LOG.debug("Error decoding a CTCS tone")
+ pass
+ else:
+ # DTCS
+ mode = "DTCS"
+ try:
+ tone = ((tMSB - 0x88) * 100) + bcd_to_int(tLSB)
+ except IndexError:
+ LOG.debug("Error decoding a DTCS tone")
+ pass
+
+ return (mode, tone, None)
+
+ def _encode_tone(self, mem, mode, value, pol, rx=True):
+ """Parse the tone data to encode from UI to mem
+ CTCS: mapped [0x80...0xa5] = [67.0...250.3]
+ DTCS: mixed [0x88, 0x23] last is BCD and first is the 100 power - 88
+ """
+
+ # array to pass
+ tone = [0x00, 0x00]
+
+ # which mod
+ if mode == "DTCS":
+ tone[0] = int(value / 100) + 0x88
+ tone[1] = int_to_bcd(value % 100)
+
+ if mode == "Tone":
+ #CTCS
+ tone[1] = TONES.index(value) + 128
+
+ # set it
+ if rx:
+ mem.rx_tone = tone
+ else:
+ mem.tx_tone = tone
+
+ def get_memory(self, number):
+ """Extract a memory object from the memory map"""
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[number - 1]
+ # Create a high-level memory object to return to the UI
+ mem = chirp_common.Memory()
+ # number
+ mem.number = number
+
+ # empty
+ if bool(_mem.empty) is True:
+ mem.empty = True
+ return mem
+
+ # rx freq
+ mem.freq = int(_mem.rx_freq) * 1000
+
+ # power
+ mem.power = POWER_LEVELS[int(_mem.power)]
+
+ # checking if tx freq is disabled
+ if bool(_mem.notx) is True:
+ mem.duplex = "off"
+ mem.offset = 0
+ else:
+ tx = int(_mem.tx_freq) * 1000
+ if tx == mem.freq:
+ mem.offset = 0
+ mem.duplex = ""
+ else:
+ mem.duplex = mem.freq > tx and "-" or "+"
+ mem.offset = abs(tx - mem.freq)
+
+ # skip
+ mem.skip = SKIP_VALUES[_mem.skip]
+
+ # tone data
+ rxtone = txtone = None
+ rxtone = self._decode_tone(_mem)
+ txtone = self._decode_tone(_mem, False)
+ chirp_common.split_tone_decode(mem, txtone, rxtone)
+
+ # this radio has a primitive mode to show the channel number on a 7-segment
+ # two digit LCD, we will use channel number
+ # we will use a trick to show the numbers < 10 with a space not a zero in front
+ chname = int_to_bcd(mem.number)
+ if mem.number < 10:
+ # convert to F# as BCD
+ chname = mem.number + 240
+
+ _mem.chname = chname
+
+ # Extra
+ mem.extra = RadioSettingGroup("extra", "Extra")
+
+ # bcl preparations: ["OFF", "Carrier", "Tone"]
+ bcls = 0
+ if _mem.bclo_cw:
+ bcls = 1
+ if _mem.bclo_tone:
+ bcls = 2
+
+ bcl = RadioSetting("bclo", "Busy channel lockout",
+ RadioSettingValueList(LIST_BCL,
+ LIST_BCL[bcls]))
+ mem.extra.append(bcl)
+
+ # return mem
+ return mem
+
+ def set_memory(self, mem):
+ """Store details about a high-level memory to the memory map
+ This is called when a user edits a memory in the UI"""
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[mem.number - 1]
+
+ # Empty memory
+ if mem.empty:
+ _mem.empty = True
+ _mem.rx_freq = _mem.tx_freq = 0
+ return
+
+ # freq rx
+ _mem.rx_freq = mem.freq / 1000
+
+ # power, # default power level is high
+ _mem.power = 0 if mem.power is None else POWER_LEVELS.index(mem.power)
+
+ # freq tx
+ if mem.duplex == "+":
+ _mem.tx_freq = (mem.freq + mem.offset) / 1000
+ elif mem.duplex == "-":
+ _mem.tx_freq = (mem.freq - mem.offset) / 1000
+ elif mem.duplex == "off":
+ _mem.notx = 1
+ _mem.tx_freq = _mem.rx_freq
+ else:
+ _mem.tx_freq = mem.freq / 1000
+
+ # scan add property
+ _mem.skip = SKIP_VALUES.index(mem.skip)
+
+ # tone data
+ ((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \
+ chirp_common.split_tone_encode(mem)
+
+ # validate tone data from here
+ if rxmode == "Tone" and rxtone in invalid_tones:
+ msg = "The tone %shz is not valid for this radio" % rxtone
+ raise errors.UnsupportedToneError(msg)
+
+ if txmode == "Tone" and txtone in invalid_tones:
+ msg = "The tone %shz is not valid for this radio" % txtone
+ raise errors.UnsupportedToneError(msg)
+
+ if rxmode == "DTCS" and rxtone not in DTCS_CODES:
+ msg = "The digital tone %s is not valid for this radio" % rxtone
+ raise errors.UnsupportedToneError(msg)
+
+ if txmode == "DTCS" and txtone not in DTCS_CODES:
+ msg = "The digital tone %s is not valid for this radio" % txtone
+ raise errors.UnsupportedToneError(msg)
+
+ self._encode_tone(_mem, rxmode, rxtone, rxpol)
+ self._encode_tone(_mem, txmode, txtone, txpol, False)
+
+ # this radio has a primitive mode to show the channel number on a 7-segment
+ # two digit LCD, we will use channel number
+ # we will use a trick to show the numbers < 10 with a space not a zero in front
+ chname = int_to_bcd(mem.number)
+ if mem.number < 10:
+ # convert to F# as BCD
+ chname = mem.number + 240
+
+ def _zero_settings():
+ _mem.bclo_cw = 0
+ _mem.bclo_tone = 0
+
+ # extra settings
+ if len(mem.extra) > 0:
+ # there are setting, parse
+ LOG.debug("Extra-Setting supplied. Setting them.")
+ # Zero them all first so any not provided by model don't
+ # stay set
+ _zero_settings()
+ for setting in mem.extra:
+ if setting.get_name() == "bclo":
+ sw = LIST_BCL.index(str(setting.value))
+ if sw == 0:
+ # empty
+ _zero_settings()
+ if sw == 1:
+ # carrier
+ _mem.bclo_cw = 1
+ if sw == 2:
+ # tone
+ _mem.bclo_tone = 1
+ # activate the tone
+ _mem.rx_tone = [0x00, 0x80]
+ else:
+ # reset extra settings
+ _zero_settings()
+
+ _mem.chname = chname
+
+ return mem
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ group = RadioSettings(basic)
+
+ # ## Basic Settings
+ scanr = RadioSetting("scan_resume", "Scan resume by",
+ RadioSettingValueList(
+ LIST_SCAN_RESUME, LIST_SCAN_RESUME[_settings.scan_resume]))
+ basic.append(scanr)
+
+ scant = RadioSetting("scan_time", "Scan time per channel",
+ RadioSettingValueList(
+ LIST_SCAN_TIME, LIST_SCAN_TIME[_settings.scan_time]))
+ basic.append(scant)
+
+ LIST_PCH = ["%s" % x for x in range(1, _settings.chcount + 1)]
+ pch1 = RadioSetting("pch1", "Priority channel 1",
+ RadioSettingValueList(
+ LIST_PCH, LIST_PCH[_settings.pch1]))
+ basic.append(pch1)
+
+ pch2 = RadioSetting("pch2", "Priority channel 2",
+ RadioSettingValueList(
+ LIST_PCH, LIST_PCH[_settings.pch2]))
+ basic.append(pch2)
+
+ scanp = RadioSetting("priority_during_scan", "Disable priority during scan",
+ RadioSettingValueBoolean(_settings.priority_during_scan))
+ basic.append(scanp)
+
+ scanps = RadioSetting("priority_speed", "Priority scan speed",
+ RadioSettingValueList(
+ LIST_SCAN_P_SPEED, LIST_SCAN_P_SPEED[_settings.priority_speed]))
+ basic.append(scanps)
+
+ oh = RadioSetting("off_hook", "Off Hook", #inverted
+ RadioSettingValueBoolean(not _settings.off_hook))
+ basic.append(oh)
+
+ tb = RadioSetting("talk_back", "Talk Back", # inverted
+ RadioSettingValueBoolean(not _settings.talk_back))
+ basic.append(tb)
+
+ tot = RadioSetting("tot", "Time out timer",
+ RadioSettingValueList(
+ LIST_TOT, LIST_TOT[_settings.tot]))
+ basic.append(tot)
+
+ totr = RadioSetting("tot_resume", "Time out timer resume guard",
+ RadioSettingValueList(
+ LIST_TOT_RESUME, LIST_TOT_RESUME[_settings.tot_resume]))
+ basic.append(totr)
+
+ ak = RadioSetting("a_key", "A Key function",
+ RadioSettingValueList(
+ LIST_A_KEY, LIST_A_KEY[_settings.a_key]))
+ basic.append(ak)
+
+ monitor = RadioSetting("monitor", "Monitor", # inverted
+ RadioSettingValueBoolean(not _settings.monitor))
+ basic.append(monitor)
+
+ homec = RadioSetting("home_channel", "Home Channel is",
+ RadioSettingValueList(
+ LIST_HOME_CHANNEL, LIST_HOME_CHANNEL[_settings.home_channel]))
+ basic.append(homec)
+
+ txd = RadioSetting("tx_carrier_delay", "Talk Back",
+ RadioSettingValueBoolean(_settings.tx_carrier_delay))
+ basic.append(txd)
+
+
+ return group
+
+ def set_settings(self, uisettings):
+ _settings = self._memobj.settings
+
+ for element in uisettings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ if not element.changed():
+ continue
+
+ try:
+ name = element.get_name()
+ value = element.value
+
+ print(("== Setting %s: %s" % (name, value)))
+
+ obj = getattr(_settings, name)
+ if name in ["off_hook", "talk_back", "monitor"]:
+ setattr(_settings, name, not value)
+ else:
+ setattr(_settings, name, value)
+
+ LOG.debug("Setting %s: %s" % (name, value))
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ match_size = False
+ match_model = False
+
+ # testing the file data size
+ if len(filedata) == cls._memsize:
+ match_size = True
+ print(("Comp: %i file / %i memzise" % (len(filedata), cls._memsize) ))
+
+ # testing the firmware fingerprint, this experimental
+ match_model = _model_match(cls, filedata)
+
+ if match_size and match_model:
+ return True
+ else:
+ return False
+
+
+@directory.register
+class ftl1011(ftlx011):
+ """Vertex FTL-1011"""
+ MODEL = "FTL-1011"
+ _memsize = MEM_SIZE
+ _upper = 4
+ _range = [44000000, 56000000]
+ finger = ["\x52", "\x16\x90"]
+
+
+@directory.register
+class ftl2011(ftlx011):
+ """Vertex FTL-2011"""
+ MODEL = "FTL-2011"
+ _memsize = MEM_SIZE
+ _upper = 24
+ _range = [134000000, 174000000]
+ finger = ["\x50", "\x21\x40"]
+
+
+@directory.register
+class ftl7011(ftlx011):
+ """Vertex FTL-7011"""
+ MODEL = "FTL-7011"
+ _memsize = MEM_SIZE
+ _upper = 24
+ _range = [400000000, 512000000]
+ finger = ["\x54", "\x47\x90"]
+
+
+@directory.register
+class ftl8011(ftlx011):
+ """Vertex FTL-8011"""
+ MODEL = "FTL-8011"
+ _memsize = MEM_SIZE
+ _upper = 24
+ _range = [400000000, 512000000]
+ finger = ["\x5c", "\x45\x10"]
diff --git a/chirp/drivers/ftm350.py b/chirp/drivers/ftm350.py
index ea5bc2f..95ef755 100644
--- a/chirp/drivers/ftm350.py
+++ b/chirp/drivers/ftm350.py
@@ -85,7 +85,7 @@ _TMODES = ["", "Tone", "TSQL", "-RVT", "DTCS", "-PR", "-PAG"]
TMODES = ["", "Tone", "TSQL", "", "DTCS", "", ""]
MODES = ["FM", "AM", "NFM", "", "WFM"]
DUPLEXES = ["", "", "-", "+", "split"]
-# TODO: add japaneese characters (viewable in special menu, scroll backwards)
+# TODO: add japanese characters (viewable in special menu, scroll backwards)
CHARSET = \
('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"' +
'#$%&`()*+,-./:;<=>?@[\\]^_`{|}~?????? ' + '?' * 91)
@@ -278,7 +278,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
self._mmap = _clone_in(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to download from radio (%s)" % e)
self.process_mmap()
@@ -287,7 +287,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
_clone_out(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to upload to radio (%s)" % e)
def process_mmap(self):
@@ -399,7 +399,7 @@ class FTM350Radio(yaesu_clone.YaesuCloneModeRadio):
@classmethod
def match_model(self, filedata, filename):
- return filedata.startswith("AH033$")
+ return filedata.startswith(b"AH033$")
def get_settings(self):
top = RadioSettings()
diff --git a/chirp/drivers/ftm7250d.py b/chirp/drivers/ftm7250d.py
new file mode 100644
index 0000000..dd5b164
--- /dev/null
+++ b/chirp/drivers/ftm7250d.py
@@ -0,0 +1,202 @@
+# Copyright 2010 Dan Smith <dsmith@danplanet.com>
+# Copyright 2017 Wade Simmons <wade@wades.im>
+# FTM-7250D driver cloned from the FTM-3200 and modified by Iain White
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+from textwrap import dedent
+
+from chirp.drivers import yaesu_clone, ft1d
+from chirp import chirp_common, directory, bitwise
+from chirp.settings import RadioSettings
+
+LOG = logging.getLogger(__name__)
+
+POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5),
+ chirp_common.PowerLevel("Mid", watts=25),
+ chirp_common.PowerLevel("Hi", watts=50)]
+
+TMODES = ["", "Tone", "TSQL", "DTCS", "TSQL-R", None, None, "Pager", "Cross"]
+CROSS_MODES = [None, "DTCS->", "Tone->DTCS", "DTCS->Tone"]
+
+MODES = ["FM", "NFM"]
+STEPS = [0, 5, 6.25, 10, 12.5, 15, 20, 25, 50, 100] # 0 = auto
+RFSQUELCH = ["OFF", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8"]
+
+# Charset is subset of ASCII + some unknown chars \x80-\x86
+VALID_CHARS = ["%i" % int(x) for x in range(0, 10)] + \
+ list(":>=<?@") + \
+ [chr(x) for x in range(ord("A"), ord("Z") + 1)] + \
+ list("[\\]_") + \
+ [chr(x) for x in range(ord("a"), ord("z") + 1)] + \
+ list("%*+,-/=$ ")
+
+MEM_FORMAT = """
+#seekto 0xceca;
+struct {
+ u8 unknown5;
+ u8 unknown3;
+ u8 unknown4:6,
+ dsqtype:2;
+ u8 dsqcode;
+ u8 unknown1[2];
+ char mycall[10];
+ u8 unknown2[368];
+} settings;
+
+#seekto 0xfec9;
+u8 checksum;
+"""
+
+
+@directory.register
+class FTM7250Radio(ft1d.FT1Radio):
+ """Yaesu FTM-7250D"""
+ BAUD_RATE = 38400
+ VENDOR = "Yaesu"
+ MODEL = "FTM-7250D"
+ VARIANT = "R"
+
+ _model = "AH75M"
+ _memsize = 65227
+ _block_lengths = [10, 65217]
+ _has_vibrate = False
+ _has_af_dual = False
+
+ _mem_params = (199, # size of memories array
+ 199) # size of flags array
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.pre_download = _(dedent("""\
+ 1. Turn radio off.
+ 2. Connect cable to MIC Jack.
+ 3. Press and hold in the [MHz(SETUP)] key while turning the radio
+ on ("CLONE" will appear on the display).
+ 4. <b>After clicking OK</b>, press the [GM(AMS)] key
+ to send image."""))
+ rp.pre_upload = _(dedent("""\
+ 1. Turn radio off.
+ 2. Connect cable to MIC Jack.
+ 3. Press and hold in the [MHz(SETUP)] key while turning the radio
+ on ("CLONE" will appear on the display).
+ 4. Press the [MHz(SETUP)] key
+ ("-WAIT-" will appear on the LCD)."""))
+ return rp
+
+ def process_mmap(self):
+ mem_format = ft1d.MEM_FORMAT + MEM_FORMAT
+ self._memobj = bitwise.parse(mem_format % self._mem_params, self._mmap)
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_dtcs_polarity = False
+ rf.valid_modes = list(MODES)
+ rf.valid_tmodes = [x for x in TMODES if x is not None]
+ rf.valid_cross_modes = [x for x in CROSS_MODES if x is not None]
+ rf.valid_duplexes = list(ft1d.DUPLEX)
+ rf.valid_tuning_steps = list(STEPS)
+ rf.valid_bands = [(108000000, 580000000)]
+ # rf.valid_skips = SKIPS
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_characters = "".join(VALID_CHARS)
+ rf.valid_name_length = 8
+ rf.memory_bounds = (1, 199)
+ rf.can_odd_split = True
+ rf.has_ctone = False
+ rf.has_bank = False
+ rf.has_bank_names = False
+ # disable until implemented
+ rf.has_settings = False
+ return rf
+
+ def _decode_label(self, mem):
+ # TODO preserve the unknown \x80-x86 chars?
+ return str(mem.label).rstrip("\xFF").decode('ascii', 'replace')
+
+ def _encode_label(self, mem):
+ label = mem.name.rstrip().encode('ascii', 'ignore')
+ return self._add_ff_pad(label, 16)
+
+ def _encode_charsetbits(self, mem):
+ # TODO this is a setting to decide if the memory should be displayed
+ # as a name or frequency. Should we expose this setting to the user
+ # instead of autoselecting it (and losing their preference)?
+ if mem.name.rstrip() == '':
+ return [0x00, 0x00]
+ return [0x00, 0x80]
+
+ def _decode_power_level(self, mem):
+ return POWER_LEVELS[mem.power - 1]
+
+ def _encode_power_level(self, mem):
+ return POWER_LEVELS.index(mem.power) + 1
+
+ def _decode_mode(self, mem):
+ return MODES[mem.mode_alt]
+
+ def _encode_mode(self, mem):
+ return MODES.index(mem.mode)
+
+ def _get_tmode(self, mem, _mem):
+ if _mem.tone_mode > 8:
+ tmode = "Cross"
+ mem.cross_mode = CROSS_MODES[_mem.tone_mode - 8]
+ else:
+ tmode = TMODES[_mem.tone_mode]
+
+ if tmode == "Pager":
+ # TODO chirp_common does not allow 'Pager'
+ # Expose as a different setting?
+ mem.tmode = ""
+ else:
+ mem.tmode = tmode
+
+ def _set_tmode(self, _mem, mem):
+ if mem.tmode == "Cross":
+ _mem.tone_mode = 8 + CROSS_MODES.index(mem.cross_mode)
+ else:
+ _mem.tone_mode = TMODES.index(mem.tmode)
+
+ def _set_mode(self, _mem, mem):
+ _mem.mode_alt = self._encode_mode(mem)
+
+ def get_bank_model(self):
+ return None
+
+ def _debank(self, mem):
+ return
+
+ def _checksums(self):
+ return [yaesu_clone.YaesuChecksum(0x064A, 0x06C8),
+ yaesu_clone.YaesuChecksum(0x06CA, 0x0748),
+ yaesu_clone.YaesuChecksum(0x074A, 0x07C8),
+ yaesu_clone.YaesuChecksum(0x07CA, 0x0848),
+ yaesu_clone.YaesuChecksum(0x0000, 0xFEC9)]
+
+ def _get_settings(self):
+ # TODO
+ top = RadioSettings()
+ return top
+
+ @classmethod
+ def _wipe_memory(cls, mem):
+ mem.set_raw("\x00" * (mem.size() / 8))
+
+ def sync_out(self):
+ # Need to give enough time for the radio to ACK after writes
+ self.pipe.timeout = 1
+ return super(FTM7250Radio, self).sync_out()
diff --git a/chirp/drivers/ga510.py b/chirp/drivers/ga510.py
new file mode 100644
index 0000000..18957f4
--- /dev/null
+++ b/chirp/drivers/ga510.py
@@ -0,0 +1,850 @@
+import logging
+import struct
+
+from chirp import bitwise
+from chirp import chirp_common
+from chirp import directory
+from chirp import errors
+from chirp import memmap
+from chirp.settings import RadioSetting, RadioSettingGroup, RadioSettings
+from chirp.settings import RadioSettingValueBoolean, RadioSettingValueList
+from chirp.settings import RadioSettingValueInteger, RadioSettingValueString
+
+LOG = logging.getLogger(__name__)
+
+try:
+ from builtins import bytes
+ has_future = True
+except ImportError:
+ has_future = False
+ LOG.debug('python-future package is not available; '
+ '%s requires it' % __name__)
+
+# GA510 also has DTCS code 645
+DTCS_CODES = list(sorted(chirp_common.DTCS_CODES + [645]))
+
+DTMFCHARS = '0123456789ABCD*#'
+
+
+def reset(radio):
+ radio.pipe.write(b'E')
+
+
+def start_program(radio):
+ reset(radio)
+ radio.pipe.read(256)
+ radio.pipe.write(radio._magic)
+ ack = radio.pipe.read(256)
+ if not ack.endswith(b'\x06'):
+ LOG.debug('Ack was %r' % ack)
+ raise errors.RadioError('Radio did not respond to clone request')
+
+ radio.pipe.write(b'F')
+
+ ident = radio.pipe.read(8)
+ LOG.debug('Radio ident string is %r' % ident)
+
+ return ident
+
+
+def do_download(radio):
+ ident = start_program(radio)
+
+ s = chirp_common.Status()
+ s.msg = 'Downloading'
+ s.max = 0x1C00
+
+ data = bytes()
+ for addr in range(0, 0x1C40, 0x40):
+ cmd = struct.pack('>cHB', b'R', addr, 0x40)
+ LOG.debug('Reading block at %04x: %r' % (addr, cmd))
+ radio.pipe.write(cmd)
+
+ block = radio.pipe.read(0x44)
+ header = block[:4]
+ rcmd, raddr, rlen = struct.unpack('>BHB', header)
+ block = block[4:]
+ if raddr != addr:
+ raise errors.RadioError('Radio send address %04x, expected %04x' %
+ (raddr, addr))
+ if rlen != 0x40 or len(block) != 0x40:
+ raise errors.RadioError('Radio sent %02x (%02x) bytes, '
+ 'expected %02x' % (rlen, len(block), 0x40))
+
+ data += block
+
+ s.cur = addr
+ radio.status_fn(s)
+
+ reset(radio)
+
+ return data
+
+
+def do_upload(radio):
+ ident = start_program(radio)
+
+ s = chirp_common.Status()
+ s.msg = 'Uploading'
+ s.max = 0x1C00
+
+ # The factory software downloads 0x40 for the block
+ # at 0x1C00, but only uploads 0x20 there. Mimic that
+ # here.
+ for addr in range(0, 0x1C20, 0x20):
+ cmd = struct.pack('>cHB', b'W', addr, 0x20)
+ LOG.debug('Writing block at %04x: %r' % (addr, cmd))
+ block = radio._mmap[addr:addr + 0x20]
+ radio.pipe.write(cmd)
+ radio.pipe.write(block)
+
+ ack = radio.pipe.read(1)
+ if ack != b'\x06':
+ raise errors.RadioError('Radio refused block at addr %04x' % addr)
+
+ s.cur = addr
+ radio.status_fn(s)
+
+
+MEM_FORMAT = """
+struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 signal;
+ u8 unknown1:6,
+ pttid:2;
+ u8 unknown2:6,
+ power:2;
+ u8 unknown3_0:1,
+ narrow:1,
+ unknown3_1:2,
+ bcl:1,
+ scan:1,
+ unknown3_2:1,
+ fhss:1;
+} memories[128];
+
+#seekto 0x0C00;
+struct {
+ char name[10];
+ u8 pad[6];
+} names[128];
+
+#seekto 0x1A00;
+struct {
+ // 0x1A00
+ u8 squelch;
+ u8 savemode; // [off, mode1, mode2, mode3]
+ u8 vox; // off=0
+ u8 backlight;
+ u8 tdr; // bool
+ u8 timeout; // n*15 = seconds
+ u8 beep; // bool
+ u8 voice;
+
+ // 0x1A08
+ u8 language; // [eng, chin]
+ u8 dtmfst;
+ u8 scanmode; // [TO, CO, SE]
+ u8 pttid; // [off, BOT, EOT, Both]
+ u8 pttdelay; // 0-30
+ u8 cha_disp; // [ch-name, ch-freq]
+ // [ch, ch-name]; retevis
+ u8 chb_disp;
+ u8 bcl; // bool
+
+ // 0x1A10
+ u8 autolock; // bool
+ u8 alarm_mode; // [site, tone, code]
+ u8 alarmsound; // bool
+ u8 txundertdr; // [off, bandA, bandB]
+ u8 tailnoiseclear; // [off, on]
+ u8 rptnoiseclr; // 10*ms, 0-1000
+ u8 rptnoisedet;
+ u8 roger; // bool
+
+ // 0x1A18
+ u8 unknown1a10;
+ u8 fmradio; // boolean, inverted
+ u8 workmode; // [vfo, chan]; 1A30-1A31 related?
+ u8 kblock; // boolean
+} settings;
+
+#seekto 0x1A80;
+struct {
+ u8 skey1sp; // [off, lamp, sos, fm, noaa, moni, search]
+ u8 skey1lp; // [off, lamp, sos, fm, noaa, moni, search]
+ u8 skey2sp; // [off, lamp, sos, fm, noaa, moni, search]
+ u8 skey2lp; // [off, lamp, sos, fm, noaa, moni, search]
+} skey;
+
+struct dtmfcode {
+ u8 code[5];
+ u8 ffpad[11]; // always 0xFF
+};
+#seekto 0x1B00;
+struct dtmfcode dtmfgroup[15];
+struct {
+ u8 code[5];
+ u8 groupcode; // 0->D, *, #
+ u8 nothing:6,
+ releasetosend:1,
+ presstosend:1;
+ u8 dtmfspeedon; // 80 + n*10, up to [194]
+ u8 dtmfspeedoff;
+} anicode;
+
+//dtmf on -> 90ms
+//dtmf off-> 120ms
+//group code *->0
+//press 0->1
+//release 1->0
+
+"""
+
+
+PTTID = ['Off', 'BOT', 'EOT', 'Both']
+SIGNAL = [str(i) for i in range(1, 16)]
+
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3
+
+
+@directory.register
+class RadioddityGA510Radio(chirp_common.CloneModeRadio):
+ VENDOR = 'Radioddity'
+ MODEL = 'GA-510'
+ BAUD_RATE = 9600
+ NEEDS_COMPAT_SERIAL = False
+ POWER_LEVELS = [
+ chirp_common.PowerLevel('H', watts=10),
+ chirp_common.PowerLevel('L', watts=1),
+ chirp_common.PowerLevel('M', watts=5)]
+
+ _magic = (b'PROGROMBFHU')
+
+ _gmrs = False
+
+ def sync_in(self):
+ try:
+ data = do_download(self)
+ self._mmap = memmap.MemoryMapBytes(data)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ LOG.exception('General failure')
+ raise errors.RadioError('Failed to download from radio: %s' % e)
+ self.process_mmap()
+
+ def sync_out(self):
+ try:
+ do_upload(self)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ LOG.exception('General failure')
+ raise errors.RadioError('Failed to upload to radio: %s' % e)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.memory_bounds = (0, 127)
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_tuning_step = False
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_sub_devices = False
+ rf.has_dtcs_polarity = True
+ rf.has_rx_dtcs = True
+ rf.can_odd_split = True
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = ['Tone->Tone', 'DTCS->', '->DTCS', 'Tone->DTCS',
+ 'DTCS->Tone', '->Tone', 'DTCS->DTCS']
+ rf.valid_modes = ['FM', 'NFM']
+ rf.valid_tuning_steps = [2.5, 5.0, 6.25, 12.5, 10.0, 15.0, 20.0,
+ 25.0, 50.0, 100.0]
+ rf.valid_dtcs_codes = DTCS_CODES
+ rf.valid_duplexes = ['', '-', '+', 'split', 'off']
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_name_length = 10
+ rf.valid_characters = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ 'abcdefghijklmnopqrstuvwxyz'
+ '0123456789'
+ '!"#$%&\'()~+-,./:;<=>?@[\\]^`{}*| ')
+ rf.valid_bands = [(136000000, 174000000),
+ (400000000, 480000000)]
+ return rf
+
+ def get_raw_memory(self, num):
+ return repr(self._memobj.memories[num]) + repr(self._memobj.names[num])
+
+ @staticmethod
+ def _decode_tone(toneval):
+ if toneval in (0, 0xFFFF):
+ LOG.debug('no tone value: %s' % toneval)
+ return '', None, None
+ elif toneval < 670:
+ toneval = toneval - 1
+ index = toneval % len(DTCS_CODES)
+ if index != int(toneval):
+ pol = 'R'
+ # index -= 1
+ else:
+ pol = 'N'
+ return 'DTCS', DTCS_CODES[index], pol
+ else:
+ return 'Tone', toneval / 10.0, 'N'
+
+ @staticmethod
+ def _encode_tone(mode, val, pol):
+ if not mode:
+ return 0x0000
+ elif mode == 'Tone':
+ return int(val * 10)
+ elif mode == 'DTCS':
+ index = DTCS_CODES.index(val)
+ if pol == 'R':
+ index += len(DTCS_CODES)
+ index += 1
+ LOG.debug('Encoded dtcs %s/%s to %04x' % (val, pol, index))
+ return index
+ else:
+ raise errors.RadioError('Unsupported tone mode %r' % mode)
+
+ def _get_extra(self, _mem):
+ group = RadioSettingGroup('extra', 'Extra')
+
+ s = RadioSetting('bcl', 'Busy Channel Lockout',
+ RadioSettingValueBoolean(_mem.bcl))
+ group.append(s)
+
+ s = RadioSetting('fhss', 'FHSS',
+ RadioSettingValueBoolean(_mem.fhss))
+ group.append(s)
+
+ # pttid, signal
+
+ cur = PTTID[int(_mem.pttid)]
+ s = RadioSetting('pttid', 'PTTID',
+ RadioSettingValueList(PTTID, cur))
+ group.append(s)
+
+ cur = SIGNAL[int(_mem.signal)]
+ s = RadioSetting('signal', 'Signal',
+ RadioSettingValueList(SIGNAL, cur))
+ group.append(s)
+
+ return group
+
+ def _set_extra(self, _mem, mem):
+ _mem.bcl = int(mem.extra['bcl'].value)
+ _mem.fhss = int(mem.extra['fhss'].value)
+ _mem.pttid = int(mem.extra['pttid'].value)
+ _mem.signal = int(mem.extra['signal'].value)
+
+ def _is_txinh(self, _mem):
+ raw_tx = ""
+ for i in range(0, 4):
+ raw_tx += _mem.txfreq[i].get_raw()
+ return raw_tx == "\xFF\xFF\xFF\xFF"
+
+ def _get_mem(self, num):
+ return self._memobj.memories[num]
+
+ def _get_nam(self, num):
+ return self._memobj.names[num]
+
+ def get_memory(self, num):
+ _mem = self._get_mem(num)
+ _nam = self._get_nam(num)
+ mem = chirp_common.Memory()
+ mem.number = num
+ if int(_mem.rxfreq) == 166666665:
+ mem.empty = True
+ return mem
+
+ mem.name = ''.join([str(c) for c in _nam.name
+ if ord(str(c)) < 127]).rstrip()
+ mem.freq = int(_mem.rxfreq) * 10
+ offset = (int(_mem.txfreq) - int(_mem.rxfreq)) * 10
+ if self._is_txinh(_mem):
+ mem.duplex = 'off'
+ mem.offset = 0
+ elif offset == 0:
+ mem.duplex = ''
+ elif abs(offset) < 100000000:
+ mem.duplex = offset < 0 and '-' or '+'
+ mem.offset = abs(offset)
+ else:
+ mem.duplex = 'split'
+ mem.offset = int(_mem.txfreq) * 10
+
+ mem.power = self.POWER_LEVELS[_mem.power]
+ mem.mode = 'NFM' if _mem.narrow else 'FM'
+ mem.skip = '' if _mem.scan else 'S'
+
+ LOG.debug('got txtone: %s' % repr(self._decode_tone(_mem.txtone)))
+ LOG.debug('got rxtone: %s' % repr(self._decode_tone(_mem.rxtone)))
+ chirp_common.split_tone_decode(mem,
+ self._decode_tone(_mem.txtone),
+ self._decode_tone(_mem.rxtone))
+ try:
+ mem.extra = self._get_extra(_mem)
+ except:
+ LOG.exception('Failed to get extra for %i' % num)
+ return mem
+
+ def _set_mem(self, number):
+ return self._memobj.memories[number]
+
+ def _set_nam(self, number):
+ return self._memobj.names[number]
+
+ def set_memory(self, mem):
+ _mem = self._set_mem(mem.number)
+ _nam = self._set_nam(mem.number)
+
+ if mem.empty:
+ _mem.set_raw(b'\xff' * 16)
+ _nam.set_raw(b'\xff' * 16)
+ return
+
+ if int(_mem.rxfreq) == 166666665:
+ LOG.debug('Initializing new memory %i' % mem.number)
+ _mem.set_raw(b'\x00' * 16)
+
+ if self._gmrs:
+ if float(mem.freq) / 1000000 in GMRS_FREQS:
+ if float(mem.freq) / 1000000 in GMRS_FREQS1:
+ mem.duplex = ''
+ mem.offset = 0
+ if float(mem.freq) / 1000000 in GMRS_FREQS2:
+ mem.duplex = ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ if float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.duplex = ''
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
+ _nam.name = mem.name.ljust(10)
+
+ _mem.rxfreq = mem.freq // 10
+ if mem.duplex == '':
+ _mem.txfreq = mem.freq // 10
+ elif mem.duplex == 'split':
+ _mem.txfreq = mem.offset // 10
+ elif mem.duplex == 'off':
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw(b'\xFF')
+ elif mem.duplex == '-':
+ _mem.txfreq = (mem.freq - mem.offset) // 10
+ elif mem.duplex == '+':
+ _mem.txfreq = (mem.freq + mem.offset) // 10
+ else:
+ raise errors.RadioError('Unsupported duplex mode %r' % mem.duplex)
+
+ txtone, rxtone = chirp_common.split_tone_encode(mem)
+ LOG.debug('tx tone is %s' % repr(txtone))
+ LOG.debug('rx tone is %s' % repr(rxtone))
+ _mem.txtone = self._encode_tone(*txtone)
+ _mem.rxtone = self._encode_tone(*rxtone)
+
+ try:
+ _mem.power = self.POWER_LEVELS.index(mem.power)
+ except ValueError:
+ _mem.power = 0
+ _mem.narrow = mem.mode == 'NFM'
+ _mem.scan = mem.skip != 'S'
+ if mem.extra:
+ self._set_extra(_mem, mem)
+
+ def get_settings(self):
+ _set = self._memobj.settings
+
+ basic = RadioSettingGroup('basic', 'Basic')
+ adv = RadioSettingGroup('advanced', 'Advanced')
+ dtmf = RadioSettingGroup('dtmf', 'DTMF')
+
+ radioddity_settings = {
+ 'savemode': ['Off', 'Mode 1', 'Mode 2', 'Mode 3'],
+ 'cha_disp': ['CH+Name', 'CH+Freq'],
+ 'chb_disp': ['CH+Name', 'CH+Freq'],
+ 'txundertdr': ['Off', 'Band A', 'Band B'],
+ 'rptnoiseclr': ['Off'] + ['%i' % i for i in range(100, 1001, 100)],
+ 'rptnoisedet': ['Off'] + ['%i' % i for i in range(100, 1001, 100)],
+ }
+
+ retevis_settings = {
+ 'savemode': ['Off', 'On'],
+ 'cha_disp': ['CH', 'CH+Name'],
+ 'chb_disp': ['CH', 'CH+Name'],
+ }
+
+ choice_settings = {
+ 'vox': ['Off'] + ['%i' % i for i in range(1, 11)],
+ 'backlight': ['Off'] + ['%i' % i for i in range(1, 11)],
+ 'timeout': ['Off'] + ['%i' % i for i in range(15, 615, 15)],
+ 'language': ['English', 'Chinese'],
+ 'dtmfst': ['OFF', 'KB Side Tone', 'ANI Side Tone',
+ 'KB ST+ANI ST', 'Both'],
+ 'scanmode': ['TO', 'CO', 'SE'],
+ 'pttid': ['Off', 'BOT', 'EOT', 'Both'],
+ 'alarm_mode': ['Site', 'Tone', 'Code'],
+ 'workmode': ['VFO', 'Chan'],
+ }
+
+ if self.VENDOR == "Retevis":
+ choice_settings.update(retevis_settings)
+ else:
+ choice_settings.update(radioddity_settings)
+
+ basic_settings = ['timeout', 'vox', 'backlight', 'language',
+ 'cha_disp', 'chb_disp', 'workmode']
+ titles = {
+ 'savemode': 'Save Mode',
+ 'vox': 'VOX',
+ 'backlight': 'Auto Backlight',
+ 'timeout': 'Time Out Timer (s)',
+ 'language': 'Language',
+ 'dtmfst': 'DTMF-ST',
+ 'scanmode': 'Scan Mode',
+ 'pttid': 'PTT-ID',
+ 'cha_disp': 'Channel A Display',
+ 'chb_disp': 'Channel B Display',
+ 'alarm_mode': 'Alarm Mode',
+ 'txundertdr': 'TX Under TDR',
+ 'rptnoiseclr': 'RPT Noise Clear (ms)',
+ 'rptnoisedet': 'RPT Noise Detect (ms)',
+ 'workmode': 'Work Mode',
+ }
+
+ basic.append(
+ RadioSetting('squelch', 'Squelch Level',
+ RadioSettingValueInteger(0, 9, int(_set.squelch))))
+ adv.append(
+ RadioSetting('pttdelay', 'PTT Delay',
+ RadioSettingValueInteger(0, 30, int(_set.pttdelay))))
+ adv.append(
+ RadioSetting('tdr', 'TDR',
+ RadioSettingValueBoolean(
+ int(_set.tdr))))
+ adv.append(
+ RadioSetting('beep', 'Beep',
+ RadioSettingValueBoolean(
+ int(_set.beep))))
+ basic.append(
+ RadioSetting('voice', 'Voice Enable',
+ RadioSettingValueBoolean(
+ int(_set.voice))))
+ adv.append(
+ RadioSetting('bcl', 'BCL',
+ RadioSettingValueBoolean(
+ int(_set.bcl))))
+ adv.append(
+ RadioSetting('autolock', 'Auto Lock',
+ RadioSettingValueBoolean(
+ int(_set.autolock))))
+ adv.append(
+ RadioSetting('alarmsound', 'Alarm Sound',
+ RadioSettingValueBoolean(
+ int(_set.alarmsound))))
+ adv.append(
+ RadioSetting('tailnoiseclear', 'Tail Noise Clear',
+ RadioSettingValueBoolean(
+ int(_set.tailnoiseclear))))
+ adv.append(
+ RadioSetting('roger', 'Roger',
+ RadioSettingValueBoolean(
+ int(_set.roger))))
+ adv.append(
+ RadioSetting('fmradio', 'FM Radio Disabled',
+ RadioSettingValueBoolean(
+ int(_set.fmradio))))
+ adv.append(
+ RadioSetting('kblock', 'KB Lock',
+ RadioSettingValueBoolean(
+ int(_set.kblock))))
+
+ for key in sorted(choice_settings):
+ choices = choice_settings[key]
+ title = titles[key]
+ if key in basic_settings:
+ group = basic
+ else:
+ group = adv
+
+ val = int(getattr(_set, key))
+ try:
+ cur = choices[val]
+ except IndexError:
+ LOG.error('Value %i for %s out of range for list (%i): %s' % (
+ val, key, len(choices), choices))
+ raise
+ group.append(
+ RadioSetting(key, title,
+ RadioSettingValueList(
+ choices,
+ choices[val])))
+
+ if self.VENDOR == "Retevis":
+ # Side Keys
+ _skey = self._memobj.skey
+ SK_CHOICES = ['OFF', 'LAMP', 'SOS', 'FM', 'NOAA', 'MONI', 'SEARCH']
+ SK_VALUES = [0xFF, 0x08, 0x03, 0x07, 0x0C, 0x05, 0x1D]
+
+ def apply_sk_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = SK_CHOICES.index(val)
+ val = SK_VALUES[index]
+ obj.set_value(val)
+
+ # Side Key 1 - Short Press
+ if _skey.skey1sp in SK_VALUES:
+ idx = SK_VALUES.index(_skey.skey1sp)
+ else:
+ idx = SK_VALUES.index(0xFF)
+ rs = RadioSetting('skey.skey1sp', 'Side Key 1 - Short Press',
+ RadioSettingValueList(SK_CHOICES,
+ SK_CHOICES[idx]))
+ rs.set_apply_callback(apply_sk_listvalue, _skey.skey1sp)
+ adv.append(rs)
+
+ # Side Key 1 - Long Press
+ if _skey.skey1lp in SK_VALUES:
+ idx = SK_VALUES.index(_skey.skey1lp)
+ else:
+ idx = SK_VALUES.index(0xFF)
+ rs = RadioSetting('skey.skey1lp', 'Side Key 1 - Long Press',
+ RadioSettingValueList(SK_CHOICES,
+ SK_CHOICES[idx]))
+ rs.set_apply_callback(apply_sk_listvalue, _skey.skey1lp)
+ adv.append(rs)
+
+ # Side Key 2 - Short Press
+ if _skey.skey2sp in SK_VALUES:
+ idx = SK_VALUES.index(_skey.skey2sp)
+ else:
+ idx = SK_VALUES.index(0xFF)
+ rs = RadioSetting('skey.skey2sp', 'Side Key 2 - Short Press',
+ RadioSettingValueList(SK_CHOICES,
+ SK_CHOICES[idx]))
+ rs.set_apply_callback(apply_sk_listvalue, _skey.skey2sp)
+ adv.append(rs)
+
+ # Side Key 1 - Long Press
+ if _skey.skey2lp in SK_VALUES:
+ idx = SK_VALUES.index(_skey.skey2lp)
+ else:
+ idx = SK_VALUES.index(0xFF)
+ rs = RadioSetting('skey.skey2lp', 'Side Key 2 - Long Press',
+ RadioSettingValueList(SK_CHOICES,
+ SK_CHOICES[idx]))
+ rs.set_apply_callback(apply_sk_listvalue, _skey.skey2lp)
+ adv.append(rs)
+
+ for i in range(1, 16):
+ cur = ''.join(
+ DTMFCHARS[i]
+ for i in self._memobj.dtmfgroup[i - 1].code if int(i) < 0xF)
+ dtmf.append(
+ RadioSetting(
+ 'dtmf.code@%i' % i, 'DTMF Group %i' % i,
+ RadioSettingValueString(0, 5, cur,
+ autopad=False,
+ charset=DTMFCHARS)))
+ cur = ''.join(
+ '%X' % i
+ for i in self._memobj.anicode.code if int(i) < 0xE)
+ dtmf.append(
+ RadioSetting(
+ 'anicode.code', 'ANI Code',
+ RadioSettingValueString(0, 5, cur,
+ autopad=False,
+ charset=DTMFCHARS)))
+
+ anicode = self._memobj.anicode
+
+ dtmf.append(
+ RadioSetting(
+ 'anicode.groupcode', 'Group Code',
+ RadioSettingValueList(
+ list(DTMFCHARS),
+ DTMFCHARS[int(anicode.groupcode)])))
+
+ dtmf.append(
+ RadioSetting(
+ 'anicode.releasetosend', 'Release To Send',
+ RadioSettingValueBoolean(
+ int(anicode.releasetosend))))
+ dtmf.append(
+ RadioSetting(
+ 'anicode.presstosend', 'Press To Send',
+ RadioSettingValueBoolean(
+ int(anicode.presstosend))))
+ cur = int(anicode.dtmfspeedon) * 10 + 80
+ dtmf.append(
+ RadioSetting(
+ 'anicode.dtmfspeedon', 'DTMF Speed (on time in ms)',
+ RadioSettingValueInteger(60, 2000, cur, 10)))
+ cur = int(anicode.dtmfspeedoff) * 10 + 80
+ dtmf.append(
+ RadioSetting(
+ 'anicode.dtmfspeedoff', 'DTMF Speed (off time in ms)',
+ RadioSettingValueInteger(60, 2000, cur, 10)))
+
+ top = RadioSettings(basic, adv, dtmf)
+ return top
+
+ def set_settings(self, settings):
+ for element in settings:
+ if element.get_name().startswith('anicode.'):
+ self._set_anicode(element)
+ elif element.get_name().startswith('dtmf.code'):
+ self._set_dtmfcode(element)
+ elif element.get_name().startswith('skey.'):
+ self._set_skey(element)
+ elif not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ self._set_setting(element)
+
+ def _set_setting(self, setting):
+ key = setting.get_name()
+ val = setting.value
+
+ setattr(self._memobj.settings, key, int(val))
+
+ def _set_anicode(self, setting):
+ name = setting.get_name().split('.', 1)[1]
+ if name == 'code':
+ val = [DTMFCHARS.index(c) for c in str(setting.value)]
+ for i in range(0, 5):
+ try:
+ value = val[i]
+ except IndexError:
+ value = 0xFF
+ self._memobj.anicode.code[i] = value
+ elif name.startswith('dtmfspeed'):
+ setattr(self._memobj.anicode, name,
+ (int(setting.value) - 80) // 10)
+ else:
+ setattr(self._memobj.anicode, name, int(setting.value))
+
+ def _set_dtmfcode(self, setting):
+ index = int(setting.get_name().split('@', 1)[1]) - 1
+ val = [DTMFCHARS.index(c) for c in str(setting.value)]
+ for i in range(0, 5):
+ try:
+ value = val[i]
+ except IndexError:
+ value = 0xFF
+ self._memobj.dtmfgroup[index].code[i] = value
+
+ def _set_skey(self, setting):
+ if setting.has_apply_callback():
+ LOG.debug("Using apply callback")
+ setting.run_apply_callback()
+
+
+@directory.register
+class RetevisRA685Radio(RadioddityGA510Radio):
+ VENDOR = 'Retevis'
+ MODEL = 'RA685'
+ POWER_LEVELS = [
+ chirp_common.PowerLevel('H', watts=5),
+ chirp_common.PowerLevel('L', watts=1),
+ chirp_common.PowerLevel('M', watts=3)]
+
+ _magic = b'PROGROMWLTU'
+
+ def get_features(self):
+ rf = RadioddityGA510Radio.get_features(self)
+ rf.memory_bounds = (1, 128)
+ rf.valid_bands = [(136000000, 174000000),
+ (400000000, 520000000)]
+ return rf
+
+ def _get_mem(self, num):
+ return self._memobj.memories[num - 1]
+
+ def _get_nam(self, number):
+ return self._memobj.names[number - 1]
+
+ def _set_mem(self, num):
+ return self._memobj.memories[num - 1]
+
+ def _set_nam(self, number):
+ return self._memobj.names[number - 1]
+
+ vhftx = [144000000, 146000000]
+ uhftx = [430000000, 440000000]
+
+ def set_memory(self, mem):
+ # If memory is outside the TX limits, the radio will refuse
+ # transmit. Retevis asked for us to enforce this behavior
+ # in CHIRP for consistency.
+ if not (mem.freq >= self.vhftx[0] and mem.freq < self.vhftx[1]) and \
+ not (mem.freq >= self.uhftx[0] and mem.freq < self.uhftx[1]):
+ LOG.info('Memory frequency outside TX limits of radio; '
+ 'forcing duplex=off')
+ mem.duplex = 'off'
+ mem.offset = 0
+ RadioddityGA510Radio.set_memory(self, mem)
+
+
+@directory.register
+class RetevisRA85Radio(RadioddityGA510Radio):
+ VENDOR = 'Retevis'
+ MODEL = 'RA85'
+ POWER_LEVELS = [
+ chirp_common.PowerLevel('H', watts=5),
+ chirp_common.PowerLevel('L', watts=0.5),
+ chirp_common.PowerLevel('M', watts=0.6)]
+
+ _magic = b'PROGROMWLTU'
+ _gmrs = True
+
+ def get_features(self):
+ rf = RadioddityGA510Radio.get_features(self)
+ rf.memory_bounds = (1, 128)
+ rf.valid_bands = [(136000000, 174000000),
+ (400000000, 520000000)]
+ return rf
+
+ def _get_mem(self, num):
+ return self._memobj.memories[num - 1]
+
+ def _get_nam(self, number):
+ return self._memobj.names[number - 1]
+
+ def _set_mem(self, num):
+ return self._memobj.memories[num - 1]
+
+ def _set_nam(self, number):
+ return self._memobj.names[number - 1]
+
+
+@directory.register
+class TDH6Radio(RadioddityGA510Radio):
+ VENDOR = "TIDRADIO"
+ MODEL = "TD-H6"
diff --git a/chirp/drivers/generic_csv.py b/chirp/drivers/generic_csv.py
index 0c60108..0a3eab2 100644
--- a/chirp/drivers/generic_csv.py
+++ b/chirp/drivers/generic_csv.py
@@ -47,7 +47,7 @@ def write_memory(writer, mem):
@directory.register
-class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
+class CSVRadio(chirp_common.FileBackedRadio):
"""A driver for Generic CSV files"""
VENDOR = "Generic"
MODEL = "CSV"
@@ -67,20 +67,15 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
"Mode": (str, "mode"),
"TStep": (float, "tuning_step"),
"Skip": (str, "skip"),
- "URCALL": (str, "dv_urcall"),
- "RPT1CALL": (str, "dv_rpt1call"),
- "RPT2CALL": (str, "dv_rpt2call"),
"Comment": (str, "comment"),
}
- def _blank(self):
+ def _blank(self, setDefault=False):
self.errors = []
- self.memories = []
- for i in range(0, 1000):
- mem = chirp_common.Memory()
- mem.number = i
- mem.empty = True
- self.memories.append(mem)
+ self.memories = [chirp_common.Memory(i, True) for i in range(0, 1000)]
+ if (setDefault):
+ self.memories[0].empty = False
+ self.memories[0].freq = 146010000
def __init__(self, pipe):
chirp_common.FileBackedRadio.__init__(self, None)
@@ -92,14 +87,14 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
if self._filename and os.path.exists(self._filename):
self.load()
else:
- self._blank()
+ self._blank(True)
def get_features(self):
rf = chirp_common.RadioFeatures()
rf.has_bank = False
rf.requires_call_lists = False
rf.has_implicit_calls = False
- rf.memory_bounds = (0, len(self.memories))
+ rf.memory_bounds = (0, len(self.memories)-1)
rf.has_infinite_number = True
rf.has_nostep_tuning = True
rf.has_comment = True
@@ -366,11 +361,11 @@ class CommanderCSVRadio(CSVRadio):
def match_model(cls, filedata, filename):
"""Match files ending in .csv and using Commander column names."""
return filename.lower().endswith("." + cls.FILE_EXTENSION) and \
- filedata.startswith("Name,RX Freq,TX Freq,Decode,Encode,TX Pwr,"
- "Scan,TX Dev,Busy Lck,Group/Notes") or \
- filedata.startswith('"#","Name","RX Freq","TX Freq","Decode",'
- '"Encode","TX Pwr","Scan","TX Dev",'
- '"Busy Lck","Group/Notes"')
+ filedata.startswith(b"Name,RX Freq,TX Freq,Decode,Encode,TX Pwr,"
+ b"Scan,TX Dev,Busy Lck,Group/Notes") or \
+ filedata.startswith(b'"#","Name","RX Freq","TX Freq","Decode",'
+ b'"Encode","TX Pwr","Scan","TX Dev",'
+ b'"Busy Lck","Group/Notes"')
@directory.register
diff --git a/chirp/drivers/gmrsuv1.py b/chirp/drivers/gmrsuv1.py
index 7bb1d2f..dfb1232 100644
--- a/chirp/drivers/gmrsuv1.py
+++ b/chirp/drivers/gmrsuv1.py
@@ -19,8 +19,6 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp.drivers import baofeng_common
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
@@ -31,18 +29,20 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
InvalidValueError
from textwrap import dedent
-##### MAGICS #########################################################
+LOG = logging.getLogger(__name__)
+
+# #### MAGICS #########################################################
# BTECH GMRS-V1 magic string
MSTRING_GMRSV1 = "\x50\x5F\x20\x15\x12\x15\x4D"
-##### ID strings #####################################################
+# #### ID strings #####################################################
# BTECH GMRS-V1
-GMRSV1_fp1 = "US32411" # original
-GMRSV1_fp2 = "US32416" # original
-GMRSV1_fp3 = "US32418" # new rules
-GMRSV1_fp4 = "US32412" # original
+GMRSV1_fp1 = "US32411" # original
+GMRSV1_fp2 = "US32416" # original
+GMRSV1_fp3 = "US32418" # new rules
+GMRSV1_fp4 = "US32412" # original
DTMF_CHARS = "0123456789 *#ABCD"
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
@@ -81,6 +81,7 @@ GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
GMRS_FREQS_ORIG = GMRS_FREQS1 + GMRS_FREQS3 * 2
GMRS_FREQS_2017 = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+
def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
rid = data[0x1EF0:0x1EF7]
@@ -97,7 +98,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
VENDOR = "BTECH"
MODEL = "GMRS-V1"
- _fileid = [GMRSV1_fp3, GMRSV1_fp2, GMRSV1_fp1, ]
+ _fileid = [GMRSV1_fp4, GMRSV1_fp3, GMRSV1_fp2, GMRSV1_fp1, ]
_is_orig = [GMRSV1_fp2, GMRSV1_fp1, GMRSV1_fp4, ]
_magic = [MSTRING_GMRSV1, ]
@@ -128,7 +129,6 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
PTTID_LIST = LIST_PTTID
SCODE_LIST = LIST_SCODE
-
def get_features(self):
"""Get the radio's features"""
@@ -167,7 +167,6 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
return rf
-
MEM_FORMAT = """
#seekto 0x0000;
struct {
@@ -193,157 +192,167 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
u8 code[5];
u8 unused[11];
} pttid[15];
-
- #seekto 0x0CAA;
+
+ #seekto 0x0C80;
+ struct {
+ u8 unknown222[5];
+ u8 unknown333[5];
+ u8 alarm[5];
+ u8 unknown1;
+ u8 unknown555[5];
+ u8 unknown666[5];
+ u8 unknown777[5];
+ u8 unknown2;
+ u8 unknown60606[5];
+ u8 unknown70707[5];
+ u8 code[5];
+ u8 unused1:6,
+ aniid:2;
+ u8 unknown[2];
+ u8 dtmfon;
+ u8 dtmfoff;
+ } ani;
+
+ #seekto 0x0E20;
+ struct {
+ u8 unused01:4,
+ squelch:4;
+ u8 unused02;
+ u8 unused03;
+ u8 unused04:5,
+ save:3;
+ u8 unused05:4,
+ vox:4;
+ u8 unused06;
+ u8 unused07:4,
+ abr:4;
+ u8 unused08:7,
+ tdr:1;
+ u8 unused09:7,
+ beep:1;
+ u8 unused10:2,
+ timeout:6;
+ u8 unused11[4];
+ u8 unused12:6,
+ voice:2;
+ u8 unused13;
+ u8 unused14:6,
+ dtmfst:2;
+ u8 unused15;
+ u8 unused16:6,
+ screv:2;
+ u8 unused17:6,
+ pttid:2;
+ u8 unused18:2,
+ pttlt:6;
+ u8 unused19:6,
+ mdfa:2;
+ u8 unused20:6,
+ mdfb:2;
+ u8 unused21;
+ u8 unused22:7,
+ sync:1;
+ u8 unused23[4];
+ u8 unused24:6,
+ wtled:2;
+ u8 unused25:6,
+ rxled:2;
+ u8 unused26:6,
+ txled:2;
+ u8 unused27:6,
+ almod:2;
+ u8 unused28:7,
+ dbptt:1;
+ u8 unused29:6,
+ tdrab:2;
+ u8 unused30:7,
+ ste:1;
+ u8 unused31:4,
+ rpste:4;
+ u8 unused32:4,
+ rptrl:4;
+ u8 unused33:7,
+ ponmsg:1;
+ u8 unused34:7,
+ roger:1;
+ u8 unused35:6,
+ rtone:2;
+ u8 unused36;
+ u8 unused37:6,
+ rogerrx:2;
+ u8 unused38;
+ u8 displayab:1,
+ unknown1:2,
+ fmradio:1,
+ alarm:1,
+ unknown2:1,
+ reset:1,
+ menu:1;
+ u8 unused39;
+ u8 workmode;
+ u8 keylock;
+ u8 cht;
+ } settings;
+
+ #seekto 0x0E76;
+ struct {
+ u8 unused1:1,
+ mrcha:7;
+ u8 unused2:1,
+ mrchb:7;
+ } wmchannel;
+
+ struct vfo {
+ u8 unknown0[8];
+ u8 freq[8];
+ u8 unknown1;
+ u8 offset[4];
+ u8 unknown2;
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unused1:7,
+ band:1;
+ u8 unknown3;
+ u8 unused2:2,
+ sftd:2,
+ scode:4;
+ u8 unknown4;
+ u8 unused3:1
+ step:3,
+ unused4:4;
+ u8 txpower:1,
+ widenarr:1,
+ unknown5:4,
+ txpower3:2;
+ };
+
+ #seekto 0x0F00;
struct {
- u8 code[5];
- u8 unused1:6,
- aniid:2;
- u8 unknown[2];
- u8 dtmfon;
- u8 dtmfoff;
- } ani;
-
- #seekto 0x0E20;
- struct {
- u8 unused01:4,
- squelch:4;
- u8 unused02;
- u8 unused03;
- u8 unused04:5,
- save:3;
- u8 unused05:4,
- vox:4;
- u8 unused06;
- u8 unused07:4,
- abr:4;
- u8 unused08:7,
- tdr:1;
- u8 unused09:7,
- beep:1;
- u8 unused10:2,
- timeout:6;
- u8 unused11[4];
- u8 unused12:6,
- voice:2;
- u8 unused13;
- u8 unused14:6,
- dtmfst:2;
- u8 unused15;
- u8 unused16:6,
- screv:2;
- u8 unused17:6,
- pttid:2;
- u8 unused18:2,
- pttlt:6;
- u8 unused19:6,
- mdfa:2;
- u8 unused20:6,
- mdfb:2;
- u8 unused21;
- u8 unused22:7,
- sync:1;
- u8 unused23[4];
- u8 unused24:6,
- wtled:2;
- u8 unused25:6,
- rxled:2;
- u8 unused26:6,
- txled:2;
- u8 unused27:6,
- almod:2;
- u8 unused28:7,
- dbptt:1;
- u8 unused29:6,
- tdrab:2;
- u8 unused30:7,
- ste:1;
- u8 unused31:4,
- rpste:4;
- u8 unused32:4,
- rptrl:4;
- u8 unused33:7,
- ponmsg:1;
- u8 unused34:7,
- roger:1;
- u8 unused35:6,
- rtone:2;
- u8 unused36;
- u8 unused37:6,
- rogerrx:2;
- u8 unused38;
- u8 displayab:1,
- unknown1:2,
- fmradio:1,
- alarm:1,
- unknown2:1,
- reset:1,
- menu:1;
- u8 unused39;
- u8 workmode;
- u8 keylock;
- u8 cht;
- } settings;
-
- #seekto 0x0E76;
- struct {
- u8 unused1:1,
- mrcha:7;
- u8 unused2:1,
- mrchb:7;
- } wmchannel;
-
- struct vfo {
- u8 unknown0[8];
- u8 freq[8];
- u8 unknown1;
- u8 offset[4];
- u8 unknown2;
- ul16 rxtone;
- ul16 txtone;
- u8 unused1:7,
- band:1;
- u8 unknown3;
- u8 unused2:2,
- sftd:2,
- scode:4;
- u8 unknown4;
- u8 unused3:1
- step:3,
- unused4:4;
- u8 txpower:1,
- widenarr:1,
- unknown5:4,
- txpower3:2;
- };
-
- #seekto 0x0F00;
- struct {
struct vfo a;
struct vfo b;
} vfo;
-
+
#seekto 0x0F4E;
u16 fm_presets;
-
+
#seekto 0x1000;
struct {
char name[7];
u8 unknown1[9];
} names[128];
-
+
#seekto 0x1ED0;
struct {
char line1[7];
char line2[7];
} sixpoweron_msg;
-
+
#seekto 0x1EE0;
struct {
char line1[7];
char line2[7];
} poweron_msg;
-
+
#seekto 0x1EF0;
struct {
char line1[7];
@@ -362,7 +371,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
u8 sql8;
u8 sql9;
};
-
+
#seekto 0x1F60;
struct {
struct squelch vhf;
@@ -679,7 +688,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
basic.append(rs)
rs = RadioSetting("settings.beep", "Beep",
- RadioSettingValueBoolean(_mem.settings.beep))
+ RadioSettingValueBoolean(_mem.settings.beep))
basic.append(rs)
if _mem.settings.timeout > 0x27:
@@ -719,7 +728,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
_mem.settings.pttid]))
basic.append(rs)
- if _mem.settings.pttlt > 0x1E:
+ if _mem.settings.pttlt > 0x32:
val = 0x05
else:
val = _mem.settings.pttlt
@@ -785,7 +794,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
val = _mem.settings.rpste
rs = RadioSetting("settings.rpste",
"Squelch Tail Eliminate (repeater)",
- RadioSettingValueList(
+ RadioSettingValueList(
LIST_RPSTE, LIST_RPSTE[val]))
basic.append(rs)
@@ -815,7 +824,7 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
rs = RadioSetting("settings.rogerrx", "Roger Beep (RX)",
RadioSettingValueList(
LIST_OFFAB, LIST_OFFAB[
- _mem.settings.rogerrx]))
+ _mem.settings.rogerrx]))
basic.append(rs)
# Advanced settings
@@ -894,12 +903,12 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrcha))
+ _mem.wmchannel.mrcha))
work.append(rs)
rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrchb))
+ _mem.wmchannel.mrchb))
work.append(rs)
def convert_bytes_to_freq(bytes):
@@ -1013,6 +1022,23 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
LIST_PTTID[_mem.ani.aniid]))
dtmfe.append(rs)
+ def apply_alarmcode(setting, obj, length):
+ code = []
+ for j in range(0, length):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.alarm = code
+
+ _codeobj = self._memobj.ani.alarm
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 5, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("ani.alarm", "Alarm Code", val)
+ rs.set_apply_callback(apply_alarmcode, self._memobj.ani, 5)
+ dtmfe.append(rs)
+
# Service settings
for band in ["vhf", "uhf"]:
for index in range(0, 10):
@@ -1022,7 +1048,8 @@ class GMRSV1(baofeng_common.BaofengCommonHT):
elif band == "uhf":
_obj = self._memobj.squelch.uhf
val = RadioSettingValueInteger(0, 123,
- getattr(_obj, "sql%i" % (index)))
+ getattr(_obj, "sql%i" % (
+ index)))
if index == 0:
val.set_mutable(False)
name = "%s Squelch %i" % (band.upper(), index)
diff --git a/chirp/drivers/gmrsv2.py b/chirp/drivers/gmrsv2.py
new file mode 100644
index 0000000..691583c
--- /dev/null
+++ b/chirp/drivers/gmrsv2.py
@@ -0,0 +1,1030 @@
+# Copyright 2022:
+# * Jim Unroe KC9HI, <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import struct
+import logging
+import re
+
+from chirp.drivers import baofeng_common
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, \
+ InvalidValueError
+from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+# #### MAGICS #########################################################
+
+# BTECH GMRS-V2 magic string
+MSTRING_GMRSV2 = "\x50\x5F\x20\x21\x12\x15\x4D"
+
+# #### ID strings #####################################################
+
+# BTECH GMRS-V2
+GMRSV2_fp1 = "US32419" # original
+
+DTMF_CHARS = "0123456789 *#ABCD"
+STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
+
+LIST_AB = ["A", "B"]
+LIST_ALMOD = ["Off", "Site", "Tone", "Code"]
+LIST_BANDWIDTH = ["Wide", "Narrow"]
+LIST_COLOR = ["Off", "Blue", "Orange", "Purple"]
+LIST_DTMFSPEED = ["%s ms" % x for x in range(50, 2010, 10)]
+LIST_DTMFST = ["Off", "DT-ST", "ANI-ST", "DT+ANI"]
+LIST_MODE = ["Channel", "Name", "Frequency"]
+LIST_OFF1TO9 = ["Off"] + list("123456789")
+LIST_OFF1TO10 = LIST_OFF1TO9 + ["10"]
+LIST_OFFAB = ["Off"] + LIST_AB
+LIST_RESUME = ["TO", "CO", "SE"]
+LIST_PONMSG = ["Full", "Message"]
+LIST_PTTID = ["Off", "BOT", "EOT", "Both"]
+LIST_SCODE = ["%s" % x for x in range(1, 16)]
+LIST_RPSTE = ["Off"] + ["%s" % x for x in range(1, 11)]
+LIST_RTONE = ["1000 Hz", "1450 Hz", "1750 Hz", "2100 Hz"]
+LIST_SAVE = ["Off", "1:1", "1:2", "1:3", "1:4"]
+LIST_SHIFTD = ["Off", "+", "-"]
+LIST_STEDELAY = ["Off"] + ["%s ms" % x for x in range(100, 1100, 100)]
+LIST_STEP = [str(x) for x in STEPS]
+LIST_TIMEOUT = ["%s sec" % x for x in range(15, 615, 15)]
+LIST_TXPOWER = ["High", "Low"]
+LIST_VOICE = ["Off", "English", "Chinese"]
+LIST_WORKMODE = ["Frequency", "Channel"]
+
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+
+
+@directory.register
+class GMRSV2(baofeng_common.BaofengCommonHT):
+ """BTech GMRS-V2"""
+ VENDOR = "BTECH"
+ MODEL = "GMRS-V2"
+
+ _fileid = [GMRSV2_fp1, ]
+
+ _magic = [MSTRING_GMRSV2, ]
+ _magic_response_length = 8
+ _fw_ver_start = 0x1EF0
+ _recv_block_size = 0x40
+ _mem_size = 0x2000
+ _ack_block = True
+
+ _ranges = [(0x0000, 0x0DF0),
+ (0x0E00, 0x1EF0),
+ (0x1F60, 0x1F70),
+ (0x1F80, 0x1F90),
+ (0x1FC0, 0x1FD0)]
+
+ _send_block_size = 0x10
+
+ MODES = ["NFM", "FM"]
+ VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
+ "!@#$%^&*()+-=[]:\";'<>?,./"
+ LENGTH_NAME = 7
+ SKIP_VALUES = ["", "S"]
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+ VALID_BANDS = [(130000000, 180000000),
+ (400000000, 521000000)]
+ PTTID_LIST = LIST_PTTID
+ SCODE_LIST = LIST_SCODE
+
+ def get_features(self):
+ """Get the radio's features"""
+
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_tuning_step = False
+ rf.can_odd_split = False
+ rf.has_name = True
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_dtcs = True
+ rf.has_rx_dtcs = True
+ rf.has_dtcs_polarity = True
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.valid_modes = self.MODES
+ rf.valid_characters = self.VALID_CHARS
+ rf.valid_name_length = self.LENGTH_NAME
+ rf.valid_duplexes = ["", "+", "off"]
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = [
+ "Tone->Tone",
+ "DTCS->",
+ "->DTCS",
+ "Tone->DTCS",
+ "DTCS->Tone",
+ "->Tone",
+ "DTCS->DTCS"]
+ rf.valid_skips = self.SKIP_VALUES
+ rf.valid_dtcs_codes = self.DTCS_CODES
+ rf.memory_bounds = (0, 199)
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_bands = self.VALID_BANDS
+ rf.valid_tuning_steps = STEPS
+
+ return rf
+
+ MEM_FORMAT = """
+ #seekto 0x0000;
+ struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unknown0:4,
+ scode:4;
+ u8 unknown1;
+ u8 unknown2:7,
+ lowpower:1;
+ u8 unknown3:1,
+ wide:1,
+ unknown4:2,
+ bcl:1,
+ scan:1,
+ pttid:2;
+ } memory[200];
+
+ #seekto 0x0D00;
+ struct {
+ u8 code[5];
+ u8 unused[11];
+ } pttid[15];
+
+ #seekto 0x0DF0;
+ struct {
+ u8 dtmfon;
+ u8 dtmfoff;
+ u8 unknown1:4,
+ unknown2:2,
+ aniid:2;
+ u8 alarm[5];
+ u8 code[5];
+ } ani;
+
+ #seekto 0x0E20;
+ struct {
+ u8 unused01:4,
+ squelch:4;
+ u8 unused02;
+ u8 unused03;
+ u8 unused04:5,
+ save:3;
+ u8 unused05:4,
+ vox:4;
+ u8 unused06;
+ u8 unused07:4,
+ abr:4;
+ u8 unused08:7,
+ tdr:1;
+ u8 unused09:7,
+ beep:1;
+ u8 unused10:2,
+ timeout:6;
+ u8 unused11[4];
+ u8 unused12:6,
+ voice:2;
+ u8 unused13;
+ u8 unused14:6,
+ dtmfst:2;
+ u8 unused15;
+ u8 unused16:6,
+ screv:2;
+ u8 unused17;
+ u8 unused18:2,
+ pttlt:6;
+ u8 unused19:6,
+ mdfa:2;
+ u8 unused20:6,
+ mdfb:2;
+ u8 unused21;
+ u8 unused22:7,
+ sync:1;
+ u8 unused23[4];
+ u8 unused24:6,
+ wtled:2;
+ u8 unused25:6,
+ rxled:2;
+ u8 unused26:6,
+ txled:2;
+ u8 unused27:6,
+ almod:2;
+ u8 unused28:7,
+ dbptt:1;
+ u8 unused29:6,
+ tdrab:2;
+ u8 unused30:7,
+ ste:1;
+ u8 unused31:4,
+ rpste:4;
+ u8 unused32:4,
+ rptrl:4;
+ u8 unused33:7,
+ ponmsg:1;
+ u8 unused34:7,
+ roger:1;
+ u8 unused35:6,
+ rtone:2;
+ u8 unused36;
+ u8 unused37:6,
+ rogerrx:2;
+ u8 unused38;
+ u8 displayab:1,
+ unknown1:7;
+ u8 unused39[2];
+ u8 keylock;
+ u8 cht;
+ u8 unused40[5];
+ u8 unknown1:3,
+ fmradio:1,
+ alarm:1,
+ unknown2:1,
+ reset:1,
+ menu:1;
+ u8 unused41;
+ u8 unknown:7,
+ workmode:1;
+ } settings;
+
+ #seekto 0x0E76;
+ struct {
+ u8 unused1:1,
+ mrcha:7;
+ u8 unused2:1,
+ mrchb:7;
+ } wmchannel;
+
+ struct vfo {
+ u8 unknown0[8];
+ u8 freq[8];
+ u8 unknown1;
+ u8 offset[4];
+ u8 unknown2;
+ ul16 rxtone;
+ ul16 txtone;
+ u8 unused1:7,
+ band:1;
+ u8 unknown3;
+ u8 unused2:2,
+ sftd:2,
+ unused5:4;
+ u8 unknown4;
+ u8 unused3:1
+ step:3,
+ unused4:4;
+ u8 txpower:1,
+ widenarr:1,
+ unknown5:4,
+ txpower3:2;
+ };
+
+ #seekto 0x0F00;
+ struct {
+ struct vfo a;
+ struct vfo b;
+ } vfo;
+
+ #seekto 0x0F4E;
+ u16 fm_presets;
+
+ #seekto 0x1000;
+ struct {
+ char name[7];
+ u8 unknown1[9];
+ } names[200];
+
+ #seekto 0x1ED0;
+ struct {
+ char line1[7];
+ char line2[7];
+ } sixpoweron_msg;
+
+ #seekto 0x1EE0;
+ struct {
+ char line1[7];
+ char line2[7];
+ } poweron_msg;
+
+ #seekto 0x1EF0;
+ struct {
+ char line1[7];
+ char line2[7];
+ } firmware_msg;
+
+ struct squelch {
+ u8 sql0;
+ u8 sql1;
+ u8 sql2;
+ u8 sql3;
+ u8 sql4;
+ u8 sql5;
+ u8 sql6;
+ u8 sql7;
+ u8 sql8;
+ u8 sql9;
+ };
+
+ #seekto 0x1F60;
+ struct {
+ struct squelch vhf;
+ u8 unknown1[6];
+ u8 unknown2[16];
+ struct squelch uhf;
+ } squelch;
+
+ """
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = \
+ ('The BTech GMRS-V2 driver is a beta version.\n'
+ '\n'
+ 'Please save an unedited copy of your first successful\n'
+ 'download to a CHIRP Radio Images(*.img) file.'
+ )
+ rp.pre_download = _(dedent("""\
+ Follow these instructions to download your info:
+
+ 1 - Turn off your radio
+ 2 - Connect your interface cable
+ 3 - Turn on your radio
+ 4 - Do the download of your radio data
+ """))
+ rp.pre_upload = _(dedent("""\
+ Follow this instructions to upload your info:
+
+ 1 - Turn off your radio
+ 2 - Connect your interface cable
+ 3 - Turn on your radio
+ 4 - Do the upload of your radio data
+ """))
+ return rp
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+ self._memobj = bitwise.parse(self.MEM_FORMAT, self._mmap)
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number]
+ _nam = self._memobj.names[number]
+
+ mem = chirp_common.Memory()
+ mem.number = number
+
+ if _mem.get_raw()[0] == "\xff":
+ mem.empty = True
+ return mem
+
+ mem.freq = int(_mem.rxfreq) * 10
+
+ if self._is_txinh(_mem):
+ # TX freq not set
+ mem.duplex = "off"
+ mem.offset = 0
+ else:
+ # TX freq set
+ offset = (int(_mem.txfreq) * 10) - mem.freq
+ if offset != 0:
+ if offset > 0:
+ mem.duplex = "+"
+ mem.offset = 5000000
+ else:
+ mem.duplex = ""
+ mem.offset = 0
+
+ for char in _nam.name:
+ if str(char) == "\xFF":
+ char = " " # The OEM software may have 0xFF mid-name
+ mem.name += str(char)
+ mem.name = mem.name.rstrip()
+
+ dtcs_pol = ["N", "N"]
+
+ if _mem.txtone in [0, 0xFFFF]:
+ txmode = ""
+ elif _mem.txtone >= 0x0258:
+ txmode = "Tone"
+ mem.rtone = int(_mem.txtone) / 10.0
+ elif _mem.txtone <= 0x0258:
+ txmode = "DTCS"
+ if _mem.txtone > 0x69:
+ index = _mem.txtone - 0x6A
+ dtcs_pol[0] = "R"
+ else:
+ index = _mem.txtone - 1
+ mem.dtcs = self.DTCS_CODES[index]
+ else:
+ LOG.warn("Bug: txtone is %04x" % _mem.txtone)
+
+ if _mem.rxtone in [0, 0xFFFF]:
+ rxmode = ""
+ elif _mem.rxtone >= 0x0258:
+ rxmode = "Tone"
+ mem.ctone = int(_mem.rxtone) / 10.0
+ elif _mem.rxtone <= 0x0258:
+ rxmode = "DTCS"
+ if _mem.rxtone >= 0x6A:
+ index = _mem.rxtone - 0x6A
+ dtcs_pol[1] = "R"
+ else:
+ index = _mem.rxtone - 1
+ mem.rx_dtcs = self.DTCS_CODES[index]
+ else:
+ LOG.warn("Bug: rxtone is %04x" % _mem.rxtone)
+
+ if txmode == "Tone" and not rxmode:
+ mem.tmode = "Tone"
+ elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
+ mem.tmode = "TSQL"
+ elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
+ mem.tmode = "DTCS"
+ elif rxmode or txmode:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ mem.dtcs_polarity = "".join(dtcs_pol)
+
+ if not _mem.scan:
+ mem.skip = "S"
+
+ levels = self.POWER_LEVELS
+ try:
+ mem.power = levels[_mem.lowpower]
+ except IndexError:
+ LOG.error("Radio reported invalid power level %s (in %s)" %
+ (_mem.power, levels))
+ mem.power = levels[0]
+
+ mem.mode = _mem.wide and "FM" or "NFM"
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ rs = RadioSetting("bcl", "BCL",
+ RadioSettingValueBoolean(_mem.bcl))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("pttid", "PTT ID",
+ RadioSettingValueList(self.PTTID_LIST,
+ self.PTTID_LIST[_mem.pttid]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("scode", "S-CODE",
+ RadioSettingValueList(self.SCODE_LIST,
+ self.SCODE_LIST[_mem.scode]))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ _mem = self._memobj.memory[mem.number]
+ _nam = self._memobj.names[mem.number]
+
+ if mem.empty:
+ _mem.set_raw("\xff" * 16)
+ _nam.set_raw("\xff" * 16)
+ return
+
+ _mem.set_raw("\x00" * 16)
+
+ if float(mem.freq) / 1000000 in GMRS_FREQS1:
+ mem.duplex == ''
+ mem.offset = 0
+ elif float(mem.freq) / 1000000 in GMRS_FREQS2:
+ mem.duplex == ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ elif float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.duplex == ''
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
+ _mem.rxfreq = mem.freq / 10
+
+ if mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw("\xFF")
+ elif mem.duplex == "+":
+ mem.offset = 5000000
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ else:
+ _mem.txfreq = mem.freq / 10
+
+ _namelength = self.get_features().valid_name_length
+ for i in range(_namelength):
+ try:
+ _nam.name[i] = mem.name[i]
+ except IndexError:
+ _nam.name[i] = "\xFF"
+
+ rxmode = txmode = ""
+ if mem.tmode == "Tone":
+ _mem.txtone = int(mem.rtone * 10)
+ _mem.rxtone = 0
+ elif mem.tmode == "TSQL":
+ _mem.txtone = int(mem.ctone * 10)
+ _mem.rxtone = int(mem.ctone * 10)
+ elif mem.tmode == "DTCS":
+ rxmode = txmode = "DTCS"
+ _mem.txtone = self.DTCS_CODES.index(mem.dtcs) + 1
+ _mem.rxtone = self.DTCS_CODES.index(mem.dtcs) + 1
+ elif mem.tmode == "Cross":
+ txmode, rxmode = mem.cross_mode.split("->", 1)
+ if txmode == "Tone":
+ _mem.txtone = int(mem.rtone * 10)
+ elif txmode == "DTCS":
+ _mem.txtone = self.DTCS_CODES.index(mem.dtcs) + 1
+ else:
+ _mem.txtone = 0
+ if rxmode == "Tone":
+ _mem.rxtone = int(mem.ctone * 10)
+ elif rxmode == "DTCS":
+ _mem.rxtone = self.DTCS_CODES.index(mem.rx_dtcs) + 1
+ else:
+ _mem.rxtone = 0
+ else:
+ _mem.rxtone = 0
+ _mem.txtone = 0
+
+ if txmode == "DTCS" and mem.dtcs_polarity[0] == "R":
+ _mem.txtone += 0x69
+ if rxmode == "DTCS" and mem.dtcs_polarity[1] == "R":
+ _mem.rxtone += 0x69
+
+ _mem.scan = mem.skip != "S"
+ _mem.wide = mem.mode == "FM"
+
+ if mem.power:
+ _mem.lowpower = self.POWER_LEVELS.index(mem.power)
+ else:
+ _mem.lowpower = 0
+
+ # extra settings
+ if len(mem.extra) > 0:
+ # there are setting, parse
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+ else:
+ # there are no extra settings, load defaults
+ _mem.bcl = 0
+ _mem.pttid = 0
+ _mem.scode = 0
+
+ def get_settings(self):
+ """Translate the bit in the mem_struct into settings in the UI"""
+ _mem = self._memobj
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ advanced = RadioSettingGroup("advanced", "Advanced Settings")
+ other = RadioSettingGroup("other", "Other Settings")
+ work = RadioSettingGroup("work", "Work Mode Settings")
+ fm_preset = RadioSettingGroup("fm_preset", "FM Preset")
+ dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
+ service = RadioSettingGroup("service", "Service Settings")
+ top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
+ service)
+
+ # Basic settings
+ if _mem.settings.squelch > 0x09:
+ val = 0x00
+ else:
+ val = _mem.settings.squelch
+ rs = RadioSetting("settings.squelch", "Squelch",
+ RadioSettingValueList(
+ LIST_OFF1TO9, LIST_OFF1TO9[val]))
+ basic.append(rs)
+
+ if _mem.settings.save > 0x04:
+ val = 0x00
+ else:
+ val = _mem.settings.save
+ rs = RadioSetting("settings.save", "Battery Saver",
+ RadioSettingValueList(
+ LIST_SAVE, LIST_SAVE[val]))
+ basic.append(rs)
+
+ if _mem.settings.vox > 0x0A:
+ val = 0x00
+ else:
+ val = _mem.settings.vox
+ rs = RadioSetting("settings.vox", "Vox",
+ RadioSettingValueList(
+ LIST_OFF1TO10, LIST_OFF1TO10[val]))
+ basic.append(rs)
+
+ if _mem.settings.abr > 0x0A:
+ val = 0x00
+ else:
+ val = _mem.settings.abr
+ rs = RadioSetting("settings.abr", "Backlight Timeout",
+ RadioSettingValueList(
+ LIST_OFF1TO10, LIST_OFF1TO10[val]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.tdr", "Dual Watch",
+ RadioSettingValueBoolean(_mem.settings.tdr))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.beep", "Beep",
+ RadioSettingValueBoolean(_mem.settings.beep))
+ basic.append(rs)
+
+ if _mem.settings.timeout > 0x27:
+ val = 0x03
+ else:
+ val = _mem.settings.timeout
+ rs = RadioSetting("settings.timeout", "Timeout Timer",
+ RadioSettingValueList(
+ LIST_TIMEOUT, LIST_TIMEOUT[val]))
+ basic.append(rs)
+
+ if _mem.settings.voice > 0x02:
+ val = 0x01
+ else:
+ val = _mem.settings.voice
+ rs = RadioSetting("settings.voice", "Voice Prompt",
+ RadioSettingValueList(
+ LIST_VOICE, LIST_VOICE[val]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.dtmfst", "DTMF Sidetone",
+ RadioSettingValueList(LIST_DTMFST, LIST_DTMFST[
+ _mem.settings.dtmfst]))
+ basic.append(rs)
+
+ if _mem.settings.screv > 0x02:
+ val = 0x01
+ else:
+ val = _mem.settings.screv
+ rs = RadioSetting("settings.screv", "Scan Resume",
+ RadioSettingValueList(
+ LIST_RESUME, LIST_RESUME[val]))
+ basic.append(rs)
+
+ if _mem.settings.pttlt > 0x32:
+ val = 0x05
+ else:
+ val = _mem.settings.pttlt
+ rs = RadioSetting("pttlt", "PTT ID Delay",
+ RadioSettingValueInteger(0, 50, val))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.mdfa", "Display Mode (A)",
+ RadioSettingValueList(LIST_MODE, LIST_MODE[
+ _mem.settings.mdfa]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.mdfb", "Display Mode (B)",
+ RadioSettingValueList(LIST_MODE, LIST_MODE[
+ _mem.settings.mdfb]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.sync", "Sync A & B",
+ RadioSettingValueBoolean(_mem.settings.sync))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.wtled", "Standby LED Color",
+ RadioSettingValueList(
+ LIST_COLOR, LIST_COLOR[_mem.settings.wtled]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.rxled", "RX LED Color",
+ RadioSettingValueList(
+ LIST_COLOR, LIST_COLOR[_mem.settings.rxled]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.txled", "TX LED Color",
+ RadioSettingValueList(
+ LIST_COLOR, LIST_COLOR[_mem.settings.txled]))
+ basic.append(rs)
+
+ val = _mem.settings.almod
+ rs = RadioSetting("settings.almod", "Alarm Mode",
+ RadioSettingValueList(
+ LIST_ALMOD, LIST_ALMOD[val]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.dbptt", "Double PTT",
+ RadioSettingValueBoolean(_mem.settings.dbptt))
+ basic.append(rs)
+
+ if _mem.settings.tdrab > 0x02:
+ val = 0x00
+ else:
+ val = _mem.settings.tdrab
+ rs = RadioSetting("settings.tdrab", "Dual Watch TX Priority",
+ RadioSettingValueList(
+ LIST_OFFAB, LIST_OFFAB[val]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.ste", "Squelch Tail Eliminate (HT to HT)",
+ RadioSettingValueBoolean(_mem.settings.ste))
+ basic.append(rs)
+
+ if _mem.settings.rpste > 0x0A:
+ val = 0x00
+ else:
+ val = _mem.settings.rpste
+ rs = RadioSetting("settings.rpste",
+ "Squelch Tail Eliminate (repeater)",
+ RadioSettingValueList(
+ LIST_RPSTE, LIST_RPSTE[val]))
+ basic.append(rs)
+
+ if _mem.settings.rptrl > 0x0A:
+ val = 0x00
+ else:
+ val = _mem.settings.rptrl
+ rs = RadioSetting("settings.rptrl", "STE Repeater Delay",
+ RadioSettingValueList(
+ LIST_STEDELAY, LIST_STEDELAY[val]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.ponmsg", "Power-On Message",
+ RadioSettingValueList(LIST_PONMSG, LIST_PONMSG[
+ _mem.settings.ponmsg]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.roger", "Roger Beep",
+ RadioSettingValueBoolean(_mem.settings.roger))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.rtone", "Tone Burst Frequency",
+ RadioSettingValueList(LIST_RTONE, LIST_RTONE[
+ _mem.settings.rtone]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings.rogerrx", "Roger Beep (RX)",
+ RadioSettingValueList(
+ LIST_OFFAB, LIST_OFFAB[
+ _mem.settings.rogerrx]))
+ basic.append(rs)
+
+ # Advanced settings
+ rs = RadioSetting("settings.reset", "RESET Menu",
+ RadioSettingValueBoolean(_mem.settings.reset))
+ advanced.append(rs)
+
+ rs = RadioSetting("settings.menu", "All Menus",
+ RadioSettingValueBoolean(_mem.settings.menu))
+ advanced.append(rs)
+
+ rs = RadioSetting("settings.fmradio", "Broadcast FM Radio",
+ RadioSettingValueBoolean(_mem.settings.fmradio))
+ advanced.append(rs)
+
+ rs = RadioSetting("settings.alarm", "Alarm Sound",
+ RadioSettingValueBoolean(_mem.settings.alarm))
+ advanced.append(rs)
+
+ # Other settings
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in chirp_common.CHARSET_ASCII:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
+
+ _msg = _mem.firmware_msg
+ val = RadioSettingValueString(0, 7, _filter(_msg.line1))
+ val.set_mutable(False)
+ rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
+ other.append(rs)
+
+ val = RadioSettingValueString(0, 7, _filter(_msg.line2))
+ val.set_mutable(False)
+ rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
+ other.append(rs)
+
+ _msg = _mem.sixpoweron_msg
+ val = RadioSettingValueString(0, 7, _filter(_msg.line1))
+ val.set_mutable(False)
+ rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", val)
+ other.append(rs)
+ val = RadioSettingValueString(0, 7, _filter(_msg.line2))
+ val.set_mutable(False)
+ rs = RadioSetting("sixpoweron_msg.line2", "6+Power-On Message 2", val)
+ other.append(rs)
+
+ _msg = _mem.poweron_msg
+ rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
+ RadioSettingValueString(
+ 0, 7, _filter(_msg.line1)))
+ other.append(rs)
+ rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
+ RadioSettingValueString(
+ 0, 7, _filter(_msg.line2)))
+ other.append(rs)
+
+ # Work mode settings
+ rs = RadioSetting("settings.displayab", "Display",
+ RadioSettingValueList(
+ LIST_AB, LIST_AB[_mem.settings.displayab]))
+ work.append(rs)
+
+ rs = RadioSetting("settings.workmode", "VFO/MR Mode",
+ RadioSettingValueList(
+ LIST_WORKMODE,
+ LIST_WORKMODE[_mem.settings.workmode]))
+ work.append(rs)
+
+ rs = RadioSetting("settings.keylock", "Keypad Lock",
+ RadioSettingValueBoolean(_mem.settings.keylock))
+ work.append(rs)
+
+ rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
+ RadioSettingValueInteger(0, 127,
+ _mem.wmchannel.mrcha))
+ work.append(rs)
+
+ rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
+ RadioSettingValueInteger(0, 127,
+ _mem.wmchannel.mrchb))
+ work.append(rs)
+
+ def convert_bytes_to_freq(bytes):
+ real_freq = 0
+ for byte in bytes:
+ real_freq = (real_freq * 10) + byte
+ return chirp_common.format_freq(real_freq * 10)
+
+ def my_validate(value):
+ value = chirp_common.parse_freq(value)
+ msg = ("Can't be less than %i.0000")
+ if value > 99000000 and value < 130 * 1000000:
+ raise InvalidValueError(msg % (130))
+ msg = ("Can't be between %i.9975-%i.0000")
+ if (179 + 1) * 1000000 <= value and value < 400 * 1000000:
+ raise InvalidValueError(msg % (179, 400))
+ msg = ("Can't be greater than %i.9975")
+ if value > 99000000 and value > (520 + 1) * 1000000:
+ raise InvalidValueError(msg % (520))
+ return chirp_common.format_freq(value)
+
+ def apply_freq(setting, obj):
+ value = chirp_common.parse_freq(str(setting.value)) / 10
+ for i in range(7, -1, -1):
+ obj.freq[i] = value % 10
+ value /= 10
+
+ val1a = RadioSettingValueString(0, 10,
+ convert_bytes_to_freq(_mem.vfo.a.freq))
+ val1a.set_validate_callback(my_validate)
+ rs = RadioSetting("vfo.a.freq", "VFO A Frequency", val1a)
+ rs.set_apply_callback(apply_freq, _mem.vfo.a)
+ work.append(rs)
+
+ val1b = RadioSettingValueString(0, 10,
+ convert_bytes_to_freq(_mem.vfo.b.freq))
+ val1b.set_validate_callback(my_validate)
+ rs = RadioSetting("vfo.b.freq", "VFO B Frequency", val1b)
+ rs.set_apply_callback(apply_freq, _mem.vfo.b)
+ work.append(rs)
+
+ rs = RadioSetting("vfo.a.step", "VFO A Tuning Step",
+ RadioSettingValueList(
+ LIST_STEP, LIST_STEP[_mem.vfo.a.step]))
+ work.append(rs)
+ rs = RadioSetting("vfo.b.step", "VFO B Tuning Step",
+ RadioSettingValueList(
+ LIST_STEP, LIST_STEP[_mem.vfo.b.step]))
+ work.append(rs)
+
+ # broadcast FM settings
+ _fm_presets = self._memobj.fm_presets
+ if _fm_presets <= 108.0 * 10 - 650:
+ preset = _fm_presets / 10.0 + 65
+ elif _fm_presets >= 65.0 * 10 and _fm_presets <= 108.0 * 10:
+ preset = _fm_presets / 10.0
+ else:
+ preset = 76.0
+ rs = RadioSetting("fm_presets", "FM Preset(MHz)",
+ RadioSettingValueFloat(65, 108.0, preset, 0.1, 1))
+ fm_preset.append(rs)
+
+ # DTMF settings
+ def apply_code(setting, obj, length):
+ code = []
+ for j in range(0, length):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.code = code
+
+ for i in range(0, 15):
+ _codeobj = self._memobj.pttid[i].code
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 5, _code, False)
+ val.set_charset(DTMF_CHARS)
+ pttid = RadioSetting("pttid/%i.code" % i,
+ "Signal Code %i" % (i + 1), val)
+ pttid.set_apply_callback(apply_code, self._memobj.pttid[i], 5)
+ dtmfe.append(pttid)
+
+ if _mem.ani.dtmfon > 0xC3:
+ val = 0x03
+ else:
+ val = _mem.ani.dtmfon
+ rs = RadioSetting("ani.dtmfon", "DTMF Speed (on)",
+ RadioSettingValueList(LIST_DTMFSPEED,
+ LIST_DTMFSPEED[val]))
+ dtmfe.append(rs)
+
+ if _mem.ani.dtmfoff > 0xC3:
+ val = 0x03
+ else:
+ val = _mem.ani.dtmfoff
+ rs = RadioSetting("ani.dtmfoff", "DTMF Speed (off)",
+ RadioSettingValueList(LIST_DTMFSPEED,
+ LIST_DTMFSPEED[val]))
+ dtmfe.append(rs)
+
+ _codeobj = self._memobj.ani.code
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 5, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("ani.code", "ANI Code", val)
+ rs.set_apply_callback(apply_code, self._memobj.ani, 5)
+ dtmfe.append(rs)
+
+ rs = RadioSetting("ani.aniid", "When to send ANI ID",
+ RadioSettingValueList(LIST_PTTID,
+ LIST_PTTID[_mem.ani.aniid]))
+ dtmfe.append(rs)
+
+ def apply_alarmcode(setting, obj, length):
+ code = []
+ for j in range(0, length):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.alarm = code
+
+ _codeobj = self._memobj.ani.alarm
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 5, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("ani.alarm", "Alarm Code", val)
+ rs.set_apply_callback(apply_alarmcode, self._memobj.ani, 5)
+ dtmfe.append(rs)
+
+ # Service settings
+ for band in ["vhf", "uhf"]:
+ for index in range(0, 10):
+ key = "squelch.%s.sql%i" % (band, index)
+ if band == "vhf":
+ _obj = self._memobj.squelch.vhf
+ elif band == "uhf":
+ _obj = self._memobj.squelch.uhf
+ val = RadioSettingValueInteger(0, 123,
+ getattr(_obj, "sql%i" % (
+ index)))
+ if index == 0:
+ val.set_mutable(False)
+ name = "%s Squelch %i" % (band.upper(), index)
+ rs = RadioSetting(key, name, val)
+ service.append(rs)
+
+ return top
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py
index f3353be..a2dd0be 100644
--- a/chirp/drivers/h777.py
+++ b/chirp/drivers/h777.py
@@ -95,6 +95,8 @@ SETTING_LISTS = {
def _h777_enter_programming_mode(radio):
serial = radio.pipe
+ # increase default timeout from .25 to .5 for all serial communications
+ serial.timeout = 0.5
try:
serial.write(b"\x02")
@@ -109,19 +111,15 @@ def _h777_enter_programming_mode(radio):
elif ack != CMD_ACK:
raise errors.RadioError("Radio refused to enter programming mode")
- original_timeout = serial.timeout
try:
serial.write(b"\x02")
# At least one version of the Baofeng BF-888S has a consistent
# ~0.33s delay between sending the first five bytes of the
# version data and the last three bytes. We need to raise the
# timeout so that the read doesn't finish early.
- serial.timeout = 0.5
ident = serial.read(8)
except:
raise errors.RadioError("Error communicating with radio")
- finally:
- serial.timeout = original_timeout
if not ident.startswith(b"P3107"):
LOG.debug(util.hexprint(ident))
@@ -180,20 +178,16 @@ def _h777_write_block(radio, block_addr, block_size):
LOG.debug("Writing Data:")
LOG.debug(util.hexprint(cmd + data))
- original_timeout = serial.timeout
try:
serial.write(cmd + data)
# Time required to write data blocks varies between individual
# radios of the Baofeng BF-888S model. The longest seen is
# ~0.31s.
- serial.timeout = 0.5
if serial.read(1) != CMD_ACK:
raise Exception("No ACK")
except:
raise errors.RadioError("Failed to send block "
"to radio at %04x" % block_addr)
- finally:
- serial.timeout = original_timeout
def do_download(radio):
@@ -271,6 +265,11 @@ class TenwayTW325Alias(chirp_common.Alias):
MODEL = 'TW-325'
+class RetevisH777Alias(chirp_common.Alias):
+ VENDOR = 'Retevis'
+ MODEL = 'H777'
+
+
@directory.register
class H777Radio(chirp_common.CloneModeRadio):
"""HST H-777"""
@@ -282,11 +281,11 @@ class H777Radio(chirp_common.CloneModeRadio):
NEEDS_COMPAT_SERIAL = False
ALIASES = [ArcshellAR5, ArcshellAR6, GV8SAlias, GV9SAlias, A8SAlias,
- TenwayTW325Alias]
+ TenwayTW325Alias, RetevisH777Alias]
SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"]
# This code currently requires that ranges start at 0x0000
- # and are continious. In the original program 0x0388 and 0x03C8
+ # and are continuous. In the original program 0x0388 and 0x03C8
# are only written (all bytes 0xFF), not read.
# _ranges = [
# (0x0000, 0x0110),
@@ -297,12 +296,13 @@ class H777Radio(chirp_common.CloneModeRadio):
_ranges = [
(0x0000, 0x0110),
- (0x02B0, 0x02C0),
(0x0380, 0x03E0),
+ (0x02B0, 0x02C0),
]
_memsize = 0x03E0
_has_fm = True
_has_sidekey = True
+ _has_scanmodes = True
def get_features(self):
rf = chirp_common.RadioFeatures()
@@ -481,11 +481,13 @@ class H777Radio(chirp_common.CloneModeRadio):
RadioSettingValueBoolean(_settings.scan))
basic.append(rs)
- rs = RadioSetting("settings2.scanmode", "Scan mode",
- RadioSettingValueList(
- SCANMODE_LIST,
- SCANMODE_LIST[self._memobj.settings2.scanmode]))
- basic.append(rs)
+ if self._has_scanmodes:
+ rs = RadioSetting("settings2.scanmode", "Scan mode",
+ RadioSettingValueList(
+ SCANMODE_LIST,
+ SCANMODE_LIST[
+ self._memobj.settings2.scanmode]))
+ basic.append(rs)
rs = RadioSetting("vox", "VOX",
RadioSettingValueBoolean(_settings.vox))
@@ -640,3 +642,16 @@ class ROGA2SRadio(H777Radio):
def match_model(cls, filedata, filename):
# This model is only ever matched via metadata
return False
+
+
+@directory.register
+class H777PlusRadio(H777Radio):
+ VENDOR = "Retevis"
+ MODEL = "H777 Plus"
+ _has_fm = False
+ _has_scanmodes = False
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This model is only ever matched via metadata
+ return False
diff --git a/chirp/drivers/hg_uv98.py b/chirp/drivers/hg_uv98.py
new file mode 100644
index 0000000..d95608c
--- /dev/null
+++ b/chirp/drivers/hg_uv98.py
@@ -0,0 +1,897 @@
+# -*- coding: utf-8 -*-
+# Copyright 2022 Masen Furer <kf7hvm@0x26.net>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Lanchonlh HG-UV98 driver written by
+# Masen Furer <kf7hvm@0x26.net>
+# With assistance from
+# KG7KMV and Bartłomiej Zieliński
+# Based on the implementation of Kenwood TK-8102
+
+from builtins import bytes
+import os
+import logging
+import struct
+
+from chirp import chirp_common, directory, memmap, errors, util
+from chirp import bitwise
+from chirp.settings import RadioSettingGroup, RadioSetting
+from chirp.settings import RadioSettingValueBoolean, RadioSettingValueList
+from chirp.settings import RadioSettingValueString, RadioSettings
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ lbcd rx_freq[4];
+ lbcd tx_freq[4];
+ ul16 rx_tone;
+ ul16 tx_tone;
+ u8 unknown1:6,
+ wide:1,
+ highpower:1;
+ u8 unknown2:5,
+ bcl:1,
+ scan:1,
+ unknown3:1;
+ u8 unknown4[2];
+} memory[130];
+
+#seekto 0x0a00;
+struct {
+ u8 abr; // 0x0a00
+ u8 save;
+ u8 ch_a_step;
+ u8 ch_b_step;
+ u8 vox_grd;
+ u8 ch_a_sql;
+ u8 ch_b_sql;
+ u8 roger;
+ u8 ch_a_v_m;
+ u8 ch_b_v_m;
+ u8 ch_a_ch_mdf;
+ u8 ch_b_ch_mdf;
+ u8 tdr;
+ u8 unknown5[3];
+ u8 unknown6[5]; // 0x0a10
+ u8 english;
+ u8 beep;
+ u8 voice;
+ u8 night_mode;
+ u8 abr_lv; // backlight level
+ u8 tot;
+ u8 toa;
+ u8 vox_dly;
+ u8 sc_rev;
+ u8 lockmode;
+ u8 autolock;
+ u8 unknown7; // 0x0a20
+ u8 pf1_short;
+ u8 pf1_long;
+ u8 pf2_short;
+ u8 pf2_long;
+ u8 top_short;
+ u8 top_long;
+ u8 rpt_rct;
+ u8 sc_qt;
+ u8 pri_ch;
+ u8 pri_scn;
+ u8 unknown8;
+ u8 aprs_rx_band;
+ u8 ch_a_mute;
+ u8 ch_b_mute;
+ u8 unknown9[7]; // 0x0a30
+ u8 tx_priority;
+ u8 aprs_rx_popup;
+ u8 aprs_rx_tone;
+ u8 aprs_tx_tone;
+ u8 unknown10;
+ u8 auto_lock_dly;
+ u8 menu_dly;
+ u8 beacon_exit_dly;
+ u8 unknown11;
+ u8 unknown12[2]; // 0x0a40
+ u8 ch_a_mem_ch;
+ u8 ch_b_mem_ch;
+ u8 unknown13[12];
+} settings;
+
+#seekto 0x1000;
+struct {
+ char name[11];
+ u8 unknown[5];
+} name[128];
+
+struct {
+ char callsign[9];
+ u8 null;
+} aprs;
+
+#seekto 0x1f80;
+struct {
+ ul32 unknown[8];
+} unknown_settings;
+
+"""
+
+BOUNDS = [(136000000, 174000000), (400000000, 500000000)]
+OFFSETS = [600000, 5000000]
+MAX_CHANNELS = 128
+MAX_NAME = 8
+NAME_FIELD_SIZE = 11
+CHUNK_SIZE = 64
+MAX_ADDR = 0x2000
+POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1),
+ chirp_common.PowerLevel("High", watts=5)]
+MODES = ["FM", "NFM"]
+SPECIAL_CHANNELS = {
+ 129: ("VFO-A", "A"),
+ 130: ("VFO-B", "B"),
+}
+
+# Settings maps
+ABR_LIST = [str(v) for v in range(0, 151, 5)]
+STEP_LIST = ["5.0", "6.25", "10.0", "12.5", "25.0", "50.0", "100.0"]
+VOX_LIST = ["OFF", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+SQL_LIST = [str(v) for v in range(0, 10)]
+ROGER_LIST = ["OFF", "BEGIN", "END", "BOTH"]
+MDF_LIST = ["NUM+FREQ", "NUMBER", "NAME"]
+VM_LIST = ["VFO", "MEMORY"]
+LANG_LIST = ["CHINESE", "ENGLISH"]
+ABR_LV_LIST = [str(v) for v in range(1, 11)]
+TOT_LIST = [str(v) for v in range(0, 601, 15)]
+TOA_LIST = ["OFF"] + ["{} S".format(v) for v in range(1, 11)]
+VOX_DLY_LIST = [str(v) for v in range(1, 11)]
+SC_REV_LIST = ["TIME", "BUSY", "HOLD"]
+LOCKMODE_LIST = ["KEY", "KEY+DIAL", "KEY+DIAL+PTT"]
+AUTOLOCK_LIST = ["AUTO", "Manual"]
+PF1_LIST = ["BACK LIGHT", "SCAN", "SQUELCH", "TORCH", "BAND A/B"]
+PF2_LIST = ["BEACON", "LIST", "TORCH", "BACK LIGHT"]
+TOP_LIST = ["ALERT", "REMOTE ALERT", "TORCH", "TXP", "CH MDF", "OFF_NET_KEY"]
+SC_QT_LIST = ["Decode", "Encode", "Decode+Encode"]
+APRS_RX_LIST = ["OFF", "BAND A", "BAND B"]
+TX_PRIORITY_LIST = ["VOICE", "APRS"]
+AUTOLOCK_DLY_LIST = ["{} S".format(v) for v in range(5, 31)]
+BEACON_EXIT_DLY_LIST = MENU_DLY_LIST = AUTOLOCK_DLY_LIST
+
+
+def make_frame(cmd, addr, length, data=b""):
+ if not isinstance(data, bytes):
+ data = data.decode("ascii")
+ return struct.pack(">BHB", ord(cmd), addr, length) + data
+
+
+def send(radio, frame):
+ LOG.debug("%04i P>R: %s" % (len(frame), util.hexprint(frame)))
+ radio.pipe.write(frame)
+
+
+def recv(radio, readdata=True):
+ hdr = radio.pipe.read(4)
+ cmd, addr, length = struct.unpack(">BHB", hdr)
+ if readdata:
+ data = radio.pipe.read(length)
+ LOG.debug(" P<R: %s" % util.hexprint(hdr + data))
+ if len(data) != length:
+ raise errors.RadioError("Radio sent %i bytes (expected %i)" % (
+ len(data), length))
+ else:
+ data = b""
+ radio.pipe.write(b"\x06")
+ ack = radio.pipe.read(1)
+ if ack != b"\x06":
+ raise errors.RadioError("Radio didn't ack our read ack")
+ return addr, bytes(data)
+
+
+def do_ident(radio):
+ send(radio, b"NiNHSG0N")
+ ack = radio.pipe.read(1)
+ if ack != b"\x06":
+ raise errors.RadioError("Radio refused program mode: {}".format(ack))
+ radio.pipe.write(b"\x02")
+ ident = radio.pipe.read(8)
+ LOG.debug('ident string was %r' % ident)
+ if ident != radio.IDENT:
+ raise errors.RadioError(
+ "Incorrect model: {}, expected {!r}".format(
+ util.hexprint(ident), radio.IDENT,
+ )
+ )
+ LOG.info("Model: %s (%s)" % (radio.MODEL, util.hexprint(ident)))
+ radio.pipe.write(b"\x06")
+ ack = radio.pipe.read(1)
+ if ack != b"\x06":
+ raise errors.RadioError("Radio entered program mode, but didn't ack our ack")
+
+
+def do_download(radio):
+ radio.pipe.parity = "E"
+ radio.pipe.timeout = 1
+ do_ident(radio)
+
+ data = bytes(b"")
+ for addr in range(0, MAX_ADDR, CHUNK_SIZE):
+ send(radio, make_frame(bytes(b"R"), addr, CHUNK_SIZE))
+ _addr, _data = recv(radio)
+ if _addr != addr:
+ raise errors.RadioError("Radio sent unexpected address")
+ data += _data
+ radio.pipe.write(b"\x06")
+ ack = radio.pipe.read(1)
+ if ack != b"\x06":
+ raise errors.RadioError("Radio refused block at %04x" % addr)
+
+ status = chirp_common.Status()
+ status.cur = addr
+ status.max = MAX_ADDR
+ status.msg = "Cloning from radio"
+ radio.status_fn(status)
+
+ radio.pipe.write(b"\x45")
+ return memmap.MemoryMapBytes(data)
+
+
+def do_upload(radio):
+ radio.pipe.parity = "E"
+ radio.pipe.timeout = 1
+ do_ident(radio)
+
+ mmap = radio._mmap
+ if callable(getattr(mmap, "get_byte_compatible", None)):
+ # for py3-CHIRP
+ mmap = mmap.get_byte_compatible()
+ for addr in range(0, MAX_ADDR, CHUNK_SIZE):
+ send(radio, make_frame(b"W", addr, CHUNK_SIZE, mmap[addr:addr + CHUNK_SIZE]))
+ ack = radio.pipe.read(1)
+ if ack != b"\x06":
+ raise errors.RadioError("Radio refused block at %04x" % addr)
+ radio.pipe.write(b"\x06")
+ ack = radio.pipe.read(1)
+ if ack != b"\x06":
+ raise errors.RadioError("Radio didn't ack our read ack")
+
+ status = chirp_common.Status()
+ status.cur = addr
+ status.max = MAX_ADDR
+ status.msg = "Cloning to radio"
+ radio.status_fn(status)
+
+ radio.pipe.write(b"\x45")
+
+
+def offset_for(freq):
+ for bounds, offset in zip(BOUNDS, OFFSETS):
+ if bounds[0] <= freq <= bounds[1]:
+ return offset
+ return 0
+
+
+class RadioSettingValueChannel(RadioSettingValueList):
+ """A setting that points to a defined channel."""
+ def __init__(self, radio, current_raw):
+ current = int(current_raw)
+ current_mem = radio.get_memory(current)
+ options = [
+ self._format_memory(mem)
+ for mem in [
+ radio.get_memory(n)
+ for n in range(*radio.get_features().memory_bounds)
+ ]
+ ]
+ RadioSettingValueList.__init__(
+ self,
+ options,
+ self._format_memory(current_mem),
+ )
+
+ @staticmethod
+ def _format_memory(m):
+ if m.empty:
+ return str(int(m.number))
+ return "{} {:.4f} {}".format(int(m.number), m.freq / float(1e6), m.name)
+
+ def __trunc__(self):
+ return int(self.get_value().partition(" ")[0])
+
+
+@directory.register
+class LanchonlhHG_UV98(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
+ """
+ Lanchonlh HG-UV98
+
+ Memory map decoding by KG7KMV
+ Chirp integration by KF7HVM
+ """
+ VENDOR = "Lanchonlh"
+ MODEL = "HG-UV98"
+ IDENT = b"P3107\0\0\0"
+ BAUD_RATE = 9600
+ NEEDS_COMPAT_SERIAL = False
+
+ _upper = MAX_CHANNELS
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = (
+ "This Lanchonlh HG-UV98 driver is an alpha version. "
+ "Proceed with Caution and backup your data. "
+ "Always confirm the correctness of your settings with the "
+ "official programming tool."
+ )
+ return rp
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_cross = False
+ rf.has_bank = False
+ rf.has_tuning_step = False
+ rf.has_name = True
+ rf.has_rx_dtcs = True
+ rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC
+ rf.valid_tuning_steps = [5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0, 100.0]
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_modes = MODES
+ rf.valid_cross_modes = [
+ "Tone->Tone",
+ "DTCS->",
+ "->DTCS",
+ "Tone->DTCS",
+ "DTCS->Tone",
+ "->Tone",
+ "DTCS->DTCS"]
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_skips = ["", "S"]
+ rf.valid_bands = [(136000000, 174000000), (400000000, 500000000)]
+ rf.valid_name_length = 8
+ rf.valid_special_chans = [129, 130]
+ rf.memory_bounds = (1, self._upper)
+ return rf
+
+ def sync_in(self):
+ try:
+ self._mmap = do_download(self)
+ except errors.RadioError:
+ self.pipe.write(b"\x45")
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to download from radio: %s" % e)
+ self.process_mmap()
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def sync_out(self):
+ try:
+ do_upload(self)
+ except errors.RadioError:
+ self.pipe.write(b"\x45")
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to upload to radio: %s" % e)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ def _get_tone(self, _mem, mem):
+ def _get_dcs(val):
+ code = int("%03o" % (val & 0x07FF))
+ pol = (val & 0x8000) and "R" or "N"
+ return code, pol
+
+ if _mem.tx_tone != 0xFFFF and _mem.tx_tone > 0x2800:
+ tcode, tpol = _get_dcs(_mem.tx_tone)
+ mem.dtcs = tcode
+ txmode = "DTCS"
+ elif _mem.tx_tone != 0xFFFF:
+ mem.rtone = _mem.tx_tone / 10.0
+ txmode = "Tone"
+ else:
+ txmode = ""
+
+ if _mem.rx_tone != 0xFFFF and _mem.rx_tone > 0x2800:
+ rcode, rpol = _get_dcs(_mem.rx_tone)
+ mem.rx_dtcs = rcode
+ rxmode = "DTCS"
+ elif _mem.rx_tone != 0xFFFF:
+ mem.ctone = _mem.rx_tone / 10.0
+ rxmode = "Tone"
+ else:
+ rxmode = ""
+
+ if txmode == "Tone" and not rxmode:
+ mem.tmode = "Tone"
+ elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
+ mem.tmode = "TSQL"
+ elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
+ mem.tmode = "DTCS"
+ elif rxmode or txmode:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ if mem.tmode == "DTCS":
+ mem.dtcs_polarity = "%s%s" % (tpol, rpol)
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number - 1]
+
+ mem = chirp_common.Memory()
+ mem.number = number
+
+ if _mem.get_raw()[:4] == "\xFF\xFF\xFF\xFF":
+ mem.empty = True
+ return mem
+
+ if mem.number in SPECIAL_CHANNELS:
+ mem.name, mem.extd_number = SPECIAL_CHANNELS[mem.number]
+ else:
+ _name = self._memobj.name[number - 1]
+ mem.name, _, _ = _name.name.get_raw().partition("\xFF")
+ # XXX: other drivers rstrip the name and test_badname enforces this
+ mem.name = mem.name.rstrip()
+ mem.freq = int(_mem.rx_freq) * 10
+ offset = (int(_mem.tx_freq) * 10) - mem.freq
+ if offset < 0:
+ mem.offset = abs(offset)
+ mem.duplex = "-"
+ elif offset > 0:
+ mem.offset = offset
+ mem.duplex = "+"
+ else:
+ mem.offset = 0
+
+ self._get_tone(_mem, mem)
+ mem.power = POWER_LEVELS[_mem.highpower]
+ mem.mode = MODES[_mem.wide]
+ mem.skip = not _mem.scan and "S" or ""
+
+ mem.extra = RadioSettingGroup("all", "All Settings")
+
+ bcl = RadioSetting("bcl", "Busy Channel Lockout",
+ RadioSettingValueBoolean(bool(_mem.bcl)))
+ mem.extra.append(bcl)
+
+ return mem
+
+ def _set_tone(self, mem, _mem):
+ def _set_dcs(code, pol):
+ val = int("%i" % code, 8) + 0x2800
+ if pol == "R":
+ val += 0xA000
+ return val
+
+ rx_mode = tx_mode = None
+ rx_tone = tx_tone = 0xFFFF
+
+ if mem.tmode == "Tone":
+ tx_mode = "Tone"
+ rx_mode = None
+ tx_tone = int(mem.rtone * 10)
+ elif mem.tmode == "TSQL":
+ rx_mode = tx_mode = "Tone"
+ rx_tone = tx_tone = int(mem.ctone * 10)
+ elif mem.tmode == "DTCS":
+ tx_mode = rx_mode = "DTCS"
+ tx_tone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ rx_tone = _set_dcs(mem.dtcs, mem.dtcs_polarity[1])
+ elif mem.tmode == "Cross":
+ tx_mode, rx_mode = mem.cross_mode.split("->")
+ if tx_mode == "DTCS":
+ tx_tone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ elif tx_mode == "Tone":
+ tx_tone = int(mem.rtone * 10)
+ if rx_mode == "DTCS":
+ rx_tone = _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[1])
+ elif rx_mode == "Tone":
+ rx_tone = int(mem.ctone * 10)
+
+ _mem.rx_tone = rx_tone
+ _mem.tx_tone = tx_tone
+
+ LOG.debug("Set TX %s (%i) RX %s (%i)" %
+ (tx_mode, _mem.tx_tone, rx_mode, _mem.rx_tone))
+
+ def set_memory(self, mem):
+ _mem = self._memobj.memory[mem.number - 1]
+
+ if mem.empty:
+ _mem.set_raw("\xFF" * 16)
+ return
+
+ if mem.number not in SPECIAL_CHANNELS:
+ _name = self._memobj.name[mem.number - 1]
+ _namelength = self.get_features().valid_name_length
+ for i in range(NAME_FIELD_SIZE):
+ try:
+ _name.name[i] = mem.name[i]
+ except IndexError:
+ _name.name[i] = "\xFF"
+
+ # clear reserved fields
+ _mem.unknown1 = 0xFF
+ _mem.unknown2 = 0xFF
+ _mem.unknown3 = 0xFF
+ _mem.unknown4 = (0xFF, 0xFF)
+ _mem.rx_freq = mem.freq / 10
+ mem_offset = mem.offset or offset_for(mem.freq)
+ if mem.duplex == "+":
+ _mem.tx_freq = (mem.freq + mem_offset) / 10
+ elif mem.duplex == "-":
+ _mem.tx_freq = (mem.freq - mem_offset) / 10
+ else:
+ _mem.tx_freq = mem.freq / 10
+
+ self._set_tone(mem, _mem)
+
+ _mem.highpower = mem.power == POWER_LEVELS[1]
+ _mem.wide = mem.mode == "NFM"
+ _mem.scan = mem.skip != "S"
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def get_settings(self):
+ _mem = self._memobj
+ _settings = _mem.settings
+ basic = RadioSettingGroup("basic", "Basic")
+ display = RadioSettingGroup("display", "Display")
+ scan = RadioSettingGroup("scan", "Scan")
+ buttons = RadioSettingGroup("buttons", "Buttons")
+ vfo = RadioSettingGroup("vfo", "VFO")
+ advanced = RadioSettingGroup("advanced", "Advanced")
+ aprs = RadioSettingGroup("aprs", "APRS")
+ top = RadioSettings(basic, display, scan, buttons, vfo, advanced, aprs)
+
+ basic.append(
+ RadioSetting(
+ "save",
+ "Power Save",
+ RadioSettingValueBoolean(_settings.save),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "roger",
+ "Roger Beep",
+ RadioSettingValueList(ROGER_LIST, ROGER_LIST[_settings.roger]),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "beep",
+ "System Beep",
+ RadioSettingValueBoolean(_settings.beep),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "tot",
+ "Timeout Timer (sec)",
+ RadioSettingValueList(TOT_LIST, TOT_LIST[_settings.tot]),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "toa",
+ "Timeout Timer Alarm",
+ RadioSettingValueList(TOA_LIST, TOA_LIST[_settings.toa]),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "lockmode",
+ "Lock Mode",
+ RadioSettingValueList(LOCKMODE_LIST, LOCKMODE_LIST[_settings.lockmode]),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "autolock",
+ "Auto Lock",
+ RadioSettingValueList(AUTOLOCK_LIST, AUTOLOCK_LIST[_settings.autolock]),
+ )
+ )
+ basic.append(
+ RadioSetting(
+ "auto_lock_dly",
+ "Auto Lock Delay",
+ RadioSettingValueList(AUTOLOCK_DLY_LIST, AUTOLOCK_DLY_LIST[_settings.auto_lock_dly]),
+ )
+ )
+ display.append(
+ RadioSetting(
+ "abr",
+ "Screen Save",
+ RadioSettingValueList(ABR_LIST, ABR_LIST[_settings.abr]),
+ )
+ )
+ display.append(
+ RadioSetting(
+ "abr_lv",
+ "Back Light Brightness",
+ RadioSettingValueList(ABR_LV_LIST, ABR_LV_LIST[_settings.abr_lv]),
+ )
+ )
+ display.append(
+ RadioSetting(
+ "night_mode",
+ "Night Mode (Light on Dark)",
+ RadioSettingValueBoolean(_settings.night_mode),
+ )
+ )
+ display.append(
+ RadioSetting(
+ "menu_dly",
+ "Menu Delay",
+ RadioSettingValueList(MENU_DLY_LIST, MENU_DLY_LIST[_settings.menu_dly]),
+ )
+ )
+ display.append(
+ RadioSetting(
+ "english",
+ "Language",
+ RadioSettingValueList(LANG_LIST, LANG_LIST[_settings.english]),
+ )
+ )
+ scan.append(
+ RadioSetting(
+ "pri_scn",
+ "Priority Scan",
+ RadioSettingValueBoolean(_settings.pri_scn),
+ )
+ )
+ scan.append(
+ RadioSetting(
+ "pri_ch",
+ "Priority Channel",
+ RadioSettingValueChannel(self, _settings.pri_ch),
+ )
+ )
+ scan.append(
+ RadioSetting(
+ "sc_rev",
+ "Scan Resume",
+ RadioSettingValueList(SC_REV_LIST, SC_REV_LIST[_settings.sc_rev]),
+ )
+ )
+ scan.append(
+ RadioSetting(
+ "sc_qt",
+ "Code Save",
+ RadioSettingValueList(SC_QT_LIST, SC_QT_LIST[_settings.sc_qt]),
+ )
+ )
+ buttons.append(
+ RadioSetting(
+ "pf1_short",
+ "PF1 (Side, Upper) Button Short Press",
+ RadioSettingValueList(PF1_LIST, PF1_LIST[_settings.pf1_short]),
+ )
+ )
+ buttons.append(
+ RadioSetting(
+ "pf1_long",
+ "PF1 (Side, Upper) Button Long Press",
+ RadioSettingValueList(PF1_LIST, PF1_LIST[_settings.pf1_long]),
+ )
+ )
+ buttons.append(
+ RadioSetting(
+ "pf2_short",
+ "PF2 (Side, Lower) Button Short Press",
+ RadioSettingValueList(PF2_LIST, PF2_LIST[_settings.pf2_short]),
+ )
+ )
+ buttons.append(
+ RadioSetting(
+ "pf2_long",
+ "PF2 (Side, Lower) Button Long Press",
+ RadioSettingValueList(PF2_LIST, PF2_LIST[_settings.pf2_long]),
+ )
+ )
+ buttons.append(
+ RadioSetting(
+ "top_short",
+ "Top Button Short Press",
+ RadioSettingValueList(TOP_LIST, TOP_LIST[_settings.top_short]),
+ )
+ )
+ buttons.append(
+ RadioSetting(
+ "top_long",
+ "Top Button Long Press",
+ RadioSettingValueList(TOP_LIST, TOP_LIST[_settings.top_long]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "tdr",
+ "VFO B Enabled",
+ RadioSettingValueBoolean(_settings.tdr),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_a_step",
+ "VFO Frequency Step (A)",
+ RadioSettingValueList(STEP_LIST, STEP_LIST[_settings.ch_a_step]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_b_step",
+ "VFO Frequency Step (B)",
+ RadioSettingValueList(STEP_LIST, STEP_LIST[_settings.ch_b_step]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_a_sql",
+ "Squelch (A)",
+ RadioSettingValueList(SQL_LIST, SQL_LIST[_settings.ch_a_sql]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_b_sql",
+ "Squelch (B)",
+ RadioSettingValueList(SQL_LIST, SQL_LIST[_settings.ch_b_sql]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_a_mem_ch",
+ "Memory Channel (A)",
+ RadioSettingValueChannel(self, _settings.ch_a_mem_ch),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_b_mem_ch",
+ "Memory Channel (B)",
+ RadioSettingValueChannel(self, _settings.ch_b_mem_ch),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_a_ch_mdf",
+ "Memory Display Format (A)",
+ RadioSettingValueList(MDF_LIST, MDF_LIST[_settings.ch_a_ch_mdf]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_b_ch_mdf",
+ "Memory Display Format (B)",
+ RadioSettingValueList(MDF_LIST, MDF_LIST[_settings.ch_b_ch_mdf]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_a_v_m",
+ "VFO/MEM (A)",
+ RadioSettingValueList(VM_LIST, VM_LIST[_settings.ch_a_v_m]),
+ )
+ )
+ vfo.append(
+ RadioSetting(
+ "ch_b_v_m",
+ "VFO/MEM (B)",
+ RadioSettingValueList(VM_LIST, VM_LIST[_settings.ch_b_v_m]),
+ )
+ )
+ advanced.append(
+ RadioSetting(
+ "vox_grd",
+ "VOX Sensitivity",
+ RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox_grd]),
+ )
+ )
+ advanced.append(
+ RadioSetting(
+ "vox_dly",
+ "VOX Delay",
+ RadioSettingValueList(VOX_DLY_LIST, VOX_DLY_LIST[_settings.vox_dly]),
+ )
+ )
+ advanced.append(
+ RadioSetting(
+ "voice",
+ "Voice Assist",
+ RadioSettingValueBoolean(_settings.voice),
+ )
+ )
+ advanced.append(
+ RadioSetting(
+ "rpt_rct",
+ "RPT Roger",
+ RadioSettingValueBoolean(_settings.rpt_rct),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "aprs_rx_band",
+ "RX Band",
+ RadioSettingValueList(APRS_RX_LIST, APRS_RX_LIST[_settings.aprs_rx_band]),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "ch_a_mute",
+ "Band A Mute",
+ RadioSettingValueBoolean(_settings.ch_a_mute),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "ch_b_mute",
+ "Band B Mute",
+ RadioSettingValueBoolean(_settings.ch_b_mute),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "tx_priority",
+ "TX Priority",
+ RadioSettingValueList(TX_PRIORITY_LIST, TX_PRIORITY_LIST[_settings.tx_priority]),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "aprs_rx_popup",
+ "APRS Popup",
+ RadioSettingValueBoolean(_settings.aprs_rx_popup),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "aprs_rx_tone",
+ "RX Tone",
+ RadioSettingValueBoolean(_settings.aprs_rx_tone),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "aprs_tx_tone",
+ "TX Tone",
+ RadioSettingValueBoolean(_settings.aprs_tx_tone),
+ )
+ )
+ aprs.append(
+ RadioSetting(
+ "beacon_exit_dly",
+ "Beacon Message Delay",
+ RadioSettingValueList(BEACON_EXIT_DLY_LIST, BEACON_EXIT_DLY_LIST[_settings.beacon_exit_dly]),
+ )
+ )
+
+ return top
+
+ def set_settings(self, settings):
+ _mem = self._memobj
+ _settings = _mem.settings
+
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ name = element.get_name()
+ value = element.value
+
+ if hasattr(_settings, name):
+ setattr(_settings, name, value)
diff --git a/chirp/drivers/ic2200.py b/chirp/drivers/ic2200.py
index 3d42148..07453fb 100644
--- a/chirp/drivers/ic2200.py
+++ b/chirp/drivers/ic2200.py
@@ -79,9 +79,9 @@ DTCSP = ["NN", "NR", "RN", "RR"]
STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0]
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=65),
- chirp_common.PowerLevel("Mid", watts=25),
+ chirp_common.PowerLevel("Low", watts=5),
chirp_common.PowerLevel("MidLow", watts=10),
- chirp_common.PowerLevel("Low", watts=5)]
+ chirp_common.PowerLevel("Mid", watts=25)]
def _get_special():
diff --git a/chirp/drivers/ic2300.py b/chirp/drivers/ic2300.py
index b563e60..5969da5 100644
--- a/chirp/drivers/ic2300.py
+++ b/chirp/drivers/ic2300.py
@@ -62,7 +62,7 @@ struct {
duplex:2,
unknown3:1,
reverse_duplex:1,
- unknown4:1,
+ tx_inhibit:1,
display_style:1;
} memory[200];
#seekto 0x1340; // channel memory flags
@@ -188,6 +188,12 @@ class IC2300Radio(icf.IcomCloneModeRadio):
rev.set_doc("Reverse duplex")
mem.extra.append(rev)
+ # Tx inhibit
+ tx_inhibit = RadioSetting("tx_inhibit", "TX inhibit",
+ RadioSettingValueBoolean(bool(_mem.tx_inhibit)))
+ tx_inhibit.set_doc("TX inhibit")
+ mem.extra.append(tx_inhibit)
+
# Memory display style
opt = ["Frequency", "Label"]
dsp = RadioSetting("display_style", "Display style",
diff --git a/chirp/drivers/ic2730.py b/chirp/drivers/ic2730.py
index 3f981e6..3d80a18 100644
--- a/chirp/drivers/ic2730.py
+++ b/chirp/drivers/ic2730.py
@@ -1,5 +1,8 @@
-# Copyright 2018 Rhett Robinson <rrhett@gmail.com>
-# Added Settings support, 6/2019 Rick DeWitt <aa0rd@yahoo.com>
+# Copyright 2018 Rhett Robinson <rrhett@gmail.com> Vers 1.0
+# 6/2019: Vers 1.1 Added Settings support, Rick DeWitt <aa0rd@yahoo.com>
+# 7/2020: Vers 1.2 Fixed reversed E:* / F:# DTMF codes Issue #8159
+# 9/2020: Vers 1.3 Expanded tone mode support and added py3 HAS_FUTURE
+# bytes() per issue #8233. (icf.py is NOT updated)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,6 +30,14 @@ from textwrap import dedent
LOG = logging.getLogger(__name__)
+HAS_FUTURE = True
+try: # PY3 compliance
+ from builtins import bytes
+except ImportError:
+ HAS_FUTURE = False
+ LOG.debug('python-future package is not '
+ 'available; %s requires it' % __name__)
+
MEM_FORMAT = """
struct {
u24 freq_flags:6
@@ -219,15 +230,17 @@ u8 msk[4];
u16 mem_writes_count;
"""
-# Guessing some of these intermediate values are with the Pocket Beep function,
-# but I haven't reliably reproduced these.
-TMODES = ["", "Tone", "??0", "TSQL", "??1", "DTCS", "TSQL-R", "DTCS-R",
- "DTC.OFF", "TON.DTC", "DTC.TSQ", "TON.TSQ"]
-DUPLEX = ["", "-", "+"]
-MODES = ["FM", "NFM", "AM", "NAM"]
-DTCSP = ["NN", "NR", "RN", "RR"]
-DTMF_CHARS = list("0123456789ABCD*#")
-BANKLINK_CHARS = list("ABCDEFGHIJ")
+MDUPLEX = ["", "-", "+"]
+MSKIPS = ["", "S", "P"]
+MMODES = ["FM", "NFM", "AM", "NAM"]
+MTONE_MODES = chirp_common.TONE_MODES
+MTMODES = ["", "Tone", "TonePoc", "TSQL", "DTCSPoc", "DTCS",
+ "TSQL-R", "DTCS-R", "DTC.OFF", "TON.DTC",
+ "DTC.TSQ", "TON.TSQ"]
+MCROSS_MODES = ["Tone->Tone", "DTCS->", "Tone->DTCS", "DTCS->Tone"]
+MDTCSP = ["NN", "NR", "RN", "RR"]
+MDTMF_CHARS = list("0123456789ABCD*#")
+MBANKLINK_CHARS = list("ABCDEFGHIJ")
AUTOREPEATER = ["OFF", "DUP", "DUP.TON"]
MICKEYOPTS = ["Off", "Up", "Down", "Vol Up", "Vol Down", "SQL Up",
"SQL Down", "Monitor", "Call", "MR (Ch 0)", "MR (Ch 1)",
@@ -285,7 +298,9 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
def get_prompts(cls):
rp = chirp_common.RadioPrompts()
rp.info = ('Click the Special Channels tab on the main screen to '
- 'access the C0 and C1 frequencies.\n')
+ 'access the C0 and C1 frequencies.\n'
+ 'The Pocket Beep tone/dtcs modes are not supported by '
+ 'CHIRP. Set those manually.\n')
rp.pre_download = _(dedent("""\
Follow these instructions to download your config:
@@ -338,16 +353,22 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
rf.has_settings = True
rf.has_bank_index = True
rf.has_bank_names = True
+ rf.has_cross = True
+ rf.has_ctone = True
+ rf.has_dtcs = True
+ rf.has_rx_dtcs = False
+ rf.has_dtcs_polarity = True
rf.requires_call_lists = False
rf.memory_bounds = (0, 999)
- rf.valid_modes = list(MODES)
- rf.valid_tmodes = list(TMODES)
- rf.valid_duplexes = list(set(DUPLEX))
+ rf.valid_modes = MMODES
+ rf.valid_tmodes = MTONE_MODES
+ rf.valid_duplexes = MDUPLEX
rf.valid_tuning_steps = list(chirp_common.TUNING_STEPS[0:9])
rf.valid_bands = [(118000000, 174000000),
(375000000, 550000000)]
- rf.valid_skips = ["", "S", "P"]
+ rf.valid_skips = MSKIPS
rf.valid_characters = chirp_common.CHARSET_ASCII
+ rf.valid_cross_modes = MCROSS_MODES
rf.valid_name_length = 6
rf.valid_special_chans = sorted(_get_special().keys())
@@ -369,9 +390,9 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
_skip = self._memobj.skip_flags[bytepos]
_pskip = self._memobj.pskip_flags[bytepos]
if _skip & bitpos:
- mem.skip = "S"
+ mem.skip = MSKIPS[1] # "S"
elif _pskip & bitpos:
- mem.skip = "P"
+ mem.skip = MSKIPS[2] # "P"
if not is_used:
mem.empty = True
return mem
@@ -403,11 +424,37 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
mem.offset = int(_mem.offset) * offset_multiplier
mem.rtone = chirp_common.TONES[_mem.rtone]
mem.ctone = chirp_common.TONES[_mem.ctone]
- mem.tmode = TMODES[_mem.tmode]
- mem.duplex = DUPLEX[_mem.duplex]
- mem.mode = MODES[_mem.mode]
+ tmx = 0 # MTONE_MODES index default
+ cmx = 0 # MCROSS_MODES index
+ if _mem.tmode == 1: # Tone
+ tmx = 1
+ elif _mem.tmode == 3: # TSQL
+ tmx = 2
+ elif _mem.tmode == 5: # DTCS
+ tmx = 3
+ elif _mem.tmode == 6: # TSQL-R
+ tmx = 5
+ elif _mem.tmode == 7: # DTCS-R
+ tmx = 4
+ elif _mem.tmode == 8: # DTC.OFF
+ tmx = 6 # Real Cross modes now
+ cmx = 1
+ elif _mem.tmode == 9: # TON.DTC
+ tmx = 6
+ cmx = 2
+ elif _mem.tmode == 10: # DTC.TSQ
+ tmx = 6
+ cmx = 3
+ elif _mem.tmode == 11: # TON.TSQ
+ tmx = 6
+ cmx = 0
+ mem.tmode = MTONE_MODES[tmx]
+ mem.cross_mode = MCROSS_MODES[cmx]
+ mem.duplex = MDUPLEX[_mem.duplex]
+ mem.mode = MMODES[_mem.mode]
mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs]
- mem.dtcs_polarity = DTCSP[_mem.dtcs_polarity]
+ mem.dtcs_polarity = MDTCSP[_mem.dtcs_polarity]
+
if _mem.tune_step > 8:
mem.tuning_step = 5.0 # Sometimes TS is garbage?
else:
@@ -477,11 +524,32 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
_mem.freq_flags = frequency_flags
_mem.rtone = chirp_common.TONES.index(mem.rtone)
_mem.ctone = chirp_common.TONES.index(mem.ctone)
- _mem.tmode = TMODES.index(mem.tmode)
- _mem.duplex = DUPLEX.index(mem.duplex)
- _mem.mode = MODES.index(mem.mode)
+ tmx = MTONE_MODES.index(mem.tmode)
+ cmx = MCROSS_MODES.index(mem.cross_mode)
+ if tmx != 6: # Not Cross
+ if tmx < 2: # "", Tone
+ _mem.tmode = tmx
+ if tmx == 2: # TSQL
+ _mem.tmode = 3
+ if tmx == 3: # DTCS
+ _mem.tmode = 5
+ if tmx == 4: # DTCS-R
+ _mem.tmode = 7
+ if tmx == 5: # TSQL-R
+ _mem.tmode = 6
+ else: # Cross modes
+ if cmx == 0: # Tone->Tone
+ _mem.tmode = 11
+ if cmx == 1: # DTCS->
+ _mem.tmode = 8
+ if cmx == 2: # Tone->DTCS
+ _mem.tmode = 9
+ if cmx == 3: # DTCS->Tone
+ _mem.tmode = 10
+ _mem.duplex = MDUPLEX.index(mem.duplex)
+ _mem.mode = MMODES.index(mem.mode)
_mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
- _mem.dtcs_polarity = DTCSP.index(mem.dtcs_polarity)
+ _mem.dtcs_polarity = MDTCSP.index(mem.dtcs_polarity)
_mem.tune_step = chirp_common.TUNING_STEPS.index(mem.tuning_step)
def get_raw_memory(self, number):
@@ -528,11 +596,11 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
"""Convert u8 DTMF array to a string: NOT a callback."""
stx = ""
for i in range(0, 24): # unpack up to ff
- if codestr[i] != 0xff:
+ if codestr[i] != 0xff: # Issue 8159 fix
if codestr[i] == 0x0E:
- stx += "#"
- elif codestr[i] == 0x0F:
stx += "*"
+ elif codestr[i] == 0x0F:
+ stx += "#"
else:
stx += format(int(codestr[i]), '0X')
return stx
@@ -547,13 +615,13 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
# Remove illegal characters first
sty = ""
for j in range(0, len(stx)):
- if stx[j] in DTMF_CHARS:
+ if stx[j] in MDTMF_CHARS:
sty += stx[j]
for j in range(0, 24):
- if j < len(sty):
- if sty[j] == "#":
+ if j < len(sty): # Issue 8159 fix
+ if sty[j] == "*":
chrv = 0xE
- elif sty[j] == "*":
+ elif sty[j] == "#":
chrv = 0xF
else:
chrv = int(sty[j], 16)
@@ -664,7 +732,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
return
def myset_bitmask(setting, obj, ndx, atrb, knt):
- """ Callback to gnerate byte-array bitmask from string"""
+ """ Callback to generate byte-array bitmask from string"""
# knt is BIT count to process
lsx = str(setting.value).strip().split(",")
for kx in range(0, len(lsx)):
@@ -749,7 +817,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
stx = ""
for i in range(0, 16):
- stx += chr(_cmnt.com[i])
+ stx += chr(int(_cmnt.com[i]))
stx = stx.rstrip()
rx = RadioSettingValueString(0, 16, stx)
rset = RadioSetting("comment.com", "Comment (16 chars)", rx)
@@ -917,7 +985,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
abset.append(rset)
# --- Microphone Keys
- # The Mic keys get wierd: stored values are indecis to the full
+ # The Mic keys get weird: stored values are indecis to the full
# options list, but only a subset is valid...
shortopts = ["Off", "Monitor", "MR (Ch 0)", "MR (Ch 1)", "Band/Bank",
"Scan", "Temp Skip", "Mode", "Low", "Dup", "Priority",
@@ -1119,7 +1187,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
for kx in range(0, 25):
stx = ""
for i in range(0, 6):
- stx += chr(_pses[kx].name[i])
+ stx += chr(int(_pses[kx].name[i]))
stx = stx.rstrip()
rx = RadioSettingValueString(0, 6, stx)
rset = RadioSetting("pgmscanedge/%d.name" % kx,
@@ -1218,7 +1286,7 @@ class IC2730Radio(icf.IcomRawCloneModeRadio):
for kx in range(0, 10):
stx = ""
for i in range(0, 6):
- stx += chr(_psln[kx].nam[i])
+ stx += chr(int(_psln[kx].nam[i]))
stx = stx.rstrip()
rx = RadioSettingValueString(0, 6, stx)
rset = RadioSetting("pslnam/%d.nam" % kx,
diff --git a/chirp/drivers/icf.py b/chirp/drivers/icf.py
index 6d702db..c04e80a 100644
--- a/chirp/drivers/icf.py
+++ b/chirp/drivers/icf.py
@@ -121,15 +121,19 @@ class RadioStream:
return frames
- def get_frames(self, nolimit=False):
+ def get_frames(self, nolimit=False, limit=None):
"""Read any pending frames from the stream"""
while True:
- _data = self.pipe.read(64)
+ _data = self.pipe.read(1)
if not _data:
+ if limit:
+ LOG.warning('Hit timeout before one frame')
break
else:
self.data += _data
+ if limit and 0xFD in self.data:
+ break
if not nolimit and len(self.data) > 128 and 0xFD in self.data:
break # Give us a chance to do some status
if len(self.data) > 1024:
@@ -335,7 +339,7 @@ def clone_from_radio(radio):
raise errors.RadioError("Failed to communicate with the radio: %s" % e)
-def send_mem_chunk(radio, start, stop, bs=32):
+def send_mem_chunk(radio, stream, start, stop, bs=32):
"""Send a single chunk of the radio's memory from @start-@stop"""
_mmap = radio.get_mmap().get_byte_compatible()
@@ -361,6 +365,8 @@ def send_mem_chunk(radio, start, stop, bs=32):
raw=False,
checksum=True)
+ stream.get_frames(1)
+
if radio.status_fn:
status.cur = i+bs
radio.status_fn(status)
@@ -396,9 +402,8 @@ def _clone_to_radio(radio):
frames = []
for start, stop, bs in radio.get_ranges():
- if not send_mem_chunk(radio, start, stop, bs):
+ if not send_mem_chunk(radio, stream, start, stop, bs):
break
- frames += stream.get_frames()
send_clone_frame(radio, CMD_CLONE_END,
radio.get_endframe(),
@@ -449,7 +454,13 @@ def convert_data_line(line):
line = line.strip()
- if len(line) == 38:
+ # Detection of the prefix length. The code assumes that the data line
+ # length (without the prefix) is multiply of 8 characters (i.e. multiply
+ # of 4 bytes), so the rest (remainder of division by 8) has to be the
+ # prefix (prefix = address + length) - for small memory the address is
+ # 2 bytes long and the length indicator is 1 byte long which means 3 bytes
+ # in total which is 6 characters in total for the prefix on the ICF line.
+ if len(line) % 8 == 6:
# Small memory (< 0x10000)
size = int(line[4:6], 16)
data = line[6:]
diff --git a/chirp/drivers/icomciv.py b/chirp/drivers/icomciv.py
index af7fa90..e9baf8f 100644
--- a/chirp/drivers/icomciv.py
+++ b/chirp/drivers/icomciv.py
@@ -127,15 +127,6 @@ char pad1;
bbcd rtone[2]; // 12-14 tx tone freq
char pad2;
bbcd ctone[2]; // 15-17 tone rx squelch setting
-lbcd freq_tx[5]; // 4-8 transmit freq
-u8 mode_tx; // 9 tx operating mode
-u8 filter_tx; // 10
-u8 dataMode_tx:4, // 11 tx data mode setting (on or off)
- tmode_tx:4; // 11 tx tone type
-char pad3;
-bbcd rtone_tx[2]; // 12-14 repeater tone freq
-char pad4;
-bbcd ctone_tx[2]; // 15-17 tone squelch setting
char name[10]; // 18-27 Callsign
"""
@@ -722,7 +713,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
@directory.register
class Icom7200Radio(IcomCIVRadio):
"""Icom IC-7200"""
- MODEL = "7200"
+ MODEL = "IC-7200"
_model = "\x76"
_template = 201
@@ -961,7 +952,7 @@ class Icom7300Radio(IcomCIVRadio): # Added March, 2021 by Rick DeWitt
_SPECIAL_CHANNELS.keys()))
def _is_special(self, number):
- return number > 99 or isinstance(number, str)
+ return isinstance(number, str) or number > 99
def _get_special_info(self, number):
info = SpecialChannel()
@@ -999,8 +990,14 @@ class Icom7300Radio(IcomCIVRadio): # Added March, 2021 by Rick DeWitt
self._rf.valid_special_chans = sorted(self._SPECIAL_CHANNELS.keys())
+@directory.register
+class Icom7610Radio(Icom7300Radio):
+ MODEL = "IC-7610"
+ _model = '\x98'
+
+
def probe_model(ser):
- """Probe the radio attatched to @ser for its model"""
+ """Probe the radio attached to @ser for its model"""
f = Frame()
f.set_command(0x19, 0x00)
diff --git a/chirp/drivers/icp7.py b/chirp/drivers/icp7.py
index c9a2459..5d8dbf8 100644
--- a/chirp/drivers/icp7.py
+++ b/chirp/drivers/icp7.py
@@ -16,7 +16,7 @@
from chirp.drivers import icf
from chirp import chirp_common, directory, bitwise
-# memory nuber:
+# memory number:
# 000 - 999 regular memory channels (supported, others not)
# 1000 - 1049 scan edges
# 1050 - 1249 auto write channels
diff --git a/chirp/drivers/ict8.py b/chirp/drivers/ict8.py
index 299333a..1bc6714 100644
--- a/chirp/drivers/ict8.py
+++ b/chirp/drivers/ict8.py
@@ -84,6 +84,7 @@ class ICT8ARadio(icf.IcomCloneModeRadio):
rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC
rf.has_dtcs = False
rf.has_dtcs_polarity = False
+ rf.valid_tuning_steps = [5, 10, 12.5, 15, 20, 25, 30, 50, 100]
rf.has_tuning_step = False
rf.has_mode = False
rf.has_bank = False
diff --git a/chirp/drivers/icv86.py b/chirp/drivers/icv86.py
new file mode 100644
index 0000000..52e84e0
--- /dev/null
+++ b/chirp/drivers/icv86.py
@@ -0,0 +1,371 @@
+# Copyright 2008 Dan Smith <dsmith@danplanet.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from chirp.drivers import icf
+from chirp import chirp_common, memmap, bitwise, errors, directory
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueInteger, RadioSettingValueList, \
+ RadioSettingValueBoolean, RadioSettingValueString, \
+ RadioSettingValueFloat, RadioSettings
+
+LOG = logging.getLogger(__name__)
+
+
+ICV86_MEM_FORMAT = """
+#seekto 0x040;
+u8 skips[26];
+
+#seekto 0x060;
+u8 used[26];
+
+#seekto 0x00BF;
+struct {
+ u8 reserved1[8];
+ u8 reserved2:6,
+ disp_type:2;
+ u8 reserved3;
+ u8 reserved4:7,
+ dial_assignment:1;
+ u8 reserved5[8];
+ u8 reserved6:6,
+ lcd:2;
+ u8 reserved7[2];
+ u8 reserved8:6,
+ mic:2;
+} settings;
+
+#seekto 0x0200;
+struct {
+ ul32 freq;
+ ul32 offset;
+ char name[5];
+ u8 reserved1:2,
+ rtone:6;
+ u8 reserved2:2,
+ ctone:6;
+ u8 reserved3:1,
+ dtcs:7;
+ u8 reserved4:5,
+ tuning_step:3;
+ u8 reserved5:2,
+ mode:1,
+ rev:1,
+ duplex:2,
+ reserved6:2;
+ u8 reserved7:2,
+ dtcs_polarity:2,
+ tmode:4;
+ u8 reserved8:5,
+ tx:1,
+ power:2;
+ u8 reserved9;
+ u8 reserved10;
+ u8 reserved11;
+ u8 reserved12;
+} memory[207];
+
+"""
+
+SPECIAL = {
+ "0A": 200, "0B": 201,
+ "1A": 202, "1B": 203,
+ "2A": 204, "2B": 205,
+ "C": 206,
+}
+
+SPECIAL_REV = {
+ 200: "0A", 201: "0B",
+ 202: "1A", 203: "1B",
+ 204: "2A", 205: "2B",
+ 206: "C",
+}
+
+TMODES = ["", "Tone", "TSQL", "DTCS", "DTCS-R"]
+MODES = ["FM", "NFM"]
+SKIPS = ["", "S"]
+DUPLEXES = ["", "-", "+"]
+DTCS_POLARITY = ["NN", "NR", "RN", "RR"]
+TUNING_STEPS = [5., 10., 12.5, 15., 20., 25., 30., 50.]
+POWER_LEVELS = [
+ chirp_common.PowerLevel("High", watts=5.5),
+ chirp_common.PowerLevel("Low", watts=0.5),
+ chirp_common.PowerLevel("Mid", watts=2.5)
+]
+
+
+@directory.register
+class ICV86Radio(icf.IcomCloneModeRadio):
+ """Icom IC-V86"""
+ VENDOR = "Icom"
+ MODEL = "IC-V86"
+ # read clone response after each clone frame is sent
+ MUNCH_CLONE_RESP = True
+
+ _model = "\x40\x66\x00\x01"
+ _memsize = 5504
+ _endframe = "Icom Inc\x2eAC"
+
+ _ranges = [(0x0000, 5504, 32)]
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+
+ rf.memory_bounds = (0, 199)
+ rf.valid_modes = MODES
+ rf.valid_tmodes = TMODES
+ rf.valid_duplexes = DUPLEXES
+ rf.valid_tuning_steps = TUNING_STEPS
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_skips = SKIPS
+ rf.valid_name_length = 5
+ rf.valid_special_chans = sorted(SPECIAL.keys())
+ rf.valid_bands = [(136000000, 174000000)]
+ rf.has_ctone = True
+ rf.has_offset = True
+ rf.has_bank = False
+ rf.has_settings = True
+
+ return rf
+
+ def __init__(self, pipe):
+ icf.IcomCloneModeRadio.__init__(self, pipe)
+
+ def sync_in(self):
+ icf.IcomCloneModeRadio.sync_in(self)
+
+ def sync_out(self):
+ icf.IcomCloneModeRadio.sync_out(self)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(ICV86_MEM_FORMAT, self._mmap)
+
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+
+ setmode = RadioSettingGroup("setmode", "General Settings")
+
+ settings = RadioSettings(setmode)
+
+ # LCD Backlight
+ opts = ["Off", "On", "Auto"]
+ setmode.append(
+ RadioSetting(
+ "lcd", "LCD Backlight",
+ RadioSettingValueList(opts, opts[_settings.lcd])))
+
+ # Mic Gain
+ rs = RadioSetting("mic", "Mic Gain",
+ RadioSettingValueInteger(1, 4, _settings.mic + 1))
+ def apply_mic(s, obj):
+ setattr(obj, s.get_name(), int(s.value) - 1)
+ rs.set_apply_callback(apply_mic, self._memobj.settings)
+ setmode.append(rs)
+
+ # Dial Assignment
+ opts = ["Volume", "Tuning"]
+ setmode.append(
+ RadioSetting(
+ "dial_assignment", "Dial Assignment",
+ RadioSettingValueList(opts, opts[_settings.dial_assignment])))
+
+ # Display Type
+ opts = ["Frequency", "Channel", "Name"]
+ setmode.append(
+ RadioSetting(
+ "disp_type", "Display Type",
+ RadioSettingValueList(opts, opts[_settings.disp_type])))
+
+ return settings
+
+ def set_settings(self, settings):
+ _settings = self._memobj.settings
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ if not element.changed():
+ continue
+
+ try:
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ else:
+ setting = element.get_name()
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(_settings, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ def _get_memory(self, number):
+ bit = 1 << (number % 8)
+ byte = int(number / 8)
+
+ mem = chirp_common.Memory()
+ mem.number = number
+
+ _mem = self._memobj.memory[number]
+
+ if number < 200:
+ _usd = self._memobj.used[byte]
+ _skp = self._memobj.skips[byte]
+ else:
+ mem.extd_number = SPECIAL_REV[number]
+ mem.immutable = ["name", "number", "extd_number", "skip"]
+ _usd = self._memobj.used[byte] if (number <= 206) else None
+ _skp = None
+
+ if _usd is not None and (_usd & bit):
+ mem.empty = True
+ return mem
+
+ mem.freq = _mem.freq
+ mem.offset = int(_mem.offset)
+ if number < 200:
+ mem.name = str(_mem.name).rstrip()
+ mem.rtone = chirp_common.TONES[_mem.rtone]
+ mem.ctone = chirp_common.TONES[_mem.ctone]
+ mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs]
+ mem.tuning_step = TUNING_STEPS[_mem.tuning_step]
+ mem.mode = MODES[_mem.mode]
+ mem.duplex = DUPLEXES[_mem.duplex]
+ mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_polarity]
+ mem.tmode = TMODES[_mem.tmode]
+ mem.power = POWER_LEVELS[_mem.power]
+
+ # Extras
+ mem.extra = RadioSettingGroup("extra", "Extra")
+ rev = RadioSetting("rev", "Reverse duplex",
+ RadioSettingValueBoolean(bool(_mem.rev)))
+ rev.set_doc("Reverse duplex")
+ mem.extra.append(rev)
+
+ tx = RadioSetting("tx", "Tx permission",
+ RadioSettingValueBoolean(bool(_mem.tx)))
+ tx.set_doc("Tx permission")
+ mem.extra.append(tx)
+
+ if _skp is not None:
+ mem.skip = (_skp & bit) and "S" or ""
+
+ return mem
+
+ def get_memory(self, number):
+ if not self._mmap:
+ self.sync_in()
+
+ assert(self._mmap)
+
+ if isinstance(number, str):
+ try:
+ number = SPECIAL[number]
+ except KeyError:
+ raise errors.InvalidMemoryLocation("Unknown channel %s" % number)
+
+ return self._get_memory(number)
+
+ def _fill_memory(self, number):
+ _mem = self._memobj.memory[number]
+
+ assert(_mem)
+
+ # zero-fill
+ _mem.freq = 146010000
+ _mem.offset = 146010000
+ _mem.name = str("").ljust(5)
+ _mem.reserved1 = 0x0
+ _mem.rtone = 0x8
+ _mem.reserved2 = 0x0
+ _mem.ctone = 0x8
+ _mem.reserved3 = 0x0
+ _mem.dtcs = 0x0
+ _mem.reserved4 = 0x0
+ _mem.tuning_step = 0x0
+ _mem.reserved5 = 0x0
+ _mem.mode = 0x0
+ _mem.rev = 0x0
+ _mem.duplex = 0x0
+ _mem.reserved6 = 0x0
+ _mem.reserved7 = 0x0
+ _mem.dtcs_polarity = 0x0
+ _mem.tmode = 0x0
+ _mem.tx = 0x1
+ _mem.reserved8 = 0x0
+ _mem.power = 0x0
+ _mem.reserved9 = 0x0
+ _mem.reserved10 = 0x0
+ _mem.reserved11 = 0x0
+ _mem.reserved12 = 0x0
+
+ def _set_memory(self, mem):
+ bit = 1 << (mem.number % 8)
+ byte = int(mem.number / 8)
+
+ _mem = self._memobj.memory[mem.number]
+ _usd = self._memobj.used[byte] if mem.number <= 206 else None
+ _skp = self._memobj.skips[byte] if mem.number < 200 else None
+
+ assert(_mem)
+
+ if mem.empty:
+ self._fill_memory(mem.number)
+ if _usd is not None:
+ _usd |= bit
+ return
+
+ if _usd is None or (_usd & bit):
+ self._fill_memory(mem.number)
+
+ _mem.freq = mem.freq
+ _mem.offset = int(mem.offset)
+ _mem.name = str(mem.name).ljust(5)
+ _mem.rtone = chirp_common.TONES.index(mem.rtone)
+ _mem.ctone = chirp_common.TONES.index(mem.ctone)
+ _mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
+ _mem.tuning_step = TUNING_STEPS.index(mem.tuning_step)
+ _mem.mode = MODES.index(mem.mode)
+ _mem.duplex = DUPLEXES.index(mem.duplex)
+ _mem.dtcs_polarity = DTCS_POLARITY.index(mem.dtcs_polarity)
+ _mem.tmode = TMODES.index(mem.tmode)
+ _mem.power = POWER_LEVELS.index(mem.power)
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ if _usd is not None:
+ _usd &= ~bit
+
+ if _skp is not None:
+ if mem.skip == "S":
+ _skp |= bit
+ else:
+ _skp &= ~bit
+
+ def set_memory(self, mem):
+ if not self._mmap:
+ self.sync_in()
+
+ assert(self._mmap)
+
+ return self._set_memory(mem)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number]) + \
+ repr(self._memobj.flags[(number)])
+
diff --git a/chirp/drivers/icx90.py b/chirp/drivers/icx90.py
new file mode 100644
index 0000000..33294d7
--- /dev/null
+++ b/chirp/drivers/icx90.py
@@ -0,0 +1,926 @@
+# -*- coding: utf-8 -*-
+# Copyright 2018-2020 Jaroslav Škarvada <jskarvad@redhat.com>
+# Based on various code from the CHIRP
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+
+from chirp.drivers import icf
+import struct
+from chirp import chirp_common, bitwise, errors, directory
+from chirp.memmap import MemoryMap
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueInteger, RadioSettingValueList, \
+ RadioSettingValueBoolean, RadioSettingValueString, \
+ RadioSettingValueFloat, InvalidValueError, RadioSettings
+import argparse
+
+ICX90_MEM_FORMAT = """
+struct mem_item {
+ ul24 freq;
+ u8 dtcs_polarity:2,
+ unknown_1:2,
+ offset_freq_mult:1,
+ unknown_2:2,
+ freq_mult:1;
+ u8 unknown_3:1,
+ duplex:2,
+ mode:2,
+ tone_mode:3;
+ ul16 offset_freq;
+ u8 dtcs;
+ u8 tx_tone_lo:4,
+ tune_step:4;
+ u8 rx_tone:6,
+ tx_tone_hi:2;
+ char name[6];
+};
+struct bank_item {
+ u8 invisible_channel:1,
+ prog_skip:1,
+ mem_skip:1,
+ bank_index:5;
+ u8 bank_channel;
+};
+struct tv_mem_item {
+ u8 fixed:7,
+ mode:1;
+ ul24 freq;
+ char name[4];
+};
+
+struct mem_item memory[500];
+struct mem_item scan_edges[50];
+struct bank_item banks[500];
+u8 unknown_4[120];
+struct mem_item vfo_a_band[10];
+struct mem_item vfo_b_band[10];
+struct mem_item call_channels[5];
+struct tv_mem_item tv_memory[68];
+u8 unknown_5[35];
+ul16 mem_channel;
+u8 autodial;
+u8 unknown_6[8];
+u8 unknown_7:6,
+ skip_scan:1,
+ unknown_8:1;
+u8 squelch_level;
+struct {
+ char dtmf_digits[16];
+} dtmf_codes[10];
+u8 tv_channel_skip[68];
+u8 unknown_9[128];
+u8 scan_resume;
+u8 scan_pause;
+u8 unknown_10;
+u8 beep_volume;
+u8 beep;
+u8 backlight;
+u8 busy_led;
+u8 auto_power_off;
+u8 power_save;
+u8 monitor;
+u8 dial_speedup;
+u8 unknown_11;
+u8 auto_repeater;
+u8 dtmf_speed;
+u8 hm_75a_function;
+u8 wx_alert;
+u8 expand_1;
+u8 scan_stop_beep;
+u8 scan_stop_light;
+u8 unknown_12;
+u8 light_position;
+u8 light_color;
+u8 unknown_13;
+u8 band_edge_beep;
+u8 auto_power_on;
+u8 key_lock;
+u8 ptt_lock;
+u8 lcd_contrast;
+u8 opening_message;
+u8 expand_2;
+u8 unknown_14;
+u8 busy_lockout;
+u8 timeout_timer;
+u8 active_band;
+u8 split;
+u8 fm_narrow;
+u8 morse_code_enable;
+u8 morse_code_speed;
+u8 unknown_15[22];
+char opening_message_text[6];
+u8 unknown_16[186];
+u8 unknown_17:4,
+ tune_step:4;
+u8 unknown_18[4];
+u8 band_selected;
+u8 unknown_19[2];
+u8 unknown_20:2,
+ attenuator:1,
+ vfo:1,
+ power:1,
+ dial_select:1,
+ memory_name:1,
+ memory_display:1;
+u8 unknown_21[2];
+u8 mode:4,
+ unknown_22:4;
+u8 unknown_23[9];
+char alpha_tag[6];
+u8 vfo_scan;
+u8 memory_scan;
+u8 unknown_24;
+u8 tv_channel;
+u8 wx_channel;
+char comment[16];
+"""
+
+LOG = logging.getLogger(__name__)
+
+# in bytes
+MEM_ITEM_SIZE = 16
+TV_MEM_ITEM_SIZE = 8
+
+BANK_INDEX = ["A", "B", "C", "D", "E", "F", "G", "H", "J", "L", "N", "O",
+ "P", "Q", "R", "T", "U", "Y"]
+MEM_NUM = 500
+BANKS = 18
+BANK_NUM = 100
+BANK_INDEX_NUM = len(BANK_INDEX)
+DTMF_AUTODIAL_NUM = 10
+DTMF_DIGITS_NUM = 16
+OPENING_MESSAGE_LEN = 6
+COMMENT_LEN = 16
+BANDS=10
+TV_CHANNELS=68
+
+CHARSET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789()*+-,/|= "
+NAME_LENGTH = 6
+TV_NAME_LENGTH = 4
+DUPLEX = ["", "-", "+", ""]
+DTCS_POLARITY = ["NN", "NR", "RN", "RR"]
+TONE_MODE = ["", "Tone", "TSQL", "DTCS"]
+TUNE_STEP = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0, 200.0]
+TUNE_STEP_STR = [str(x) for x in TUNE_STEP]
+MODE = ["FM", "WFM", "AM"]
+TV_MODE = ["WFM", "AM"]
+
+SQUELCH_LEVEL = ["Open", "Auto", "Level 1", "Level 2", "Level 3", "Level 4", "Level 5",
+ "Level 6", "Level 7", "Level 8", "Level 9"]
+AUTODIAL = ["Tone call", "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9"]
+DTMF_SPEED = ["100 ms", "200 ms", "300 ms", "400 ms"]
+SCAN_RESUME = ["0 s", "1 s", "2 s", "3 s", "4 s", "5 s", "Hold"]
+SCAN_PAUSE = ["2 s", "4 s", "6 s", "8 s", "10 s", "12 s", "14 s", "16 s", "18 s", "20 s", "Hold"]
+BEEP_VOLUME = ["Volume", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
+ "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25",
+ "26", "27", "28", "29", "30", "31"]
+BACKLIGHT = ["Off", "On", "Auto"]
+AUTO_POWER_OFF = ["Off", "30 min", "60 min", "90 min", "120 min"]
+POWER_SAVE = ["Off", "1:1", "1:4", "1:8", "1:16", "Auto"]
+MONITOR = ["Push", "Hold"]
+AUTO_REPEATER = ["Off", "Duplex only", "Duplex & tone"]
+HM_75A_FUNCTION = ["Simple", "Normal 1", "Normal 2"]
+LIGHT_POSITION = ["LCD", "Key", "All"]
+LIGHT_COLOR = ["Green", "Orange", "Red"]
+AUTO_POWER_ON = ["Off", "00:30", "01:00", "01:30", "02:00", "02:30", "03:00", "03:30", "04:00",
+ "04:30", "05:00", "05:30", "06:00", "06:30", "07:00", "07:30", "08:00",
+ "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00",
+ "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00",
+ "16:30", "17:00", "17:30", "18:00", "18:30", "19:00", "19:30", "20:00",
+ "20:30", "21:00", "21:30", "22:00", "22:30", "23:00", "23:30", "24:00"]
+KEY_LOCK = ["Normal", "No squelch", "No volume", "All"]
+LCD_CONTRAST = ["1", "2", "3", "4"]
+TIMEOUT_TIMER = ["Off", "1 min", "3 min", "5 min", "10 min"]
+ACTIVE_BAND = ["All", "Single"]
+MORSE_CODE_SPEED = ["10 WPM", "15 WPM", "20 WPM", "25 WPM"]
+WX_CHANNEL = ["WX01", "WX02", "WX03", "WX04", "WX05", "WX06", "WX07", "WX08", "WX09", "WX10"]
+MEMORY_DISPLAY = ["Channel", "Bank"]
+DIAL_SELECT = ["Normal", "Volume"]
+POWER = ["High", "Low"]
+VFO = ["A", "B"]
+OPERATION_MODE = ["VFO", "Memory", "Call channel", "TV"]
+VFO_SCAN = ["All", "Band", "P0", "P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8",
+ "P9", "P10", "P11", "P12", "P13", "P14", "P15", "P16", "P17", "P18",
+ "P19", "P20", "P21", "P22", "P23", "P24"]
+MEMORY_SCAN = ["All", "Bank", "Sel BC", "Sel 5 MHz", "Sel 50 MHz", "Sel WFM", "Sel Air",
+ "Sel 144 MHz", "Sel 220 MHz", "Sel 300 MHz", "Sel 440 MHz", "Sel 800 MHz"]
+
+class ICx90BankModel(icf.IcomIndexedBankModel):
+ bank_index = BANK_INDEX
+
+ def get_mappings(self):
+ banks = []
+
+ if (self._radio._num_banks != len(type(self).bank_index)):
+ raise Exception("Invalid number of banks %d, supported only %d banks" %
+ (self._radio._num_banks, len(type(self).bank_index)))
+
+ for i in range(0, self._radio._num_banks):
+ index = type(self).bank_index[i]
+ bank = self._radio._bank_class(self, index, "BANK-%s" % index)
+ bank.index = i
+ banks.append(bank)
+
+ return banks
+
+class ICT90_Alias(chirp_common.Alias):
+ VENDOR = "Icom"
+ MODEL = "IC-T90"
+
+@directory.register
+class ICx90Radio(icf.IcomCloneModeRadio):
+ """Icom IC-E/T90"""
+ VENDOR = "Icom"
+ MODEL = "IC-E90"
+ # read clone response after each clone frame is sent
+ MUNCH_CLONE_RESP = True
+
+ ALIASES = [ICT90_Alias]
+
+ _model = "\x25\x07\x00\x01"
+ _memsize = 0x2d40
+ _endframe = "Icom Inc."
+
+ _ranges = [(0x0000, 0x2d40, 32)]
+ _num_banks = BANKS
+ _bank_index_bounds = (0, BANK_NUM - 1)
+ _can_hispeed = False
+
+ def __init__(self, pipe):
+ icf.IcomCloneModeRadio.__init__(self, pipe)
+
+ def special_add(self, key, item_type, num, unique_idx):
+ item = {}
+ item["item_type"] = item_type
+ item["num"] = num
+ item["uidx"] = unique_idx
+ self.special[key] = item
+
+ def init_special(self):
+ self.special = {}
+ i = 0
+ # program scan edges
+ for x in range(25):
+ self.special_add("Scan edge: %02dA" % x, "scan_edge", x * 2, i)
+ self.special_add("Scan edge: %02dB" % x, "scan_edge", x * 2 + 1, i + 1)
+ i += 2
+ # call channels
+ for x in range(5):
+ self.special_add("Call ch: %d" % x, "call_chan", x, i)
+ i += 1
+ # VFO A
+ for x in range(10):
+ self.special_add("VFO A: %d" % x, "vfo_a", x, i)
+ i += 1
+ # VFO B
+ for x in range(10):
+ self.special_add("VFO B: %d" % x, "vfo_b", x, i)
+ i += 1
+
+ def get_sub_devices(self):
+ return [ICx90Radio_ham(self._mmap), ICx90Radio_tv(self._mmap)]
+
+ def clear_bank(self, loc):
+ # it seems that empty invisible channel which isn't in bank is defined in bank_item by bytes 0x9f 0x00,
+ # i.e. it has invisible_channel == 1
+ # it seems that non-empty visible channel which isn't in bank is defined in bank_item by bytes 0x1f 0x00,
+ # i.e. it has invisible_channel == 0
+ # so do not touch the invisible_channel (the bit 7 of the first byte) here and only
+ # set the rest of the bits
+ self.memobj.banks[loc].bank_index = 0x1f
+ self.memobj.banks[loc].prog_skip = 0
+ self.memobj.banks[loc].mem_skip = 0
+ self.memobj.banks[loc].bank_channel = 0
+
+ # it seems the bank driver has different terminology about bank number and index
+ # so in fact _get_bank and _set_bank are about indexes (i.e index in the array
+ # of bank names - A .. Y
+ # and _get_bank_index and _set_bank_index are about positions in the bank (0..99)
+ def _get_bank(self, loc):
+ i = self.memobj.banks[loc].bank_index
+ return i if i < BANK_INDEX_NUM else None
+
+ def _set_bank(self, loc, bank):
+ if bank is None:
+ self.clear_bank(loc)
+ else:
+ self.memobj.banks[loc].bank_index = bank
+ # it seems if invisible_channel == 1 the channel is invisible (deleted)
+ # so set it explicitly as visible
+ self.memobj.banks[loc].invisible_channel = 0
+
+ def _get_bank_index(self, loc):
+ i = self.memobj.banks[loc].bank_channel
+ return i if i < BANK_NUM else None
+
+ def _set_bank_index(self, loc, index):
+ self.memobj.banks[loc].bank_channel = index
+
+ def get_features(self):
+ self.init_special()
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_name = True
+ rf.has_bank = True
+ rf.has_bank_index = True
+ rf.has_bank_names = False
+ rf.can_delete = True
+ rf.has_ctone = True
+ rf.has_dtcs = True
+ rf.has_dtcs_polarity = True
+ rf.has_tuning_step = True
+ rf.has_comment = False
+ rf.memory_bounds = (0, MEM_NUM - 1)
+ rf.has_sub_devices = True
+ rf.valid_characters = CHARSET
+ rf.valid_modes = list(MODE)
+ rf.valid_tmodes = list(TONE_MODE)
+ rf.valid_duplexes = list(DUPLEX)[:-1]
+ rf.valid_tuning_steps = list(TUNE_STEP)
+ rf.valid_bands = [(495000, 999990000)]
+ rf.valid_skips = ["", "S", "P"]
+ rf.valid_name_length = NAME_LENGTH
+ rf.valid_special_chans = sorted(self.special.keys())
+
+ return rf
+
+ def map_dtmf_chirp2icom(self, item):
+ item = str(item).upper()
+ if item == "*":
+ item = "E"
+ elif item == "#":
+ item = "F"
+ elif item == " ":
+ return 0xff
+ try:
+ ret = int(item, 16)
+ except ValueError:
+ raise errors.InvalidDataError("invalid DTMF number '%s'" % item)
+ return ret
+
+ def dtmf_chirp2icom(self, dtmf):
+ return "".join(map(self.map_dtmf_chirp2icom, str(dtmf).rjust(DTMF_DIGITS_NUM)))
+
+ def map_dtmf_icom2chirp(self, item):
+ item = ord(item)
+ if item == 0xff:
+ return " "
+ else:
+ item &= 0x0f
+ if item < 10:
+ return str(item)
+ else:
+ return ["A", "B", "C", "D", "*", "#"][item - 10]
+
+ def dtmf_icom2chirp(self, dtmf):
+ return "".join(map(self.map_dtmf_icom2chirp, str(dtmf)))
+
+ def apply_dtmf_autodial(self, setting, obj):
+ obj = self.dtmf_chirp2icom(setting.value)
+
+ def get_settings(self):
+ try:
+ _squelch = 1
+ basic = RadioSettingGroup("basic", "Basic")
+ expand_1 = RadioSettingGroup("expand_1", "Expand 1")
+ expand_2 = RadioSettingGroup("expand_2", "Expand 2")
+ dtmf_autodial = RadioSettingGroup("dtmf_autodial", "DTMF autodial")
+ group = RadioSettings(basic, expand_1, expand_2, dtmf_autodial)
+
+ # basic
+ basic.append(RadioSetting("mem_channel", "Current memory channel",
+ RadioSettingValueInteger(0, MEM_NUM - 1, self.memobj.mem_channel)))
+ basic.append(RadioSetting("squelch_level", "Squelch level",
+ RadioSettingValueList(SQUELCH_LEVEL,
+ SQUELCH_LEVEL[self.memobj.squelch_level])))
+ basic.append(RadioSetting("scan_resume", "Scan resume",
+ RadioSettingValueList(SCAN_RESUME,
+ SCAN_RESUME[self.memobj.scan_resume])))
+ basic.append(RadioSetting("scan_pause", "Scan pause",
+ RadioSettingValueList(SCAN_PAUSE,
+ SCAN_PAUSE[self.memobj.scan_pause])))
+ basic.append(RadioSetting("beep_volume", "Beep audio",
+ RadioSettingValueList(BEEP_VOLUME,
+ BEEP_VOLUME[self.memobj.beep_volume])))
+ basic.append(RadioSetting("beep", "Operation beep",
+ RadioSettingValueBoolean(self.memobj.beep)))
+ basic.append(RadioSetting("backlight", "LCD backlight",
+ RadioSettingValueList(BACKLIGHT,
+ BACKLIGHT[self.memobj.backlight])))
+ basic.append(RadioSetting("busy_led", "Busy LED",
+ RadioSettingValueBoolean(self.memobj.busy_led)))
+ basic.append(RadioSetting("auto_power_off", "Auto power off",
+ RadioSettingValueList(AUTO_POWER_OFF,
+ AUTO_POWER_OFF[self.memobj.auto_power_off])))
+ basic.append(RadioSetting("power_save", "Power save",
+ RadioSettingValueList(POWER_SAVE,
+ POWER_SAVE[self.memobj.power_save])))
+ basic.append(RadioSetting("monitor", "Monitor",
+ RadioSettingValueList(MONITOR,
+ MONITOR[self.memobj.monitor])))
+ basic.append(RadioSetting("dial_speedup", "Dial speedup",
+ RadioSettingValueBoolean(self.memobj.dial_speedup)))
+ basic.append(RadioSetting("auto_repeater", "Auto repeater",
+ RadioSettingValueList(AUTO_REPEATER,
+ AUTO_REPEATER[self.memobj.auto_repeater])))
+ basic.append(RadioSetting("hm_75a_function", "HM-75A function",
+ RadioSettingValueList(HM_75A_FUNCTION,
+ HM_75A_FUNCTION[self.memobj.hm_75a_function])))
+ basic.append(RadioSetting("wx_alert", "WX alert",
+ RadioSettingValueBoolean(self.memobj.wx_alert)))
+ basic.append(RadioSetting("wx_channel", "Current WX channel",
+ RadioSettingValueList(WX_CHANNEL,
+ WX_CHANNEL[self.memobj.wx_channel])))
+ basic.append(RadioSetting("comment", "Comment",
+ RadioSettingValueString(0, COMMENT_LEN,
+ str(self.memobj.comment),
+ autopad = True)))
+ basic.append(RadioSetting("tune_step", "Current tune step",
+ RadioSettingValueList(TUNE_STEP_STR,
+ TUNE_STEP_STR[self.memobj.tune_step])))
+ basic.append(RadioSetting("band_selected", "Selected band",
+ RadioSettingValueInteger(0, BANDS - 1, self.memobj.band_selected)))
+ basic.append(RadioSetting("memory_display", "Memory display",
+ RadioSettingValueList(MEMORY_DISPLAY,
+ MEMORY_DISPLAY[self.memobj.memory_display])))
+ basic.append(RadioSetting("memory_name", "Memory name",
+ RadioSettingValueBoolean(self.memobj.memory_name)))
+ basic.append(RadioSetting("dial_select", "Dial select",
+ RadioSettingValueList(DIAL_SELECT,
+ DIAL_SELECT[self.memobj.dial_select])))
+ basic.append(RadioSetting("power", "RF power",
+ RadioSettingValueList(POWER,
+ POWER[self.memobj.power])))
+ basic.append(RadioSetting("vfo", "Current VFO",
+ RadioSettingValueList(VFO,
+ VFO[self.memobj.vfo])))
+ basic.append(RadioSetting("attenuator", "RF attenuator",
+ RadioSettingValueBoolean(self.memobj.attenuator)))
+ basic.append(RadioSetting("skip_scan", "Skip scan",
+ RadioSettingValueBoolean(self.memobj.skip_scan)))
+# TODO: this needs to be reverse engineered, because the following commented
+# code does not seem correct
+# basic.append(RadioSetting("mode", "Current mode",
+# RadioSettingValueList(OPERATION_MODE,
+# OPERATION_MODE[self.memobj.mode])))
+ basic.append(RadioSetting("vfo_scan", "VFO scan",
+ RadioSettingValueList(VFO_SCAN,
+ VFO_SCAN[self.memobj.vfo_scan])))
+ basic.append(RadioSetting("memory_scan", "Memory scan",
+ RadioSettingValueList(MEMORY_SCAN,
+ MEMORY_SCAN[self.memobj.memory_scan])))
+ basic.append(RadioSetting("tv_channel", "Current TV channel",
+ RadioSettingValueInteger(0, TV_CHANNELS - 1, self.memobj.tv_channel)))
+
+ # DTMF auto dial
+ dtmf_autodial.append(RadioSetting("autodial", "Autodial",
+ RadioSettingValueList(AUTODIAL,
+ AUTODIAL[self.memobj.autodial])))
+ dtmf_autodial.append(RadioSetting("dtmf_speed", "Speed",
+ RadioSettingValueList(DTMF_SPEED,
+ DTMF_SPEED[self.memobj.dtmf_speed])))
+ for x in range(DTMF_AUTODIAL_NUM):
+ rs = RadioSetting("dtmf_codes[%d].dtmf_digits" % x, "DTMF autodial: %d" % x,
+ RadioSettingValueString(0, DTMF_DIGITS_NUM,
+ self.dtmf_icom2chirp(self.memobj.dtmf_codes[x].dtmf_digits),
+ autopad = True, charset = "0123456789ABCD*#abcd "))
+ rs.set_apply_callback(self.apply_dtmf_autodial, self.memobj.dtmf_codes[x].dtmf_digits)
+ dtmf_autodial.append(rs)
+
+ # expand 1
+ expand_1.append(RadioSetting("expand_1", "Expand 1",
+ RadioSettingValueBoolean(self.memobj.expand_1)))
+ expand_1.append(RadioSetting("scan_stop_beep", "Scan stop beep",
+ RadioSettingValueBoolean(self.memobj.scan_stop_beep)))
+ expand_1.append(RadioSetting("scan_stop_light", "Scan stop light",
+ RadioSettingValueBoolean(self.memobj.scan_stop_light)))
+ expand_1.append(RadioSetting("light_postion", "Light position",
+ RadioSettingValueList(LIGHT_POSITION,
+ LIGHT_POSITION[self.memobj.light_position])))
+ expand_1.append(RadioSetting("light_color", "Light color",
+ RadioSettingValueList(LIGHT_COLOR,
+ LIGHT_COLOR[self.memobj.light_color])))
+ expand_1.append(RadioSetting("band_edge_beep", "Band edge beep",
+ RadioSettingValueBoolean(self.memobj.band_edge_beep)))
+ expand_1.append(RadioSetting("auto_power_on", "Auto power on",
+ RadioSettingValueList(AUTO_POWER_ON,
+ AUTO_POWER_ON[self.memobj.auto_power_on])))
+ expand_1.append(RadioSetting("key_lock", "Key lock",
+ RadioSettingValueList(KEY_LOCK,
+ KEY_LOCK[self.memobj.key_lock])))
+ expand_1.append(RadioSetting("ptt_lock", "PTT lock",
+ RadioSettingValueBoolean(self.memobj.ptt_lock)))
+ expand_1.append(RadioSetting("lcd_contrast", "LCD contrast",
+ RadioSettingValueList(LCD_CONTRAST,
+ LCD_CONTRAST[self.memobj.lcd_contrast])))
+ expand_1.append(RadioSetting("opening_message", "Opening message",
+ RadioSettingValueBoolean(self.memobj.opening_message)))
+ expand_1.append(RadioSetting("opening_message_text", "Opening message",
+ RadioSettingValueString(0, OPENING_MESSAGE_LEN,
+ str(self.memobj.opening_message_text),
+ autopad = True, charset = CHARSET)))
+
+ # expand 2
+ expand_2.append(RadioSetting("expand_2", "Expand 2",
+ RadioSettingValueBoolean(self.memobj.expand_2)))
+ expand_2.append(RadioSetting("busy_lockout", "Busy lock out",
+ RadioSettingValueBoolean(self.memobj.busy_lockout)))
+ expand_2.append(RadioSetting("timeout_timer", "Timeout timer",
+ RadioSettingValueList(TIMEOUT_TIMER,
+ TIMEOUT_TIMER[self.memobj.timeout_timer])))
+ expand_2.append(RadioSetting("active_band", "Active band",
+ RadioSettingValueList(ACTIVE_BAND,
+ ACTIVE_BAND[self.memobj.active_band])))
+ expand_2.append(RadioSetting("fm_narrow", "FM narrow",
+ RadioSettingValueBoolean(self.memobj.fm_narrow)))
+ expand_2.append(RadioSetting("split", "Split",
+ RadioSettingValueBoolean(self.memobj.split)))
+ expand_2.append(RadioSetting("morse_code_enable", "Morse code synthesizer",
+ RadioSettingValueBoolean(self.memobj.morse_code_enable)))
+ expand_2.append(RadioSetting("morse_code_speed", "Morse code speed",
+ RadioSettingValueList(MORSE_CODE_SPEED,
+ MORSE_CODE_SPEED[self.memobj.morse_code_speed])))
+
+ return group
+ except:
+ import traceback
+ LOG.error("Failed to parse settings: %s", traceback.format_exc())
+ return None
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ if not element.changed():
+ continue
+ try:
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ try:
+ element.run_apply_callback()
+ except NotImplementedError as e:
+ LOG.error("icx90: %s", e)
+ continue
+
+ # Find the object containing setting.
+ obj = self.memobj
+ bits = element.get_name().split(".")
+ setting = bits[-1]
+ for name in bits[:-1]:
+ if name.endswith("]"):
+ name, index = name.split("[")
+ index = int(index[:-1])
+ obj = getattr(obj, name)[index]
+ else:
+ obj = getattr(obj, name)
+
+ try:
+ old_val = getattr(obj, setting)
+ LOG.debug("Setting %s(%r) <= %s" % (
+ element.get_name(), old_val, element.value))
+ setattr(obj, setting, element.value)
+ except AttributeError as e:
+ LOG.error("Setting %s is not in the memory map: %s" %
+ (element.get_name(), e))
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ def process_mmap(self):
+ self.memobj = bitwise.parse(ICX90_MEM_FORMAT, self._mmap)
+
+ def get_raw_memory(self, number):
+ (mem_item, special, unique_idx) = self.get_mem_item(number)
+ return repr(mem_item)
+
+ def sync_in(self):
+ icf.IcomCloneModeRadio.sync_in(self)
+ self.process_mmap()
+
+ def sync_out(self):
+ icf.IcomCloneModeRadio.sync_out(self)
+
+ def freq_chirp2icom(self, freq):
+ if chirp_common.is_fractional_step(freq):
+ mult = 6250
+ multr = 1
+ else:
+ mult = 5000
+ multr = 0
+
+ return (freq / mult, multr)
+
+ def freq_icom2chirp(self, freq, mult):
+ return freq * (6250 if mult else 5000)
+
+ def get_skip(self, number):
+ bank_item = self.memobj.banks[number]
+ if bank_item.prog_skip:
+ return "P"
+ elif bank_item.mem_skip:
+ return "S"
+ return ""
+
+ def set_skip(self, number, skip):
+ bank_item = self.memobj.banks[number]
+ if skip == "P":
+ bank_item.prog_skip = 1
+ bank_item.mem_skip = 1
+ elif skip == "S":
+ bank_item.prog_skip = 0
+ bank_item.mem_skip = 1
+ elif skip == "":
+ bank_item.prog_skip = 0
+ bank_item.mem_skip = 0
+ else:
+ raise errors.InvalidDataError("skip '%s' not supported" % skip)
+
+ # returns (memobj.mem_item, is_special_channel, unique_idx)
+ def get_mem_item(self, number):
+ try:
+ item_type = self.special[number]["item_type"]
+ num = self.special[number]["num"]
+ unique_idx = self.special[number]["uidx"]
+ if item_type == "scan_edge":
+ return (self.memobj.scan_edges[num], True, unique_idx)
+ elif item_type == "call_chan":
+ return (self.memobj.call_channels[num], True, unique_idx)
+ elif item_type == "vfo_a":
+ return (self.memobj.vfo_a_band[num], True, unique_idx)
+ elif item_type == "vfo_b":
+ return (self.memobj.vfo_b_band[num], True, unique_idx)
+ else:
+ raise errors.InvalidDataError("unknown special channel type '%s'" % item_type)
+ except KeyError:
+ return (self.memobj.memory[number], False, number)
+
+ def get_raw_memory(self, number):
+ (mem_item, special, unique_idx) = self.get_mem_item(number)
+ return repr(mem_item)
+
+ def get_memory(self, number):
+ mem = chirp_common.Memory()
+
+ (mem_item, special, unique_idx) = self.get_mem_item(number)
+
+ freq = self.freq_icom2chirp(mem_item.freq, mem_item.freq_mult)
+ if freq == 0:
+ mem.empty = True
+ else:
+ mem.empty = False
+ mem.freq = freq
+ if special:
+ mem.name = " " * NAME_LENGTH
+ else:
+ mem.name = str(mem_item.name).rstrip("\x00 ")
+ mem.rtone = chirp_common.TONES[(mem_item.tx_tone_hi << 4) + mem_item.tx_tone_lo]
+ mem.ctone = chirp_common.TONES[mem_item.rx_tone]
+ mem.dtcs = chirp_common.DTCS_CODES[mem_item.dtcs]
+ mem.dtcs_polarity = DTCS_POLARITY[mem_item.dtcs_polarity]
+ mem.offset = self.freq_icom2chirp(mem_item.offset_freq, mem_item.offset_freq_mult)
+ mem.duplex = DUPLEX[mem_item.duplex]
+ mem.tmode = TONE_MODE[mem_item.tone_mode]
+ mem.tuning_step = TUNE_STEP[mem_item.tune_step]
+ mem.mode = MODE[mem_item.mode]
+ if not special:
+ mem.skip = self.get_skip(number)
+ if special:
+ mem.extd_number = number
+ mem.number = -len(self.special) + unique_idx
+ else:
+ mem.number = number
+
+ return mem
+
+ def set_memory(self, memory):
+ (mem_item, special, unique_idx) = self.get_mem_item(memory.number)
+ if memory.empty:
+ mem_item.set_raw("\x00" * MEM_ITEM_SIZE)
+ self.clear_bank(memory.number)
+ self.memobj.banks[memory.number].invisible_channel = 1
+ else:
+ (mem_item.freq, mem_item.freq_mult) = self.freq_chirp2icom(memory.freq)
+ if special:
+ mem_item.name = " " * NAME_LENGTH
+ else:
+ self.memobj.banks[memory.number].invisible_channel = 0
+
+ for x in range(NAME_LENGTH):
+ try:
+ mem_item.name[x] = str(memory.name[x])
+ except IndexError:
+ mem_item.name[x] = " "
+ mem_item.tx_tone_hi = chirp_common.TONES.index(memory.rtone) >> 4
+ mem_item.tx_tone_lo = chirp_common.TONES.index(memory.rtone) & 0x0f
+ mem_item.rx_tone = chirp_common.TONES.index(memory.ctone)
+ mem_item.dtcs = chirp_common.DTCS_CODES.index(memory.dtcs)
+ mem_item.dtcs_polarity = DTCS_POLARITY.index(memory.dtcs_polarity)
+ (mem_item.offset_freq, mem_item.offset_freq_mult) = self.freq_chirp2icom(memory.offset)
+ mem_item.duplex = DUPLEX.index(memory.duplex)
+ mem_item.tone_mode = TONE_MODE.index(memory.tmode)
+ mem_item.tune_step = TUNE_STEP.index(memory.tuning_step)
+ mem_item.mode = MODE.index(memory.mode)
+ if not special:
+ self.set_skip(memory.number, memory.skip)
+
+ def get_bank_model(self):
+ return ICx90BankModel(self)
+
+class ICx90Radio_ham(ICx90Radio):
+
+ def get_features(self):
+ rf = ICx90Radio.get_features(self)
+ rf.has_sub_devices = False
+
+ return rf
+
+class ICx90Radio_tv(ICx90Radio):
+ VARIANT = "TV"
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_name = True
+ rf.has_bank = False
+ rf.has_bank_index = False
+ rf.has_bank_names = False
+ rf.can_delete = True
+ rf.has_ctone = False
+ rf.has_dtcs = False
+ rf.has_dtcs_polarity = False
+ rf.has_tuning_step = False
+ rf.has_comment = False
+ rf.has_sub_devices = False
+ rf.memory_bounds = (0, TV_CHANNELS - 1)
+ rf.valid_characters = CHARSET
+ rf.valid_modes = list(TV_MODE)
+ rf.valid_tmodes = []
+ rf.valid_duplexes = [""]
+ rf.valid_tuning_steps = []
+ rf.valid_bands = [(46750000, 957750000)]
+ rf.valid_skips = ["", "S"]
+ rf.valid_name_length = TV_NAME_LENGTH
+ rf.valid_special_chans = []
+
+ return rf
+
+ def get_bank_model(self):
+ return None
+
+ def freq_chirp2icom(self, freq):
+ return freq / 5000
+
+ def freq_icom2chirp(self, freq):
+ return freq * 5000
+
+ def get_skip(self, number):
+ if self.memobj.tv_channel_skip[number] == 2:
+ return "S"
+ return ""
+
+ def set_skip(self, number, skip):
+ if skip == "S":
+ self.memobj.tv_channel_skip[number] = 2
+ elif skip == "":
+ self.memobj.tv_channel_skip[number] = 0
+ else:
+ raise errors.InvalidDataError("skip '%s' not supported" % skip)
+
+ def get_raw_memory(self, number):
+ return repr(self.memobj.tv_memory[number])
+
+ def get_memory(self, number):
+ mem = chirp_common.Memory()
+
+ mem_item = self.memobj.tv_memory[number]
+
+ mem.freq = self.freq_icom2chirp(mem_item.freq)
+ if self.memobj.tv_channel_skip[number] == 1:
+ mem.empty = True
+ mem.mode = TV_MODE[0]
+ else:
+ mem.empty = False
+ mem.name = str(mem_item.name).rstrip("\x00 ")
+ mem.mode = TV_MODE[mem_item.mode]
+ mem.skip = self.get_skip(number)
+ mem.number = number
+
+ return mem
+
+ def set_memory(self, memory):
+ mem_item = self.memobj.tv_memory[memory.number]
+ if memory.empty:
+ self.memobj.tv_channel_skip[memory.number] = 1
+ mem_item.set_raw("\x00" * TV_MEM_ITEM_SIZE)
+ else:
+ mem_item.freq = self.freq_chirp2icom(memory.freq)
+ for x in range(TV_NAME_LENGTH):
+ try:
+ mem_item.name[x] = str(memory.name[x])
+ except IndexError:
+ mem_item.name[x] = " "
+
+ mem_item.mode = TV_MODE.index(memory.mode)
+ self.set_skip(memory.number, memory.skip)
+
+def dump_banks(icx90, template_file):
+ mb = icx90.get_features().memory_bounds
+ with open(template_file, "w") as f:
+ for mi in range(mb[0], mb[1] + 1):
+ mem = icx90.get_memory(mi)
+ bank = icx90._get_bank(mi)
+ if bank is not None:
+ bank = BANK_INDEX[bank]
+ bank_pos = icx90._get_bank_index(mi)
+ if not mem.empty and bank is not None and bank_pos is not None:
+ f.write("%s;%s;%d\n" % (mem.name, bank, bank_pos))
+
+def read_template_file(template_file):
+ banks_templ = {}
+ with open(template_file, "r") as f:
+ for line in f:
+ l = line.split(";")
+ l[1] = BANK_INDEX.index(l[1])
+ banks_templ[l[0]] = l[1:]
+ return banks_templ
+
+def reorder_banks(icx90, preserve_position, preserve_unknown, banks_templ):
+ banks_cnt = []
+ mb = icx90.get_features().memory_bounds
+ for i in range(0, BANKS):
+ banks_cnt.append(0)
+ for mi in range(mb[0], mb[1] + 1):
+ mem = icx90.get_memory(mi)
+ if preserve_unknown:
+ bank = icx90._get_bank(mi)
+ bank_pos = icx90._get_bank_index(mi)
+ else:
+ bank = None
+ bank_pos = 0
+ if not mem.empty:
+ if mem.name in banks_templ:
+ bank = int(banks_templ[mem.name][0])
+ if preserve_position:
+ bank_pos = int(banks_templ[mem.name][1])
+ else:
+ bank_pos = banks_cnt[bank]
+ banks_cnt[bank] += 1
+ print("%s\t-> %s, %02d" % (mem.name, BANK_INDEX[bank], bank_pos))
+ # explicitly set non empty channel as visible
+ icx90.memobj.banks[mi].invisible_channel = 0
+ if bank >= BANKS or bank_pos >= BANK_NUM:
+ bank = None
+ bank_pos = 0
+ icx90._set_bank(mi, bank)
+ icx90._set_bank_index(mi, bank_pos)
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description="Icom IC-E90 banks handling helper.")
+ parser.add_argument("icx90_img_file", help="IC-X90 IMG file.")
+ parser.add_argument("template_file", help="Banks template file.")
+ parser.add_argument("-r", "--read-banks", action="store_true",
+ help="Read banks content and store it to template file.")
+ parser.add_argument("-f", "--fix-banks", action="store_true",
+ help="Fix banks content, reorder channels in banks according to the provided template file and write it to IMG file.")
+ parser.add_argument("-p", "--preserve-position", action="store_true",
+ help="Preserve bank position as in the template file if possible, otherwise put channels to banks according their position in the memory.")
+ parser.add_argument("-u", "--preserve-unknown", action="store_true",
+ help="Preserve channels in banks if they aren't in the template file and don't conflicts with the template file, otherwise remove them from the banks.")
+ parser.add_argument("-b", "--backup_img", action="store_true",
+ help="Backup IMG file before changing it.")
+
+ args = vars(parser.parse_args())
+
+ options_ok = True
+ try:
+ icx90_img_file = str(args.pop("icx90_img_file"))
+ template_file = str(args.pop("template_file"))
+ except KeyError:
+ options_ok = False
+
+ if options_ok and (args["read_banks"] or args["fix_banks"]):
+ icx90 = ICx90Radio(icx90_img_file)
+ if args["read_banks"]:
+ dump_banks(icx90, template_file)
+ elif args["fix_banks"]:
+ banks_templ = read_template_file(template_file)
+ if args["backup_img"]:
+ icx90.save_mmap(icx90_img_file + ".bak")
+ reorder_banks(icx90, args["preserve_position"], args["preserve_unknown"], banks_templ)
+ icx90.save_mmap(icx90_img_file)
+ else:
+ parser.print_help()
diff --git a/chirp/drivers/id51plus.py b/chirp/drivers/id51plus.py
index fc4812f..b88aaa6 100644
--- a/chirp/drivers/id51plus.py
+++ b/chirp/drivers/id51plus.py
@@ -160,7 +160,7 @@ class ID51PLUSRadio(id31.ID31Radio):
def get_repeater_call_list(self):
calls = []
- # Unlike previos DStar radios, there is not a seperate repeater
+ # Unlike previous DStar radios, there is not a separate repeater
# callsign list. It's only the DV Memory banks.
for repeater in self._memobj.repeaters:
call = id31._decode_call(repeater.call)
diff --git a/chirp/drivers/id880.py b/chirp/drivers/id880.py
index 19c2c00..5fd6079 100644
--- a/chirp/drivers/id880.py
+++ b/chirp/drivers/id880.py
@@ -112,7 +112,7 @@ def decode_call(sevenbytes):
# places for the next round
rem = (byte & mask) << 7 - i
- # After seven trips gathering overflow bits, we chould have seven
+ # After seven trips gathering overflow bits, we should have seven
# left, which is the final character
call += chr(rem)
@@ -374,7 +374,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
# This is a horrid hack, given that people can change the GPS-A
# destination, but it should suffice in most cases until we get
# a rich container file format
- return len(filedata) == cls._memsize and "API880," in filedata
+ return len(filedata) == cls._memsize and b"API880," in filedata
# This radio isn't really supported yet and detects as a conflict with
@@ -391,4 +391,4 @@ class ID80Radio(ID880Radio):
# This is a horrid hack, given that people can change the GPS-A
# destination, but it should suffice in most cases until we get
# a rich container file format
- return len(filedata) == cls._memsize and "API80," in filedata
+ return len(filedata) == cls._memsize and b"API80," in filedata
diff --git a/chirp/drivers/iradio_uv-5118.py b/chirp/drivers/iradio_uv-5118.py
new file mode 100644
index 0000000..68b90f3
--- /dev/null
+++ b/chirp/drivers/iradio_uv-5118.py
@@ -0,0 +1,1119 @@
+# Copyright 2022 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import os
+import struct
+import re
+import logging
+
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueInteger, RadioSettingValueList, \
+ RadioSettingValueBoolean, RadioSettingValueString, \
+ RadioSettingValueFloat, RadioSettings
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+struct memory {
+ ul32 rxfreq; // 00-03
+ ul16 rx_tone; // PL/DPL Decode // 04-05
+ ul32 txfreq; // 06-09
+ ul16 tx_tone; // PL/DPL Encode // 0a-0b
+ u8 lowpower:1, // Power Level // 0c
+ isnarrow:1, // Bandwidth
+ unknown1:1,
+ unknown2:3,
+ bcl:1, // Busy Channel Lockout
+ scan:1; // Scan Add
+ u8 unknown3[3]; // 0d-0f
+};
+
+#seekto 0x0050;
+struct memory channels[128];
+
+#seekto 0x0010;
+struct {
+ u8 range174_180; // 174-180 MHz
+ u8 range180_190; // 180-190 MHz
+ u8 range190_200; // 190-200 MHz
+ u8 range200_210; // 200-210 MHz
+ u8 range210_220; // 210-220 MHz
+ u8 range220_230; // 220-230 MHz
+ u8 range230_240; // 230-240 MHz
+ u8 range240_250; // 240-250 MHz
+ u8 range250_260; // 240-250 MHz
+ u8 range260_270; // 260-270 MHz
+ u8 range270_280; // 270-280 MHz
+ u8 range280_290; // 280-290 MHz
+ u8 range290_300; // 290-300 MHz
+ u8 range300_310; // 300-310 MHz
+ u8 range310_320; // 310-320 MHz
+ u8 range320_330; // 320-330 MHz
+ u8 range330_340; // 330-340 MHz
+ u8 range340_350; // 340-350 MHz
+ u8 range350_360; // 350-360 MHz
+ u8 range360_370; // 360-370 MHz
+ u8 range370_380; // 370-380 MHz
+ u8 range380_390; // 380-390 MHz
+ u8 range390_400; // 290-400 MHz
+ u8 range520_530; // 520-530 MHz
+ u8 range530_540; // 530-540 MHz
+ u8 range540_550; // 540-550 MHz
+ u8 range550_560; // 550-560 MHz
+ u8 range560_570; // 560-570 MHz
+ u8 range570_580; // 570-580 MHz
+ u8 range580_590; // 580-590 MHz
+ u8 range590_600; // 590-600 MHz
+ u8 range600_610; // 600-610 MHz
+ u8 range610_620; // 610-620 MHz
+ u8 range620_630; // 620-630 MHz
+ u8 range630_640; // 630-640 MHz
+ u8 range640_650; // 640-650 MHz
+ u8 range650_660; // 650-660 MHz
+} txallow;
+
+#seekto 0x0039;
+struct {
+ u8 display_timer; // 0x0039 Display Timer
+ u8 led_timer; // 0x003A LED Timer
+ u8 auto_lock; // 0x003B Auto Lock
+ u8 pfkey1short; // 0x003C FS1 Short
+ u8 pfkey1long; // 0x003D FS1 Long
+ u8 pfkey2short; // 0x003E FS2 Short
+ u8 pfkey2long; // 0x003F FS2 Long
+ u8 unknown_0; // 0x0040
+ u8 voice:2, // 0x0041 Voice Prompt
+ beep:1, // Beep Switch
+ roger:2, // Roger Tone
+ save:3; // Power Save
+ u8 dispmode:1, // 0x0042 Display Mode
+ dstandby:1, // Dual Standby
+ unknown_1:1
+ standby:1, // Radio Standby
+ squelch:4; // Squelch Level
+ u8 vox_level:4, // 0x0043 VOX Level
+ vox_delay:4; // VOX Delay
+ u8 brightness:2, // 0x0044 Screen Light
+ unknown_2:1,
+ alarm:1, // Alarm
+ scramble:4; // Scramble
+ u8 screen:1, // 0x0045 Screen On-off
+ led:1, // LED On-off
+ key_lock:1, // Key Lock
+ radio:1, // Radio On-off
+ compander:1, // Compander
+ rp:1, // Offset
+ freq_lock:1, // Freq Lock
+ vox:1; // VOX On-off
+ u8 unknown_4:4, // 0x0046
+ txpri:1, // TX PRI
+ unknown_5:1,
+ tail_tone:2; // Tail Tone
+ ul16 fmcur; // 0x0047 Radio Freq
+ u8 unknown_49; // 0x0049
+ u8 unknown_4A; // 0x004A
+ u8 unknown_4B; // 0x004B
+ u8 unknown_4C; // 0x004C
+ u8 dsrangea; // 0x004D Dual Standby Range A
+ u8 dsrangeb; // 0x004E Dual Standby Range B
+ u8 tot; // 0x004F
+} settings;
+
+"""
+
+CMD_ACK = "\x06"
+
+RB15_DTCS = sorted(chirp_common.DTCS_CODES + [645])
+
+_STEP_LIST = [0.25, 1.25, 2.5, 5., 6.25, 10., 12.5, 25., 50., 100.]
+
+LIST_ALARM = ["Local", "Remote"]
+LIST_BRIGHT = ["Low", "Middle", "High"]
+LIST_DISPM = ["Frequency", "Channel Number"]
+LIST_ROGER = ["Off", "Start", "End", "Start and End"]
+LIST_SAVE = ["Off", "1:1", "1:2", "1:3", "1:4", "1:5"]
+LIST_SCRAMBLE = ["Off"] + ["%s" % x for x in range(1, 9)]
+LIST_SKEY = ["None", "Monitor", "Local Alarm", "Remote Alarm",
+ "Screen On/Off", "Frequency Lock"]
+LIST_TIMER = ["Off"] + ["%s seconds" % x for x in range(15, 615, 15)]
+LIST_TXPRI = ["Edit", "Busy"]
+LIST_VOICE = ["Off", "Chinese", "English"]
+
+TXALLOW_CHOICES = ["RX Only", "TX/RX"]
+TXALLOW_VALUES = [0xFF, 0x00]
+
+
+def _checksum(data):
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+ return cs % 256
+
+
+def _enter_programming_mode(radio):
+ serial = radio.pipe
+
+ # lengthen the timeout here as these radios are reseting due to timeout
+ radio.pipe.timeout = 0.75
+
+ exito = False
+ for i in range(0, 5):
+ serial.write(radio.magic)
+ ack = serial.read(1)
+
+ try:
+ if ack == CMD_ACK:
+ exito = True
+ break
+ except:
+ LOG.debug("Attempt #%s, failed, trying again" % i)
+ pass
+
+ # return timeout to default value
+ radio.pipe.timeout = 0.25
+
+ # check if we had EXITO
+ if exito is False:
+ msg = "The radio did not accept program mode after five tries.\n"
+ msg += "Check you interface cable and power cycle your radio."
+ raise errors.RadioError(msg)
+
+
+def _exit_programming_mode(radio):
+ serial = radio.pipe
+ try:
+ serial.write("93" + "\x05\xEE\x5F")
+ except:
+ raise errors.RadioError("Radio refused to exit programming mode")
+
+
+def _read_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">BH", ord('R'), block_addr + 0x0340)
+
+ ccs = _checksum(cmd)
+
+ expectedresponse = "R" + cmd[1:]
+
+ cmd = cmd + chr(ccs)
+
+ LOG.debug("Reading block %04x..." % (block_addr + 0x0340))
+
+ try:
+ serial.write(cmd)
+ response = serial.read(3 + block_size + 1)
+
+ cs = _checksum(response[:-1])
+
+ if response[:3] != expectedresponse:
+ raise Exception("Error reading block %04x." % (block_addr +
+ 0x0340))
+
+ chunk = response[3:]
+
+ if ord(chunk[-1]) != cs:
+ raise Exception("Block failed checksum!")
+
+ block_data = chunk[:-1]
+ except:
+ raise errors.RadioError("Failed to read block at %04x" % block_addr +
+ 0x0340)
+
+ return block_data
+
+
+def _write_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
+
+ cmd = struct.pack(">BH", ord('W'), block_addr + 0x0340)
+
+ cs = _checksum(cmd + data)
+ data += chr(cs)
+
+ LOG.debug("Writing Data:")
+ LOG.debug(util.hexprint(cmd + data))
+
+ try:
+ serial.write(cmd + data)
+ if serial.read(1) != CMD_ACK:
+ raise Exception("No ACK")
+ except:
+ raise errors.RadioError("Failed to send block "
+ "to radio at %04x" % (block_addr + 0x0340))
+
+
+def do_download(radio):
+ LOG.debug("download")
+ _enter_programming_mode(radio)
+
+ data = ""
+
+ status = chirp_common.Status()
+ status.msg = "Cloning from radio"
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+
+ block = _read_block(radio, addr, radio.BLOCK_SIZE)
+ data += block
+
+ LOG.debug("Address: %04x" % addr)
+ LOG.debug(util.hexprint(block))
+
+ _exit_programming_mode(radio)
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ status = chirp_common.Status()
+ status.msg = "Uploading to radio"
+
+ _enter_programming_mode(radio)
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for start_addr, end_addr in radio._ranges:
+ for addr in range(start_addr, end_addr, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+ _write_block(radio, addr, radio.BLOCK_SIZE)
+
+ _exit_programming_mode(radio)
+
+
+def _split(rf, f1, f2):
+ """Returns False if the two freqs are in the same band (no split)
+ or True otherwise"""
+
+ # determine if the two freqs are in the same band
+ for low, high in rf.valid_bands:
+ if f1 >= low and f1 <= high and \
+ f2 >= low and f2 <= high:
+ # if the two freqs are on the same Band this is not a split
+ return False
+
+ # if you get here is because the freq pairs are split
+ return True
+
+
+class IradioUV5118(chirp_common.CloneModeRadio):
+ """IRADIO UV5118"""
+ VENDOR = "Iradio"
+ MODEL = "UV-5118"
+ BAUD_RATE = 9600
+
+ BLOCK_SIZE = 0x10
+ magic = "93" + "\x05\x10\x81"
+
+ VALID_BANDS = [(20000000, 64000000), # RX only
+ (108000000, 136000000), # RX only (Air Band)
+ (136000000, 174000000), # TX/RX (VHF)
+ (174000000, 400000000), # TX/RX
+ (400000000, 520000000), # TX/RX (UHF)
+ (520000000, 660000000)] # TX/RX
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ # Radio's memory starts at 0x0340
+ # Radio's memory ends at 0x0B90
+
+ _ranges = [
+ (0x0000, 0x0850),
+ ]
+ _memsize = 0x0850
+
+ _upper = 128
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_rx_dtcs = True
+ rf.has_tuning_step = False
+ rf.can_odd_split = True
+ rf.has_name = False
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_duplexes = ["", "-", "+", "split"]
+ rf.valid_modes = ["FM", "NFM"] # 25 KHz, 12.5 KHz.
+ rf.valid_dtcs_codes = RB15_DTCS
+ rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = _STEP_LIST
+ rf.valid_bands = self.VALID_BANDS
+
+ return rf
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ data = do_download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = data
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ do_upload(self)
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ @staticmethod
+ def _decode_tone(toneval):
+ # DCS examples:
+ # D023N - 1013 - 0001 0000 0001 0011
+ # ^-DCS
+ # D023I - 2013 - 0010 0000 0001 0100
+ # ^--DCS inverted
+ # D754I - 21EC - 0010 0001 1110 1100
+ # code in octal-------^^^^^^^^^^^
+
+ if toneval == 0x3000:
+ return '', None, None
+ elif toneval & 0x1000:
+ # DTCS N
+ code = int('%o' % (toneval & 0x1FF))
+ return 'DTCS', code, 'N'
+ elif toneval & 0x2000:
+ # DTCS R
+ code = int('%o' % (toneval & 0x1FF))
+ return 'DTCS', code, 'R'
+ else:
+ return 'Tone', toneval / 10.0, None
+
+ @staticmethod
+ def _encode_tone(mode, val, pol):
+ if not mode:
+ return 0x3000
+ elif mode == 'Tone':
+ return int(val * 10)
+ elif mode == 'DTCS':
+ code = int('%i' % val, 8)
+ if pol == 'N':
+ code |= 0x1800
+ if pol == 'R':
+ code |= 0x2800
+ return code
+ else:
+ raise errors.RadioError('Unsupported tone mode %r' % mode)
+
+ def get_memory(self, number):
+ mem = chirp_common.Memory()
+ _mem = self._memobj.channels[number - 1]
+ mem.number = number
+
+ mem.freq = int(_mem.rxfreq) * 10
+
+ # We'll consider any blank (i.e. 0MHz frequency) to be empty
+ if mem.freq == 0:
+ mem.empty = True
+ return mem
+
+ if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
+ mem.freq = 0
+ mem.empty = True
+ return mem
+
+ if _mem.get_raw() == ("\xFF" * 16):
+ LOG.debug("Initializing empty memory")
+ _mem.set_raw("\xFF" * 4 + "\x00\x30" + "\xFF" * 4 + "\x00\x30" +
+ "\x00" * 4)
+
+ # Freq and offset
+ mem.freq = int(_mem.rxfreq) * 10
+ # TX freq set
+ offset = (int(_mem.txfreq) * 10) - mem.freq
+ if offset != 0:
+ if _split(self.get_features(), mem.freq, int(
+ _mem.txfreq) * 10):
+ mem.duplex = "split"
+ mem.offset = int(_mem.txfreq) * 10
+ elif offset < 0:
+ mem.offset = abs(offset)
+ mem.duplex = "-"
+ elif offset > 0:
+ mem.offset = offset
+ mem.duplex = "+"
+ else:
+ mem.offset = 0
+
+ mem.mode = _mem.isnarrow and "NFM" or "FM"
+
+ chirp_common.split_tone_decode(mem,
+ self._decode_tone(_mem.tx_tone),
+ self._decode_tone(_mem.rx_tone))
+
+ mem.power = self.POWER_LEVELS[_mem.lowpower]
+
+ if not _mem.scan:
+ mem.skip = "S"
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ rs = RadioSetting("bcl", "BCL",
+ RadioSettingValueBoolean(_mem.bcl))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ LOG.debug("Setting %i(%s)" % (mem.number, mem.extd_number))
+ _mem = self._memobj.channels[mem.number - 1]
+
+ # if empty memmory
+ if mem.empty:
+ _mem.set_raw("\xFF" * 16)
+ return
+
+ _mem.set_raw("\xFF" * 4 + "\x00\x30" + "\xFF" * 4 + "\x00\x30" +
+ "\x00" * 4)
+
+ _mem.rxfreq = mem.freq / 10
+
+ if mem.duplex == "split":
+ _mem.txfreq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.txfreq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.txfreq = mem.freq / 10
+
+ _mem.scan = mem.skip != "S"
+ _mem.isnarrow = mem.mode == "NFM"
+
+ txtone, rxtone = chirp_common.split_tone_encode(mem)
+ _mem.tx_tone = self._encode_tone(*txtone)
+ _mem.rx_tone = self._encode_tone(*rxtone)
+
+ _mem.lowpower = mem.power == self.POWER_LEVELS[1]
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+ _txallow = self._memobj.txallow
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ sidekey = RadioSettingGroup("sidekey", "Side Key Settings")
+ dwatch = RadioSettingGroup("dwatch", "Dual Watch Settings")
+ txallow = RadioSettingGroup("txallow", "TX Allow")
+ top = RadioSettings(basic, sidekey, dwatch, txallow)
+
+ voice = RadioSetting("voice", "Language", RadioSettingValueList(
+ LIST_VOICE, LIST_VOICE[_settings.voice]))
+ basic.append(voice)
+
+ beep = RadioSetting("beep", "Key Beep",
+ RadioSettingValueBoolean(_settings.beep))
+ basic.append(beep)
+
+ roger = RadioSetting("roger", "Roger Tone",
+ RadioSettingValueList(
+ LIST_ROGER, LIST_ROGER[_settings.roger]))
+ basic.append(roger)
+
+ save = RadioSetting("save", "Battery Save",
+ RadioSettingValueList(
+ LIST_SAVE, LIST_SAVE[_settings.save]))
+ basic.append(save)
+
+ dispmode = RadioSetting("dispmode", "Display Mode",
+ RadioSettingValueList(
+ LIST_DISPM,
+ LIST_DISPM[_settings.dispmode]))
+ basic.append(dispmode)
+
+ brightness = RadioSetting("brightness", "Screen Light",
+ RadioSettingValueList(
+ LIST_BRIGHT,
+ LIST_BRIGHT[_settings.brightness]))
+ basic.append(brightness)
+
+ screen = RadioSetting("screen", "Screen",
+ RadioSettingValueBoolean(_settings.screen))
+ basic.append(screen)
+
+ display_timer = RadioSetting("display_timer", "Display Timer",
+ RadioSettingValueList(
+ LIST_TIMER,
+ LIST_TIMER[_settings.display_timer]))
+ basic.append(display_timer)
+
+ led = RadioSetting("led", "LED",
+ RadioSettingValueBoolean(_settings.led))
+ basic.append(led)
+
+ led_timer = RadioSetting("led_timer", "LED Timer",
+ RadioSettingValueList(
+ LIST_TIMER,
+ LIST_TIMER[_settings.led_timer]))
+ basic.append(led_timer)
+
+ squelch = RadioSetting("squelch", "Squelch Level",
+ RadioSettingValueInteger(
+ 0, 9, _settings.squelch))
+ basic.append(squelch)
+
+ vox = RadioSetting("vox", "VOX",
+ RadioSettingValueBoolean(_settings.vox))
+ basic.append(vox)
+
+ vox_level = RadioSetting("vox_level", "VOX Level",
+ RadioSettingValueInteger(
+ 0, 9, _settings.vox_level))
+ basic.append(vox_level)
+
+ vox_delay = RadioSetting("vox_delay", "VOX Delay",
+ RadioSettingValueInteger(
+ 0, 9, _settings.vox_delay))
+ basic.append(vox_delay)
+
+ compander = RadioSetting("compander", "Compander",
+ RadioSettingValueBoolean(_settings.compander))
+ basic.append(compander)
+
+ scramble = RadioSetting("scramble", "Scramble",
+ RadioSettingValueList(
+ LIST_SCRAMBLE,
+ LIST_SCRAMBLE[_settings.scramble]))
+ basic.append(scramble)
+
+ rp = RadioSetting("rp", "Offset",
+ RadioSettingValueBoolean(_settings.rp))
+ basic.append(rp)
+
+ txpri = RadioSetting("txpri", "TX Priority",
+ RadioSettingValueList(
+ LIST_TXPRI,
+ LIST_TXPRI[_settings.txpri]))
+ basic.append(txpri)
+
+ tot = RadioSetting("tot", "Time-out Timer",
+ RadioSettingValueList(
+ LIST_TIMER,
+ LIST_TIMER[_settings.tot]))
+ basic.append(tot)
+
+ tail_tone = RadioSetting("tail_tone", "Tail Tone",
+ RadioSettingValueInteger(
+ 0, 3, _settings.tail_tone))
+ basic.append(tail_tone)
+
+ alarm = RadioSetting("alarm", "Alarm",
+ RadioSettingValueList(
+ LIST_ALARM,
+ LIST_ALARM[_settings.alarm]))
+ basic.append(alarm)
+
+ freq_lock = RadioSetting("freq_lock", "Frequency Lock",
+ RadioSettingValueBoolean(_settings.freq_lock))
+ basic.append(freq_lock)
+
+ key_lock = RadioSetting("key_lock", "Key Lock",
+ RadioSettingValueBoolean(_settings.key_lock))
+ basic.append(key_lock)
+
+ auto_lock = RadioSetting("auto_lock", "Auto Lock Timer",
+ RadioSettingValueList(
+ LIST_TIMER,
+ LIST_TIMER[_settings.auto_lock]))
+ basic.append(auto_lock)
+
+ radio = RadioSetting("radio", "Broadcast FM Radio",
+ RadioSettingValueBoolean(_settings.radio))
+ basic.append(radio)
+
+ standby = RadioSetting("standby", "Radio Standby",
+ RadioSettingValueBoolean(_settings.standby))
+ basic.append(standby)
+
+ def myset_freq(setting, obj, atrb, mult):
+ """ Callback to set frequency by applying multiplier"""
+ value = int(float(str(setting.value)) * mult)
+ setattr(obj, atrb, value)
+ return
+
+ # FM Broadcast Settings
+ val = _settings.fmcur
+ val = val / 10.0
+ if val < 87.5 or val > 108.0:
+ val = 90.4
+ rx = RadioSettingValueFloat(87.5, 108.0, val, 0.1, 1)
+ rset = RadioSetting("fmcur", "Broadcast FM Freq (MHz)", rx)
+ rset.set_apply_callback(myset_freq, _settings, "fmcur", 10)
+ basic.append(rset)
+
+ # Side Key Settings
+ pfkey1short = RadioSetting("pfkey1short", "Side Key 1 - Short Press",
+ RadioSettingValueList(
+ LIST_SKEY,
+ LIST_SKEY[_settings.pfkey1short]))
+ sidekey.append(pfkey1short)
+
+ pfkey1long = RadioSetting("pfkey1long", "Side Key 1 - Long Press",
+ RadioSettingValueList(
+ LIST_SKEY,
+ LIST_SKEY[_settings.pfkey1long]))
+ sidekey.append(pfkey1long)
+
+ pfkey2short = RadioSetting("pfkey2short", "Side Key 2 - Short Press",
+ RadioSettingValueList(
+ LIST_SKEY,
+ LIST_SKEY[_settings.pfkey2short]))
+ sidekey.append(pfkey2short)
+
+ pfkey2long = RadioSetting("pfkey2long", "Side Key 2 - Long Press",
+ RadioSettingValueList(
+ LIST_SKEY,
+ LIST_SKEY[_settings.pfkey2long]))
+ sidekey.append(pfkey2long)
+
+ dstandby = RadioSetting("dstandby", "Dual Standby",
+ RadioSettingValueBoolean(_settings.dstandby))
+ dwatch.append(dstandby)
+
+ dsrangea = RadioSetting("dsrangea", "Dual Standby Range A",
+ RadioSettingValueInteger(
+ 1, 128, _settings.dsrangea + 1))
+ dwatch.append(dsrangea)
+
+ dsrangeb = RadioSetting("dsrangeb", "Dual Standby Range B",
+ RadioSettingValueInteger(
+ 1, 128, _settings.dsrangeb + 1))
+ dwatch.append(dsrangeb)
+
+ def apply_txallow_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(
+ setting.value) + " from list")
+ val = str(setting.value)
+ index = TXALLOW_CHOICES.index(val)
+ val = TXALLOW_VALUES[index]
+ obj.set_value(val)
+
+ if _txallow.range174_180 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range174_180)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range174_180", "174-180 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range174_180)
+ txallow.append(rset)
+
+ if _txallow.range180_190 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range180_190)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range180_190", "180-190 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range180_190)
+ txallow.append(rset)
+
+ if _txallow.range190_200 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range190_200)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range190_200", "190-200 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range190_200)
+ txallow.append(rset)
+
+ if _txallow.range200_210 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range200_210)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range200_210", "200-210 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range200_210)
+ txallow.append(rset)
+
+ if _txallow.range210_220 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range210_220)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range210_220", "210-220 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range210_220)
+ txallow.append(rset)
+
+ if _txallow.range220_230 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range220_230)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range220_230", "220-230 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range220_230)
+ txallow.append(rset)
+
+ if _txallow.range230_240 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range230_240)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range230_240", "230-240 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range230_240)
+ txallow.append(rset)
+
+ if _txallow.range240_250 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range240_250)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range240_250", "240-250 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range240_250)
+ txallow.append(rset)
+
+ if _txallow.range250_260 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range250_260)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range250_260", "250-260 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range250_260)
+ txallow.append(rset)
+
+ if _txallow.range260_270 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range260_270)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range260_270", "260-270 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range260_270)
+ txallow.append(rset)
+
+ if _txallow.range270_280 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range270_280)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range270_280", "270-280 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range270_280)
+ txallow.append(rset)
+
+ if _txallow.range280_290 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range280_290)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range280_290", "280-290 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range280_290)
+ txallow.append(rset)
+
+ if _txallow.range290_300 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range290_300)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range290_300", "290-300 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range290_300)
+ txallow.append(rset)
+
+ if _txallow.range300_310 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range300_310)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range300_310", "300-310 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range300_310)
+ txallow.append(rset)
+
+ if _txallow.range310_320 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range310_320)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range310_320", "310-320 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range310_320)
+ txallow.append(rset)
+
+ if _txallow.range320_330 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range320_330)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range320_330", "320-330 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range320_330)
+ txallow.append(rset)
+
+ if _txallow.range330_340 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range330_340)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range330_340", "330-340 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range330_340)
+ txallow.append(rset)
+
+ if _txallow.range340_350 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range340_350)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range340_350", "340-350 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range340_350)
+ txallow.append(rset)
+
+ if _txallow.range350_360 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range350_360)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range350_360", "350-360 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range350_360)
+ txallow.append(rset)
+
+ if _txallow.range360_370 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range360_370)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range360_370", "360-370 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range360_370)
+ txallow.append(rset)
+
+ if _txallow.range370_380 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range370_380)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range370_380", "370-380 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range370_380)
+ txallow.append(rset)
+
+ if _txallow.range380_390 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range380_390)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range380_390", "380-390 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range380_390)
+ txallow.append(rset)
+
+ if _txallow.range390_400 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range390_400)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range390_400", "390-400 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range390_400)
+ txallow.append(rset)
+
+ if _txallow.range520_530 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range520_530)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range520_530", "520-530 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range520_530)
+ txallow.append(rset)
+
+ if _txallow.range530_540 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range530_540)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range530_540", "530-540 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range530_540)
+ txallow.append(rset)
+
+ if _txallow.range540_550 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range540_550)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range540_550", "540-550 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range540_550)
+ txallow.append(rset)
+
+ if _txallow.range550_560 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range550_560)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range550_560", "550-560 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range550_560)
+ txallow.append(rset)
+
+ if _txallow.range560_570 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range560_570)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range560_570", "560-570 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range560_570)
+ txallow.append(rset)
+
+ if _txallow.range570_580 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range570_580)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range570_580", "570-580 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range570_580)
+ txallow.append(rset)
+
+ if _txallow.range580_590 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range580_590)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range580_590", "580-590 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range580_590)
+ txallow.append(rset)
+
+ if _txallow.range590_600 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range590_600)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range590_600", "590-600 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range590_600)
+ txallow.append(rset)
+
+ if _txallow.range600_610 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range600_610)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range600_610", "600-610 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range600_610)
+ txallow.append(rset)
+
+ if _txallow.range610_620 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range610_620)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range610_620", "610-620 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range610_620)
+ txallow.append(rset)
+
+ if _txallow.range620_630 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range620_630)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range620_630", "620-630 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range620_630)
+ txallow.append(rset)
+
+ if _txallow.range630_640 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range630_640)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range630_640", "630-640 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range630_640)
+ txallow.append(rset)
+
+ if _txallow.range640_650 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range640_650)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range640_650", "640-650 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range640_650)
+ txallow.append(rset)
+
+ if _txallow.range650_660 in TXALLOW_VALUES:
+ idx = TXALLOW_VALUES.index(_txallow.range650_660)
+ else:
+ idx = TXALLOW_VALUES.index(0xFF)
+ rs = RadioSettingValueList(TXALLOW_CHOICES, TXALLOW_CHOICES[idx])
+ rset = RadioSetting("txallow.range650_660", "650-660 MHz", rs)
+ rset.set_apply_callback(apply_txallow_listvalue, _txallow.range650_660)
+ txallow.append(rset)
+
+ return top
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif setting == "dsrangea":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "dsrangeb":
+ setattr(obj, setting, int(element.value) - 1)
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+@directory.register
+class AbbreeAR518Radio(IradioUV5118):
+ """ABBREE AR518"""
+ VENDOR = "Abbree"
+ MODEL = "AR-518"
diff --git a/chirp/drivers/kenwood_live.py b/chirp/drivers/kenwood_live.py
index 33981d5..07c035f 100644
--- a/chirp/drivers/kenwood_live.py
+++ b/chirp/drivers/kenwood_live.py
@@ -65,14 +65,12 @@ LAST_DELIMITER = ("\r", " ")
# fields, but others do.
-def command(ser, cmd, *args):
+def _command(ser, cmd, *args):
"""Send @cmd to radio via @ser"""
global LOCK, LAST_DELIMITER, COMMAND_RESP_BUFSIZE
start = time.time()
- LOCK.acquire()
-
# TODO: This global use of LAST_DELIMITER breaks reentrancy
# and needs to be fixed.
if args:
@@ -95,11 +93,14 @@ def command(ser, cmd, *args):
else:
LOG.error("Giving up")
- LOCK.release()
-
return result.strip()
+def command(ser, cmd, *args):
+ with LOCK:
+ return _command(ser, cmd, *args)
+
+
def get_id(ser):
"""Get the ID of the radio attached to @ser"""
global LAST_BAUD
@@ -121,7 +122,12 @@ def get_id(ser):
ser.baudrate = i
ser.write(LAST_DELIMITER[0].encode())
ser.read(25)
- resp = command(ser, "ID")
+ try:
+ resp = command(ser, "ID")
+ except UnicodeDecodeError:
+ # If we got binary here, we are using the wrong rate
+ # or not talking to a kenwood live radio.
+ continue
# most kenwood radios
if " " in resp:
@@ -173,6 +179,7 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
_upper = 200
_kenwood_split = False
_kenwood_valid_tones = list(chirp_common.TONES)
+ _has_name = True
def __init__(self, *args, **kwargs):
chirp_common.LiveRadio.__init__(self, *args, **kwargs)
@@ -235,13 +242,14 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
mem = self._parse_mem_spec(spec)
self._memcache[mem.number] = mem
- result = command(self.pipe, *self._cmd_get_memory_name(number))
- if " " in result:
- value = result.split(" ", 1)[1]
- if value.count(",") == 2:
- _zero, _loc, mem.name = value.split(",")
- else:
- _loc, mem.name = value.split(",")
+ if self._has_name:
+ result = command(self.pipe, *self._cmd_get_memory_name(number))
+ if " " in result:
+ value = result.split(" ", 1)[1]
+ if value.count(",") == 2:
+ _zero, _loc, mem.name = value.split(",")
+ else:
+ _loc, mem.name = value.split(",")
if mem.duplex == "" and self._kenwood_split:
result = command(self.pipe, *self._cmd_get_split(number))
@@ -272,7 +280,7 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
spec = self._make_mem_spec(memory)
spec = ",".join(spec)
r1 = command(self.pipe, *self._cmd_set_memory(memory.number, spec))
- if not iserr(r1):
+ if not iserr(r1) and self._has_name:
time.sleep(0.5)
r2 = command(self.pipe, *self._cmd_set_memory_name(memory.number,
memory.name))
@@ -283,7 +291,7 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
raise errors.InvalidDataError("Radio refused name %i: %s" %
(memory.number,
repr(memory.name)))
- else:
+ elif self._has_name:
raise errors.InvalidDataError("Radio refused %i" % memory.number)
if memory.duplex == "split" and self._kenwood_split:
@@ -1216,6 +1224,96 @@ class THD72Radio(TMD710Radio):
@directory.register
+class THD74Radio(TMD710Radio):
+ """Kenwood TH_D74"""
+ MODEL = "TH-D74 (live mode)"
+ HARDWARE_FLOW = sys.platform == "darwin"
+
+ STEPS = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0,
+ 25.0, 30.0, 50.0, 100.0]
+ MODES = ['FM', 'DV', 'AM', 'LSB', 'USB', 'CW', 'NFM', 'DR',
+ 'WFM', 'R-CW']
+ CROSS_MODES = ['DTCS->', 'Tone->DTCS', 'DTCS->Tone', 'Tone->Tone']
+ DUPLEX = ['', '+', '-', 'split']
+ _has_name = False
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = ("This driver is incomplete as the D74 lacks "
+ "the full serial command set of older radios. "
+ "As such, this should be considered permanently "
+ "experimental.")
+ return rp
+
+ def _cmd_get_memory_name(self, number):
+ return ''
+
+ def get_features(self):
+ rf = super(THD74Radio, self).get_features()
+ rf.valid_tuning_steps = self.STEPS
+ rf.valid_modes = self.MODES
+ rf.valid_cross_modes = self.CROSS_MODES
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.has_name = False # Radio has it, but no command to retrieve
+ rf.has_cross = True
+ return rf
+
+ def _parse_mem_spec(self, spec):
+ mem = chirp_common.Memory()
+ mem.number = int(spec[0])
+ mem.freq = int(spec[1])
+ mem.offset = int(spec[2])
+ mem.tuning_step = self.STEPS[int(spec[3])]
+ mem.mode = self.MODES[int(spec[5])]
+ if int(spec[11]):
+ mem.tmode = "Cross"
+ mem.cross_mode = self.CROSS_MODES[int(spec[18])]
+ elif int(spec[8]):
+ mem.tmode = "Tone"
+ elif int(spec[9]):
+ mem.tmode = "TSQL"
+ elif int(spec[10]):
+ mem.tmode = "DTCS"
+
+ mem.duplex = self.DUPLEX[int(spec[14])]
+ mem.rtone = chirp_common.TONES[int(spec[15])]
+ mem.ctone = chirp_common.TONES[int(spec[16])]
+ mem.dtcs = chirp_common.DTCS_CODES[int(spec[17])]
+ mem.skip = int(spec[22]) and 'S' or ''
+
+ return mem
+
+ def _make_mem_spec(self, mem):
+ spec = (
+ "%010i" % mem.freq,
+ "%010i" % mem.offset,
+ "%X" % self.STEPS.index(mem.tuning_step),
+ "%X" % self.STEPS.index(mem.tuning_step),
+ "%i" % self.MODES.index(mem.mode),
+ "0", # Fine mode
+ "0", # Fine step
+ "%i" % (mem.tmode == "Tone" and 1 or 0),
+ "%i" % (mem.tmode == "TSQL" and 1 or 0),
+ "%i" % (mem.tmode == "DTCS" and 1 or 0),
+ "%i" % (mem.tmode == 'Cross'),
+ "0", # Reverse
+ "0", # Odd split channel
+ "%i" % self.DUPLEX.index(mem.duplex),
+ "%02i" % (chirp_common.TONES.index(mem.rtone)),
+ "%02i" % (chirp_common.TONES.index(mem.ctone)),
+ "%03i" % (chirp_common.DTCS_CODES.index(mem.dtcs)),
+ "%i" % self.CROSS_MODES.index(mem.cross_mode),
+ "CQCQCQ", # URCALL
+ "0", # D-STAR squelch type
+ "00", # D-STAR squelch code
+ "%i" % D710_SKIP.index(mem.skip), # Memory Lockout
+ )
+
+ return spec
+
+
+@directory.register
class TMV71Radio(TMD710Radio):
"""Kenwood TM-V71"""
MODEL = "TM-V71"
@@ -1665,7 +1763,7 @@ class TS480Radio(KenwoodLiveRadio):
mem.number = number
spec0 = command(self.pipe, "MR0%03i" % mem.number)
spec1 = command(self.pipe, "MR1%03i" % mem.number)
- # Add 1 to string idecis if refering to CAT manual
+ # Add 1 to string idecis if referring to CAT manual
mem.name = spec0[41:49] # Max 8-Char Name if assigned
mem.name = mem.name.strip()
mem.name = mem.name.upper()
diff --git a/chirp/drivers/kg935g.py b/chirp/drivers/kg935g.py
new file mode 100644
index 0000000..0538685
--- /dev/null
+++ b/chirp/drivers/kg935g.py
@@ -0,0 +1,1547 @@
+# Wouxun KG-935G Driver
+# Updated by:
+# melvin.terechenok@gmail.com
+
+# Copyright 2019 Pavel Milanes CO7WT <pavelmc@gmail.com>
+#
+# Based on the work of Krystian Struzik <toner_82@tlen.pl>
+# who figured out the crypt used and made possible the
+# Wuoxun KG-UV8D Plus driver, in which this work is based.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""Wouxun KG-935G radio management module"""
+
+import time
+import os
+import logging
+
+from chirp import util, chirp_common, bitwise, memmap, errors, directory
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueInteger, RadioSettingValueString, \
+ RadioSettingValueFloat, RadioSettingValueMap, RadioSettings
+
+
+LOG = logging.getLogger(__name__)
+
+CMD_ID = 128 # \x80
+CMD_END = 129 # \x81
+CMD_RD = 130 # \82
+CMD_WR = 131 # \83
+
+MEM_VALID = 158
+
+AB_LIST = ["A", "B"]
+STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 50.0, 100.0]
+STEP_LIST = [str(x) for x in STEPS]
+ROGER_LIST = ["Off", "Begin", "End", "Both"]
+TIMEOUT_LIST = ["Off"] + [str(x) + "s" for x in range(15, 901, 15)]
+VOX_LIST = ["Off"] + ["%s" % x for x in range(1, 10)]
+BANDWIDTH_LIST = ["Narrow", "Wide"]
+VOICE_LIST = ["Off", "On"]
+LANGUAGE_LIST = ["Chinese", "English"]
+SCANMODE_LIST = ["TO", "CO", "SE"]
+# MRT - EDIT FOR 935G
+PFKEYLONG_LIST = ["undef", "FRQ2-PTT", "Selec Call", "Scan", "Flashlight",
+ "Alarm", "SOS", "FM Radio", "Moni", "Strobe", "Weather",
+ "Tlk A", "Reverse", "CTC Scan", "DCS Scan", "BRT"]
+PFKEYSHORT_LIST = ["undef", "Scan", "Flashlight", "Alarm", "SOS", "FM Radio",
+ "Moni", "Strobe", "Weather", "Tlk A", "Reverse",
+ "CTC Scan", "DCS Scan", "BRT"]
+#
+WORKMODE_LIST = ["VFO", "Ch.Number.", "Ch.Freq.", "Ch.Name"]
+BACKLIGHT_LIST = ["Always On"] + [str(x) + "s" for x in range(1, 21)] + \
+ ["Always Off"]
+OFFSET_LIST = ["+", "-"]
+PONMSG_LIST = ["MSG - Bitmap", "Battery Volts"]
+SPMUTE_LIST = ["QT", "QT+DTMF", "QT*DTMF"]
+DTMFST_LIST = ["OFF", "DTMF", "ANI", "DTMF+ANI"]
+# DTMF_TIMES = [str(x) + "ms" for x in range(0, 501, 10)]
+DTMF_TIMES = [('%dms' % dtmf, (dtmf // 10)) for dtmf in range(50, 501, 10)]
+ALERTS = [1750, 2100, 1000, 1450]
+ALERTS_LIST = [str(x) for x in ALERTS]
+PTTID_LIST = ["BOT", "EOT", "Both"]
+LIST_10 = ["Off"] + ["%s" % x for x in range(1, 11)]
+SCANGRP_LIST = ["All"] + ["%s" % x for x in range(1, 11)]
+SCQT_LIST = ["Decoder", "Encoder", "All"]
+SMUTESET_LIST = ["Off", "Tx", "Rx", "Tx+Rx"]
+POWER_LIST = ["Lo", "Mid", "Hi"]
+HOLD_TIMES = ["Off"] + ["%s" % x for x in range(100, 5001, 100)]
+RPTMODE_LIST = ["Radio", "Repeater"]
+# MRT ADDED NEW LISTS
+CALLGROUP_LIST = [str(x) for x in range(1, 21)]
+THEME_LIST = ["White-1", "White-2", "Black-1", "Black-2"]
+DSPBRTSBY_LIST = ["OFF", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
+DSPBRTACT_MAP = [("1", 1), ("2", 2), ("3", 3), ("4", 4), ("5", 5),
+ ("6", 6), ("7", 7), ("8", 8), ("9", 9), ("10", 10)]
+TONESCANSAVELIST = ["Rx", "Tx", "Tx/Rx"]
+# PTTDELAY_LIST = [str(x) + "ms" for x in range(0, 3001, 100)]
+PTTDELAY_TIMES = [('%dms' % pttdelay,
+ (pttdelay // 100)) for pttdelay in range(100, 3001, 100)]
+SCRAMBLE_LIST = ["OFF"] + [str(x) for x in range(1, 9)]
+ONOFF_LIST = ["OFF", "ON"]
+# MRT - Map CTCSS Tones - Value in mem is hex value of
+# (ctcss tone * 10) + 0x8000
+# MRT - 0x8000 is for CTCSS tones
+# MRT - Map DCS Tones - Value in mem is hex representation of
+# DCS Tone# in Octal + either 0x4000 or 0x6000 for polarity
+# MRT - 0x4000 is for DCS n tones
+# MRT - 0x6000 is for DCS i tones
+TONE_MAP = [('Off', 0x0000)] + \
+ [('%.1f' % tone,
+ int(0x8000 + tone * 10)) for tone in chirp_common.TONES] + \
+ [('D%03dn' % tone, int(0x4000 + int(str(tone), 8)))
+ for tone in chirp_common.DTCS_CODES] + \
+ [('D%03di' % tone, int(0x6000 + int(str(tone), 8)))
+ for tone in chirp_common.DTCS_CODES]
+
+
+# memory slot 0 is not used, start at 1 (so need 1000 slots, not 999)
+# structure elements whose name starts with x are currently unidentified
+
+# MRT made Power = 4 bits to handle 935G's 3 power levels and
+# to prevent display errors
+# MRT beta 1.3 - updates to structure to match KG935G Custom
+# programming SW configuration settings, FM Radio presets, Key Settings
+# MRT beta 1.4 - modified some value names and merged FM Radio
+# memories with other settings to resolve errors in UI implementation
+_MEM_FORMAT = """
+ #seekto 0x0044;
+ struct {
+ u32 rx_start;
+ u32 rx_stop;
+ u32 tx_start;
+ u32 tx_stop;
+ } uhf_limits;
+
+ #seekto 0x0054;
+ struct {
+ u32 rx_start;
+ u32 rx_stop;
+ u32 tx_start;
+ u32 tx_stop;
+ } vhf_limits;
+
+ #seekto 0x0400;
+ struct {
+ char oem1[8];
+ char unknown[2];
+ u8 unknown2[10];
+ u8 unknown3[10];
+ u8 unknown4[8];
+ char oem2[10];
+ u8 version[6];
+ char date[8];
+ u8 unknown5[2];
+ char model[8];
+ } oem_info;
+
+ #seekto 0x0480;
+ struct {
+ u16 Group_lower1;
+ u16 Group_upper1;
+ u16 Group_lower2;
+ u16 Group_upper2;
+ u16 Group_lower3;
+ u16 Group_upper3;
+ u16 Group_lower4;
+ u16 Group_upper4;
+ u16 Group_lower5;
+ u16 Group_upper5;
+ u16 Group_lower6;
+ u16 Group_upper6;
+ u16 Group_lower7;
+ u16 Group_upper7;
+ u16 Group_lower8;
+ u16 Group_upper8;
+ u16 Group_lower9;
+ u16 Group_upper9;
+ u16 Group_lower10;
+ u16 Group_upper10;
+ } scan_groups;
+
+ #seekto 0x0500;
+ struct {
+ u8 call_code_1[6];
+ u8 call_code_2[6];
+ u8 call_code_3[6];
+ u8 call_code_4[6];
+ u8 call_code_5[6];
+ u8 call_code_6[6];
+ u8 call_code_7[6];
+ u8 call_code_8[6];
+ u8 call_code_9[6];
+ u8 call_code_10[6];
+ u8 call_code_11[6];
+ u8 call_code_12[6];
+ u8 call_code_13[6];
+ u8 call_code_14[6];
+ u8 call_code_15[6];
+ u8 call_code_16[6];
+ u8 call_code_17[6];
+ u8 call_code_18[6];
+ u8 call_code_19[6];
+ u8 call_code_20[6];
+ } call_groups;
+
+ #seekto 0x0580;
+ struct {
+ char call_name1[6];
+ char call_name2[6];
+ char call_name3[6];
+ char call_name4[6];
+ char call_name5[6];
+ char call_name6[6];
+ char call_name7[6];
+ char call_name8[6];
+ char call_name9[6];
+ char call_name10[6];
+ char call_name11[6];
+ char call_name12[6];
+ char call_name13[6];
+ char call_name14[6];
+ char call_name15[6];
+ char call_name16[6];
+ char call_name17[6];
+ char call_name18[6];
+ char call_name19[6];
+ char call_name20[6];
+ } call_names;
+
+
+ #seekto 0x0600;
+ struct {
+ u16 FM_radio1;
+ u16 FM_radio2;
+ u16 FM_radio3;
+ u16 FM_radio4;
+ u16 FM_radio5;
+ u16 FM_radio6;
+ u16 FM_radio7;
+ u16 FM_radio8;
+ u16 FM_radio9;
+ u16 FM_radio10;
+ u16 FM_radio11;
+ u16 FM_radio12;
+ u16 FM_radio13;
+ u16 FM_radio14;
+ u16 FM_radio15;
+ u16 FM_radio16;
+ u16 FM_radio17;
+ u16 FM_radio18;
+ u16 FM_radio19;
+ u16 FM_radio20;
+ u16 unknown_pad_x0640[235];
+ u8 unknown07fe;
+ u8 unknown07ff;
+ u8 ponmsg;
+ char dispstr[15];
+ u8 unknown0810;
+ u8 unknown0811;
+ u8 unknown0812;
+ u8 unknown0813;
+ u8 unknown0814;
+ u8 voice;
+ u8 timeout;
+ u8 toalarm;
+ u8 channel_menu;
+ u8 power_save;
+ u8 autolock;
+ u8 keylock;
+ u8 beep;
+ u8 stopwatch;
+ u8 vox;
+ u8 scan_rev;
+ u8 backlight;
+ u8 roger_beep;
+ char mode_sw_pwd[6];
+ char reset_pwd[6];
+ u16 pri_ch;
+ u8 ani_sw;
+ u8 ptt_delay;
+ u8 ani_code[6];
+ u8 dtmf_st;
+ u8 BCL_A;
+ u8 BCL_B;
+ u8 ptt_id;
+ u8 prich_sw;
+ u8 unknown083d;
+ u8 unknown083e;
+ u8 unknown083f;
+ u8 alert;
+ u8 pf1_shrt;
+ u8 pf1_long;
+ u8 pf2_shrt;
+ u8 pf2_long;
+ u8 unknown0845;
+ u8 work_mode_a;
+ u8 work_mode_b;
+ u8 dtmf_tx_time;
+ u8 dtmf_interval;
+ u8 main_band;
+ u16 work_ch_a;
+ u16 work_ch_b;
+ u8 unknown084f;
+ u8 unknown0850;
+ u8 unknown0851;
+ u8 unknown0852;
+ u8 unknown0853;
+ u8 unknown0854;
+ u8 unknown0855;
+ u8 unknown0856;
+ u8 unknown0857;
+ u8 unknown0858;
+ u8 unknown0859;
+ u8 unknown085a;
+ u8 unknown085b;
+ u8 unknown085c;
+ u8 unknown085d;
+ u8 unknown085e;
+ u8 unknown085f;
+ u8 unknown0860;
+ u8 TDR_single_mode;
+ u8 ring_time;
+ u8 ScnGrpA_Act;
+ u8 ScnGrpB_Act;
+ u8 unknown0865;
+ u8 rpt_tone;
+ u8 unknown0867;
+ u8 scan_det;
+ u8 ToneScnSave;
+ u8 unknown086a;
+ u8 smuteset;
+ u8 cur_call_grp;
+ u8 DspBrtAct;
+ u8 DspBrtSby;
+ u8 unknown086f;
+ u8 theme;
+ u8 wxalert;
+ u8 VFO_repeater_a;
+ u8 VFO_repeater_b;
+ u8 unknown0874;
+ u8 unknown0875;
+ u8 unknown0876;
+ u8 unknown0877;
+ u8 unknown0878;
+ u8 unknown0879;
+ u8 unknown087a;
+ u8 unknown087b;
+ u8 unknown087c;
+ u8 unknown087d;
+ u8 unknown087e;
+ u8 unknown087f;
+ } settings;
+
+ #seekto 0x0880;
+ struct {
+ u32 rxfreq;
+ u32 unknown0;
+ u16 rxtone;
+ u16 txtone;
+ u8 scrambler:4,
+ power:4;
+ u8 unknown3:1,
+ unknown5:2,
+ unknown4:1,
+ cmpndr:1,
+ mute_mode:2,
+ iswide:1;
+ u8 step;
+ u8 squelch;
+ } vfoa;
+
+ #seekto 0x08c0;
+ struct {
+ u32 rxfreq;
+ u32 unknown0;
+ u16 rxtone;
+ u16 txtone;
+ u8 scrambler:4,
+ power:4;
+ u8 unknown3:1,
+ unknown5:2,
+ unknown4:1,
+ cmpndr:1,
+ mute_mode:2,
+ iswide:1;
+ u8 step;
+ u8 squelch;
+ } vfob;
+
+ #seekto 0x0900;
+ struct {
+ u32 rxfreq;
+ u32 txfreq;
+ u16 rxtone;
+ u16 txtone;
+ u8 scrambler:4,
+ power:4;
+ u8 unknown3:2,
+ scan_add:1,
+ unknown4:1,
+ compander:1,
+ mute_mode:2,
+ iswide:1;
+ u8 unknown5;
+ u8 unknown6;
+ } memory[1000];
+
+ #seekto 0x4780;
+ struct {
+ u8 name[8];
+ u8 unknown[4];
+ } names[1000];
+
+ #seekto 0x7670;
+ u8 valid[1000];
+ """
+
+# Support for the Wouxun KG-935G radio
+# Serial coms are at 19200 baud
+# The data is passed in variable length records
+# Record structure:
+# Offset Usage
+# 0 start of record (\x7c)
+# 1 Command (\x80 Identify \x81 End/Reboot \x82 Read \x83 Write)
+# 2 direction (\xff PC-> Radio, \x00 Radio -> PC)
+# 3 length of payload (excluding header/checksum) (n)
+# 4 payload (n bytes)
+# 4+n+1 checksum - byte sum (% 256) of bytes 1 -> 4+n
+#
+# Memory Read Records:
+# the payload is 3 bytes, first 2 are offset (big endian),
+# 3rd is number of bytes to read
+# Memory Write Records:
+# the maximum payload size (from the Wouxun software) seems to be 66 bytes
+# (2 bytes location + 64 bytes data).
+
+# MRT 1.2 correct spelling of Wouxon
+
+
+class KGUV8TRadio(chirp_common.Alias):
+ VENDOR = "Wouxun"
+ MODEL = "KG-935G"
+
+
+@directory.register
+class KG935GRadio(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
+
+ """Wouxun KG-935G"""
+ VENDOR = "Wouxun"
+ MODEL = "KG-935G"
+ _model = "KG-UV8D-B"
+ _file_ident = b"935G"
+ BAUD_RATE = 19200
+# MRT - Added Medium Power level for 935G support
+ POWER_LEVELS = [chirp_common.PowerLevel("L", watts=0.5),
+ chirp_common.PowerLevel("M", watts=4.5),
+ chirp_common.PowerLevel("H", watts=5.5)]
+ _mmap = ""
+ ALIASES = [KGUV8TRadio, ]
+
+ def _checksum(self, data):
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+ return chr(cs % 256)
+
+ def _write_record(self, cmd, payload=None):
+ # build the packet
+ _header = '\x7c' + chr(cmd) + '\xff'
+
+ _length = 0
+ if payload:
+ _length = len(payload)
+
+ # update the length field
+ _header += chr(_length)
+
+ if payload:
+ # calculate checksum then add it with the payload
+ # to the packet and encrypt
+ crc = self._checksum(_header[1:] + payload)
+ payload += crc
+ _header += self.encrypt(payload)
+ else:
+ # calculate and add encrypted checksum to the packet
+ crc = self._checksum(_header[1:])
+ _header += self.strxor(crc, '\x57')
+
+ try:
+ self.pipe.write(_header)
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+
+ def _read_record(self):
+ # read 4 chars for the header
+ _header = self.pipe.read(4)
+ if len(_header) != 4:
+ raise errors.RadioError('Radio did not respond')
+ _length = ord(_header[3])
+ _packet = self.pipe.read(_length)
+ _rcs_xor = _packet[-1]
+ _packet = self.decrypt(_packet)
+ _cs = ord(self._checksum(_header[1:] + _packet))
+ # read the checksum and decrypt it
+ _rcs = ord(self.strxor(self.pipe.read(1), _rcs_xor))
+ return (_rcs != _cs, _packet)
+
+ def decrypt(self, data):
+ result = ''
+ for i in range(len(data)-1, 0, -1):
+ result += self.strxor(data[i], data[i - 1])
+ result += self.strxor(data[0], '\x57')
+ return result[::-1]
+
+ def encrypt(self, data):
+ result = self.strxor('\x57', data[0])
+ for i in range(1, len(data), 1):
+ result += self.strxor(result[i - 1], data[i])
+ return result
+
+ def strxor(self, xora, xorb):
+ return chr(ord(xora) ^ ord(xorb))
+
+ # Identify the radio
+ #
+ # A Gotcha: the first identify packet returns a bad checksum, subsequent
+ # attempts return the correct checksum... (well it does on my radio!)
+ #
+ # The ID record returned by the radio also includes the
+ # current frequency range
+ # as 4 bytes big-endian in 10Hz increments
+ #
+ # Offset
+ # 0:10 Model, zero padded (Looks for 'KG-UV8D-B')
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ id = cls._file_ident
+ return cls._file_ident in filedata[0x426:0x430]
+
+ def _identify(self):
+ """Do the identification dance"""
+ for _i in range(0, 10):
+ self._write_record(CMD_ID)
+ _chksum_err, _resp = self._read_record()
+ LOG.debug("Got:\n%s" % util.hexprint(_resp))
+ if _chksum_err:
+ LOG.error("Checksum error: retrying ident...")
+ time.sleep(0.100)
+ continue
+ LOG.debug("Model %s" % util.hexprint(_resp[0:9]))
+ if _resp[0:9] == self._model:
+ return
+ if len(_resp) == 0:
+ raise Exception("Radio not responding")
+ else:
+ raise Exception("Unable to identify radio")
+
+ def _finish(self):
+ self._write_record(CMD_END)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(_MEM_FORMAT, self._mmap)
+
+ def sync_in(self):
+ try:
+ self._mmap = self._download()
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ self.process_mmap()
+
+ def sync_out(self):
+ self._upload()
+
+ # TODO: Load all memory.
+ # It would be smarter to only load the active areas and none of
+ # the padding/unused areas. Padding still need to be investigated.
+ def _download(self):
+ """Talk to a wouxun KG-935G and do a download"""
+ try:
+ self._identify()
+ return self._do_download(0, 32768, 64)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ LOG.exception('Unknown error during download process')
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+
+ def _do_download(self, start, end, blocksize):
+ # allocate & fill memory
+ image = ""
+ for i in range(start, end, blocksize):
+ req = chr(i // 256) + chr(i % 256) + chr(blocksize)
+ self._write_record(CMD_RD, req)
+ cs_error, resp = self._read_record()
+ if cs_error:
+ LOG.debug(util.hexprint(resp))
+ raise Exception("Checksum error on read")
+ # LOG.debug("Got:\n%s" % util.hexprint(resp))
+ image += resp[2:]
+ if self.status_fn:
+ status = chirp_common.Status()
+ status.cur = i
+ status.max = end
+ status.msg = "Cloning from radio"
+ self.status_fn(status)
+ self._finish()
+ return memmap.MemoryMap(''.join(image))
+
+ def _upload(self):
+ """Talk to a wouxun KG-935G and do a upload"""
+ try:
+ self._identify()
+ self._do_upload(0, 32768, 64)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ return
+
+ def _do_upload(self, start, end, blocksize):
+ ptr = start
+ for i in range(start, end, blocksize):
+ req = chr(i // 256) + chr(i % 256)
+ chunk = self.get_mmap()[ptr:ptr + blocksize]
+ self._write_record(CMD_WR, req + chunk)
+ LOG.debug(util.hexprint(req + chunk))
+ cserr, ack = self._read_record()
+ LOG.debug(util.hexprint(ack))
+ j = ord(ack[0]) * 256 + ord(ack[1])
+ if cserr or j != ptr:
+ raise Exception("Radio did not ack block %i" % ptr)
+ ptr += blocksize
+ if self.status_fn:
+ status = chirp_common.Status()
+ status.cur = i
+ status.max = end
+ status.msg = "Cloning to radio"
+ self.status_fn(status)
+ self._finish()
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_ctone = True
+ rf.has_rx_dtcs = True
+ rf.has_cross = True
+ rf.has_tuning_step = False
+ rf.has_bank = False
+ rf.can_odd_split = True
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_cross_modes = [
+ "Tone->Tone",
+ "Tone->DTCS",
+ "DTCS->Tone",
+ "DTCS->",
+ "->Tone",
+ "->DTCS",
+ "DTCS->DTCS",
+ ]
+ rf.valid_modes = ["FM", "NFM"]
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_name_length = 8
+ rf.valid_duplexes = ["", "-", "+", "split", "off"]
+# MRT - Open up channel memory freq range to support RxFreq limit expansion
+ rf.valid_bands = [(30000000, 299999990), # supports 2m
+ (300000000, 999999990)] # supports 70cm
+ # rf.valid_bands = [(self._memobj.vhf_limits.rx_start
+ # , self._memobj.vhf_limits.rx_stop), # supports 2m
+ # (self._memobj.uhf_limits.rx_start
+ # , self._memobj.uhf_limits.rx_stop)] # supports 70cm
+
+ rf.valid_characters = chirp_common.CHARSET_ASCII
+ rf.memory_bounds = (1, 999) # 999 memories
+ rf.valid_tuning_steps = STEPS
+ return rf
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = \
+ ('This driver is experimental. USE AT YOUR OWN RISK\n'
+ '\n'
+ 'Please save a copy of the image from your radio with Chirp '
+ 'before modifying any values.\n'
+ '\n'
+ 'Please keep a copy of your memories with the original Wouxon'
+ 'CPS software if you treasure them, this driver is new and'
+ 'may contain bugs.\n'
+ '\n'
+ ' All of the settings from the Wouxon Custom Programming'
+ ' Software (CSP) have been mapped\n in addition to some bonus'
+ ' settings that were found.\n'
+ ' Changing the VHF/UHF Rx limits does expand receive range -'
+ ' but radio performance\n'
+ ' is not guaranteed- and may void warranty or cause radio'
+ ' to malfunction.\n'
+ ' You can also customize the bottom banner from the OEMINFO '
+ ' Model setting\n'
+ )
+ return rp
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number])
+# MRT - corrected the Polarity decoding to match 935G implementation
+# use 0x2000 bit mask for R
+# MRT - 0x2000 appears to be the bit mask for Inverted DCS tones
+# MRT - n DCS Tone will be 0x4xxx values - i DCS Tones will
+# be 0x6xxx values.
+# MRT - Chirp Uses N for n DCS Tones and R for i DCS Tones
+
+ def _get_tone(self, _mem, mem):
+ def _get_dcs(val):
+ code = int("%03o" % (val & 0x07FF))
+ pol = (val & 0x2000) and "R" or "N"
+ return code, pol
+# MRT - Modified the function below to bitwise AND with 0x4000
+# to check for 935G DCS Tone decoding
+# MRT 0x4000 appears to be the bit mask for DCS tones
+ tpol = False
+# MRT Beta 1.1 - Fix the txtone compare to 0x4000 - was rxtone.
+ if _mem.txtone != 0xFFFF and (_mem.txtone & 0x4000) == 0x4000:
+ tcode, tpol = _get_dcs(_mem.txtone)
+ mem.dtcs = tcode
+ txmode = "DTCS"
+ elif _mem.txtone != 0xFFFF and _mem.txtone != 0x0:
+ mem.rtone = (_mem.txtone & 0x7fff) / 10.0
+ txmode = "Tone"
+ else:
+ txmode = ""
+# MRT - Modified the function below to bitwise AND with 0x4000
+# to check for 935G DCS Tone decoding
+ rpol = False
+ if _mem.rxtone != 0xFFFF and (_mem.rxtone & 0x4000) == 0x4000:
+ rcode, rpol = _get_dcs(_mem.rxtone)
+ mem.rx_dtcs = rcode
+ rxmode = "DTCS"
+ elif _mem.rxtone != 0xFFFF and _mem.rxtone != 0x0:
+ mem.ctone = (_mem.rxtone & 0x7fff) / 10.0
+ rxmode = "Tone"
+ else:
+ rxmode = ""
+
+ if txmode == "Tone" and not rxmode:
+ mem.tmode = "Tone"
+ elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
+ mem.tmode = "TSQL"
+ elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
+ mem.tmode = "DTCS"
+ elif rxmode or txmode:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ # always set it even if no dtcs is used
+ mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
+
+ LOG.debug("Got TX %s (%i) RX %s (%i)" %
+ (txmode, _mem.txtone, rxmode, _mem.rxtone))
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number]
+ _nam = self._memobj.names[number]
+
+ mem = chirp_common.Memory()
+ mem.number = number
+ _valid = self._memobj.valid[mem.number]
+ LOG.debug("%d %s", number, _valid == MEM_VALID)
+ if _valid != MEM_VALID:
+ mem.empty = True
+ return mem
+ else:
+ mem.empty = False
+
+ mem.freq = int(_mem.rxfreq) * 10
+
+ if _mem.txfreq == 0xFFFFFFFF:
+ # TX freq not set
+ mem.duplex = "off"
+ mem.offset = 0
+ elif int(_mem.rxfreq) == int(_mem.txfreq):
+ mem.duplex = ""
+ mem.offset = 0
+ elif abs(int(_mem.rxfreq) * 10 - int(_mem.txfreq) * 10) > 70000000:
+ mem.duplex = "split"
+ mem.offset = int(_mem.txfreq) * 10
+ else:
+ mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
+ mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
+
+ for char in _nam.name:
+ if char != 0:
+ mem.name += chr(char)
+ mem.name = mem.name.rstrip()
+
+ self._get_tone(_mem, mem)
+
+ mem.skip = "" if bool(_mem.scan_add) else "S"
+ _mem.power = _mem.power & 0x3
+ if _mem.power > 2:
+ _mem.power = 2
+ mem.power = self.POWER_LEVELS[_mem.power]
+ mem.mode = _mem.iswide and "FM" or "NFM"
+ return mem
+
+ def _set_tone(self, mem, _mem):
+ def _set_dcs(code, pol):
+ # MRT Change from + 0x2800 to bitwise OR with 0x4000 to
+ # set the bit for DCS
+ val = int("%i" % code, 8) | 0x4000
+ if pol == "R":
+ # MRT Change to 0x2000 from 0x8000 to set the bit for
+ # i/R polarity
+ val += 0x2000
+ return val
+
+ rx_mode = tx_mode = None
+ rxtone = txtone = 0x0000
+
+ if mem.tmode == "Tone":
+ tx_mode = "Tone"
+ rx_mode = None
+ txtone = int(mem.rtone * 10) + 0x8000
+ elif mem.tmode == "TSQL":
+ rx_mode = tx_mode = "Tone"
+ rxtone = txtone = int(mem.ctone * 10) + 0x8000
+ elif mem.tmode == "DTCS":
+ tx_mode = rx_mode = "DTCS"
+ txtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ rxtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[1])
+ elif mem.tmode == "Cross":
+ tx_mode, rx_mode = mem.cross_mode.split("->")
+ if tx_mode == "DTCS":
+ txtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ elif tx_mode == "Tone":
+ txtone = int(mem.rtone * 10) + 0x8000
+ if rx_mode == "DTCS":
+ rxtone = _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[1])
+ elif rx_mode == "Tone":
+ rxtone = int(mem.ctone * 10) + 0x8000
+
+ _mem.rxtone = rxtone
+ _mem.txtone = txtone
+
+ LOG.debug("Set TX %s (%i) RX %s (%i)" %
+ (tx_mode, _mem.txtone, rx_mode, _mem.rxtone))
+
+ def set_memory(self, mem):
+ number = mem.number
+
+ _mem = self._memobj.memory[number]
+ _nam = self._memobj.names[number]
+
+ if mem.empty:
+ _mem.set_raw("\x00" * (_mem.size() // 8))
+ self._memobj.valid[number] = 0
+ self._memobj.names[number].set_raw("\x00" * (_nam.size() // 8))
+ return
+
+ _mem.rxfreq = int(mem.freq / 10)
+ if mem.duplex == "off":
+ _mem.txfreq = 0xFFFFFFFF
+ elif mem.duplex == "split":
+ _mem.txfreq = int(mem.offset / 10)
+ elif mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw("\xFF")
+ elif mem.duplex == "+":
+ _mem.txfreq = int(mem.freq / 10) + int(mem.offset / 10)
+ elif mem.duplex == "-":
+ _mem.txfreq = int(mem.freq / 10) - int(mem.offset / 10)
+ else:
+ _mem.txfreq = int(mem.freq / 10)
+ _mem.scan_add = int(mem.skip != "S")
+ _mem.iswide = int(mem.mode == "FM")
+ # set the tone
+ self._set_tone(mem, _mem)
+ # MRT set the scrambler and compander to off by default
+ # MRT This changes them in the channel memory
+ _mem.scrambler = 0
+ _mem.compander = 0
+ # set the power
+ _mem.power = _mem.power & 0x3
+ if mem.power:
+ if _mem.power > 2:
+ _mem.power = 2
+ _mem.power = self.POWER_LEVELS.index(mem.power)
+ else:
+ _mem.power = True
+ # MRT set to mute mode to QT (not QT+DTMF or QT*DTMF) by default
+ # MRT This changes them in the channel memory
+ _mem.mute_mode = 0
+
+ # MRT it is unknown what impact these values have
+ # MRT This changes them in the channel memory to match what
+ # Wouxun CPS shows when creating a channel
+ # MRT It is likely that these are just left as is and not
+ # written to by CPS - bit remnants of 0xFF in the unused memory
+ # _mem.unknown1 = 0
+ # MRT Set to 3 to TO MATCH CPS VALUES
+ _mem.unknown3 = 3
+ # MRT Set to 1 to TO MATCH CPS VALUES
+ _mem.unknown4 = 1
+ # MRT set unknown5 to 1 and unknown6 to 0
+ _mem.unknown5 = 1
+ _mem.unknown6 = 255
+
+ for i in range(0, len(_nam.name)):
+ if i < len(mem.name) and mem.name[i]:
+ _nam.name[i] = ord(mem.name[i])
+ else:
+ _nam.name[i] = 0x0
+ self._memobj.valid[mem.number] = MEM_VALID
+
+ def _get_settings(self):
+ _settings = self._memobj.settings
+ _vfoa = self._memobj.vfoa
+ _vfob = self._memobj.vfob
+ _scan = self._memobj.scan_groups
+ _call = self._memobj.call_groups
+ _callname = self._memobj.call_names
+
+ cfg_grp = RadioSettingGroup("cfg_grp", "Config Settings")
+ vfoa_grp = RadioSettingGroup("vfoa_grp", "VFO A Settings")
+ vfob_grp = RadioSettingGroup("vfob_grp", "VFO B Settings")
+ key_grp = RadioSettingGroup("key_grp", "Key Settings")
+ fmradio_grp = RadioSettingGroup("fmradio_grp", "FM Broadcast Memory")
+ lmt_grp = RadioSettingGroup("lmt_grp", "Rx/Tx Frequency Limits")
+ uhf_lmt_grp = RadioSettingGroup("uhf_lmt_grp", "UHF")
+ vhf_lmt_grp = RadioSettingGroup("vhf_lmt_grp", "VHF")
+ oem_grp = RadioSettingGroup("oem_grp", "OEM Info")
+ scan_grp = RadioSettingGroup("scan_grp", "Scan Group")
+ call_grp = RadioSettingGroup("call_grp", "Call Settings")
+ extra_grp = RadioSettingGroup("extra_grp",
+ "Extra Settings"
+ "\nNOT Changed by RESET or CPS")
+ extra_grp.append(lmt_grp)
+ extra_grp.append(oem_grp)
+ group = RadioSettings(cfg_grp, vfoa_grp, vfob_grp,
+ fmradio_grp, key_grp, scan_grp,
+ call_grp, extra_grp)
+
+ # Call Settings
+ rs = RadioSetting("cur_call_grp", "Current Call Group",
+ RadioSettingValueList(CALLGROUP_LIST,
+ CALLGROUP_LIST[_settings.
+ cur_call_grp]))
+ call_grp.append(rs)
+
+ callchars = "0123456789"
+ for i in range(1, 21):
+ callnum = str(i)
+ _msg = ""
+ _msg1 = str(eval("_callname.call_name"+callnum)).split("\0")[0]
+# MRT - Handle default factory values of 0xFF or
+# non-ascii values in Call Name memory
+ for char in _msg1:
+ if char < chr(0x20) or char > chr(0x7E):
+ # _msg += chr(0x20)
+ _msg += ""
+ else:
+ _msg += str(char)
+ val = RadioSettingValueString(0, 6, _msg)
+ val.set_mutable(True)
+ rs = RadioSetting("call_names.call_name"+callnum,
+ "Call Name "+callnum, val)
+ call_grp.append(rs)
+
+ _codeobj = eval("_call.call_code_"+callnum)
+ _code = "".join([callchars[x] for x in _codeobj if int(x) < 0x0A])
+ val = RadioSettingValueString(3, 6, _code, False)
+ val.set_charset(callchars)
+ rs = RadioSetting("call_code_"+callnum,
+ "Call Code " + callnum, val)
+
+ def apply_call_code(setting, obj):
+ value = []
+ for j in range(0, 6):
+ try:
+ value.append(callchars.index(str(setting.value)[j]))
+ except IndexError:
+ value.append(0xFF)
+ obj.call_code = value
+ rs.set_apply_callback(apply_call_code,
+ eval("_call.call_code_"+callnum))
+ call_grp.append(rs)
+
+ # Configuration Settings
+ #
+ rs = RadioSetting("DspBrtAct", "Display Brightness ACTIVE",
+ RadioSettingValueMap(DSPBRTACT_MAP,
+ _settings.DspBrtAct))
+ cfg_grp.append(rs)
+ rs = RadioSetting("DspBrtSby", "Display Brightness STANDBY",
+ RadioSettingValueList(DSPBRTSBY_LIST,
+ DSPBRTSBY_LIST[_settings.
+ DspBrtSby]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("wxalert", "Weather Alert",
+ RadioSettingValueBoolean(_settings.wxalert))
+ cfg_grp.append(rs)
+ rs = RadioSetting("power_save", "Battery Saver",
+ RadioSettingValueBoolean(_settings.power_save))
+ cfg_grp.append(rs)
+ rs = RadioSetting("theme", "Theme",
+ RadioSettingValueList(
+ THEME_LIST, THEME_LIST[_settings.theme]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("backlight", "Backlight Active Time",
+ RadioSettingValueList(BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.
+ backlight]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("scan_rev", "Scan Mode",
+ RadioSettingValueList(SCANMODE_LIST,
+ SCANMODE_LIST[_settings.
+ scan_rev]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("prich_sw", "Priority Channel Scan",
+ RadioSettingValueBoolean(_settings.prich_sw))
+ cfg_grp.append(rs)
+ rs = RadioSetting("pri_ch",
+ "Priority Channel - Can not be empty Channel",
+ RadioSettingValueInteger(1, 999, _settings.pri_ch))
+ cfg_grp.append(rs)
+ rs = RadioSetting("scan_det", "Scan Mode Tone Detect",
+ RadioSettingValueBoolean(_settings.scan_det))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ToneScnSave", "Tone Scan Save",
+ RadioSettingValueList(TONESCANSAVELIST,
+ TONESCANSAVELIST[_settings.
+ ToneScnSave]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("roger_beep", "Roger Beep",
+ RadioSettingValueList(ROGER_LIST,
+ ROGER_LIST[_settings.
+ roger_beep]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("timeout", "Timeout Timer (TOT)",
+ RadioSettingValueList(
+ TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("toalarm", "Timeout Alarm (TOA)",
+ RadioSettingValueInteger(0, 10, _settings.toalarm))
+ cfg_grp.append(rs)
+ rs = RadioSetting("vox", "VOX",
+ RadioSettingValueList(LIST_10,
+ LIST_10[_settings.vox]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("voice", "Voice Guide",
+ RadioSettingValueBoolean(_settings.voice))
+ cfg_grp.append(rs)
+ rs = RadioSetting("beep", "Keypad Beep",
+ RadioSettingValueBoolean(_settings.beep))
+ cfg_grp.append(rs)
+ rs = RadioSetting("BCL_B", "Busy Channel Lock-out A",
+ RadioSettingValueBoolean(_settings.BCL_A))
+ cfg_grp.append(rs)
+ rs = RadioSetting("BCL_A", "Busy Channel Lock-out B",
+ RadioSettingValueBoolean(_settings.BCL_B))
+ cfg_grp.append(rs)
+ rs = RadioSetting("smuteset", "Secondary Area Mute (SMUTESET)",
+ RadioSettingValueList(SMUTESET_LIST,
+ SMUTESET_LIST[_settings.
+ smuteset]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ani_sw", "ANI-ID Switch (ANI-SW)",
+ RadioSettingValueBoolean(_settings.ani_sw))
+ cfg_grp.append(rs)
+ rs = RadioSetting("dtmf_st", "DTMF Sidetone (SIDETONE)",
+ RadioSettingValueList(DTMFST_LIST,
+ DTMFST_LIST[_settings.
+ dtmf_st]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("alert", "Alert Tone",
+ RadioSettingValueList(ALERTS_LIST,
+ ALERTS_LIST[_settings.alert]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ptt_delay", "PTT-DLY",
+ RadioSettingValueMap(PTTDELAY_TIMES,
+ _settings.ptt_delay))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ptt_id", "PTT-ID",
+ RadioSettingValueList(PTTID_LIST,
+ PTTID_LIST[_settings.ptt_id]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ring_time", "Ring Time",
+ RadioSettingValueList(LIST_10,
+ LIST_10[_settings.ring_time]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("rpt_tone", "Repeater Tone",
+ RadioSettingValueBoolean(_settings.rpt_tone))
+ cfg_grp.append(rs)
+ rs = RadioSetting("stopwatch", "Timer / Stopwatch",
+ RadioSettingValueBoolean(_settings.stopwatch))
+ cfg_grp.append(rs)
+ rs = RadioSetting("autolock", "Autolock",
+ RadioSettingValueBoolean(_settings.autolock))
+ cfg_grp.append(rs)
+ rs = RadioSetting("keylock", "Keypad Lock",
+ RadioSettingValueBoolean(_settings.keylock))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ponmsg", "Poweron message",
+ RadioSettingValueList(
+ PONMSG_LIST, PONMSG_LIST[_settings.ponmsg]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("dtmf_tx_time", "DTMF Transmit Time",
+ RadioSettingValueMap(DTMF_TIMES,
+ _settings.dtmf_tx_time))
+ cfg_grp.append(rs)
+ rs = RadioSetting("dtmf_interval", "DTMF Interval Time",
+ RadioSettingValueMap(DTMF_TIMES,
+ _settings.dtmf_interval))
+ cfg_grp.append(rs)
+ rs = RadioSetting("channel_menu", "Menu available in channel mode",
+ RadioSettingValueBoolean(_settings.channel_menu))
+ cfg_grp.append(rs)
+
+ pswdchars = "0123456789"
+ _msg = str(_settings.mode_sw_pwd).split("\0")[0]
+ val = RadioSettingValueString(0, 6, _msg, False)
+ val.set_mutable(True)
+ val.set_charset(pswdchars)
+ rs = RadioSetting("mode_sw_pwd", "Mode SW Pwd", val)
+ cfg_grp.append(rs)
+
+ _msg = str(_settings.reset_pwd).split("\0")[0]
+ val = RadioSettingValueString(0, 6, _msg, False)
+ val.set_charset(pswdchars)
+ val.set_mutable(True)
+ rs = RadioSetting("reset_pwd", "Reset Pwd", val)
+ cfg_grp.append(rs)
+
+ # Key Settings
+ #
+ _msg = str(_settings.dispstr).split("\0")[0]
+ val = RadioSettingValueString(0, 15, _msg)
+ val.set_mutable(True)
+ rs = RadioSetting("dispstr",
+ "Display Message - Interface Display Edit", val)
+ key_grp.append(rs)
+
+ dtmfchars = "0123456789"
+ _codeobj = _settings.ani_code
+ _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x0A])
+ val = RadioSettingValueString(3, 6, _code, False)
+ val.set_charset(dtmfchars)
+ rs = RadioSetting("ani_code", "ANI Code", val)
+
+ def apply_ani_id(setting, obj):
+ value = []
+ for j in range(0, 6):
+ try:
+ value.append(dtmfchars.index(str(setting.value)[j]))
+ except IndexError:
+ value.append(0xFF)
+ obj.ani_code = value
+ rs.set_apply_callback(apply_ani_id, _settings)
+ key_grp.append(rs)
+
+ rs = RadioSetting("pf1_shrt", "PF1 SHORT Key function",
+ RadioSettingValueList(
+ PFKEYSHORT_LIST,
+ PFKEYSHORT_LIST[_settings.pf1_shrt]))
+ key_grp.append(rs)
+ rs = RadioSetting("pf1_long", "PF1 LONG Key function",
+ RadioSettingValueList(
+ PFKEYLONG_LIST,
+ PFKEYLONG_LIST[_settings.pf1_long]))
+ key_grp.append(rs)
+ rs = RadioSetting("pf2_shrt", "PF2 SHORT Key function",
+ RadioSettingValueList(
+ PFKEYSHORT_LIST,
+ PFKEYSHORT_LIST[_settings.pf2_shrt]))
+ key_grp.append(rs)
+ rs = RadioSetting("pf2_long", "PF2 LONG Key function",
+ RadioSettingValueList(
+ PFKEYLONG_LIST,
+ PFKEYLONG_LIST[_settings.pf2_long]))
+ key_grp.append(rs)
+
+# SCAN GROUP settings
+ rs = RadioSetting("ScnGrpA_Act", "Scan Group A Active",
+ RadioSettingValueList(SCANGRP_LIST,
+ SCANGRP_LIST[_settings.
+ ScnGrpA_Act]))
+ scan_grp.append(rs)
+ rs = RadioSetting("ScnGrpB_Act", "Scan Group B Active",
+ RadioSettingValueList(SCANGRP_LIST,
+ SCANGRP_LIST[_settings.
+ ScnGrpB_Act]))
+ scan_grp.append(rs)
+
+ for i in range(1, 11):
+ scgroup = str(i)
+
+ rs = RadioSetting("scan_groups.Group_lower"+scgroup,
+ "Scan Group "+scgroup+" Lower",
+ RadioSettingValueInteger(1, 999,
+ eval("self._memobj. \
+ scan_groups. \
+ Group_lower" +
+ scgroup)))
+ scan_grp.append(rs)
+
+ rs = RadioSetting("scan_groups.Group_upper"+scgroup,
+ "Scan Group "+scgroup+" Upper",
+ RadioSettingValueInteger(1, 999,
+ eval("self._memobj. \
+ scan_groups. \
+ Group_upper" +
+ scgroup)))
+ scan_grp.append(rs)
+
+ # VFO A Settings
+ #
+ rs = RadioSetting("work_mode_a", "VFO A Workmode",
+ RadioSettingValueList(WORKMODE_LIST,
+ WORKMODE_LIST[_settings.
+ work_mode_a]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("work_ch_a", "VFO A Work Channel",
+ RadioSettingValueInteger(1, 999,
+ _settings.work_ch_a))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.rxfreq", "VFO A Rx Frequency (MHz)",
+ RadioSettingValueFloat(
+ 30.00000, 999.999999,
+ (_vfoa.rxfreq / 100000.0), 0.000001, 6))
+ vfoa_grp.append(rs)
+
+ rs = RadioSetting("vfoa.rxtone", "VFOA Rx tone",
+ RadioSettingValueMap(
+ TONE_MAP, _vfoa.rxtone))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.txtone", "VFOA Tx tone",
+ RadioSettingValueMap(
+ TONE_MAP, _vfoa.txtone))
+ vfoa_grp.append(rs)
+
+
+# MRT - AND power with 0x03 to display only the lower 2 bits for
+# power level and to clear the upper bits
+# MRT - any bits set in the upper 2 bits will cause radio to show
+# invalid values for power level and a display glitch
+# MRT - when PTT is pushed
+ _vfoa.power = _vfoa.power & 0x3
+ if _vfoa.power > 2:
+ _vfoa.power = 2
+ rs = RadioSetting("vfoa.power", "VFO A Power",
+ RadioSettingValueList(
+ POWER_LIST, POWER_LIST[_vfoa.power]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.iswide", "VFO A Wide/Narrow",
+ RadioSettingValueList(
+ BANDWIDTH_LIST, BANDWIDTH_LIST[_vfoa.iswide]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.mute_mode", "VFO A Mute (SP Mute)",
+ RadioSettingValueList(
+ SPMUTE_LIST, SPMUTE_LIST[_vfoa.mute_mode]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("VFO_repeater_a", "VFO A Repeater",
+ RadioSettingValueBoolean(_settings.VFO_repeater_a))
+ vfoa_grp.append(rs)
+
+ rs = RadioSetting("vfoa.scrambler", "VFO A Descramble",
+ RadioSettingValueList(
+ SCRAMBLE_LIST, SCRAMBLE_LIST[_vfoa.scrambler]))
+ vfoa_grp.append(rs)
+
+ rs = RadioSetting("vfoa.cmpndr", "VFO A Compander",
+ RadioSettingValueList(
+ ONOFF_LIST, ONOFF_LIST[_vfoa.cmpndr]))
+ vfoa_grp.append(rs)
+
+ rs = RadioSetting("vfoa.step", "VFO A Step (kHz)",
+ RadioSettingValueList(
+ STEP_LIST, STEP_LIST[_vfoa.step]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.squelch", "VFO A Squelch",
+ RadioSettingValueList(
+ LIST_10, LIST_10[_vfoa.squelch]))
+ vfoa_grp.append(rs)
+
+ # VFO B Settings
+ rs = RadioSetting("work_mode_b", "VFO B Workmode",
+ RadioSettingValueList(WORKMODE_LIST,
+ WORKMODE_LIST[_settings.
+ work_mode_b]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("work_ch_b", "VFO B Work Channel",
+ RadioSettingValueInteger(1, 999,
+ _settings.work_ch_b))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.rxfreq", "VFO B Rx Frequency (MHz)",
+ RadioSettingValueFloat(
+ 30.000000, 999.999999,
+ (_vfob.rxfreq / 100000.0), 0.000001, 6))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.rxtone", "VFOB Rx tone",
+ RadioSettingValueMap(
+ TONE_MAP, _vfob.rxtone))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.txtone", "VFOB Tx tone",
+ RadioSettingValueMap(
+ TONE_MAP, _vfob.txtone))
+ vfob_grp.append(rs)
+
+# MRT - AND power with 0x03 to display only the lower 2 bits for
+# power level and to clear the upper bits
+# MRT - any bits set in the upper 2 bits will cause radio to show
+# invalid values for power level and a display glitch
+# MRT - when PTT is pushed
+ _vfob.power = _vfob.power & 0x3
+ if _vfob.power > 2:
+ _vfob.power = 2
+ rs = RadioSetting("vfob.power", "VFO B Power",
+ RadioSettingValueList(
+ POWER_LIST, POWER_LIST[_vfob.power]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.iswide", "VFO B Wide/Narrow",
+ RadioSettingValueList(
+ BANDWIDTH_LIST, BANDWIDTH_LIST[_vfob.iswide]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.mute_mode", "VFO B Mute (SP Mute)",
+ RadioSettingValueList(
+ SPMUTE_LIST, SPMUTE_LIST[_vfob.mute_mode]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("VFO_repeater_b", "VFO B Repeater",
+ RadioSettingValueBoolean(_settings.VFO_repeater_b))
+ vfob_grp.append(rs)
+
+ rs = RadioSetting("vfob.scrambler", "VFO B Descramble",
+ RadioSettingValueList(
+ SCRAMBLE_LIST, SCRAMBLE_LIST[_vfob.scrambler]))
+ vfob_grp.append(rs)
+
+ rs = RadioSetting("vfob.cmpndr", "VFO B Compander",
+ RadioSettingValueList(
+ ONOFF_LIST, ONOFF_LIST[_vfob.cmpndr]))
+ vfob_grp.append(rs)
+
+ rs = RadioSetting("vfob.step", "VFO B Step (kHz)",
+ RadioSettingValueList(
+ STEP_LIST, STEP_LIST[_vfob.step]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.squelch", "VFO B Squelch",
+ RadioSettingValueList(
+ LIST_10, LIST_10[_vfob.squelch]))
+ vfob_grp.append(rs)
+
+# FM RADIO PRESETS
+
+# memory stores raw integer value like 760
+# radio will divide 760 by 10 and interpret correctly at 76.0Mhz
+ for i in range(1, 21):
+ chan = str(i)
+ rs = RadioSetting("FM_radio" + chan, "FM Preset" + chan,
+ RadioSettingValueFloat(76.0, 108.0,
+ eval("_settings. \
+ FM_radio" +
+ chan)/10.0,
+ 0.1, 1))
+ fmradio_grp.append(rs)
+
+# Freq Limits settings
+ #
+ rs = RadioSetting("vhf_limits.rx_start", "VHF RX Lower Limit (MHz)",
+ RadioSettingValueFloat(
+ 30.000000, 299.999999,
+ (self._memobj.vhf_limits.rx_start / 100000.0),
+ 0.000001, 6))
+
+ lmt_grp.append(rs)
+ rs = RadioSetting("vhf_limits.rx_stop", "VHF RX Upper Limit (MHz)",
+ RadioSettingValueFloat(
+ 30.000000, 299.999999,
+ (self._memobj.vhf_limits.rx_stop / 100000.0),
+ 0.000001, 6))
+ lmt_grp.append(rs)
+
+ rs = RadioSetting("vhf_limits.tx_start", "VHF TX Lower Limit (MHz)",
+ RadioSettingValueFloat(
+ 30.000000, 299.999999,
+ (self._memobj.vhf_limits.tx_start / 100000.0),
+ 0.000001, 6))
+
+ lmt_grp.append(rs)
+ rs = RadioSetting("vhf_limits.tx_stop", "VHF TX Upper Limit (MHz)",
+ RadioSettingValueFloat(
+ 30.000000, 299.999999,
+ (self._memobj.vhf_limits.tx_stop / 100000.0),
+ 0.000001, 6))
+ lmt_grp.append(rs)
+
+# MRT - TX Limits do not appear to change radio's ability
+# to transmit on other freqs.
+# MRT - Appears that the radio firmware prevent Tx
+# on anything other than a valid GMRS Freq
+
+ # rs = RadioSetting("vhf_limits.tx_start", "VHF TX Lower Limit",
+ # RadioSettingValueInteger(
+ # 10000000, 299999999,
+ # self._memobj.vhf_limits.tx_start * 10, 5000))
+ # val.set_mutable(False)
+ # vhf_lmt_grp.append(rs)
+ # rs = RadioSetting("vhf_limits.tx_stop", "VHF TX Upper Limit",
+ # RadioSettingValueInteger(
+ # 10000000, 299999999,
+ # self._memobj.vhf_limits.tx_stop * 10, 5000))
+ # val.set_mutable(False)
+ # vhf_lmt_grp.append(rs)
+
+ rs = RadioSetting("uhf_limits.rx_start", "UHF RX Lower Limit (MHz)",
+ RadioSettingValueFloat(
+ 300.000000, 999.999999,
+ (self._memobj.uhf_limits.rx_start / 100000.0),
+ 0.000001, 6))
+ lmt_grp.append(rs)
+ rs = RadioSetting("uhf_limits.rx_stop", "UHF RX Upper Limit (MHz)",
+ RadioSettingValueFloat(
+ 300.000000, 999.999999,
+ (self._memobj.uhf_limits.rx_stop / 100000.0),
+ 0.000001, 6))
+ lmt_grp.append(rs)
+
+ rs = RadioSetting("uhf_limits.tx_start", "UHF TX Lower Limit (MHz)",
+ RadioSettingValueFloat(
+ 300.000000, 999.999999,
+ (self._memobj.uhf_limits.tx_start / 100000.0),
+ 0.000001, 6))
+ lmt_grp.append(rs)
+ rs = RadioSetting("uhf_limits.tx_stop", "UHF TX Upper Limit (MHz)",
+ RadioSettingValueFloat(
+ 300.000000, 999.999999,
+ (self._memobj.uhf_limits.tx_stop / 100000.0),
+ 0.000001, 6))
+ lmt_grp.append(rs)
+
+ # rs = RadioSetting("uhf_limits.tx_start", "UHF TX Lower Limit",
+ # RadioSettingValueInteger(
+ # 300000000, 999999999,
+ # self._memobj.uhf_limits.tx_start * 10, 5000))
+ # uhf_lmt_grp.append(rs)
+ # rs = RadioSetting("uhf_limits.tx_stop", "UHF TX Upper Limit",
+ # RadioSettingValueInteger(
+ # 300000000, 999999999,
+ # self._memobj.uhf_limits.tx_stop * 10, 5000))
+ # uhf_lmt_grp.append(rs)
+
+
+# OEM info
+ #
+ def _decode(lst):
+ _str = ''.join([chr(int(c)) for c in lst
+ if chr(int(c)) in chirp_common.CHARSET_ASCII])
+ return _str
+
+ def do_nothing(setting, obj):
+ return
+
+ _str = _decode(self._memobj.oem_info.model)
+ val = RadioSettingValueString(0, 8, _str)
+ val.set_mutable(True)
+ rs = RadioSetting("oem_info.model", "Model / Bottom Banner", val)
+ oem_grp.append(rs)
+ _str = _decode(self._memobj.oem_info.oem1)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("oem_info.oem1", "OEM String 1", val)
+ rs.set_apply_callback(do_nothing, _settings)
+ oem_grp.append(rs)
+ _str = _decode(self._memobj.oem_info.oem2)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("oem_info.oem2", "Firmware Version ??", val)
+ rs.set_apply_callback(do_nothing, _settings)
+ oem_grp.append(rs)
+ # _str = _decode(self._memobj.oem_info.version)
+ # val = RadioSettingValueString(0, 15, _str)
+ # val.set_mutable(False)
+ # rs = RadioSetting("oem_info.version", "Software Version", val)
+ # rs.set_apply_callback(do_nothing, _settings)
+ # oem_grp.append(rs)
+ _str = _decode(self._memobj.oem_info.date)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("oem_info.date", "OEM Date", val)
+ rs.set_apply_callback(do_nothing, _settings)
+ oem_grp.append(rs)
+
+ return group
+
+ def get_settings(self):
+ try:
+ return self._get_settings()
+ except:
+ import traceback
+ LOG.error("Failed to parse settings: %s", traceback.format_exc())
+ return None
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ else:
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ if self._is_freq(element):
+ # setattr(obj, setting, int(element.value / 10))
+ # MRT rescale freq values to match radio
+ # expected values
+ setattr(obj, setting,
+ int(element.values()[0]._current *
+ 100000.0))
+ elif self._is_fmradio(element):
+ # MRT rescale FM Radio values to match radio
+ # expected values
+ setattr(obj, setting,
+ int(element.values()[0]._current * 10.0))
+ else:
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ def _is_freq(self, element):
+ return "rxfreq" in element.get_name() or \
+ "txoffset" in element.get_name() or \
+ "rx_start" in element.get_name() or \
+ "rx_stop" in element.get_name() or \
+ "tx_start" in element.get_name() or \
+ "tx_stop" in element.get_name()
+
+ def _is_fmradio(self, element):
+ return "FM_radio" in element.get_name()
diff --git a/chirp/drivers/kguv8d.py b/chirp/drivers/kguv8d.py
index 5fe16b4..3b921f9 100644
--- a/chirp/drivers/kguv8d.py
+++ b/chirp/drivers/kguv8d.py
@@ -281,7 +281,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
VENDOR = "Wouxun"
MODEL = "KG-UV8D"
_model = "KG-UV8D"
- _file_ident = "KGUV8D"
+ _file_ident = b"KGUV8D"
BAUD_RATE = 19200
POWER_LEVELS = [chirp_common.PowerLevel("L", watts=1),
chirp_common.PowerLevel("H", watts=5)]
@@ -376,7 +376,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
self._mmap = self._download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -393,7 +393,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
return self._do_download(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -426,7 +426,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
self._do_upload(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
return
@@ -628,9 +628,9 @@ class KGUV8DRadio(chirp_common.CloneModeRadio,
_nam = self._memobj.names[number]
if mem.empty:
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
self._memobj.valid[number] = 0
- self._memobj.names[number].set_raw("\x00" * (_nam.size() / 8))
+ self._memobj.names[number].set_raw("\x00" * (_nam.size() // 8))
return
_mem.rxfreq = int(mem.freq / 10)
diff --git a/chirp/drivers/kguv8dplus.py b/chirp/drivers/kguv8dplus.py
index b4a0cb8..33739d7 100644
--- a/chirp/drivers/kguv8dplus.py
+++ b/chirp/drivers/kguv8dplus.py
@@ -300,7 +300,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
VENDOR = "Wouxun"
MODEL = "KG-UV8D Plus"
_model = "KG-UV8D"
- _file_ident = "kguv8dplus"
+ _file_ident = b"kguv8dplus"
BAUD_RATE = 19200
POWER_LEVELS = [chirp_common.PowerLevel("L", watts=1),
chirp_common.PowerLevel("H", watts=5)]
@@ -387,7 +387,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
#
@classmethod
def match_model(cls, filedata, filename):
- return cls._file_ident in 'kg' + filedata[0x426:0x430].replace('(', '').replace(')', '').lower()
+ return cls._file_ident in b'kg' + filedata[0x426:0x430].replace(b'(', b'').replace(b')', b'').lower()
def _identify(self):
"""Do the identification dance"""
@@ -418,7 +418,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
self._mmap = self._download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -435,7 +435,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
return self._do_download(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -467,7 +467,7 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
self._do_upload(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
return
@@ -666,9 +666,9 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
_nam = self._memobj.names[number]
if mem.empty:
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
self._memobj.valid[number] = 0
- self._memobj.names[number].set_raw("\x00" * (_nam.size() / 8))
+ self._memobj.names[number].set_raw("\x00" * (_nam.size() // 8))
return
_mem.rxfreq = int(mem.freq / 10)
@@ -1103,9 +1103,15 @@ class KGUV8DPlusRadio(chirp_common.CloneModeRadio,
setattr(obj, setting, int(element.value)/10)
else:
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
def _is_freq(self, element):
- return "rxfreq" in element.get_name() or "txoffset" in element.get_name() or "rx_start" in element.get_name() or "rx_stop" in element.get_name() or "tx_start" in element.get_name() or "tx_stop" in element.get_name() \ No newline at end of file
+ return "rxfreq" in element.get_name() \
+ or "txoffset" in element.get_name() \
+ or "rx_start" in element.get_name() \
+ or "rx_stop" in element.get_name() \
+ or "tx_start" in element.get_name() \
+ or "tx_stop" in element.get_name()
+
diff --git a/chirp/drivers/kguv8e.py b/chirp/drivers/kguv8e.py
index b76f0e5..7e0d035 100644
--- a/chirp/drivers/kguv8e.py
+++ b/chirp/drivers/kguv8e.py
@@ -302,7 +302,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
VENDOR = "Wouxun"
MODEL = "KG-UV8E"
_model = "KG-UV8D-A"
- _file_ident = "kguv8e" # lowercase
+ _file_ident = b"kguv8e" # lowercase
BAUD_RATE = 19200
POWER_LEVELS = [chirp_common.PowerLevel("L", watts=1),
chirp_common.PowerLevel("H", watts=5)]
@@ -337,7 +337,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
try:
self.pipe.write(_header)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def _read_record(self):
@@ -392,7 +392,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
@classmethod
def match_model(cls, filedata, filename):
id = cls._file_ident
- return cls._file_ident in 'kg' + filedata[0x426:0x430].replace('(', '').replace(')', '').lower()
+ return cls._file_ident in b'kg' + filedata[0x426:0x430].replace(b'(', b'').replace(b')', b'').lower()
def _identify(self):
"""Do the identification dance"""
@@ -423,7 +423,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
self._mmap = self._download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -440,7 +440,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
return self._do_download(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -448,7 +448,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
# allocate & fill memory
image = ""
for i in range(start, end, blocksize):
- req = chr(i / 256) + chr(i % 256) + chr(blocksize)
+ req = chr(i // 256) + chr(i % 256) + chr(blocksize)
self._write_record(CMD_RD, req)
cs_error, resp = self._read_record()
if cs_error:
@@ -472,14 +472,14 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
self._do_upload(0, 32768, 64)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
return
def _do_upload(self, start, end, blocksize):
ptr = start
for i in range(start, end, blocksize):
- req = chr(i / 256) + chr(i % 256)
+ req = chr(i // 256) + chr(i % 256)
chunk = self.get_mmap()[ptr:ptr + blocksize]
self._write_record(CMD_WR, req + chunk)
# ~ LOG.debug(util.hexprint(req + chunk))
@@ -523,7 +523,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_bands = [(134000000, 175000000), # supports 2m
(220000000, 260000000), # supports 1.25m
- (400000000, 520000000)] # supports 70cm
+ (350000000, 520000000)] # supports 70cm
rf.valid_characters = chirp_common.CHARSET_ASCII
rf.memory_bounds = (1, 999) # 999 memories
rf.valid_tuning_steps = STEPS
@@ -677,9 +677,9 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
_nam = self._memobj.names[number]
if mem.empty:
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
self._memobj.valid[number] = 0
- self._memobj.names[number].set_raw("\x00" * (_nam.size() / 8))
+ self._memobj.names[number].set_raw("\x00" * (_nam.size() // 8))
return
_mem.rxfreq = int(mem.freq / 10)
@@ -1041,12 +1041,12 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
rs = RadioSetting("uhf_limits.rx_start", "UHF RX Lower Limit",
RadioSettingValueInteger(
- 400000000, 520000000,
+ 350000000, 520000000,
self._memobj.uhf_limits.rx_start * 10, 5000))
uhf_lmt_grp.append(rs)
rs = RadioSetting("uhf_limits.rx_stop", "UHF RX Upper Limit",
RadioSettingValueInteger(
- 400000000, 520000000,
+ 350000000, 520000000,
self._memobj.uhf_limits.rx_stop * 10, 5000))
uhf_lmt_grp.append(rs)
rs = RadioSetting("uhf_limits.tx_start", "UHF TX Lower Limit",
@@ -1138,7 +1138,7 @@ class KGUV8ERadio(chirp_common.CloneModeRadio,
setattr(obj, setting, int(element.value)/10)
else:
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/kguv920pa.py b/chirp/drivers/kguv920pa.py
new file mode 100644
index 0000000..d106763
--- /dev/null
+++ b/chirp/drivers/kguv920pa.py
@@ -0,0 +1,1407 @@
+# Copyright 2022 Matthew Handley <kf7tal@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""Wouxun KG-UV920P-A radio management module based"""
+
+import time
+import os
+import logging
+from chirp import util, chirp_common, bitwise, memmap, errors, directory
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueInteger, RadioSettingValueString, \
+ RadioSettingValueMap, RadioSettingValueFloat, RadioSettings, \
+ InvalidValueError
+
+LOG = logging.getLogger(__name__)
+
+CMD_ID = 0x80
+CMD_END = 0x81
+CMD_RD = 0x82
+CMD_WR = 0x83
+
+CHARSET_NUMERIC = "0123456789"
+CHARSET = "0123456789" + \
+ ":;<=>?@" + \
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + \
+ "[\]^_`" + \
+ "abcdefghijklmnopqrstuvwxyz" + \
+ "{|}~\x4E" + \
+ " !\"#$%&'()*+,-./"
+
+MUTE_MODE_MAP = [('QT', 0b01),
+ ('QT*DTMF', 0b10),
+ ('QT+DTMF', 0b11)]
+STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 30.0, 50.0, 100.0]
+STEP_LIST = [str(x) for x in STEPS]
+
+M_POWER_MAP = [('10', 1),
+ ('20', 2)]
+ROGER_LIST = ["Off", "BOT", "EOT", "Both"]
+VOICE_LIST = ["Off", "Chinese", "English"]
+SC_REV_MAP = [('Timeout (TO)', 1),
+ ('Carrier (CO)', 2),
+ ('Stop (SE)', 3)]
+TOT_MAP = [('%d' % i, int('%02d' % i, 16)) for i in range(1, 61)]
+TOA_MAP = [('Off', 0)] + \
+ [('%d' % i, int('%02d' % i, 16)) for i in range(1, 11)]
+RING_MAP = [('Off', 0)] + \
+ [('%d' % i, int('%02d' % i, 16)) for i in range(1, 11)]
+DTMF_ST_LIST = ["Off", "DT-ST", "ANI-ST", "DT+ANI"]
+PTT_ID_LIST = ["BOT", "EOT", "Both"]
+PTT_ID_MAP = [('BOT', 1),
+ ('EOT', 2),
+ ('Both', 3)]
+BACKLIGHT_LIST = ["Off", "White", "Blue", "Green"]
+SPEAKER_MAP = [('1', 1),
+ ('2', 2),
+ ('1+2', 3)]
+RPT_MODE_LIST = ["Off", "X-DIRPT", "X-TWRPT", "CRPT-RX", "CRPT-TX"]
+APO_TIME_LIST = ["Off", "30", "60", "90", "120", "150"]
+ALERT_MAP = [('1750', 1),
+ ('2100', 2),
+ ('1000', 3),
+ ('1450', 4)]
+FAN_MODE_LIST = ["TX", "Hi-Temp/TX", "Always"]
+SCAN_GROUP_LIST = ["All", "1", "2", "3", "4"]
+WORKMODE_MAP = [('VFO', 1),
+ ('Ch. No.', 2),
+ ('Ch. No.+Freq.', 3),
+ ('Ch. No.+Name', 4)]
+AB_LIST = ["A", "B"]
+POWER_MAP = [('L', 0),
+ ('M', 1),
+ ('H', 3)]
+BANDWIDTH_MAP = [('NFM', 0b11),
+ ('FM', 0b00)]
+SCRAMBLER_LIST = ["Off", "1", "2", "3", "4", "5", "6", "7", "8"]
+ANS_LIST = ["Off", "Normal", "Strong"]
+DTMF_TIMES = [str(x) for x in range(80, 501, 20)]
+DTMF_INTERVALS = [str(x) for x in range(60, 501, 20)]
+ROGER_TIMES = [str(x) for x in range(20, 1001, 20)]
+PTT_ID_DELAY_MAP = [(str(x), x/100) for x in range(100, 1001, 100)]
+ROGER_INTERVALS = ROGER_TIMES
+TONE_MAP = [('Off', 0x0000)] + \
+ [('%.1f' % tone, int(tone * 10)) for tone in chirp_common.TONES] + \
+ [('DN%d' % tone, int(0x8000 + tone * 10))
+ for tone in chirp_common.DTCS_CODES] + \
+ [('DR%d' % tone, int(0xC000 + tone * 10))
+ for tone in chirp_common.DTCS_CODES]
+DUPLEX_LIST = ["Off", "+", "-"]
+
+# structure elements whose name starts with x are currently unidentified
+_MEM_FORMAT = """
+ #seekto 0x0040;
+ struct {
+ u8 left[8];
+ u8 right[8];
+ } ponmsg;
+
+ // Limit changes here don't persist, so may be incorrect. Currently unused
+ // in driver.
+ #seekto 0x0070;
+ struct {
+ u16 uhf_rx_start; // 0x0070
+ u16 uhf_rx_stop; // 0x0072
+ u16 vhf_rx_start; // 0x0074
+ u16 vhf_rx_stop; // 0x0076
+
+ u16 uhf_tx_start; // 0x0078
+ u16 uhf_tx_stop; // 0x007A
+ u16 vhf_tx_start; // 0x007C
+ u16 vhf_tx_stop; // 0x007E
+ } limits;
+
+ #seekto 0x0068;
+ struct {
+ u8 unknown1[8]; // 0x0068
+ u8 x0070[368];
+ u8 x01E0[8];
+ u8 x01E8[8];
+ u8 model[8]; // 0x01F0
+ u8 date[8];
+ u8 oem1[8];
+ u8 oem2[8];
+ u8 unknown2[8];
+ u8 unknown3[8];
+ } oem_info;
+
+ #seekto 0x0250;
+ struct {
+ u32 rxfreq;
+ u32 txoffset;
+ u16 txtone;
+ u16 rxtone;
+ u8 unknown1_7downto5:3,
+ mute_mode:2,
+ unknown1_3downto0:3;
+ u8 named:1,
+ scan_add:1
+ power:2,
+ unknown2_32:2,
+ isnarrow:2;
+ u8 unknown3_7downto2:6,
+ duplex:2;
+ u8 unknown4:3,
+ compander:1
+ scrambler:4;
+ } vfoa;
+
+ #seekto 0x0260;
+ struct {
+ u32 rxfreq;
+ u32 txoffset;
+ u16 txtone;
+ u16 rxtone;
+ u8 unknown1_7downto5:3,
+ mute_mode:2,
+ unknown1_3downto0:3;
+ u8 named:1,
+ scan_add:1
+ power:2,
+ unknown2_3downto2:2,
+ isnarrow:2;
+ u8 unknown3_7downto2:6,
+ duplex:2;
+ u8 unknown4:3,
+ compander:1
+ scrambler:4;
+ } vfob;
+
+ #seekto 0x0270;
+ struct {
+ u8 rc_power; // 0x0270
+ u8 voice; // 0x0271
+ u8 tot; // 0x0272
+ u8 toa; // 0x0273
+ u8 roger; // 0x0274
+ u8 sc_rev; // 0x0275
+ u8 dtmf_st; // 0x0276
+ u8 ptt_id; // 0x0277
+ u8 ring; // 0x0278
+ u8 ani_sw; // 0x0279
+ u8 x027A;
+ u8 alert; // 0x027B
+ u8 bcl_a; // 0x027C
+ u8 pri_ch_sw; // 0x027D
+ u8 scan_group; // 0x027E
+ u8 ptt_id_delay; // 0x027F
+
+ u8 x0280;
+ u8 x0281;
+ u8 beep; // 0x0282
+ u8 x0283;
+ u8 x0284;
+ u8 tx_led; // 0x0285
+ u8 wt_led; // 0x0286
+ u8 rx_led; // 0x0287
+ u8 active_display; // 0x0288
+ u8 workmode_a; // 0x0289
+ u8 workmode_b; // 0x028A
+ u8 squelch_a; // 0x028B
+ u8 squelch_b; // 0x028C
+ u8 step_a; // 0x028D
+ u8 step_b; // 0x028E
+ u8 single_display; // 0x028F
+
+ u8 x0290;
+ u16 work_cha; // 0x0291
+ u8 x0293;
+ u16 work_chb; // 0x0294
+ u8 dtmf_time; // 0x0296
+ u8 x0297;
+ u8 dtmf_interval; // 0x0298
+ u8 x0299;
+ u16 pri_ch; // 0x029A
+ u8 x029C;
+ u8 x029D;
+ u8 speaker; // 0x029E
+ u8 x029F;
+
+ u8 rpt_spk; // 0x02A0
+ u8 rpt_ptt; // 0x02A1
+ u8 autolock; // 0x02A2
+ u8 apo_time; // 0x02A3
+ u8 low_v; // 0x02A4
+ u8 fan_mode; // 0x02A5
+ u8 x02A6;
+ u8 rc_sw; // 0x02A7
+ u8 x02A8;
+ u8 roger_time; // 0x02A9
+ u8 roger_int; // 0x02AA
+ u8 bcl_b; // 0x02AB
+ u8 m_power_set; // 0x02AC
+ u8 x02AD;
+ u8 ans; // 0x02AE
+ u8 x02AF;
+
+ u8 ani[3]; // 0x02B0
+ u8 x02B3;
+ u8 ani_mcc[3]; // 0x02B4
+ u8 x02B7;
+ u8 ani_scc[3]; // 0x02B8
+ u8 x02BB;
+ u8 ani_ctrl[3]; // 0x02BC
+ u8 x02BF;
+
+ u8 roger_begin[4]; // 0x02C0
+ u8 roger_end[4]; // 0x02C4
+ u8 x02C8[8];
+
+ u16 grp1_lower; // 0x02D0
+ u16 grp1_upper;
+ u16 grp2_lower; // 0x02D4
+ u16 grp2_upper;
+ u16 grp3_lower; // 0x02D8
+ u16 grp3_upper;
+ u16 grp4_lower; // 0x02DC
+ u16 grp4_upper;
+
+ u8 x02E0[16];
+ u8 x02F0[16];
+ u8 x0300[16];
+
+ u8 x0310[7];
+ u8 rpt_tone; // 0x0317
+ u8 x0318[8];
+
+ u8 x0320[16];
+ u8 x0330[16];
+ u8 x0340[16];
+ u8 x0350[16];
+ u8 x0360[16];
+ u8 x0370[16];
+ u8 x0380[16];
+ u8 x0390[16];
+ u8 x03A0[16];
+ u8 x03B0[16];
+
+ u8 rpt_mode; // 0x03C0
+ u8 x03C1;
+ u8 x03C2;
+ u8 x03C3;
+ u8 x03C4;
+ u8 x03C5;
+ u8 scan_det; // 0x0x3C6
+ } settings;
+
+ #seekto 0x0400;
+ struct {
+ u16 freq;
+ } fm_preset[20];
+
+ #seekto 0x0800;
+ struct {
+ u32 rxfreq;
+ u32 txfreq;
+ u16 txtone;
+ u16 rxtone;
+ u8 unknown1_7downto5:3,
+ mute_mode:2,
+ unknown1_3downto0:3;
+ u8 named:1,
+ scan_add:1
+ power:2,
+ unknown2_32:2,
+ isnarrow:2;
+ u8 unknown3_7downto2:6,
+ shift_dir:2;
+ u8 unknown4:3,
+ compander:1
+ scrambler:4;
+ } memory[999];
+
+ #seekto 0x4700;
+ struct {
+ u8 name[8];
+ } names[999];
+ """
+
+
+def _checksum(data):
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+ return cs % 16
+
+
+def _str_decode(in_str):
+ out_str = ''
+ for c in in_str:
+ if isinstance(c, str):
+ c = ord(c)
+ if c < len(CHARSET):
+ out_str += CHARSET[c]
+ return out_str.rstrip()
+
+
+def _str_encode(in_str):
+ out_str = ''
+ for c in in_str:
+ try:
+ out_str += chr(CHARSET.index(c))
+ except ValueError:
+ pass
+ while len(out_str) < 8:
+ out_str += chr(CHARSET.index(' '))
+ return out_str
+
+
+def _freq_decode(in_freq, bytes=4):
+ out_freq = 0
+ for i in range(bytes*2):
+ out_freq += (in_freq & 0xF) * (10 ** i)
+ in_freq = in_freq >> 4
+ if bytes == 4:
+ return out_freq * 10
+ elif bytes == 2:
+ return out_freq * 100000
+
+
+def _freq_encode(in_freq, bytes=4):
+ if bytes == 4:
+ return int('%08d' % (in_freq / 10), 16)
+ elif bytes == 2:
+ return int('%04d' % (in_freq / 100000), 16)
+
+
+def _ani_decode(in_ani):
+ return ''.join(['%02x' % b for b in in_ani]).strip('c')
+
+
+def _ani_encode(in_ani):
+ ani_str = ''
+ while len(in_ani) < 6:
+ in_ani += 'c'
+ for i in range(3):
+ ani_str += chr(int(in_ani[i*2:i*2+2], 16))
+ return ani_str
+
+
+def _chnum_decode(in_ch):
+ return int(('%04x' % in_ch)[0:3])
+
+
+def _chnum_encode(in_ch):
+ return int('%03d0' % in_ch, 16)
+
+
+def _roger_decode(in_roger):
+ return ''.join(['%02x' % b for b in in_roger]).strip('ef')
+
+
+def _roger_encode(in_roger):
+ roger_str = ''
+ in_roger = 'e' + in_roger
+ while len(in_roger) < 8:
+ in_roger += 'f'
+ for i in range(4):
+ roger_str += chr(int(in_roger[i*2:i*2+2], 16))
+ return roger_str
+
+
+def _get_tone(_mem, mem):
+ def _get_dcs(val):
+ code = (val & 0x3FF)
+ pol = (val & 0x4000) and "R" or "N"
+ return code, pol
+
+ tpol = False
+ if _mem.txtone != 0xFFFF and (_mem.txtone & 0x8000) == 0x8000:
+ tcode, tpol = _get_dcs(_mem.txtone)
+ mem.dtcs = tcode
+ txmode = "DTCS"
+ elif _mem.txtone != 0xFFFF and _mem.txtone != 0x0:
+ mem.rtone = (_mem.txtone & 0xFff) / 10.0
+ txmode = "Tone"
+ else:
+ txmode = ""
+
+ rpol = False
+ if _mem.rxtone != 0xFFFF and (_mem.rxtone & 0x8000) == 0x8000:
+ rcode, rpol = _get_dcs(_mem.rxtone)
+ mem.rx_dtcs = rcode
+ rxmode = "DTCS"
+ elif _mem.rxtone != 0xFFFF and _mem.rxtone != 0x0:
+ mem.ctone = (_mem.rxtone & 0xFff) / 10.0
+ rxmode = "Tone"
+ else:
+ rxmode = ""
+
+ if txmode == "Tone" and not rxmode:
+ mem.tmode = "Tone"
+ elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
+ mem.tmode = "TSQL"
+ elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
+ mem.tmode = "DTCS"
+ elif rxmode or txmode:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ # always set it even if no dtcs is used
+ mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
+
+ LOG.debug("Got TX %s (%i) RX %s (%i)" %
+ (txmode, _mem.txtone, rxmode, _mem.rxtone))
+
+
+def _set_tone(mem, _mem):
+ def _set_dcs(code, pol):
+ val = (code & 0x3FF) + 0x8000
+ if pol == "R":
+ val += 0x4000
+ return val
+
+ rx_mode = tx_mode = None
+ rxtone = txtone = 0
+
+ if mem.tmode == "Tone":
+ tx_mode = "Tone"
+ rx_mode = None
+ txtone = int(mem.rtone * 10)
+ elif mem.tmode == "TSQL":
+ rx_mode = tx_mode = "Tone"
+ rxtone = txtone = int(mem.ctone * 10)
+ elif mem.tmode == "DTCS":
+ tx_mode = rx_mode = "DTCS"
+ txtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ rxtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[1])
+ elif mem.tmode == "Cross":
+ tx_mode, rx_mode = mem.cross_mode.split("->")
+ if tx_mode == "DTCS":
+ txtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ elif tx_mode == "Tone":
+ txtone = int(mem.rtone * 10)
+ if rx_mode == "DTCS":
+ rxtone = _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[1])
+ elif rx_mode == "Tone":
+ rxtone = int(mem.ctone * 10)
+
+ _mem.rxtone = rxtone
+ _mem.txtone = txtone
+
+ LOG.debug("Set TX %s (%i) RX %s (%i)" %
+ (tx_mode, _mem.txtone, rx_mode, _mem.rxtone))
+
+
+# Support for the Wouxun KG-UV920P-A radio
+# Serial coms are at 19200 baud
+# The data is passed in variable length records
+# Record structure:
+# Offset Usage
+# 0 start of record (\x7e)
+# 1 Command (\x80 Identify \x81 End/Reboot \x82 Read \x83 Write)
+# 2 direction (\xff PC-> Radio, \x00 Radio -> PC)
+# 3 length of payload (excluding header/checksum) (n)
+# 4 payload (n bytes)
+# 4+n+1 checksum - byte sum (% 16) of bytes 1 -> 4+n
+#
+# Memory Read Records:
+# the payload is 3 bytes, first 2 are offset (big endian),
+# 3rd is number of bytes to read
+# Memory Write Records:
+# 2 bytes location + data.
+
+
+@directory.register
+class KGUV920PARadio(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
+
+ """Wouxun KG-UV920P-A"""
+ VENDOR = "Wouxun"
+ MODEL = "KG-UV920P-A"
+ _model = "KG-UV920Rr" # what the radio responds to CMD_ID with
+ _file_ident = b"KGUV920PA"
+ BAUD_RATE = 19200
+ POWER_LEVELS = [chirp_common.PowerLevel("L", watts=5),
+ chirp_common.PowerLevel("M", watts=20),
+ chirp_common.PowerLevel("H", watts=50)]
+ _mmap = ""
+
+ def _write_record(self, cmd, payload=None):
+ # build the packet
+ _packet = '\x7e' + chr(cmd) + '\xff'
+ _length = 0
+ if payload:
+ _length = len(payload)
+ # update the length field
+ _packet += chr(_length)
+ if payload:
+ # add the chars to the packet
+ _packet += payload
+ # calculate and add the checksum to the packet
+ _packet += chr(_checksum(_packet[1:]))
+ LOG.debug("Sent:\n%s" % util.hexprint(_packet))
+ self.pipe.write(_packet)
+
+ def _read_record(self):
+ # read 4 chars for the header
+ _header = self.pipe.read(4)
+ if len(_header) != 4:
+ raise errors.RadioError('Radio did not respond')
+ _length = ord(_header[3])
+ _packet = self.pipe.read(_length)
+ _cs = _checksum(_header[1:])
+ _cs += _checksum(_packet)
+ _cs %= 16
+ try:
+ _rcs = ord(self.pipe.read(1))
+ except TypeError:
+ raise errors.RadioError('Radio did not respond')
+ LOG.debug("_cs =%x", _cs)
+ LOG.debug("_rcs=%x", _rcs)
+ return (_rcs != _cs, _packet)
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return cls._file_ident in filedata[0x400:0x408]
+
+ def _identify(self):
+ """
+ Offset
+ 0:10 Model 'KG-UV920Rr'
+ 11: Not used (limits)
+ """
+ self._write_record(CMD_ID)
+ time.sleep(0.6)
+ _chksum_err, _resp = self._read_record()
+ LOG.debug("Got:\n%s" % util.hexprint(_resp))
+ if _chksum_err:
+ raise Exception("Checksum error")
+ if len(_resp) == 0:
+ raise Exception("Radio not responding")
+ reported_model = _str_decode(''.join(_resp[0:10]))
+ if reported_model != self._model:
+ raise Exception("Unable to identify radio (Got %s, Expected)" %
+ reported_model, self._model)
+
+ def _finish(self):
+ self._write_record(CMD_END)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(_MEM_FORMAT, self._mmap)
+
+ def sync_in(self):
+ try:
+ self._mmap = self._download()
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ self.process_mmap()
+
+ def sync_out(self):
+ self._upload()
+
+ # TODO: This is a dumb, brute force method of downlolading the memory.
+ # it would be smarter to only load the active areas and none of
+ # the padding/unused areas.
+ def _download(self):
+ """Talk to a wouxun KG-UV920P-A and do a download"""
+ try:
+ self._identify()
+ return self._do_download(0, 0x6640, 0x40)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ LOG.exception('Unknown error during download process')
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+
+ def _do_download(self, start, end, blocksize):
+ # allocate & fill memory
+ image = ""
+ for i in range(start, end, blocksize):
+ req = chr(i / 256) + chr(i % 256) + chr(blocksize)
+ self._write_record(CMD_RD, req)
+ cs_error, resp = self._read_record()
+ if cs_error:
+ LOG.debug(util.hexprint(resp))
+ raise Exception("Checksum error on read")
+ LOG.debug("Got:\n%s" % util.hexprint(resp))
+ image += resp[2:]
+ if self.status_fn:
+ status = chirp_common.Status()
+ status.cur = i
+ status.max = end
+ status.msg = "Cloning from radio"
+ self.status_fn(status)
+ self._finish()
+ return memmap.MemoryMap(''.join(image))
+
+ def _upload(self):
+ """Talk to a wouxun KG-UV920P-A and do a upload"""
+ try:
+ self._identify()
+ self._do_upload(0x0000, 0x6640, 0x40)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ return
+
+ def _do_upload(self, start, end, blocksize):
+ ptr = start
+ for i in range(start, end, blocksize):
+ req = chr(i / 256) + chr(i % 256)
+ chunk = self.get_mmap()[ptr:ptr + blocksize]
+ self._write_record(CMD_WR, req + chunk)
+ LOG.debug(util.hexprint(req + chunk))
+ cserr, ack = self._read_record()
+ LOG.debug(util.hexprint(ack))
+ j = ord(ack[0]) * 256 + ord(ack[1])
+ if cserr or j != ptr:
+ raise Exception("Radio did not ack block %i" % ptr)
+ ptr += blocksize
+ if self.status_fn:
+ status = chirp_common.Status()
+ status.cur = i
+ status.max = end
+ status.msg = "Cloning to radio"
+ self.status_fn(status)
+ self._finish()
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_ctone = True
+ rf.has_rx_dtcs = True
+ rf.has_cross = True
+ rf.has_tuning_step = False
+ rf.has_bank = False
+ rf.can_odd_split = True
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_tuning_steps = STEPS
+ rf.valid_cross_modes = [
+ "Tone->Tone",
+ "Tone->DTCS",
+ "DTCS->Tone",
+ "DTCS->",
+ "->Tone",
+ "->DTCS",
+ "DTCS->DTCS",
+ ]
+ rf.valid_modes = ["FM", "NFM"]
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_name_length = 8
+ rf.valid_duplexes = ["", "-", "+", "split", "off"]
+ rf.valid_bands = [(136000000, 175000000), # supports 2m
+ (420000000, 520000000)] # supports 70cm
+ rf.valid_characters = CHARSET
+ rf.memory_bounds = (1, 999) # 999 memories
+ return rf
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = ("This radio driver is a beta version. "
+ "There are no known issues with it, but you should "
+ "proceed with caution.")
+ return rp
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number-1])
+
+ def get_memory(self, number):
+ mem = chirp_common.Memory()
+ mem.number = number
+ _mem = self._memobj.memory[mem.number-1]
+
+ if _mem.rxfreq & 0xFF000000 == 0xFF000000:
+ mem.empty = True
+ return mem
+ else:
+ mem.empty = False
+
+ _rxfreq = _freq_decode(_mem.rxfreq)
+ _txfreq = _freq_decode(_mem.txfreq)
+ mem.freq = _rxfreq
+
+ if _mem.txfreq == 0xFFFFFFFF:
+ # TX freq not set
+ mem.duplex = "off"
+ mem.offset = 0
+ elif int(_rxfreq) == int(_txfreq):
+ mem.duplex = ""
+ mem.offset = 0
+ elif abs(_rxfreq - _txfreq) > 70000000:
+ mem.duplex = "split"
+ mem.offset = _txfreq
+ else:
+ mem.duplex = _rxfreq > _txfreq and "-" or "+"
+ mem.offset = abs(_rxfreq - _txfreq)
+
+ if _mem.named:
+ mem.name = _str_decode(self._memobj.names[number-1].name)
+ else:
+ mem.name = ''
+
+ _get_tone(_mem, mem)
+
+ mem.skip = "" if bool(_mem.scan_add) else "S"
+
+ if _mem.power == 3:
+ mem.power = self.POWER_LEVELS[2]
+ else:
+ mem.power = self.POWER_LEVELS[_mem.power]
+
+ mem.mode = _mem.isnarrow and "NFM" or "FM"
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ _scram = _mem.scrambler
+ if _mem.scrambler > 8:
+ _scram = 0
+ rs = RadioSetting("scrambler", "Scrambler",
+ RadioSettingValueList(SCRAMBLER_LIST,
+ SCRAMBLER_LIST[_scram]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("compander", "Compander",
+ RadioSettingValueBoolean(_mem.compander))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("mute_mode", "Mute",
+ RadioSettingValueMap(MUTE_MODE_MAP, _mem.mute_mode))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ number = mem.number
+
+ _mem = self._memobj.memory[number-1]
+ _nam = self._memobj.names[number-1]
+
+ if mem.empty:
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
+ _nam.set_raw(_str_encode(""))
+ _mem.rxfreq = 0xFFFFFFFF
+ return
+
+ _mem.rxfreq = _freq_encode(mem.freq)
+ if mem.duplex == "off":
+ _mem.txfreq = 0xFFFFFFFF
+ elif mem.duplex == "split":
+ _mem.txfreq = _freq_encode(mem.offset)
+ elif mem.duplex == "+":
+ _mem.txfreq = _freq_encode(mem.freq + mem.offset)
+ elif mem.duplex == "-":
+ _mem.txfreq = _freq_encode(mem.freq - mem.offset)
+ else:
+ _mem.txfreq = _freq_encode(mem.freq)
+
+ _mem.scan_add = int(mem.skip != "S")
+
+ _mem.isnarrow = 0b11 * int(mem.mode == "NFM")
+
+ # set the tone
+ _set_tone(mem, _mem)
+
+ # set the power
+ if mem.power:
+ idx = self.POWER_LEVELS.index(mem.power)
+ if idx == 2:
+ _mem.power = 3
+ else:
+ _mem.power = idx
+ else:
+ _mem.power = True
+
+ if len(mem.name) > 0:
+ _mem.named = True
+ name_encoded = _str_encode(mem.name)
+ for i in range(0, 8):
+ _nam.name[i] = ord(name_encoded[i])
+ else:
+ _mem.named = False
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def _get_settings(self):
+ _settings = self._memobj.settings
+ _vfoa = self._memobj.vfoa
+ _vfob = self._memobj.vfob
+ _fm_preset = self._memobj.fm_preset
+
+ cfg_grp = RadioSettingGroup("cfg_grp", "Configuration")
+ ui_grp = RadioSettingGroup("ui_grp", "User Interface")
+ vfoa_grp = RadioSettingGroup("vfoa_grp", "VFO A")
+ vfob_grp = RadioSettingGroup("vfob_grp", "VFO B")
+ scn_grp = RadioSettingGroup("scn_grp", "Scan")
+ rpt_grp = RadioSettingGroup("rmt_grp", "Repeater")
+ rmt_grp = RadioSettingGroup("rmt_grp", "Remote Control")
+ fmp_grp = RadioSettingGroup("fmp_grp", "FM Radio Presets")
+ oem_grp = RadioSettingGroup("oem_grp", "OEM Info")
+
+ group = RadioSettings(cfg_grp, ui_grp, vfoa_grp, vfob_grp, scn_grp,
+ rpt_grp, rmt_grp, fmp_grp, oem_grp)
+
+ #
+ # Configuration Settings
+ #
+ rs = RadioSetting("m_power_set", "Medium Power Level (W)",
+ RadioSettingValueMap(M_POWER_MAP,
+ _settings.m_power_set))
+ cfg_grp.append(rs)
+ rs = RadioSetting("roger", "Roger Beep",
+ RadioSettingValueList(ROGER_LIST,
+ ROGER_LIST[_settings.roger]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("roger_time", "Roger Tx Duration (ms)",
+ RadioSettingValueList(
+ ROGER_TIMES,
+ ROGER_TIMES[_settings.roger_time]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("roger_int", "Roger Interval (ms)",
+ RadioSettingValueList(
+ ROGER_INTERVALS,
+ ROGER_INTERVALS[_settings.roger_int]))
+ cfg_grp.append(rs)
+ val = RadioSettingValueString(1, 6,
+ _roger_decode(_settings.roger_begin),
+ False, CHARSET_NUMERIC)
+ rs = RadioSetting("roger_begin", "Roger Begin", val)
+ cfg_grp.append(rs)
+ val = RadioSettingValueString(1, 6,
+ _roger_decode(_settings.roger_end),
+ False, CHARSET_NUMERIC)
+ rs = RadioSetting("roger_end", "Roger End", val)
+ cfg_grp.append(rs)
+ rs = RadioSetting("tot", "Time-Out Timer (TOT) (Min)",
+ RadioSettingValueMap(TOT_MAP, _settings.tot))
+ cfg_grp.append(rs)
+ rs = RadioSetting("toa", "Time-Out Alarm (TOA) (Sec)",
+ RadioSettingValueMap(TOA_MAP, _settings.toa))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ani_sw", "Caller ID Tx",
+ RadioSettingValueBoolean(_settings.ani_sw))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ptt_id", "Caller ID Tx Mode",
+ RadioSettingValueMap(PTT_ID_MAP, _settings.ptt_id))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ptt_id_delay", "Caller ID Tx Delay (ms)",
+ RadioSettingValueMap(PTT_ID_DELAY_MAP,
+ _settings.ptt_id_delay))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ring", "Ring Time (Sec)",
+ RadioSettingValueMap(RING_MAP, _settings.ring))
+ cfg_grp.append(rs)
+ rs = RadioSetting("dtmf_st", "DTMF Sidetone",
+ RadioSettingValueList(
+ DTMF_ST_LIST,
+ DTMF_ST_LIST[_settings.dtmf_st]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("pri_ch_sw", "Priority Channel Switch",
+ RadioSettingValueBoolean(_settings.pri_ch_sw))
+ cfg_grp.append(rs)
+ rs = RadioSetting("pri_ch", "Priority Channel",
+ RadioSettingValueInteger(
+ 1, 999, _chnum_decode(_settings.pri_ch)))
+ cfg_grp.append(rs)
+ rs = RadioSetting("apo_time", "Auto Power-Off (Min)",
+ RadioSettingValueList(
+ APO_TIME_LIST,
+ APO_TIME_LIST[_settings.apo_time]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("alert", "Alert Pulse (Hz)",
+ RadioSettingValueMap(ALERT_MAP, _settings.alert))
+ cfg_grp.append(rs)
+ rs = RadioSetting("fan_mode", "Fan Mode",
+ RadioSettingValueList(
+ FAN_MODE_LIST,
+ FAN_MODE_LIST[_settings.fan_mode]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("low_v", "Low Voltage Shutoff",
+ RadioSettingValueBoolean(_settings.low_v))
+ cfg_grp.append(rs)
+ rs = RadioSetting("ans", "Noise Reduction",
+ RadioSettingValueList(ANS_LIST,
+ ANS_LIST[_settings.ans]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("dtmf_time", "DTMF Tx Duration (ms)",
+ RadioSettingValueList(
+ DTMF_TIMES,
+ DTMF_TIMES[_settings.dtmf_time]))
+ cfg_grp.append(rs)
+ rs = RadioSetting("dtmf_interval", "DTMF Interval (ms)",
+ RadioSettingValueList(
+ DTMF_INTERVALS,
+ DTMF_INTERVALS[_settings.dtmf_interval]))
+ cfg_grp.append(rs)
+
+ #
+ # UI Settings
+ #
+ rs = RadioSetting("ponmsg.left",
+ "Power On Message Left & \n Single Band Message",
+ RadioSettingValueString(
+ 0, 8, _str_decode(self._memobj.ponmsg.left)))
+ ui_grp.append(rs)
+ rs = RadioSetting("ponmsg.right", "Power On Message Right",
+ RadioSettingValueString(
+ 0, 8, _str_decode(self._memobj.ponmsg.right)))
+ ui_grp.append(rs)
+ rs = RadioSetting("autolock", "Autolock",
+ RadioSettingValueBoolean(_settings.autolock))
+ ui_grp.append(rs)
+ rs = RadioSetting("speaker", "Speaker Select",
+ RadioSettingValueMap(SPEAKER_MAP, _settings.speaker))
+ ui_grp.append(rs)
+ rs = RadioSetting("voice", "Voice Guide",
+ RadioSettingValueList(VOICE_LIST,
+ VOICE_LIST[_settings.voice]))
+ ui_grp.append(rs)
+ rs = RadioSetting("beep", "Beep",
+ RadioSettingValueBoolean(_settings.beep))
+ ui_grp.append(rs)
+ rs = RadioSetting("active_display", "Active Display",
+ RadioSettingValueList(
+ AB_LIST,
+ AB_LIST[_settings.active_display]))
+ ui_grp.append(rs)
+ rs = RadioSetting("single_display", "Single Display",
+ RadioSettingValueBoolean(_settings.single_display))
+ ui_grp.append(rs)
+ rs = RadioSetting("tx_led", "TX Backlight",
+ RadioSettingValueList(
+ BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.tx_led]))
+ ui_grp.append(rs)
+ rs = RadioSetting("wt_led", "Standby Backlight",
+ RadioSettingValueList(
+ BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.wt_led]))
+ ui_grp.append(rs)
+ rs = RadioSetting("rx_led", "Rx Backlight",
+ RadioSettingValueList(
+ BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.rx_led]))
+ ui_grp.append(rs)
+
+ #
+ # VFO A Settings
+ #
+ rs = RadioSetting("workmode_a", "Workmode",
+ RadioSettingValueMap(
+ WORKMODE_MAP, _settings.workmode_a))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("work_cha", "Channel",
+ RadioSettingValueInteger(
+ 1, 999, _chnum_decode(_settings.work_cha)))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.rxfreq", "Rx Frequency",
+ RadioSettingValueInteger(
+ 137000000, 470000000,
+ _freq_decode(_vfoa.rxfreq), 2500))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.txoffset", "Tx Offset",
+ RadioSettingValueInteger(
+ 0, 470000000,
+ _freq_decode(_vfoa.txoffset), 2500))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.rxtone", "Rx Tone",
+ RadioSettingValueMap(TONE_MAP, _vfoa.rxtone))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.txtone", "Tx Tone",
+ RadioSettingValueMap(TONE_MAP, _vfoa.txtone))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.power", "Power",
+ RadioSettingValueMap(POWER_MAP, _vfoa.power))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.duplex", "Duplex",
+ RadioSettingValueList(DUPLEX_LIST,
+ DUPLEX_LIST[_vfoa.duplex]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.isnarrow", "Mode",
+ RadioSettingValueMap(BANDWIDTH_MAP, _vfoa.isnarrow))
+ vfoa_grp.append(rs)
+ _vfoa_scram = _vfoa.scrambler
+ if _vfoa_scram > 8:
+ _vfoa_scram = 0
+ rs = RadioSetting("vfoa.scrambler", "Scrambler",
+ RadioSettingValueList(SCRAMBLER_LIST,
+ SCRAMBLER_LIST[_vfoa_scram]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.compander", "Compander",
+ RadioSettingValueBoolean(_vfoa.compander))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("vfoa.mute_mode", "Mute",
+ RadioSettingValueMap(MUTE_MODE_MAP,
+ _vfoa.mute_mode))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("step_a", "Step (kHz)",
+ RadioSettingValueList(
+ STEP_LIST, STEP_LIST[_settings.step_a]))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("squelch_a", "Squelch",
+ RadioSettingValueInteger(
+ 0, 9, _settings.squelch_a))
+ vfoa_grp.append(rs)
+ rs = RadioSetting("bcl_a", "Busy Channel Lock-out",
+ RadioSettingValueBoolean(_settings.bcl_a))
+ vfoa_grp.append(rs)
+
+ #
+ # VFO B Settings
+ #
+ rs = RadioSetting("workmode_b", "Workmode",
+ RadioSettingValueMap(
+ WORKMODE_MAP, _settings.workmode_b))
+ vfob_grp.append(rs)
+ rs = RadioSetting("work_chb", "Channel",
+ RadioSettingValueInteger(
+ 1, 999, _chnum_decode(_settings.work_chb)))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.rxfreq", "Rx Frequency",
+ RadioSettingValueInteger(
+ 137000000, 470000000,
+ _freq_decode(_vfob.rxfreq), 2500))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.txoffset", "Tx Offset",
+ RadioSettingValueInteger(
+ 0, 470000000,
+ _freq_decode(_vfob.txoffset), 2500))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.rxtone", "Rx Tone",
+ RadioSettingValueMap(TONE_MAP, _vfob.rxtone))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.txtone", "Tx Tone",
+ RadioSettingValueMap(TONE_MAP, _vfob.txtone))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.power", "Power",
+ RadioSettingValueMap(POWER_MAP, _vfob.power))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.duplex", "Duplex",
+ RadioSettingValueList(DUPLEX_LIST,
+ DUPLEX_LIST[_vfob.duplex]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.isnarrow", "Mode",
+ RadioSettingValueMap(BANDWIDTH_MAP, _vfob.isnarrow))
+ vfob_grp.append(rs)
+ _vfob_scram = _vfob.scrambler
+ if _vfob_scram > 8:
+ _vfob_scram = 0
+ rs = RadioSetting("vfob.scrambler", "Scrambler",
+ RadioSettingValueList(SCRAMBLER_LIST,
+ SCRAMBLER_LIST[_vfob_scram]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.compander", "Compander",
+ RadioSettingValueBoolean(_vfob.compander))
+ vfob_grp.append(rs)
+ rs = RadioSetting("vfob.mute_mode", "Mute",
+ RadioSettingValueMap(MUTE_MODE_MAP, _vfob.mute_mode))
+ vfob_grp.append(rs)
+ rs = RadioSetting("step_b", "Step (kHz)",
+ RadioSettingValueList(
+ STEP_LIST, STEP_LIST[_settings.step_b]))
+ vfob_grp.append(rs)
+ rs = RadioSetting("squelch_b", "Squelch",
+ RadioSettingValueInteger(
+ 0, 9, _settings.squelch_b))
+ vfob_grp.append(rs)
+ rs = RadioSetting("bcl_b", "Busy Channel Lock-out",
+ RadioSettingValueBoolean(_settings.bcl_b))
+ vfob_grp.append(rs)
+
+ #
+ # Scan Settings
+ #
+ rs = RadioSetting("sc_rev", "Scan Resume Mode",
+ RadioSettingValueMap(SC_REV_MAP, _settings.sc_rev))
+ scn_grp.append(rs)
+ rs = RadioSetting("scan_group", "Scan Group",
+ RadioSettingValueList(SCAN_GROUP_LIST,
+ SCAN_GROUP_LIST[
+ _settings.scan_group]))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp1_lower", "Group 1 Lower",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp1_lower))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp1_upper", "Group 1 Upper",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp1_upper))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp2_lower", "Group 2 Lower",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp2_lower))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp2_upper", "Group 2 Upper",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp2_upper))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp3_lower", "Group 3 Lower",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp3_lower))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp3_upper", "Group 3 Upper",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp3_upper))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp4_lower", "Group 4 Lower",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp4_lower))
+ scn_grp.append(rs)
+ rs = RadioSetting("grp4_upper", "Group 4 Upper",
+ RadioSettingValueInteger(1, 999,
+ _settings.grp4_upper))
+ scn_grp.append(rs)
+ rs = RadioSetting("scan_det", "Scan DET",
+ RadioSettingValueBoolean(_settings.scan_det))
+ scn_grp.append(rs)
+
+ #
+ # Repeater Settings
+ #
+ rs = RadioSetting("rpt_spk", "Speaker",
+ RadioSettingValueBoolean(_settings.rpt_spk))
+ rpt_grp.append(rs)
+ rs = RadioSetting("rpt_ptt", "PTT",
+ RadioSettingValueBoolean(_settings.rpt_ptt))
+ rpt_grp.append(rs)
+ rs = RadioSetting("rpt_mode", "Mode",
+ RadioSettingValueList(RPT_MODE_LIST,
+ RPT_MODE_LIST[
+ _settings.rpt_mode]))
+ rpt_grp.append(rs)
+ rs = RadioSetting("rpt_tone", "Tone",
+ RadioSettingValueBoolean(_settings.rpt_tone))
+ rpt_grp.append(rs)
+
+ #
+ # Remote Settings
+ #
+ rs = RadioSetting("rc_sw", "Remote Control",
+ RadioSettingValueBoolean(_settings.rc_sw))
+ rmt_grp.append(rs)
+ rs = RadioSetting("rc_power", "Remote Control Power",
+ RadioSettingValueBoolean(_settings.rc_power))
+ rmt_grp.append(rs)
+ val = RadioSettingValueString(3, 6, _ani_decode(_settings.ani),
+ False, CHARSET_NUMERIC)
+ rs = RadioSetting("ani", "Caller ID (ANI)", val)
+ rmt_grp.append(rs)
+ val = RadioSettingValueString(3, 6, _ani_decode(_settings.ani_mcc),
+ False, CHARSET_NUMERIC)
+ rs = RadioSetting("ani_mcc", "MCC-Edit", val)
+ rmt_grp.append(rs)
+ val = RadioSettingValueString(3, 6, _ani_decode(_settings.ani_scc),
+ False, CHARSET_NUMERIC)
+ rs = RadioSetting("ani_scc", "SCC-Edit", val)
+ rmt_grp.append(rs)
+ val = RadioSettingValueString(3, 6, _ani_decode(_settings.ani_ctrl),
+ False, CHARSET_NUMERIC)
+ rs = RadioSetting("ani_ctrl", "Control", val)
+ rmt_grp.append(rs)
+
+ #
+ # FM Radio Presets Settings
+ #
+ for i in range(1, 21):
+ val = _fm_preset[i-1].freq / 100.0
+ rs = RadioSetting(str(i), str(i),
+ RadioSettingValueFloat(65.00, 108.00,
+ val, precision=2))
+ fmp_grp.append(rs)
+
+ #
+ # OEM info
+ #
+ _str = _str_decode(self._memobj.oem_info.model)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("model", "Model", val)
+ oem_grp.append(rs)
+ _str = _str_decode(self._memobj.oem_info.date)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("date", "OEM Date", val)
+ oem_grp.append(rs)
+ _str = _str_decode(self._memobj.oem_info.oem1)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("oem1", "OEM String 1", val)
+ oem_grp.append(rs)
+ _str = _str_decode(self._memobj.oem_info.oem2)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("oem2", "OEM String 2", val)
+ oem_grp.append(rs)
+ _str = _str_decode(self._memobj.oem_info.unknown1)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("unknown1", "Unknown String 1", val)
+ oem_grp.append(rs)
+ _str = _str_decode(self._memobj.oem_info.unknown2)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("unknown2", "Unknown String 2", val)
+ oem_grp.append(rs)
+ _str = _str_decode(self._memobj.oem_info.unknown3)
+ val = RadioSettingValueString(0, 15, _str)
+ val.set_mutable(False)
+ rs = RadioSetting("unknown3", "Unknown String 3", val)
+ oem_grp.append(rs)
+
+ return group
+
+ def get_settings(self):
+ try:
+ return self._get_settings()
+ except:
+ import traceback
+ LOG.error("Failed to parse settings: %s", traceback.format_exc())
+ return None
+
+ def set_settings(self, settings):
+ for group in settings:
+ for element in group:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ #
+ # Special Configuration Settings
+ #
+ if group.get_name() == 'cfg_grp':
+ if name == 'roger_begin':
+ value = _roger_encode(element[0].get_value())
+ for i in range(0, 4):
+ obj.roger_begin[i] = ord(value[i])
+ continue
+ elif name == 'roger_end':
+ value = _roger_encode(element[0].get_value())
+ for i in range(0, 4):
+ obj.roger_end[i] = ord(value[i])
+ continue
+ elif name == 'pri_ch':
+ value = _chnum_encode(element[0].get_value())
+ setattr(obj, setting, value)
+ continue
+
+ #
+ # Special UI Settings
+ #
+ if group.get_name() == 'ui_grp':
+ if name == 'ponmsg.left':
+ value = _str_encode(element[0].get_value())
+ for i in range(0, 8):
+ self._memobj.ponmsg.left[i] = ord(value[i])
+ continue
+ elif name == 'ponmsg.right':
+ value = _str_encode(element[0].get_value())
+ for i in range(0, 8):
+ self._memobj.ponmsg.right[i] = ord(value[i])
+ continue
+
+ #
+ # Special VFO A Settings
+ #
+ if (group.get_name() == 'vfoa_grp') or \
+ (group.get_name() == 'vfob_grp'):
+ if (setting == 'rxfreq') or \
+ (setting == 'txoffset'):
+ value = _freq_encode(element[0].get_value())
+ setattr(obj, setting, value)
+ continue
+ elif (setting == 'work_cha') or \
+ (setting == 'work_chb'):
+ value = _chnum_encode(element[0].get_value())
+ setattr(obj, setting, value)
+ continue
+
+ #
+ # Special VFO B Settings
+ #
+ if group.get_name() == 'vfob_grp':
+ pass
+
+ #
+ # Special Scan settings
+ #
+ if group.get_name() == 'scn_grp':
+ pass
+
+ #
+ # Special Repeater settings
+ #
+ if group.get_name() == 'rpt_grp':
+ pass
+
+ #
+ # Special Remote settings
+ #
+ if group.get_name() == 'rmt_grp':
+ if name == 'ani':
+ value = _ani_encode(element[0].get_value())
+ for i in range(0, 3):
+ obj.ani[i] = ord(value[i])
+ continue
+ elif name == 'ani_mcc':
+ value = _ani_encode(element[0].get_value())
+ for i in range(0, 3):
+ obj.ani_mcc[i] = ord(value[i])
+ continue
+ elif name == 'ani_scc':
+ value = _ani_encode(element[0].get_value())
+ for i in range(0, 3):
+ obj.ani_scc[i] = ord(value[i])
+ continue
+ elif name == 'ani_ctrl':
+ value = _ani_encode(element[0].get_value())
+ for i in range(0, 3):
+ obj.ani_ctrl[i] = ord(value[i])
+ continue
+
+ #
+ # FM Radio Presets Settings
+ #
+ if group.get_name() == 'fmp_grp':
+ value = int(element[0].get_value() * 100)
+ self._memobj.fm_preset[int(name)-1].freq = value
+ continue
+
+ #
+ # Generic Settings
+ #
+ if element[0].__class__ is RadioSettingValueList:
+ value = element[0].get_options().index(
+ element[0].get_value())
+ setattr(obj, setting, value)
+ elif element[0].__class__ is RadioSettingValueMap:
+ value = element[0].get_mem_val()
+ setattr(obj, setting, value)
+ elif element[0].__class__ is RadioSettingValueBoolean:
+ value = element[0].get_value()
+ setattr(obj, setting, value)
+ elif element[0].__class__ is RadioSettingValueInteger:
+ value = element[0].get_value()
+ setattr(obj, setting, value)
+ else:
+ LOG.debug("Unable to set_setting %s" % name)
diff --git a/chirp/drivers/kguv9dplus.py b/chirp/drivers/kguv9dplus.py
index b836af6..9856d26 100644
--- a/chirp/drivers/kguv9dplus.py
+++ b/chirp/drivers/kguv9dplus.py
@@ -405,7 +405,7 @@ def _pkt_decode(data):
cksum_match = (cksum & 0xf) == payload[-1]
if (not cksum_match):
LOG.debug(
- "Checksum missmatch: %x != %x; " % (cksum, payload[-1]))
+ "Checksum mismatch: %x != %x; " % (cksum, payload[-1]))
return (cksum_match, op, payload[:-1])
# UI callbacks to process input for mapping UI fields to memory cells
@@ -427,7 +427,7 @@ def int2freq(freq):
"""
Convert a u32 frequency to a string for UI data entry/display
This is stored in the radio as units of 10Hz which we compensate to Hz.
- A value of -1 indicates <no freqency>, i.e. unused channel.
+ A value of -1 indicates <no frequency>, i.e. unused channel.
"""
if (int(freq) > 0):
f = chirp_common.format_freq(freq)
@@ -445,7 +445,7 @@ def freq2short(val, min, max):
(chirp_common.format_freq(_freq),
chirp_common.format_freq(min),
chirp_common.format_freq(max)))
- return _freq/100000 & 0xFFFF
+ return _freq // 100000 & 0xFFFF
def short2freq(freq):
@@ -755,7 +755,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
MODEL = "KG-UV9D Plus"
_model = "KG-UV9D"
_rev = "00" # default rev for the radio I know about...
- _file_ident = "kg-uv9d"
+ _file_ident = b"kg-uv9d"
BAUD_RATE = 19200
POWER_LEVELS = [chirp_common.PowerLevel("L", watts=1),
chirp_common.PowerLevel("M", watts=2),
@@ -877,7 +877,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
self._write_record(CMD_HANGUP)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
LOG.exception('Unknown error during download process')
raise errors.RadioError(
"Failed to communicate with radio: %s" % e)
@@ -894,7 +894,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
self._write_record(CMD_HANGUP)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with radio: %s" % e)
return
@@ -1187,7 +1187,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
_nam = self._memobj.chan_name[number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
_nam.name = str2name("", 8, '\0', '\0')
_mem.state = MEM_INVALID
return
@@ -1887,7 +1887,7 @@ class KGUV9DPlusRadio(chirp_common.CloneModeRadio,
setattr(obj, setting, int(element.value)/10)
else:
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug("set_settings: Exception with %s" %
element.get_name())
raise
diff --git a/chirp/drivers/kyd.py b/chirp/drivers/kyd.py
index 27ebc74..5747808 100644
--- a/chirp/drivers/kyd.py
+++ b/chirp/drivers/kyd.py
@@ -245,6 +245,7 @@ class NC630aRadio(chirp_common.CloneModeRadio):
rf.memory_bounds = (1, 16)
rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
rf.valid_bands = [(400000000, 520000000)]
+ rf.valid_dtcs_codes = NC630A_DTCS
return rf
@@ -500,7 +501,7 @@ class NC630aRadio(chirp_common.CloneModeRadio):
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/kyd_IP620.py b/chirp/drivers/kyd_IP620.py
index 47507b8..6c8cd65 100644
--- a/chirp/drivers/kyd_IP620.py
+++ b/chirp/drivers/kyd_IP620.py
@@ -181,7 +181,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
self.pipe.write("\x06")
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Radio refused to exit programming mode: %s" % e)
def _ip620_enter_programming_mode(self):
@@ -192,7 +192,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
_ack = self.pipe.read(1)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error communicating with radio: %s" % e)
if not _ack:
raise errors.RadioError("No response from radio")
@@ -203,17 +203,17 @@ class IP620Radio(chirp_common.CloneModeRadio,
_ident = self.pipe.read(8)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error communicating with radio: %s" % e)
if not _ident.startswith("\x06\x4B\x47\x36\x37\x01\x56\xF8"):
- print util.hexprint(_ident)
+ print(util.hexprint(_ident))
raise errors.RadioError("Radio returned unknown identification string")
try:
self.pipe.write(CMD_ACK)
_ack = self.pipe.read(1)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Error communicating with radio: %s" % e)
if _ack != CMD_ACK:
raise errors.RadioError("Radio refused to enter programming mode")
@@ -316,7 +316,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
self._mmap = self._do_download()
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -470,7 +470,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
def set_memory(self, mem):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rx_freq = mem.freq / 10
@@ -597,7 +597,7 @@ class IP620Radio(chirp_common.CloneModeRadio,
setattr(self._memobj.settings_misc,
element.get_name(),
element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -624,6 +624,6 @@ class IP620Radio(chirp_common.CloneModeRadio,
setattr(_settings_misc, setting, newval)
else:
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/leixen.py b/chirp/drivers/leixen.py
index d96c5d0..fb965c8 100644
--- a/chirp/drivers/leixen.py
+++ b/chirp/drivers/leixen.py
@@ -226,7 +226,7 @@ PFKEYSHORT_LIST = ["OFF",
]
MODES = ["NFM", "FM"]
-WTFTONES = map(float, xrange(56, 64))
+WTFTONES = [float(x) for x in range(56, 64)]
TONES = WTFTONES + chirp_common.TONES
DTCS_CODES = [17, 50, 645] + chirp_common.DTCS_CODES
DTCS_CODES.sort()
@@ -261,7 +261,7 @@ def send(radio, frame):
# util.hexprint(frame).replace("\n", "\n ")))
try:
radio.pipe.write(frame)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@@ -373,8 +373,8 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
ALIASES = [LT898UV, ]
BAUD_RATE = 9600
- _file_ident = "Leixen"
- _model_ident = 'LX-\x89\x85\x63'
+ _file_ident = b"Leixen"
+ _model_ident = b'LX-\x89\x85\x63'
_memsize = 0x2000
_ranges = [
@@ -421,13 +421,14 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
rf.valid_tuning_steps = _STEP_LIST
rf.valid_bands = [(136000000, 174000000),
(400000000, 470000000)]
+ rf.valid_dtcs_codes = DTCS_CODES
rf.memory_bounds = (1, 199)
return rf
def sync_in(self):
try:
self._mmap = do_download(self)
- except Exception, e:
+ except Exception as e:
finish(self)
raise errors.RadioError("Failed to download from radio: %s" % e)
self.process_mmap()
@@ -442,7 +443,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
except errors.RadioError:
finish(self)
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to upload to radio: %s" % e)
def get_raw_memory(self, number):
@@ -796,17 +797,17 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
RadioSettingValueList(
DTMFTIME_LIST, DTMFTIME_LIST[val]))
adv_grp.append(rs)
- val = (_settings.dtmfdelay) / 5
+ val = (_settings.dtmfdelay) // 5
rs = RadioSetting("dtmfdelay", "DTMF 1st Digit Delay",
RadioSettingValueList(
DTMFDELAY_LIST, DTMFDELAY_LIST[val]))
adv_grp.append(rs)
- val = (_settings.dtmfpretime) / 10 - 1
+ val = (_settings.dtmfpretime) // 10 - 1
rs = RadioSetting("dtmfpretime", "DTMF Pretime",
RadioSettingValueList(
DTMFPRETIME_LIST, DTMFPRETIME_LIST[val]))
adv_grp.append(rs)
- val = (_settings.dtmfdelay2) / 5
+ val = (_settings.dtmfdelay2) // 5
rs = RadioSetting("dtmfdelay2", "DTMF * and # Digit Delay",
RadioSettingValueList(
DTMFDELAY2_LIST, DTMFDELAY2_LIST[val]))
@@ -941,7 +942,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -961,8 +962,8 @@ class JetstreamJT270MRadio(LeixenVV898Radio):
VENDOR = "Jetstream"
MODEL = "JT270M"
- _file_ident = "JET"
- _model_ident = 'LX-\x89\x85\x53'
+ _file_ident = b"JET"
+ _model_ident = b'LX-\x89\x85\x53'
@directory.register
@@ -972,8 +973,8 @@ class JetstreamJT270MHRadio(LeixenVV898Radio):
VENDOR = "Jetstream"
MODEL = "JT270MH"
- _file_ident = "Leixen"
- _model_ident = 'LX-\x89\x85\x85'
+ _file_ident = b"Leixen"
+ _model_ident = b'LX-\x89\x85\x85'
_ranges = [(0x0C00, 0x2000)]
_mem_formatter = {'unknownormode': 'mode:1',
'modeorpower': 'power:2',
@@ -1027,7 +1028,7 @@ class LeixenVV898SRadio(LeixenVV898Radio):
MODEL = "VV-898S"
ALIASES = [VV898E, ]
- _model_ident = 'LX-\x89\x85\x75'
+ _model_ident = b'LX-\x89\x85\x75'
_mem_formatter = {'unknownormode': 'mode:1',
'modeorpower': 'power:2',
'chanstart': 0x0D00,
diff --git a/chirp/drivers/lt725uv.py b/chirp/drivers/lt725uv.py
index a21a9c5..b787e41 100644
--- a/chirp/drivers/lt725uv.py
+++ b/chirp/drivers/lt725uv.py
@@ -1,6 +1,10 @@
-# Copyright 2016:
+# Copyright 2016-2021:
# * Jim Unroe KC9HI, <rock.unroe@gmail.com>
-# Modified for Baojie BJ-218: 2018 by Rick DeWitt (RJD), <aa0rd@yahoo.com>#
+# Modified for Baojie BJ-218: 2018
+# Rick DeWitt (RJD), <aa0rd@yahoo.com>
+# Modified for Baojie BJ-318: April 2021
+# Mark Hartong, AJ4YI <mark.hartong@verizon.net>
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
@@ -19,25 +23,25 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueBoolean, RadioSettingValueList, \
RadioSettingValueString, RadioSettingValueInteger, \
- RadioSettingValueFloat, RadioSettings,InvalidValueError
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
from textwrap import dedent
+LOG = logging.getLogger(__name__)
+
MEM_FORMAT = """
#seekto 0x0200;
struct {
- u8 init_bank;
- u8 volume;
- u16 fm_freq;
- u8 wtled;
- u8 rxled;
- u8 txled;
+ u8 init_bank; // determines which VFO is primary A or B
+ u8 volume; // not used BJ-318, band volume is controlled vfo u8 bvol
+ u16 fm_freq; // not used BJ-318, freq is controlled hello_lims u16 fm_318
+ u8 wtled; // not used BJ-318
+ u8 rxled; // not used BJ-318
+ u8 txled; // not used BJ-318
u8 ledsw;
u8 beep;
u8 ring;
@@ -45,7 +49,7 @@ struct {
u8 tot;
u16 sig_freq;
u16 dtmf_txms;
- u8 init_sql;
+ u8 init_sql; // not used BJ-318, band squelch is controlled vfo u8 sql
u8 rptr_mode;
} settings;
@@ -92,15 +96,25 @@ struct {
#seekto 0x02d0;
struct {
- u8 hello1_cnt;
- char hello1[7];
- u8 hello2_cnt;
- char hello2[7];
+ u8 hello1_cnt; // not used in BJ-318, is set in memory map
+ char hello1[7]; // not used in BJ-318, is set in memory map
+ u8 hello2_cnt; // not used in BJ-318, is set in memory map
+ char hello2[7]; // not used in BJ-318, is set in memory map
u32 vhf_low;
u32 vhf_high;
u32 uhf_low;
u32 uhf_high;
- u8 lims_on;
+ u8 lims_on; // first byte @ at address 0x02f0;
+ u8 unknown_1; // use in BJ-318 unknown
+ u8 lang; // BJ-318 Display language
+ // 02 = English 00 and 01 are Asian
+ u8 up_scr_color; // BJ-318 upper screen character color
+ u8 dn_scr_color; // BJ-318 lower screen character color
+ // purple=00, red=01, emerald=02, blue=03,
+ // sky_blue=04, black=05, required hex values for color
+ // Note sky_blue and black look the same on the
+ // BJ-318 screen
+ u16 fm_318; // FM stored Frequency in BJ-318
} hello_lims;
struct vfo {
@@ -117,14 +131,18 @@ struct vfo {
tx_tone:14;
u8 launch_sig;
u8 tx_end_sig;
- u8 bpower;
+ u8 bpower; // sets power Hi=02h, Medium=01h, Low=00
+ // sets power for entire vfo band
u8 fm_bw;
u8 cmp_nder;
u8 scrm_blr;
u8 shift;
u32 offset;
u16 step;
- u8 sql;
+ u8 sql; // squelch for entire vfo band
+ // integer values 0 (low) to 9 (high)
+ u8 bvol; // sets volume for vfo band
+ // integer values 0 (low) TO 10 (high)
};
#seekto 0x0300;
@@ -149,7 +167,11 @@ struct mem {
txtone:14;
u8 botsignal;
u8 eotsignal;
- u8 power:1,
+ u8 power:1, // binary value for
+ // indiviudal channel power
+ // set to "High" or "Low"
+ // BJ-318 band power overrides any
+ // individual channel power setting
wide:1,
compandor:1
scrambler:1
@@ -173,17 +195,18 @@ struct {
MEM_SIZE = 0x1C00
BLOCK_SIZE = 0x40
STIMEOUT = 2
-# Channel power: 2 levels
-POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5.00),
- chirp_common.PowerLevel("High", watts=30.00)]
-
LIST_RECVMODE = ["QT/DQT", "QT/DQT + Signaling"]
LIST_SIGNAL = ["Off"] + ["DTMF%s" % x for x in range(1, 9)] + \
["DTMF%s + Identity" % x for x in range(1, 9)] + \
["Identity code"]
# Band Power settings, can be different than channel power
LIST_BPOWER = ["Low", "Mid", "High"] # Tri-power models
+
+# Screen Color Settings
+# BJ-218 Colors
LIST_COLOR = ["Off", "Orange", "Blue", "Purple"]
+# BJ-318 Colors
+LIST_COLOR318 = ["Purple", "Red", "Emerald", "Blue", "Sky_Blue", "Black"]
LIST_LEDSW = ["Auto", "On"]
LIST_RING = ["Off"] + ["%s" % x for x in range(1, 10)]
LIST_TDR_DEF = ["A-Upper", "B-Lower"]
@@ -199,36 +222,39 @@ for x in chirp_common.DTCS_CODES:
for x in chirp_common.DTCS_CODES:
LIST_CTCSS.append("D{:03d}R".format(x))
LIST_BW = ["Narrow", "Wide"]
-LIST_SHIFT = ["Off"," + ", " - "]
+LIST_SHIFT = ["Off", " + ", " - "]
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
LIST_STEPS = [str(x) for x in STEPS]
LIST_STATE = ["Normal", "Stun", "Kill"]
LIST_SSF = ["1000", "1450", "1750", "2100"]
-LIST_DTMFTX = ["50", "100", "150", "200", "300","500"]
+LIST_DTMFTX = ["50", "100", "150", "200", "300", "500"]
SETTING_LISTS = {
-"init_bank": LIST_TDR_DEF ,
-"tot": LIST_TIMEOUT,
-"wtled": LIST_COLOR,
-"rxled": LIST_COLOR,
-"txled": LIST_COLOR,
-"sig_freq": LIST_SSF,
-"dtmf_txms": LIST_DTMFTX,
-"ledsw": LIST_LEDSW,
-"frq_chn_mode": LIST_VFOMODE,
-"rx_tone": LIST_CTCSS,
-"tx_tone": LIST_CTCSS,
-"rx_mode": LIST_RECVMODE,
-"launch_sig": LIST_SIGNAL,
-"tx_end_sig": LIST_SIGNAL,
-"bpower":LIST_BPOWER,
-"fm_bw": LIST_BW,
-"shift": LIST_SHIFT,
-"step": LIST_STEPS,
-"ring": LIST_RING,
-"state_now": LIST_STATE
+ "init_bank": LIST_TDR_DEF,
+ "tot": LIST_TIMEOUT,
+ "wtled": LIST_COLOR, # not used in BJ-318, other radios use
+ "rxled": LIST_COLOR, # not used in BJ-318, other radios use
+ "txled": LIST_COLOR, # not used in BJ-318, other radios use
+ "sig_freq": LIST_SSF,
+ "dtmf_txms": LIST_DTMFTX,
+ "ledsw": LIST_LEDSW,
+ "frq_chn_mode": LIST_VFOMODE,
+ "rx_tone": LIST_CTCSS,
+ "tx_tone": LIST_CTCSS,
+ "rx_mode": LIST_RECVMODE,
+ "launch_sig": LIST_SIGNAL,
+ "tx_end_sig": LIST_SIGNAL,
+ "bpower": LIST_BPOWER,
+ "fm_bw": LIST_BW,
+ "shift": LIST_SHIFT,
+ "step": LIST_STEPS,
+ "ring": LIST_RING,
+ "state_now": LIST_STATE,
+ "up_scr_color": LIST_COLOR318, # unique to BJ-318
+ "dn_scr_color": LIST_COLOR318, # unique to BJ-318
}
+
def _clean_buffer(radio):
radio.pipe.timeout = 0.005
junk = radio.pipe.read(256)
@@ -427,6 +453,17 @@ class LT725UV(chirp_common.CloneModeRadio):
NAME_LENGTH = 7
DTMF_CHARS = list("0123456789ABCD*#")
+ # Channel Power: 2 levels
+ # BJ-318 uses 3 power levels for each VFO "Band"
+ # Low = 5W, Med = 10W, High = 25W
+ # The band power selection in a VFO applies to the VFO and overrides
+ # the stored channel power selection
+ # The firmware channel memory structure provides only 1 bit for
+ # individual channel power settings, limiting potential channel
+ # power selection options to 2 levels: Low or High.
+ POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5.00),
+ chirp_common.PowerLevel("High", watts=30.00)]
+
VALID_BANDS = [(136000000, 176000000),
(400000000, 480000000)]
@@ -437,20 +474,39 @@ class LT725UV(chirp_common.CloneModeRadio):
@classmethod
def get_prompts(cls):
rp = chirp_common.RadioPrompts()
- rp.info = \
- ('Some notes about POWER settings:\n'
- '- The individual channel power settings are ignored'
- ' by the radio.\n'
- ' They are allowed to be set (and downloaded) in hopes of'
- ' a future firmware update.\n'
- '- Power settings done \'Live\' in the radio apply to the'
- ' entire upper or lower band.\n'
- '- Tri-power radio models will set and download the three'
- ' band-power'
- ' levels, but they are converted to just Low and High at'
- ' upload.'
- ' The Mid setting reverts to Low.'
- )
+ if cls.MODEL == "BJ-318":
+ msg = \
+ (' BJ-318 EXPERIMENTAL\n'
+ ' PLEASE REPORT ANY ISSUES \n'
+ '\n'
+ 'The individual channel power settings are ignored by \n'
+ 'the radio. They are allowed to be set in hopes of a \n'
+ 'future firmware change. Changing a stored channel power \n'
+ 'setting must be done manually using the front panel menu \n'
+ 'control (or the microphone control controls while in VFO \n'
+ 'mode) to change the VFO power. The CHIRP driver will \n'
+ 'allow setting the individual VFO power to High (25W), \n'
+ 'Med (10W) or Low (5W) and setting the unused individual \n'
+ 'channel power setting to High (25W) or Low (5W)'
+ )
+
+ else:
+ msg = \
+ ('Some notes about POWER settings:\n'
+ '- The individual channel power settings are ignored'
+ ' by the radio.\n'
+ ' They are allowed to be set (and downloaded) in hopes of'
+ ' a future firmware update.\n'
+ '- Power settings done \'Live\' in the radio apply to the'
+ ' entire upper or lower band.\n'
+ '- Tri-power radio models will set and download the three'
+ ' band-power'
+ ' levels, but they are converted to just Low and High at'
+ ' upload.'
+ ' The Mid setting reverts to Low.'
+ )
+
+ rp.info = msg
rp.pre_download = _(dedent("""\
Follow this instructions to download your info:
@@ -498,7 +554,7 @@ class LT725UV(chirp_common.CloneModeRadio):
"->Tone",
"DTCS->DTCS"]
rf.valid_skips = []
- rf.valid_power_levels = POWER_LEVELS
+ rf.valid_power_levels = self.POWER_LEVELS
rf.valid_name_length = self.NAME_LENGTH
rf.valid_dtcs_codes = self.DTCS_CODES
rf.valid_bands = self.VALID_BANDS
@@ -623,7 +679,7 @@ class LT725UV(chirp_common.CloneModeRadio):
mem.mode = _mem.wide and "FM" or "NFM"
- mem.power = POWER_LEVELS[_mem.power]
+ mem.power = self.POWER_LEVELS[_mem.power]
# Extra
mem.extra = RadioSettingGroup("extra", "Extra")
@@ -634,7 +690,7 @@ class LT725UV(chirp_common.CloneModeRadio):
val = _mem.recvmode
recvmode = RadioSetting("recvmode", "Receiving mode",
RadioSettingValueList(LIST_RECVMODE,
- LIST_RECVMODE[val]))
+ LIST_RECVMODE[val]))
mem.extra.append(recvmode)
if _mem.botsignal == 0xFF:
@@ -643,7 +699,7 @@ class LT725UV(chirp_common.CloneModeRadio):
val = _mem.botsignal
botsignal = RadioSetting("botsignal", "Launch signaling",
RadioSettingValueList(LIST_SIGNAL,
- LIST_SIGNAL[val]))
+ LIST_SIGNAL[val]))
mem.extra.append(botsignal)
if _mem.eotsignal == 0xFF:
@@ -744,7 +800,7 @@ class LT725UV(chirp_common.CloneModeRadio):
_mem.txtone = self._set_dcs(mem.dtcs)
_mem.wide = self.MODES.index(mem.mode)
- _mem.power = mem.power == POWER_LEVELS[1]
+ _mem.power = mem.power == self.POWER_LEVELS[1]
# Extra settings
for setting in mem.extra:
@@ -770,27 +826,34 @@ class LT725UV(chirp_common.CloneModeRadio):
# Basic Settings
bnd_mode = RadioSetting("settings.init_bank", "TDR Band Default",
RadioSettingValueList(LIST_TDR_DEF,
- LIST_TDR_DEF[ _sets.init_bank]))
+ LIST_TDR_DEF[
+ _sets.init_bank]))
basic.append(bnd_mode)
- volume = RadioSetting("settings.volume", "Volume",
- RadioSettingValueInteger(0, 20, _sets.volume))
- basic.append(volume)
-
- val = _vfoa.bpower # 2bits values 0,1,2= Low, Mid, High
- rx = RadioSettingValueList(LIST_BPOWER, LIST_BPOWER[val])
- powera = RadioSetting("upper.vfoa.bpower", "Power (Upper)", rx)
- basic.append(powera)
-
- val = _vfob.bpower
- rx = RadioSettingValueList(LIST_BPOWER, LIST_BPOWER[val])
- powerb = RadioSetting("lower.vfob.bpower", "Power (Lower)", rx)
- basic.append(powerb)
+ # BJ-318 set by vfo, skip
+ if self.MODEL != "BJ-318":
+ rs = RadioSettingValueInteger(0, 20, _sets.volume)
+ volume = RadioSetting("settings.volume", "Volume", rs)
+ basic.append(volume)
+
+ # BJ-318 set by vfo, skip
+ if self.MODEL != "BJ-318":
+ vala = _vfoa.bpower # 2bits values 0,1,2= Low, Mid, High
+ rx = RadioSettingValueList(LIST_BPOWER, LIST_BPOWER[vala])
+ powera = RadioSetting("upper.vfoa.bpower", "Power (Upper)", rx)
+ basic.append(powera)
+
+ # BJ-318 set by vfo, skip
+ if self.MODEL != "BJ-318":
+ valb = _vfob.bpower
+ rx = RadioSettingValueList(LIST_BPOWER, LIST_BPOWER[valb])
+ powerb = RadioSetting("lower.vfob.bpower", "Power (Lower)", rx)
+ basic.append(powerb)
def my_word2raw(setting, obj, atrb, mlt=10):
"""Callback function to convert UI floating value to u16 int"""
if str(setting.value) == "Off":
- frq = 0x0FFFF
+ frq = 0x0FFFF
else:
frq = int(float(str(setting.value)) * float(mlt))
if frq == 0:
@@ -801,7 +864,7 @@ class LT725UV(chirp_common.CloneModeRadio):
def my_adjraw(setting, obj, atrb, fix):
"""Callback: add or subtract fix from value."""
vx = int(str(setting.value))
- value = vx + int(fix)
+ value = vx + int(fix)
if value < 0:
value = 0
if atrb == "frq_chn_mode" and int(str(setting.value)) == 2:
@@ -829,7 +892,7 @@ class LT725UV(chirp_common.CloneModeRadio):
def my_spcl(setting, obj, atrb):
"""Callback: Special handling based on atrb."""
if atrb == "frq_chn_mode":
- idx = LIST_VFOMODE.index (str(setting.value)) # Returns 0 or 1
+ idx = LIST_VFOMODE.index(str(setting.value)) # Returns 0 or 1
value = idx * 2 # Set bit 1
setattr(obj, atrb, value)
return
@@ -871,28 +934,48 @@ class LT725UV(chirp_common.CloneModeRadio):
setattr(obj, tone_atr, tonx)
return
- val = _sets.fm_freq / 10.0
- if val == 0:
- val = 88.9 # 0 is not valid
- rx = RadioSettingValueFloat(65, 108.0, val, 0.1, 1)
- rs = RadioSetting("settings.fm_freq", "FM Broadcast Freq (MHz)", rx)
- rs.set_apply_callback(my_word2raw, _sets, "fm_freq")
- basic.append(rs)
-
- wtled = RadioSetting("settings.wtled", "Standby LED Color",
- RadioSettingValueList(LIST_COLOR, LIST_COLOR[
- _sets.wtled]))
- basic.append(wtled)
-
- rxled = RadioSetting("settings.rxled", "RX LED Color",
- RadioSettingValueList(LIST_COLOR, LIST_COLOR[
- _sets.rxled]))
- basic.append(rxled)
-
- txled = RadioSetting("settings.txled", "TX LED Color",
- RadioSettingValueList(LIST_COLOR, LIST_COLOR[
- _sets.txled]))
- basic.append(txled)
+ # not used by BJ-318 skip
+ if self.MODEL != "BJ-318":
+ val = _sets.fm_freq / 10.0
+ if val == 0:
+ val = 88.9 # 0 is not valid
+ rx = RadioSettingValueFloat(65, 108.0, val, 0.1, 1)
+ rs = RadioSetting("settings.fm_freq",
+ "FM Broadcast Freq (MHz)", rx)
+ rs.set_apply_callback(my_word2raw, _sets, "fm_freq")
+ basic.append(rs)
+
+ # BJ-318 fm frequency
+ if self.MODEL == "BJ-318":
+ val = _lims.fm_318 / 10.0
+ if val == 0:
+ val = 88.9 # 0 is not valid
+ rx = RadioSettingValueFloat(65, 108.0, val, 0.1, 1)
+ rs = RadioSetting("hello_lims.fm_318",
+ "FM Broadcast Freq (MHz)", rx)
+ rs.set_apply_callback(my_word2raw, _lims, "fm_318")
+ basic.append(rs)
+
+ # not used in BJ-318, skip
+ if self.MODEL != "BJ-318":
+ rs = RadioSettingValueList(LIST_COLOR,
+ LIST_COLOR[_sets.wtled])
+ wtled = RadioSetting("settings.wtled", "Standby LED Color", rs)
+ basic.append(wtled)
+
+ # not used in BJ-318, skip
+ if self.MODEL != "BJ-318":
+ rs = RadioSettingValueList(LIST_COLOR,
+ LIST_COLOR[_sets.rxled])
+ rxled = RadioSetting("settings.rxled", "RX LED Color", rs)
+ basic.append(rxled)
+
+ # not used in BJ-318, skip
+ if self.MODEL != "BJ-318":
+ rs = RadioSettingValueList(LIST_COLOR,
+ LIST_COLOR[_sets.txled])
+ txled = RadioSetting("settings.txled", "TX LED Color", rs)
+ basic.append(txled)
ledsw = RadioSetting("settings.ledsw", "Back light mode",
RadioSettingValueList(LIST_LEDSW, LIST_LEDSW[
@@ -912,25 +995,28 @@ class LT725UV(chirp_common.CloneModeRadio):
RadioSettingValueBoolean(bool(_sets.bcl)))
basic.append(bcl)
- if _vfoa.sql == 0xFF:
- val = 0x04
- else:
- val = _vfoa.sql
- sqla = RadioSetting("upper.vfoa.sql", "Squelch (Upper)",
- RadioSettingValueInteger(0, 9, val))
- basic.append(sqla)
+ # squelch for non-BJ-318 models
+ # BJ-318 squelch set by VFO basis
+ if self.MODEL != "BJ-318":
+ if _vfoa.sql == 0xFF:
+ val = 0x04
+ else:
+ val = _vfoa.sql
+ sqla = RadioSetting("upper.vfoa.sql", "Squelch (Upper)",
+ RadioSettingValueInteger(0, 9, val))
+ basic.append(sqla)
- if _vfob.sql == 0xFF:
- val = 0x04
- else:
- val = _vfob.sql
- sqlb = RadioSetting("lower.vfob.sql", "Squelch (Lower)",
- RadioSettingValueInteger(0, 9, val))
- basic.append(sqlb)
+ if _vfob.sql == 0xFF:
+ val = 0x04
+ else:
+ val = _vfob.sql
+ sqlb = RadioSetting("lower.vfob.sql", "Squelch (Lower)",
+ RadioSettingValueInteger(0, 9, val))
+ basic.append(sqlb)
tmp = str(int(_sets.tot) * 30) # 30 sec step counter
rs = RadioSetting("settings.tot", "Transmit Timeout (Secs)",
- RadioSettingValueList(LIST_TIMEOUT, tmp))
+ RadioSettingValueList(LIST_TIMEOUT, tmp))
rs.set_apply_callback(my_val_list, _sets, "tot")
basic.append(rs)
@@ -960,7 +1046,7 @@ class LT725UV(chirp_common.CloneModeRadio):
rs.set_apply_callback(my_spcl, _vfoa, "frq_chn_mode")
a_band.append(rs)
- val =_vfoa.chan_num + 1 # Add 1 for 1-128 displayed
+ val = _vfoa.chan_num + 1 # Add 1 for 1-128 displayed
rs = RadioSetting("upper.vfoa.chan_num", "Initial Chan",
RadioSettingValueInteger(1, 128, val))
rs.set_apply_callback(my_adjraw, _vfoa, "chan_num", -1)
@@ -995,10 +1081,10 @@ class LT725UV(chirp_common.CloneModeRadio):
rs = RadioSetting("upper.vfoa.launch_sig", "Launch Signaling",
RadioSettingValueList(LIST_SIGNAL,
- LIST_SIGNAL[_vfoa.launch_sig]))
+ LIST_SIGNAL[_vfoa.launch_sig]))
a_band.append(rs)
- rx = RadioSettingValueList(LIST_SIGNAL,LIST_SIGNAL[_vfoa.tx_end_sig])
+ rx = RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL[_vfoa.tx_end_sig])
rs = RadioSetting("upper.vfoa.tx_end_sig", "Xmit End Signaling", rx)
a_band.append(rs)
@@ -1028,9 +1114,41 @@ class LT725UV(chirp_common.CloneModeRadio):
tmp = str(_vfoa.step / 100.0)
rs = RadioSetting("step", "Freq step (KHz)",
RadioSettingValueList(LIST_STEPS, tmp))
- rs.set_apply_callback(my_word2raw, _vfoa,"step", 100)
+ rs.set_apply_callback(my_word2raw, _vfoa, "step", 100)
a_band.append(rs)
+ # BJ-318 upper band squelch
+ if self.MODEL == "BJ-318":
+ if _vfoa.sql == 0xFF:
+ valq = 0x04 # setting default squelch to 04
+ else:
+ valq = _vfoa.sql
+ sqla = RadioSetting("upper.vfoa.sql", "Squelch",
+ RadioSettingValueInteger(0, 9, valq))
+ a_band.append(sqla)
+
+ # BJ-318 upper band volume
+ if self.MODEL == "BJ-318":
+ bvolume_u = RadioSetting("upper.vfoa.bvol",
+ "Volume", RadioSettingValueInteger(
+ 0, 10, _vfoa.bvol))
+ a_band.append(bvolume_u)
+
+ # BJ-318 Upper Screen Color
+ if self.MODEL == "BJ-318":
+ rs_u = RadioSettingValueList(LIST_COLOR318,
+ LIST_COLOR318[_lims.up_scr_color])
+ up_scr_color = RadioSetting("hello_lims.up_scr_color",
+ "Screen Color", rs_u)
+ a_band.append(up_scr_color)
+
+ # BJ-318 Upper band power
+ if self.MODEL == "BJ-318":
+ val_b = _vfoa.bpower # 2bits values 0,1,2= Low, Mid, High
+ rx = RadioSettingValueList(LIST_BPOWER, LIST_BPOWER[val_b])
+ power_u = RadioSetting("upper.vfoa.bpower", "Power", rx)
+ a_band.append(power_u)
+
# LOWER BAND SETTINGS
val = _vfob.frq_chn_mode / 2
@@ -1041,7 +1159,7 @@ class LT725UV(chirp_common.CloneModeRadio):
val = _vfob.chan_num + 1
rs = RadioSetting("lower.vfob.chan_num", "Initial Chan",
- RadioSettingValueInteger(0, 127, val))
+ RadioSettingValueInteger(1, 128, val))
rs.set_apply_callback(my_adjraw, _vfob, "chan_num", -1)
b_band.append(rs)
@@ -1071,11 +1189,11 @@ class LT725UV(chirp_common.CloneModeRadio):
"txdtcs_pol", "tx_tone")
b_band.append(rs)
- rx = RadioSettingValueList(LIST_SIGNAL,LIST_SIGNAL[_vfob.launch_sig])
+ rx = RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL[_vfob.launch_sig])
rs = RadioSetting("lower.vfob.launch_sig", "Launch Signaling", rx)
b_band.append(rs)
- rx = RadioSettingValueList(LIST_SIGNAL,LIST_SIGNAL[_vfob.tx_end_sig])
+ rx = RadioSettingValueList(LIST_SIGNAL, LIST_SIGNAL[_vfob.tx_end_sig])
rs = RadioSetting("lower.vfob.tx_end_sig", "Xmit End Signaling", rx)
b_band.append(rs)
@@ -1107,8 +1225,39 @@ class LT725UV(chirp_common.CloneModeRadio):
rs.set_apply_callback(my_word2raw, _vfob, "step", 100)
b_band.append(rs)
- # PowerOn & Freq Limits Settings
+ # BJ-318 lower band squelch
+ if self.MODEL == "BJ-318":
+ if _vfob.sql == 0xFF:
+ val_l = 0x04 # setting default squelch to 04
+ else:
+ val_l = _vfob.sql
+ sql_b = RadioSetting("lower.vfob.sql", "Squelch",
+ RadioSettingValueInteger(0, 9, val_l))
+ b_band.append(sql_b)
+
+ # BJ-318 lower band volume
+ if self.MODEL == "BJ-318":
+ bvolume_l = RadioSetting("lower.vfob.bvol",
+ "Volume", RadioSettingValueInteger(
+ 0, 10, _vfob.bvol))
+ b_band.append(bvolume_l)
+
+ # BJ-318 Lower Screen Color
+ if self.MODEL == "BJ-318":
+ rs_l = RadioSettingValueList(LIST_COLOR318,
+ LIST_COLOR318[_lims.dn_scr_color])
+ dn_scr_color = RadioSetting("hello_lims.dn_scr_color",
+ "Screen Color", rs_l)
+ b_band.append(dn_scr_color)
+
+ # BJ-318 lower band power
+ if self.MODEL == "BJ-318":
+ val_l = _vfoa.bpower # 2bits values 0,1,2= Low, Mid, High
+ rx = RadioSettingValueList(LIST_BPOWER, LIST_BPOWER[val_l])
+ powera = RadioSetting("lower.vfob.bpower", "Power", rx)
+ b_band.append(powera)
+ # PowerOn & Freq Limits Settings
def chars2str(cary, knt):
"""Convert raw memory char array to a string: NOT a callback."""
stx = ""
@@ -1120,29 +1269,35 @@ class LT725UV(chirp_common.CloneModeRadio):
"""Callback: convert 7-char string to char array with count."""
ary = ""
knt = 7
- for j in range (6, -1, -1): # Strip trailing spaces
+ for j in range(6, -1, -1): # Strip trailing spaces
if str(setting.value)[j] == "" or str(setting.value)[j] == " ":
knt = knt - 1
else:
break
for j in range(0, 7, 1):
- if j < knt: ary += str(setting.value)[j]
- else: ary += chr(0xFF)
+ if j < knt:
+ ary += str(setting.value)[j]
+ else:
+ ary += chr(0xFF)
setattr(obj, atrba, ary)
setattr(obj, atrbc, knt)
return
- tmp = chars2str(_lims.hello1, _lims.hello1_cnt)
- rs = RadioSetting("hello_lims.hello1", "Power-On Message 1",
- RadioSettingValueString(0, 7, tmp))
- rs.set_apply_callback(my_str2ary, _lims, "hello1", "hello1_cnt")
- lims.append(rs)
-
- tmp = chars2str(_lims.hello2, _lims.hello2_cnt)
- rs = RadioSetting("hello_lims.hello2", "Power-On Message 2",
- RadioSettingValueString(0, 7, tmp))
- rs.set_apply_callback(my_str2ary, _lims,"hello2", "hello2_cnt")
- lims.append(rs)
+ # not used in BJ-318 startup screen
+ if self.MODEL != "BJ-318":
+ tmp = chars2str(_lims.hello1, _lims.hello1_cnt)
+ rs = RadioSetting("hello_lims.hello1", "Power-On Message 1",
+ RadioSettingValueString(0, 7, tmp))
+ rs.set_apply_callback(my_str2ary, _lims, "hello1", "hello1_cnt")
+ lims.append(rs)
+
+ # not used in BJ-318 startup screen
+ if self.MODEL != "BJ-318":
+ tmp = chars2str(_lims.hello2, _lims.hello2_cnt)
+ rs = RadioSetting("hello_lims.hello2", "Power-On Message 2",
+ RadioSettingValueString(0, 7, tmp))
+ rs.set_apply_callback(my_str2ary, _lims, "hello2", "hello2_cnt")
+ lims.append(rs)
# VALID_BANDS = [(136000000, 176000000),400000000, 480000000)]
@@ -1184,7 +1339,7 @@ class LT725UV(chirp_common.CloneModeRadio):
"""Generate the DTMF code 1-8, NOT a callback."""
tmp = ""
if knt > 0 and knt != 0xff:
- for val in ary[:knt]:
+ for val in ary[:knt]:
if val > 0 and val <= 9:
tmp += chr(val + 48)
elif val == 0x0a:
@@ -1210,7 +1365,7 @@ class LT725UV(chirp_common.CloneModeRadio):
"""Callback: DTMF Code; sends 5 or 7-byte string."""
draw = []
knt = syz
- for j in range (syz - 1, -1, -1): # Strip trailing spaces
+ for j in range(syz - 1, -1, -1): # Strip trailing spaces
if str(setting.value)[j] == "" or str(setting.value)[j] == " ":
knt = knt - 1
else:
@@ -1220,19 +1375,19 @@ class LT725UV(chirp_common.CloneModeRadio):
obx = ord(bx)
dig = 0x0ff
if j < knt and knt > 0: # (Else) is pads
- if bx == "0":
+ if bx == "0":
dig = 0x0a
- elif bx == "A":
+ elif bx == "A":
dig = 0x0d
- elif bx == "B":
+ elif bx == "B":
dig = 0x0e
- elif bx == "C":
+ elif bx == "C":
dig = 0x0f
- elif bx == "D":
+ elif bx == "D":
dig = 0x00
- elif bx == "*":
+ elif bx == "*":
dig = 0x0b
- elif bx == "#":
+ elif bx == "#":
dig = 0x0c
elif obx >= 49 and obx <= 57:
dig = obx - 48
@@ -1258,14 +1413,14 @@ class LT725UV(chirp_common.CloneModeRadio):
rs = RadioSetting("codes.master_id_code", "Master Control ID Code",
RadioSettingValueString(0, 7, tmp))
rs.set_apply_callback(my_dtmf2raw, _codes, "master_id_code",
- "master_id_cnt",7)
+ "master_id_cnt", 7)
codes.append(rs)
tmp = make_dtmf(_codes.alarm_code, _codes.alarm_cnt)
rs = RadioSetting("codes.alarm_code", "Alarm Code",
- RadioSettingValueString(0, 5, tmp))
+ RadioSettingValueString(0, 5, tmp))
rs.set_apply_callback(my_dtmf2raw, _codes, "alarm_code",
- "alarm_cnt", 5)
+ "alarm_cnt", 5)
codes.append(rs)
tmp = make_dtmf(_codes.id_disp_code, _codes.id_disp_cnt)
@@ -1278,7 +1433,7 @@ class LT725UV(chirp_common.CloneModeRadio):
tmp = make_dtmf(_codes.revive_code, _codes.revive_cnt)
rs = RadioSetting("codes.revive_code", "Revive Code",
RadioSettingValueString(0, 5, tmp))
- rs.set_apply_callback(my_dtmf2raw, _codes,"revive_code",
+ rs.set_apply_callback(my_dtmf2raw, _codes, "revive_code",
"revive_cnt", 5)
codes.append(rs)
@@ -1361,7 +1516,6 @@ class LT725UV(chirp_common.CloneModeRadio):
return group # END get_settings()
-
def set_settings(self, settings):
_settings = self._memobj.settings
_mem = self._memobj
@@ -1397,7 +1551,6 @@ class LT725UV(chirp_common.CloneModeRadio):
LOG.debug(element.get_name())
raise
-
@classmethod
def match_model(cls, filedata, filename):
match_size = False
@@ -1438,9 +1591,42 @@ class Hesenate(chirp_common.Alias):
MODEL = "BJ-218"
+class Baojie218Upper(LT725UVUpper):
+ VENDOR = "Baojie"
+ MODEL = "BJ-218"
+
+
+class Baojie218Lower(LT725UVLower):
+ VENDOR = "Baojie"
+ MODEL = "BJ-218"
+
+
@directory.register
class Baojie218(LT725UV):
"""Baojie BJ-218"""
VENDOR = "Baojie"
MODEL = "BJ-218"
ALIASES = [Zastone, Hesenate, ]
+
+ def get_sub_devices(self):
+ return [Baojie218Upper(self._mmap), Baojie218Lower(self._mmap)]
+
+
+class Baojie318Upper(LT725UVUpper):
+ VENDOR = "Baojie"
+ MODEL = "BJ-318"
+
+
+class Baojie318Lower(LT725UVLower):
+ VENDOR = "Baojie"
+ MODEL = "BJ-318"
+
+
+@directory.register
+class Baojie318(LT725UV):
+ """Baojie BJ-318"""
+ VENDOR = "Baojie"
+ MODEL = "BJ-318"
+
+ def get_sub_devices(self):
+ return [Baojie318Upper(self._mmap), Baojie318Lower(self._mmap)]
diff --git a/chirp/drivers/mursv1.py b/chirp/drivers/mursv1.py
index 31fac7e..0e8d996 100644
--- a/chirp/drivers/mursv1.py
+++ b/chirp/drivers/mursv1.py
@@ -19,8 +19,6 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp.drivers import baofeng_common
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
@@ -31,12 +29,14 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
InvalidValueError
from textwrap import dedent
-##### MAGICS #########################################################
+LOG = logging.getLogger(__name__)
+
+# #### MAGICS #########################################################
# BTECH MURS-V1 magic string
MSTRING_MURSV1 = "\x50\x5F\x20\x15\x12\x15\x4D"
-##### ID strings #####################################################
+# #### ID strings #####################################################
# BTECH MURS-V1
MURSV1_fp1 = "USM2402"
@@ -70,6 +70,7 @@ LIST_WORKMODE = ["Frequency", "Channel"]
MURS_FREQS = [151.820, 151.880, 151.940, 154.570, 154.600] * 3
FM_MODE = [3, 4, 8, 9, 13, 14]
+
def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
rid = data[0x1EF0:0x1EF7]
@@ -150,7 +151,6 @@ class MURSV1(baofeng_common.BaofengCommonHT):
return rf
-
MEM_FORMAT = """
#seekto 0x0010;
struct {
@@ -177,8 +177,18 @@ class MURSV1(baofeng_common.BaofengCommonHT):
u8 unused[11];
} pttid[15];
- #seekto 0x0CAA;
+ #seekto 0x0C80;
struct {
+ u8 unknown222[5];
+ u8 unknown333[5];
+ u8 alarm[5];
+ u8 unknown1;
+ u8 unknown555[5];
+ u8 unknown666[5];
+ u8 unknown777[5];
+ u8 unknown2;
+ u8 unknown60606[5];
+ u8 unknown70707[5];
u8 code[5];
u8 unused1:6,
aniid:2;
@@ -590,7 +600,7 @@ class MURSV1(baofeng_common.BaofengCommonHT):
basic.append(rs)
rs = RadioSetting("settings.beep", "Beep",
- RadioSettingValueBoolean(_mem.settings.beep))
+ RadioSettingValueBoolean(_mem.settings.beep))
basic.append(rs)
if _mem.settings.timeout > 0x27:
@@ -630,7 +640,7 @@ class MURSV1(baofeng_common.BaofengCommonHT):
_mem.settings.pttid]))
basic.append(rs)
- if _mem.settings.pttlt > 0x1E:
+ if _mem.settings.pttlt > 0x32:
val = 0x05
else:
val = _mem.settings.pttlt
@@ -698,7 +708,7 @@ class MURSV1(baofeng_common.BaofengCommonHT):
rs = RadioSetting("settings.rogerrx", "Roger Beep (RX)",
RadioSettingValueList(
LIST_OFFAB, LIST_OFFAB[
- _mem.settings.rogerrx]))
+ _mem.settings.rogerrx]))
basic.append(rs)
# Advanced settings
@@ -771,12 +781,12 @@ class MURSV1(baofeng_common.BaofengCommonHT):
rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
RadioSettingValueInteger(1, 15,
- _mem.wmchannel.mrcha))
+ _mem.wmchannel.mrcha))
work.append(rs)
rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
RadioSettingValueInteger(1, 15,
- _mem.wmchannel.mrchb))
+ _mem.wmchannel.mrchb))
work.append(rs)
# broadcast FM settings
@@ -842,12 +852,29 @@ class MURSV1(baofeng_common.BaofengCommonHT):
LIST_PTTID[_mem.ani.aniid]))
dtmfe.append(rs)
+ def apply_alarmcode(setting, obj, length):
+ code = []
+ for j in range(0, length):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.alarm = code
+
+ _codeobj = self._memobj.ani.alarm
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 5, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("ani.alarm", "Alarm Code", val)
+ rs.set_apply_callback(apply_alarmcode, self._memobj.ani, 5)
+ dtmfe.append(rs)
+
# Service settings
for index in range(0, 10):
key = "squelch.vhf.sql%i" % (index)
_obj = self._memobj.squelch.vhf
val = RadioSettingValueInteger(0, 123,
- getattr(_obj, "sql%i" % (index)))
+ getattr(_obj, "sql%i" % (index)))
if index == 0:
val.set_mutable(False)
name = "Squelch %i" % (index)
diff --git a/chirp/drivers/puxing.py b/chirp/drivers/puxing.py
index fb10d6b..f166c48 100644
--- a/chirp/drivers/puxing.py
+++ b/chirp/drivers/puxing.py
@@ -165,8 +165,8 @@ class Puxing777Radio(chirp_common.CloneModeRadio):
rf.valid_power_levels = POWER_LEVELS
rf.valid_characters = ''.join(set(PUXING_CHARSET))
rf.valid_name_length = 6
- rf.valid_tuning_steps = [2.5, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0,
- 50.0, 100.0]
+ rf.valid_tuning_steps = [2.5, 5.0, 6.25, 10.0, 12.5, 15.0, 20.0,
+ 25.0, 30.0, 50.0, 100.0]
rf.has_ctone = False
rf.has_tuning_step = False
rf.has_bank = False
diff --git a/chirp/drivers/puxing_px888k.py b/chirp/drivers/puxing_px888k.py
index 78f49a6..e091a07 100644
--- a/chirp/drivers/puxing_px888k.py
+++ b/chirp/drivers/puxing_px888k.py
@@ -1184,7 +1184,7 @@ class Puxing_PX888K_Radio(chirp_common.CloneModeRadio):
_priority = None
if number in SPECIAL_NUMBERS.keys():
index = number
- # speical by index
+ # special by index
designator = SPECIAL_NUMBERS[number]
elif number in SPECIAL_CHANNELS.keys():
# special by name
diff --git a/chirp/drivers/radioddity_r2.py b/chirp/drivers/radioddity_r2.py
index ca2a13e..e4b37f0 100644
--- a/chirp/drivers/radioddity_r2.py
+++ b/chirp/drivers/radioddity_r2.py
@@ -90,6 +90,7 @@ struct {
"""
CMD_ACK = "\x06"
+CMD_ALT_ACK = "\x53"
CMD_STX = "\x02"
CMD_ENQ = "\x05"
@@ -146,8 +147,8 @@ def _r2_enter_programming_mode(radio):
raise errors.RadioError("Error communicating with radio")
# No idea yet what the next 7 bytes stand for
- # as long as they start with ACK we are fine
- if not ident.startswith(CMD_ACK):
+ # as long as they start with ACK (or ALT_ACK on some devices) we are fine
+ if not ident.startswith(CMD_ACK) and not ident.startswith(CMD_ALT_ACK):
_r2_exit_programming_mode(radio)
LOG.debug(util.hexprint(ident))
raise errors.RadioError("Radio returned unknown identification string")
@@ -297,8 +298,7 @@ def do_upload(radio):
_r2_exit_programming_mode(radio)
-@directory.register
-class RadioddityR2Radio(chirp_common.CloneModeRadio):
+class RadioddityR2(chirp_common.CloneModeRadio):
"""Radioddity R2"""
VENDOR = "Radioddity"
MODEL = "R2"
@@ -454,7 +454,7 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
mem.duplex = "+"
mem.offset = txfreq - mem.freq
- # get bandwith FM or NFM
+ # get bandwidth FM or NFM
mem.mode = MODE_LIST[_mem.mode]
# tone data
@@ -611,7 +611,7 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -620,3 +620,13 @@ class RadioddityR2Radio(chirp_common.CloneModeRadio):
# This radio has always been post-metadata, so never do
# old-school detection
return False
+
+
+class RT24Alias(chirp_common.Alias):
+ VENDOR = "Retevis"
+ MODEL = "RT24"
+
+
+@directory.register
+class RadioddityR2Generic(RadioddityR2):
+ ALIASES = [RT24Alias]
diff --git a/chirp/drivers/radtel_t18.py b/chirp/drivers/radtel_t18.py
index b5eea5c..0e47396 100644
--- a/chirp/drivers/radtel_t18.py
+++ b/chirp/drivers/radtel_t18.py
@@ -1,4 +1,4 @@
-# Copyright 2017 Jim Unroe <rock.unroe@gmail.com>
+# Copyright 2021 Jim Unroe <rock.unroe@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ struct {
lbcd txfreq[4];
lbcd rxtone[2];
lbcd txtone[2];
- u8 unknown1:1,
+ u8 speccode:1,
compander:1,
scramble:1,
skip:1,
@@ -43,29 +43,101 @@ struct {
unknown2:1,
bcl:1;
u8 unknown3[3];
-} memory[16];
+} memory[%d];
#seekto 0x03C0;
struct {
u8 unknown1:1,
scanmode:1,
- unknown2:2,
+ vox:1, // Retevis RB19 VOX
+ speccode:1,
voiceprompt:2,
batterysaver:1,
beep:1;
u8 squelchlevel;
- u8 unused2;
+ u8 sidekey2; // Retevis RT22S setting
+ // Retevis RB85 sidekey 1 short
+ // Retevis RB19 sidekey 2 long
+ // Retevis RT47 sidekey 1 long
u8 timeouttimer;
u8 voxlevel;
- u8 unknown3;
- u8 unused;
+ u8 sidekey2S;
+ u8 unused; // Selected channel
u8 voxdelay;
+ u8 sidekey1L;
+ u8 sidekey2L;
+ u8 unused2[3];
+ u8 unknown3:4,
+ unknown4:1,
+ unknown5:2,
+ power10w:1; // Retevis RT85 power 10w on/off
+ // Retevis RT75 stop TX with low voltage
+} settings;
+
+#seekto 0x02B0;
+struct {
+ u8 voicesw; // Voice SW +
+ u8 voiceselect; // Voice Select
+ u8 scan; // Scan +
+ u8 vox; // VOX +
+ u8 voxgain; // Vox Gain +
+ u8 voxnotxonrx; // Rx Disable Vox +
+ u8 hivoltnotx; // High Vol Inhibit TX +
+ u8 lovoltnotx; // Low Vol Inhibit TX +
+ u8 rxemergency; // RX Emergency
+} settings2;
+"""
+
+MEM_FORMAT_RB18 = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ lbcd rxtone[2];
+ lbcd txtone[2];
+ u8 jumpcode:1,
+ unknown1:2,
+ skip:1,
+ highpower:1,
+ narrow:1,
+ unknown2:1,
+ bcl:1;
+ u8 unknown3[3];
+} memory[%d];
+#seekto 0x0630;
+struct {
+ u8 unk630:7,
+ voice:1;
+ u8 unk631:7,
+ language:1;
+ u8 unk632:7,
+ scan:1;
+ u8 unk633:7,
+ vox:1;
+ u8 unk634:5,
+ vox_level:3;
+ u8 unk635;
+ u8 unk636:7,
+ lovoltnotx:1;
+ u8 unk637:7,
+ hivoltnotx:1;
+ u8 unknown2[8];
+ u8 unk640:5,
+ rogerbeep:1,
+ batterysaver:1,
+ beep:1;
+ u8 squelchlevel;
+ u8 unk642;
+ u8 timeouttimer;
+ u8 unk644:7,
+ tail:1;
+ u8 channel;
} settings;
"""
CMD_ACK = "\x06"
-BLOCK_SIZE = 0x08
VOICE_LIST = ["Off", "Chinese", "English"]
+VOICE_LIST2 = ["English", "Chinese"]
TIMEOUTTIMER_LIST = ["Off", "30 seconds", "60 seconds", "90 seconds",
"120 seconds", "150 seconds", "180 seconds",
"210 seconds", "240 seconds", "270 seconds",
@@ -74,23 +146,94 @@ SCANMODE_LIST = ["Carrier", "Time"]
VOXLEVEL_LIST = ["Off", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
VOXDELAY_LIST = ["0.5 seconds", "1.0 seconds", "1.5 seconds",
"2.0 seconds", "2.5 seconds", "3.0 seconds"]
+SIDEKEY19_LIST = ["Off", "Scan", "Emergency Alarm"]
+SIDEKEY2_LIST = SIDEKEY19_LIST + ["Display Battery"]
+
+SIDEKEY85SHORT_LIST = ["Off",
+ "Noise Cansellation On",
+ "Continuous Monitor",
+ "High/Low Power",
+ "Emergency Alarm",
+ "Show Battery",
+ "Scan",
+ "VOX",
+ "Busy Channel Lock"]
+SIDEKEY85LONG_LIST = ["Off",
+ "Noise Cansellation On",
+ "Continuous Monitor",
+ "Monitor Momentary",
+ "High/Low Power",
+ "Emergency Alarm",
+ "Show Battery",
+ "Scan",
+ "VOX",
+ "Busy Channel Lock"]
+SPECCODE_LIST = ["SpeCode 1", "SpeCode 2"]
+SIDEKEY75_LIST = ["Off",
+ "Monitor Momentary",
+ "Scan",
+ "VOX",
+ "Monitor",
+ "Announciation"]
+SIDEKEY47_LIST = ["Monitor Momentary",
+ "Channel Lock",
+ "Scan",
+ "VOX"]
+SIDEKEYV8A_LIST = ["Off",
+ "Monitor",
+ "High/Low Power",
+ "Alarm"]
SETTING_LISTS = {
- "voice": VOICE_LIST,
+ "voiceprompt": VOICE_LIST,
+ "language": VOICE_LIST2,
"timeouttimer": TIMEOUTTIMER_LIST,
"scanmode": SCANMODE_LIST,
"voxlevel": VOXLEVEL_LIST,
- "voxdelay": VOXDELAY_LIST
+ "voxdelay": VOXDELAY_LIST,
+ "sidekey2": SIDEKEY2_LIST,
+ "sidekey2": SIDEKEY19_LIST,
+ "sidekey2": SIDEKEY85SHORT_LIST,
+ "sidekey2": SIDEKEYV8A_LIST,
+ "sidekey1L": SIDEKEY85LONG_LIST,
+ "sidekey2S": SIDEKEY85SHORT_LIST,
+ "sidekey2L": SIDEKEY85LONG_LIST,
+ "speccode": SPECCODE_LIST
}
+FRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+FRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+FRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+FRS_FREQS = FRS_FREQS1 + FRS_FREQS2 + FRS_FREQS3
+
+FRS16_FREQS = [462.5625, 462.5875, 462.6125, 462.6375,
+ 462.6625, 462.6250, 462.7250, 462.6875,
+ 462.7125, 462.5500, 462.5750, 462.6000,
+ 462.6500, 462.6750, 462.7000, 462.7250]
+
+GMRS_FREQS = FRS_FREQS1 + FRS_FREQS2 + FRS_FREQS3 * 2
+
+MURS_FREQS = [151.820, 151.880, 151.940, 154.570, 154.600]
+
+PMR_FREQS1 = [446.00625, 446.01875, 446.03125, 446.04375, 446.05625,
+ 446.06875, 446.08125, 446.09375]
+PMR_FREQS2 = [446.10625, 446.11875, 446.13125, 446.14375, 446.15625,
+ 446.16875, 446.18125, 446.19375]
+PMR_FREQS = PMR_FREQS1 + PMR_FREQS2
+
def _t18_enter_programming_mode(radio):
serial = radio.pipe
+ _magic = "\x02" + radio._magic
+
try:
- serial.write("\x02")
- time.sleep(0.1)
- serial.write("1ROGRAM")
+ serial.write(_magic)
+ if radio._echo:
+ chew = serial.read(len(_magic)) # Chew the echo
ack = serial.read(1)
except:
raise errors.RadioError("Error communicating with radio")
@@ -102,47 +245,38 @@ def _t18_enter_programming_mode(radio):
try:
serial.write("\x02")
+ if radio._echo:
+ serial.read(1) # Chew the echo
ident = serial.read(8)
except:
raise errors.RadioError("Error communicating with radio")
- if not ident.startswith("SMP558"):
+ if not ident.startswith(radio._fingerprint):
LOG.debug(util.hexprint(ident))
raise errors.RadioError("Radio returned unknown identification string")
try:
serial.write(CMD_ACK)
+ if radio._echo:
+ serial.read(1) # Chew the echo
ack = serial.read(1)
except:
raise errors.RadioError("Error communicating with radio")
- if ack != CMD_ACK:
- raise errors.RadioError("Radio refused to enter programming mode")
-
- try:
- serial.write("\x05")
- response = serial.read(6)
- except:
- raise errors.RadioError("Error communicating with radio")
-
- if not response == ("\xFF" * 6):
- LOG.debug(util.hexprint(response))
- raise errors.RadioError("Radio returned unexpected response")
-
- try:
- serial.write(CMD_ACK)
- ack = serial.read(1)
- except:
- raise errors.RadioError("Error communicating with radio")
-
- if ack != CMD_ACK:
- raise errors.RadioError("Radio refused to enter programming mode")
+ if radio.MODEL == "RT647":
+ if ack != "\xF0":
+ raise errors.RadioError("Radio refused to enter programming mode")
+ else:
+ if ack != CMD_ACK:
+ raise errors.RadioError("Radio refused to enter programming mode")
def _t18_exit_programming_mode(radio):
serial = radio.pipe
try:
- serial.write("b")
+ serial.write(radio.CMD_EXIT)
+ if radio._echo:
+ chew = serial.read(1) # Chew the echo
except:
raise errors.RadioError("Radio refused to exit programming mode")
@@ -150,25 +284,31 @@ def _t18_exit_programming_mode(radio):
def _t18_read_block(radio, block_addr, block_size):
serial = radio.pipe
- cmd = struct.pack(">cHb", 'R', block_addr, BLOCK_SIZE)
+ cmd = struct.pack(">cHb", 'R', block_addr, block_size)
expectedresponse = "W" + cmd[1:]
LOG.debug("Reading block %04x..." % (block_addr))
try:
serial.write(cmd)
- response = serial.read(4 + BLOCK_SIZE)
+ if radio._echo:
+ serial.read(4) # Chew the echo
+ response = serial.read(4 + block_size)
if response[:4] != expectedresponse:
raise Exception("Error reading block %04x." % (block_addr))
block_data = response[4:]
- serial.write(CMD_ACK)
- ack = serial.read(1)
+ if radio.ACK_BLOCK:
+ serial.write(CMD_ACK)
+ if radio._echo:
+ serial.read(1) # Chew the echo
+ ack = serial.read(1)
except:
raise errors.RadioError("Failed to read block at %04x" % block_addr)
- if ack != CMD_ACK:
- raise Exception("No ACK reading block %04x." % (block_addr))
+ if radio.ACK_BLOCK:
+ if ack != CMD_ACK:
+ raise Exception("No ACK reading block %04x." % (block_addr))
return block_data
@@ -176,14 +316,16 @@ def _t18_read_block(radio, block_addr, block_size):
def _t18_write_block(radio, block_addr, block_size):
serial = radio.pipe
- cmd = struct.pack(">cHb", 'W', block_addr, BLOCK_SIZE)
- data = radio.get_mmap()[block_addr:block_addr + 8]
+ cmd = struct.pack(">cHb", 'W', block_addr, block_size)
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
LOG.debug("Writing Data:")
LOG.debug(util.hexprint(cmd + data))
try:
serial.write(cmd + data)
+ if radio._echo:
+ serial.read(4 + len(data)) # Chew the echo
if serial.read(1) != CMD_ACK:
raise Exception("No ACK")
except:
@@ -203,11 +345,11 @@ def do_download(radio):
status.cur = 0
status.max = radio._memsize
- for addr in range(0, radio._memsize, BLOCK_SIZE):
- status.cur = addr + BLOCK_SIZE
+ for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
radio.status_fn(status)
- block = _t18_read_block(radio, addr, BLOCK_SIZE)
+ block = _t18_read_block(radio, addr, radio.BLOCK_SIZE)
data += block
LOG.debug("Address: %04x" % addr)
@@ -228,10 +370,10 @@ def do_upload(radio):
status.max = radio._memsize
for start_addr, end_addr in radio._ranges:
- for addr in range(start_addr, end_addr, BLOCK_SIZE):
- status.cur = addr + BLOCK_SIZE
+ for addr in range(start_addr, end_addr, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
radio.status_fn(status)
- _t18_write_block(radio, addr, BLOCK_SIZE)
+ _t18_write_block(radio, addr, radio.BLOCK_SIZE)
_t18_exit_programming_mode(radio)
@@ -241,7 +383,7 @@ def model_match(cls, data):
if len(data) == cls._memsize:
rid = data[0x03D0:0x03D8]
- return "P558" in rid
+ return b"P558" in rid
else:
return False
@@ -252,6 +394,19 @@ class T18Radio(chirp_common.CloneModeRadio):
VENDOR = "Radtel"
MODEL = "T18"
BAUD_RATE = 9600
+ BLOCK_SIZE = 0x08
+ CMD_EXIT = "b"
+ ACK_BLOCK = True
+
+ VALID_BANDS = [(400000000, 470000000)]
+
+ _magic = "1ROGRAM"
+ _fingerprint = "SMP558" + "\x00\x00"
+ _upper = 16
+ _mem_params = (_upper # number of channels
+ )
+ _frs = _frs16 = _murs = _pmr = _gmrs = False
+ _echo = False
_ranges = [
(0x0000, 0x03F0),
@@ -265,6 +420,10 @@ class T18Radio(chirp_common.CloneModeRadio):
rf.valid_skips = ["", "S"]
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
rf.valid_duplexes = ["", "-", "+", "split", "off"]
+ if self.MODEL != "T18" and \
+ self.MODEL != "RB618" and \
+ self.MODEL != "RT647":
+ rf.valid_power_levels = self.POWER_LEVELS
rf.can_odd_split = True
rf.has_rx_dtcs = True
rf.has_ctone = True
@@ -280,13 +439,14 @@ class T18Radio(chirp_common.CloneModeRadio):
rf.has_tuning_step = False
rf.has_bank = False
rf.has_name = False
- rf.memory_bounds = (1, 16)
- rf.valid_bands = [(400000000, 470000000)]
+ rf.memory_bounds = (1, self._upper)
+ rf.valid_bands = self.VALID_BANDS
+ rf.valid_tuning_steps = chirp_common.TUNING_STEPS
return rf
def process_mmap(self):
- self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+ self._memobj = bitwise.parse(MEM_FORMAT % self._mem_params, self._mmap)
def sync_in(self):
self._mmap = do_download(self)
@@ -358,16 +518,28 @@ class T18Radio(chirp_common.CloneModeRadio):
rxtone = self._decode_tone(_mem.rxtone)
chirp_common.split_tone_decode(mem, txtone, rxtone)
+ if self.MODEL != "T18" and self.MODEL != "RB618":
+ mem.power = self.POWER_LEVELS[1 - _mem.highpower]
+
mem.extra = RadioSettingGroup("Extra", "extra")
rs = RadioSetting("bcl", "Busy Channel Lockout",
RadioSettingValueBoolean(not _mem.bcl))
mem.extra.append(rs)
- rs = RadioSetting("scramble", "Scramble",
- RadioSettingValueBoolean(not _mem.scramble))
- mem.extra.append(rs)
- rs = RadioSetting("compander", "Compander",
- RadioSettingValueBoolean(not _mem.compander))
- mem.extra.append(rs)
+ if self.MODEL != "RB18" and self.MODEL != "RB618" and \
+ self.MODEL != "FRS-B1" and self.MODEL != "BF-V8A":
+ if self.MODEL != "RT47V":
+ rs = RadioSetting("scramble", "Scramble",
+ RadioSettingValueBoolean(not _mem.scramble))
+ mem.extra.append(rs)
+ rs = RadioSetting("compander", "Compander",
+ RadioSettingValueBoolean(not _mem.compander))
+ mem.extra.append(rs)
+ if self.MODEL != "RT47V" and self.MODEL != "T8" and \
+ self.MODEL != "RB17" and self.MODEL != "RB617" and \
+ self.MODEL != "RB75" and self.MODEL != "RB19P":
+ rs = RadioSetting("speccode", "Spec Code",
+ RadioSettingValueBoolean(not _mem.speccode))
+ mem.extra.append(rs)
return mem
@@ -376,9 +548,53 @@ class T18Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
+
return
+ _mem.set_raw("\x00" * 12 + "\xF9\xFF\xFF\xFF")
+
+ if self._gmrs:
+ GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = GMRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ if mem.number > 22:
+ mem.duplex = '+'
+ mem.offset = 5000000
+ if self._frs:
+ FRS_FREQ = int(FRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = FRS_FREQ
+ mem.mode = "NFM"
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.power = self.POWER_LEVELS[1]
+ if self._frs16:
+ FRS_FREQ = int(FRS16_FREQS[mem.number - 1] * 1000000)
+ mem.freq = FRS_FREQ
+ mem.mode = "NFM"
+ mem.duplex = ''
+ mem.offset = 0
+ if self._murs:
+ MURS_FREQ = int(MURS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = MURS_FREQ
+ if mem.number <= 3:
+ mem.mode = "NFM"
+ mem.duplex = ''
+ mem.offset = 0
+ if self._pmr:
+ PMR_FREQ = int(PMR_FREQS[mem.number - 1] * 1000000)
+ mem.freq = PMR_FREQ
+ mem.duplex = ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
@@ -397,6 +613,9 @@ class T18Radio(chirp_common.CloneModeRadio):
self._encode_tone(_mem.txtone, *txtone)
self._encode_tone(_mem.rxtone, *rxtone)
+ if self.MODEL != "T18" and self.MODEL != "RB18":
+ _mem.highpower = mem.power == self.POWER_LEVELS[0]
+
_mem.narrow = 'N' in mem.mode
_mem.skip = mem.skip == "S"
@@ -406,6 +625,8 @@ class T18Radio(chirp_common.CloneModeRadio):
def get_settings(self):
_settings = self._memobj.settings
+ if self.MODEL == "FRS-B1" or self.MODEL == "BF-V8A":
+ _settings2 = self._memobj.settings2
basic = RadioSettingGroup("basic", "Basic Settings")
top = RadioSettings(basic)
@@ -421,37 +642,259 @@ class T18Radio(chirp_common.CloneModeRadio):
_settings.timeouttimer]))
basic.append(rs)
- rs = RadioSetting("scanmode", "Scan mode",
- RadioSettingValueList(
- SCANMODE_LIST,
- SCANMODE_LIST[_settings.scanmode]))
- basic.append(rs)
-
- rs = RadioSetting("voiceprompt", "Voice prompt",
- RadioSettingValueList(
- VOICE_LIST,
- VOICE_LIST[_settings.voiceprompt]))
- basic.append(rs)
-
- rs = RadioSetting("voxlevel", "Vox level",
- RadioSettingValueList(
- VOXLEVEL_LIST,
- VOXLEVEL_LIST[_settings.voxlevel]))
- basic.append(rs)
-
- rs = RadioSetting("voxdelay", "VOX delay",
- RadioSettingValueList(
- VOXDELAY_LIST,
- VOXDELAY_LIST[_settings.voxdelay]))
- basic.append(rs)
+ if self.MODEL == "RB18" or self.MODEL == "RB618":
+ rs = RadioSetting("scan", "Scan",
+ RadioSettingValueBoolean(_settings.scan))
+ basic.append(rs)
+ elif self.MODEL == "FRS-B1" or self.MODEL == "BF-V8A":
+ rs = RadioSetting("settings2.scan", "Scan",
+ RadioSettingValueBoolean(_settings2.scan))
+ basic.append(rs)
+ else:
+ rs = RadioSetting("scanmode", "Scan mode",
+ RadioSettingValueList(
+ SCANMODE_LIST,
+ SCANMODE_LIST[_settings.scanmode]))
+ basic.append(rs)
+
+ if self.MODEL == "RT22S":
+ rs = RadioSetting("voiceprompt", "Voice prompts",
+ RadioSettingValueBoolean(_settings.voiceprompt))
+ basic.append(rs)
+ elif self.MODEL == "RB18" or self.MODEL == "RB618":
+ rs = RadioSetting("voice", "Voice prompts",
+ RadioSettingValueBoolean(_settings.voice))
+ basic.append(rs)
+ elif self.MODEL == "FRS-B1" or self.MODEL == "BF-V8A":
+ rs = RadioSetting("settings2.voicesw", "Voice prompts",
+ RadioSettingValueBoolean(_settings2.voicesw))
+ basic.append(rs)
+ else:
+ rs = RadioSetting("voiceprompt", "Voice prompts",
+ RadioSettingValueList(
+ VOICE_LIST,
+ VOICE_LIST[_settings.voiceprompt]))
+ basic.append(rs)
rs = RadioSetting("batterysaver", "Battery saver",
RadioSettingValueBoolean(_settings.batterysaver))
basic.append(rs)
- rs = RadioSetting("beep", "Beep",
- RadioSettingValueBoolean(_settings.beep))
- basic.append(rs)
+ if self.MODEL != "RB75":
+ rs = RadioSetting("beep", "Beep",
+ RadioSettingValueBoolean(_settings.beep))
+ basic.append(rs)
+
+ if self.MODEL == "RB19" or self.MODEL == "RB19P" \
+ or self.MODEL == "RB619":
+ rs = RadioSetting("vox", "VOX",
+ RadioSettingValueBoolean(_settings.vox))
+ basic.append(rs)
+
+ if self.MODEL != "RB18" and self.MODEL != "RB618" \
+ and self.MODEL != "FRS-B1" \
+ and self.MODEL != "BF-V8A":
+ rs = RadioSetting("voxlevel", "Vox level",
+ RadioSettingValueList(
+ VOXLEVEL_LIST,
+ VOXLEVEL_LIST[_settings.voxlevel]))
+ basic.append(rs)
+
+ rs = RadioSetting("voxdelay", "VOX delay",
+ RadioSettingValueList(
+ VOXDELAY_LIST,
+ VOXDELAY_LIST[_settings.voxdelay]))
+ basic.append(rs)
+
+ if self.MODEL == "RT22S":
+ rs = RadioSetting("sidekey2", "Side Key 2(Long)",
+ RadioSettingValueList(
+ SIDEKEY2_LIST,
+ SIDEKEY2_LIST[_settings.sidekey2]))
+ basic.append(rs)
+
+ if self.MODEL == "RB18" or self.MODEL == "RB618":
+ rs = RadioSetting("language", "Language",
+ RadioSettingValueList(
+ VOICE_LIST2,
+ VOICE_LIST2[_settings.language]))
+ basic.append(rs)
+
+ rs = RadioSetting("tail", "Tail",
+ RadioSettingValueBoolean(_settings.tail))
+ basic.append(rs)
+
+ rs = RadioSetting("hivoltnotx", "High voltage no TX",
+ RadioSettingValueBoolean(_settings.hivoltnotx))
+ basic.append(rs)
+
+ rs = RadioSetting("lovoltnotx", "Low voltage no TX",
+ RadioSettingValueBoolean(_settings.lovoltnotx))
+ basic.append(rs)
+
+ rs = RadioSetting("vox", "VOX",
+ RadioSettingValueBoolean(_settings.vox))
+ basic.append(rs)
+
+ if _settings.vox_level > 4:
+ val = 1
+ else:
+ val = _settings.vox_level + 1
+ rs = RadioSetting("vox_level", "VOX level",
+ RadioSettingValueInteger(1, 5, val))
+ basic.append(rs)
+
+ rs = RadioSetting("rogerbeep", "Roger beep",
+ RadioSettingValueBoolean(_settings.rogerbeep))
+ basic.append(rs)
+
+ if self.MODEL == "RB85":
+ rs = RadioSetting("speccode", "SpecCode Select",
+ RadioSettingValueList(
+ SPECCODE_LIST,
+ SPECCODE_LIST[_settings.speccode]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey2", "Side Key 1(Short)",
+ RadioSettingValueList(
+ SIDEKEY85SHORT_LIST,
+ SIDEKEY85SHORT_LIST[_settings.sidekey2]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey1L", "Side Key 1(Long)",
+ RadioSettingValueList(
+ SIDEKEY85LONG_LIST,
+ SIDEKEY85LONG_LIST[_settings.sidekey1L]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey2S", "Side Key 2(Short)",
+ RadioSettingValueList(
+ SIDEKEY85SHORT_LIST,
+ SIDEKEY85SHORT_LIST[_settings.sidekey2S]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey2L", "Side Key 2(Long)",
+ RadioSettingValueList(
+ SIDEKEY85LONG_LIST,
+ SIDEKEY85LONG_LIST[_settings.sidekey2L]))
+ basic.append(rs)
+
+ rs = RadioSetting("power10w", "Power 10W",
+ RadioSettingValueBoolean(_settings.power10w))
+ basic.append(rs)
+
+ if self.MODEL == "RB75":
+ rs = RadioSetting("sidekey2", "Side Key 1(Short)",
+ RadioSettingValueList(
+ SIDEKEY75_LIST,
+ SIDEKEY75_LIST[_settings.sidekey2]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey1L", "Side Key 1(Long)",
+ RadioSettingValueList(
+ SIDEKEY75_LIST,
+ SIDEKEY75_LIST[_settings.sidekey1L]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey2S", "Side Key 2(Short)",
+ RadioSettingValueList(
+ SIDEKEY75_LIST,
+ SIDEKEY75_LIST[_settings.sidekey2S]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey2L", "Side Key 2(Long)",
+ RadioSettingValueList(
+ SIDEKEY75_LIST,
+ SIDEKEY75_LIST[_settings.sidekey2L]))
+ basic.append(rs)
+
+ rs = RadioSetting("power10w", "Low Voltage Stop TX",
+ RadioSettingValueBoolean(_settings.power10w))
+ basic.append(rs)
+
+ if self.MODEL == "FRS-B1":
+ rs = RadioSetting("settings2.hivoltnotx",
+ "High Voltage Inhibit TX",
+ RadioSettingValueBoolean(_settings2.hivoltnotx))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.lovoltnotx", "Low Voltage Inhibit TX",
+ RadioSettingValueBoolean(_settings2.lovoltnotx))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.vox", "Vox",
+ RadioSettingValueBoolean(_settings2.vox))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.voxnotxonrx", "Rx Disable VOX",
+ RadioSettingValueBoolean(_settings2.voxnotxonrx))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.voxgain", "Vox Gain",
+ RadioSettingValueInteger(
+ 1, 5, _settings2.voxgain))
+ basic.append(rs)
+
+ if self.MODEL == "RB19" or self.MODEL == "RB19P" \
+ or self.MODEL == "RB619":
+ rs = RadioSetting("sidekey2", "Left Navigation Button(Long)",
+ RadioSettingValueList(
+ SIDEKEY19_LIST,
+ SIDEKEY19_LIST[_settings.sidekey2]))
+ basic.append(rs)
+
+ if self.MODEL == "RT47" or self.MODEL == "RT47V" or \
+ self.MODEL == "RT647":
+ rs = RadioSetting("sidekey2", "Side Key 1(Long)",
+ RadioSettingValueList(
+ SIDEKEY47_LIST,
+ SIDEKEY47_LIST[_settings.sidekey2]))
+ basic.append(rs)
+
+ rs = RadioSetting("sidekey2S", "Side Key 2(Long)",
+ RadioSettingValueList(
+ SIDEKEY47_LIST,
+ SIDEKEY47_LIST[_settings.sidekey2S]))
+ basic.append(rs)
+
+ if self.MODEL == "BF-V8A":
+ rs = RadioSetting("sidekey2", "Side key",
+ RadioSettingValueList(
+ SIDEKEYV8A_LIST,
+ SIDEKEYV8A_LIST[_settings.sidekey2]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.rxemergency", "RX emergency",
+ RadioSettingValueBoolean(_settings2.rxemergency))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.voiceselect", "Language",
+ RadioSettingValueList(
+ VOICE_LIST2,
+ VOICE_LIST2[_settings2.voiceselect]))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.hivoltnotx",
+ "High voltage inhibit TX",
+ RadioSettingValueBoolean(_settings2.hivoltnotx))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.lovoltnotx", "Low voltage inhibit TX",
+ RadioSettingValueBoolean(_settings2.lovoltnotx))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.vox", "VOX",
+ RadioSettingValueBoolean(_settings2.vox))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.voxnotxonrx", "RX disable VOX",
+ RadioSettingValueBoolean(_settings2.voxnotxonrx))
+ basic.append(rs)
+
+ rs = RadioSetting("settings2.voxgain", "Vox Gain",
+ RadioSettingValueInteger(
+ 1, 5, _settings2.voxgain))
+ basic.append(rs)
return top
@@ -475,27 +918,342 @@ class T18Radio(chirp_common.CloneModeRadio):
if element.has_apply_callback():
LOG.debug("Using apply callback")
element.run_apply_callback()
+ elif setting == "vox_level":
+ setattr(obj, setting, int(element.value) - 1)
else:
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
-
@classmethod
def match_model(cls, filedata, filename):
- match_size = False
- match_model = False
+ if cls.MODEL == "T18":
+ match_size = False
+ match_model = False
- # testing the file data size
- if len(filedata) == cls._memsize:
- match_size = True
+ # testing the file data size
+ if len(filedata) == cls._memsize:
+ match_size = True
- # testing the model fingerprint
- match_model = model_match(cls, filedata)
+ # testing the model fingerprint
+ match_model = model_match(cls, filedata)
- if match_size and match_model:
- return True
+ if match_size and match_model:
+ return True
+ else:
+ return False
else:
+ # Radios that have always been post-metadata, so never do
+ # old-school detection
return False
+
+
+@directory.register
+class RT22SRadio(T18Radio):
+ """RETEVIS RT22S"""
+ VENDOR = "Retevis"
+ MODEL = "RT22S"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "9COGRAM"
+ _fingerprint = "SMP558" + "\x02"
+ _upper = 22
+ _mem_params = (_upper # number of channels
+ )
+ _frs = True
+ _pmr = False
+
+
+@directory.register
+class RB18Radio(T18Radio):
+ """RETEVIS RB18"""
+ VENDOR = "Retevis"
+ MODEL = "RB18"
+ BLOCK_SIZE = 0x10
+ CMD_EXIT = "E"
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PROGRAL"
+ _fingerprint = "P3107" + "\xF7"
+ _upper = 22
+ _mem_params = (_upper # number of channels
+ )
+ _frs = True
+ _pmr = False
+
+ _ranges = [
+ (0x0000, 0x0660),
+ ]
+ _memsize = 0x0660
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RB18 %
+ self._mem_params, self._mmap)
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+@directory.register
+class RB618Radio(RB18Radio):
+ """RETEVIS RB618"""
+ VENDOR = "Retevis"
+ MODEL = "RB618"
+
+ _upper = 16
+ _mem_params = (_upper # number of channels
+ )
+ _frs = False
+ _pmr = True
+
+
+@directory.register
+class RT68Radio(T18Radio):
+ """RETEVIS RT68"""
+ VENDOR = "Retevis"
+ MODEL = "RT68"
+ ACK_BLOCK = False
+ CMD_EXIT = ""
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "83OGRAM"
+ _fingerprint = "\x06\x00\x00\x00\x00\x00\x00\x00"
+ _upper = 16
+ _mem_params = (_upper # number of channels
+ )
+ _frs16 = True
+ _pmr = False
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+@directory.register
+class RT668Radio(RT68Radio):
+ """RETEVIS RT668"""
+ VENDOR = "Retevis"
+ MODEL = "RT668"
+
+ _frs = False
+ _pmr = True
+
+
+@directory.register
+class RB17Radio(RT68Radio):
+ """RETEVIS RB17"""
+ VENDOR = "Retevis"
+ MODEL = "RB17"
+
+ _magic = "A5OGRAM"
+ _fingerprint = "\x53\x00\x00\x00\x00\x00\x00\x00"
+
+ _frs16 = True
+ _pmr = False
+ _murs = False
+
+
+@directory.register
+class RB617Radio(RB17Radio):
+ """RETEVIS RB617"""
+ VENDOR = "Retevis"
+ MODEL = "RB617"
+
+ _frs = False
+ _pmr = True
+ _murs = False
+
+
+@directory.register
+class RB17VRadio(RB17Radio):
+ """RETEVIS RB17V"""
+ VENDOR = "Retevis"
+ MODEL = "RB17V"
+
+ VALID_BANDS = [(136000000, 174000000)]
+
+ _upper = 5
+
+ _frs = False
+ _pmr = False
+ _murs = True
+
+
+@directory.register
+class RB85Radio(T18Radio):
+ """Retevis RB85"""
+ VENDOR = "Retevis"
+ MODEL = "RB85"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=10.00),
+ chirp_common.PowerLevel("Low", watts=5.00)]
+
+ _magic = "H19GRAM"
+ _fingerprint = "SMP558" + "\x02"
+
+
+@directory.register
+class RB75Radio(T18Radio):
+ """Retevis RB75"""
+ VENDOR = "Retevis"
+ MODEL = "RB75"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "KVOGRAM"
+ _fingerprint = "SMP558" + "\x00"
+ _upper = 30
+ _mem_params = (_upper # number of channels
+ )
+ _gmrs = True
+
+
+@directory.register
+class FRSB1Radio(T18Radio):
+ """BTECH FRS-B1"""
+ VENDOR = "BTECH"
+ MODEL = "FRS-B1"
+ ACK_BLOCK = True
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PROGRAM"
+ _fingerprint = "P3107" + "\xF7\x00"
+ _upper = 22
+ _mem_params = (_upper # number of channels
+ )
+ _frs = True
+
+
+@directory.register
+class RB19Radio(T18Radio):
+ """Retevis RB19"""
+ VENDOR = "Retevis"
+ MODEL = "RB19"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "9COGRAM"
+ _fingerprint = "SMP558" + "\x02"
+ _upper = 22
+ _mem_params = (_upper # number of channels
+ )
+ _frs = True
+
+
+@directory.register
+class RB19PRadio(T18Radio):
+ """Retevis RB19P"""
+ VENDOR = "Retevis"
+ MODEL = "RB19P"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=3.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "70OGRAM"
+ _fingerprint = "SMP558" + "\x02"
+ _upper = 30
+ _mem_params = (_upper # number of channels
+ )
+ _gmrs = True
+
+
+@directory.register
+class RB619Radio(T18Radio):
+ """Retevis RB619"""
+ VENDOR = "Retevis"
+ MODEL = "RB619"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=0.500),
+ chirp_common.PowerLevel("Low", watts=0.499)]
+
+ _magic = "9COGRAM"
+ _fingerprint = "SMP558" + "\x02"
+ _upper = 16
+ _mem_params = (_upper # number of channels
+ )
+ _pmr = True
+
+
+@directory.register
+class RT47Radio(T18Radio):
+ """Retevis RT47"""
+ VENDOR = "Retevis"
+ MODEL = "RT47"
+ ACK_BLOCK = False
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.000),
+ chirp_common.PowerLevel("Low", watts=0.500)]
+
+ _magic = "47OGRAM"
+ _fingerprint = "\x06\x00\x00\x00\x00\x00\x00\x00"
+ _upper = 16
+ _mem_params = (_upper # number of channels
+ )
+ _frs16 = True
+ _echo = True
+
+
+@directory.register
+class RT47VRadio(RT47Radio):
+ """Retevis RT47V"""
+ VENDOR = "Retevis"
+ MODEL = "RT47V"
+
+ VALID_BANDS = [(136000000, 174000000)]
+
+ _upper = 5
+ _mem_params = (_upper # number of channels
+ )
+ _frs16 = False
+ _murs = True
+
+
+@directory.register
+class RT647Radio(RT47Radio):
+ """Retevis RT647"""
+ VENDOR = "Retevis"
+ MODEL = "RT647"
+
+ _frs16 = False
+ _pmr = True
+
+
+@directory.register
+class BFV8ARadio(T18Radio):
+ """Baofeng BF-V8A"""
+ VENDOR = "Baofeng"
+ MODEL = "BF-V8A"
+ ACK_BLOCK = True
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.000),
+ chirp_common.PowerLevel("Low", watts=0.500)]
+
+ _magic = "PROGRAM"
+ _fingerprint = "P3107" + "\xF7\x00\x00"
+ _upper = 16
+ _mem_params = (_upper # number of channels
+ )
+ _echo = False
diff --git a/chirp/drivers/retevis_rb15.py b/chirp/drivers/retevis_rb15.py
new file mode 100644
index 0000000..649a55c
--- /dev/null
+++ b/chirp/drivers/retevis_rb15.py
@@ -0,0 +1,801 @@
+# Copyright 2022 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import os
+import struct
+import re
+import logging
+
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueInteger, RadioSettingValueList, \
+ RadioSettingValueBoolean, RadioSettingValueString, \
+ RadioSettings
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+struct memory {
+ u32 rxfreq; // 00-03
+ u16 decQT; // 04-05
+ u32 txfreq; // 06-09
+ u16 encQT; // 0a-0b
+ u8 lowpower:1, // Power Level // 0c
+ unknown1:1,
+ isnarrow:1, // Bandwidth
+ bcl:2, // Busy Channel Lockout
+ scan:1, // Scan Add
+ encode:1, // Encode
+ unknown2:1;
+ u8 unknown3[3]; // 0d-0f
+};
+
+#seekto 0x0170;
+struct memory channels[22];
+
+#seekto 0x0162;
+struct {
+ u8 unknown_1:1, // 0x0162
+ voice:2, // Voice Prompt
+ beep:1, // Beep Switch
+ unknown_2:1,
+ vox:1, // VOX
+ autolock:1, // Auto Lock
+ vibrate:1; // Vibrate Switch
+ u8 squelch:4, // 0x0163 SQ Level
+ unknown_3:1,
+ volume:3; // Volume Level
+ u8 voxl:4, // 0x0164 VOX Level
+ voxd:4; // VOX Delay
+ u8 unknown_5:1, // 0x0165
+ save:3, // Power Save
+ calltone:4; // Call Tone
+ u8 unknown_6:4, // 0x0166
+ roger:2, // Roger Tone
+ backlight:2; // Backlight Set
+ u16 tot; // 0x0167-0x0168 Time-out Timer
+ u8 unknown_7[3]; // 0x0169-0x016B
+ u8 skeyul; // 0x016C Side Key Up Long
+ u8 skeyus; // 0x016D Side Key Up Short
+ u8 skeydl; // 0x016E Side Key Down Long
+ u8 skeyds; // 0x016F Side Key Down Short
+} settings;
+"""
+
+CMD_ACK = "\x06"
+
+RB15_DTCS = sorted(chirp_common.DTCS_CODES + [645])
+
+LIST_BACKLIGHT = ["Off", "On", "Auto"]
+LIST_BCL = ["None", "Carrier", "QT/DQT Match"]
+LIST_ROGER = ["Off", "Start", "End", "Start and End"]
+LIST_SAVE = ["Off", "1:1", "1:2", "1:3", "1:4", "1:5"]
+_STEP_LIST = [2.5, 5., 6.25, 10., 12.5, 20., 25., 50.]
+LIST_VOICE = ["Off", "Chinese", "English"]
+LIST_VOXD = ["0.0", "0.5", "1.0", "1.5", "2.0", "2.5", "3.0", "3.5", "4.0",
+ "4.5", "5.0S"]
+
+SKEY_CHOICES = ["None", "Scan", "Monitor", "VOX On/Off",
+ "Local Alarm", "Remote Alarm", "Backlight On/Off", "Call Tone"]
+SKEY_VALUES = [0x00, 0x01, 0x03, 0x04, 0x09, 0x0A, 0x13, 0x14]
+
+TOT_CHOICES = ["Off", "15", "30", "45", "60", "75", "90", "105", "120",
+ "135", "150", "165", "180", "195", "210", "225", "240",
+ "255", "270", "285", "300", "315", "330", "345", "360",
+ "375", "390", "405", "420", "435", "450", "465", "480",
+ "495", "510", "525", "540", "555", "570", "585", "600"
+ ]
+TOT_VALUES = [0x00, 0x0F, 0x1E, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78,
+ 0x87, 0x96, 0xA5, 0xB4, 0xC3, 0xD2, 0xE1, 0xF0,
+ 0xFF, 0x10E, 0x11D, 0x12C, 0x13B, 0x14A, 0x159, 0x168,
+ 0x177, 0x186, 0x195, 0x1A4, 0x1B3, 0x1C2, 0x1D1, 0x1E0,
+ 0x1EF, 0x1FE, 0x20D, 0x21C, 0x22B, 0x23A, 0x249, 0x258
+ ]
+
+FRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+FRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+FRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+FRS_FREQS = FRS_FREQS1 + FRS_FREQS2 + FRS_FREQS3
+
+PMR_FREQS1 = [446.00625, 446.01875, 446.03125, 446.04375, 446.05625,
+ 446.06875, 446.08125, 446.09375]
+PMR_FREQS2 = [446.10625, 446.11875, 446.13125, 446.14375, 446.15625,
+ 446.16875, 446.18125, 446.19375]
+PMR_FREQS = PMR_FREQS1 + PMR_FREQS2
+
+
+def _checksum(data):
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+ return cs % 256
+
+
+def tone2short(t):
+ """Convert a string tone or DCS to an encoded u16
+ """
+ tone = str(t)
+ if tone == "----":
+ u16tone = 0x0000
+ elif tone[0] == 'D': # This is a DCS code
+ c = tone[1: -1]
+ code = int(c, 8)
+ if tone[-1] == 'I':
+ code |= 0x4000
+ u16tone = code | 0x8000
+ else: # This is an analog CTCSS
+ u16tone = int(tone[0:-2]+tone[-1]) & 0xffff # strip the '.'
+ return u16tone
+
+
+def short2tone(tone):
+ """ Map a binary CTCSS/DCS to a string name for the tone
+ """
+ if tone == 0 or tone == 0xffff:
+ ret = "----"
+ else:
+ code = tone & 0x3fff
+ if tone & 0x4000: # This is a DCS
+ ret = "D%0.3oN" % code
+ elif tone & 0x8000: # This is an inverse code
+ ret = "D%0.3oI" % code
+ else: # Just plain old analog CTCSS
+ ret = "%4.1f" % (code / 10.0)
+ return ret
+
+
+def _rb15_enter_programming_mode(radio):
+ serial = radio.pipe
+
+ # lengthen the timeout here as these radios are resetting due to timeout
+ radio.pipe.timeout = 0.75
+
+ exito = False
+ for i in range(0, 5):
+ serial.write(radio.magic)
+ ack = serial.read(1)
+
+ try:
+ if ack == CMD_ACK:
+ exito = True
+ break
+ except:
+ LOG.debug("Attempt #%s, failed, trying again" % i)
+ pass
+
+ # return timeout to default value
+ radio.pipe.timeout = 0.25
+
+ # check if we had EXITO
+ if exito is False:
+ msg = "The radio did not accept program mode after five tries.\n"
+ msg += "Check you interface cable and power cycle your radio."
+ raise errors.RadioError(msg)
+
+
+def _rb15_exit_programming_mode(radio):
+ serial = radio.pipe
+ try:
+ serial.write("21" + "\x05\xEE" + "V")
+ except:
+ raise errors.RadioError("Radio refused to exit programming mode")
+
+
+def _rb15_read_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">BH", ord('R'), block_addr)
+
+ ccs = _checksum(cmd)
+
+ expectedresponse = "R" + cmd[1:]
+
+ cmd = cmd + chr(ccs)
+
+ LOG.debug("Reading block %04x..." % (block_addr))
+
+ try:
+ serial.write(cmd)
+ response = serial.read(3 + block_size + 1)
+
+ cs = _checksum(response[:-1])
+
+ if response[:3] != expectedresponse:
+ raise Exception("Error reading block %04x." % (block_addr))
+
+ chunk = response[3:]
+
+ if ord(chunk[-1]) != cs:
+ raise Exception("Block failed checksum!")
+
+ block_data = chunk[:-1]
+ except:
+ raise errors.RadioError("Failed to read block at %04x" % block_addr)
+
+ return block_data
+
+
+def _rb15_write_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">BH", ord('W'), block_addr)
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
+
+ cs = _checksum(cmd + data)
+ data += chr(cs)
+
+ LOG.debug("Writing Data:")
+ LOG.debug(util.hexprint(cmd + data))
+
+ try:
+ serial.write(cmd + data)
+ if serial.read(1) != CMD_ACK:
+ raise Exception("No ACK")
+ except:
+ raise errors.RadioError("Failed to send block "
+ "to radio at %04x" % block_addr)
+
+
+def do_download(radio):
+ LOG.debug("download")
+ _rb15_enter_programming_mode(radio)
+
+ data = ""
+
+ status = chirp_common.Status()
+ status.msg = "Cloning from radio"
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for addr in range(0x0000, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+
+ block = _rb15_read_block(radio, addr, radio.BLOCK_SIZE)
+ data += block
+
+ LOG.debug("Address: %04x" % addr)
+ LOG.debug(util.hexprint(block))
+
+ _rb15_exit_programming_mode(radio)
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ status = chirp_common.Status()
+ status.msg = "Uploading to radio"
+
+ _rb15_enter_programming_mode(radio)
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for start_addr, end_addr in radio._ranges:
+ for addr in range(start_addr, end_addr, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+ _rb15_write_block(radio, addr, radio.BLOCK_SIZE)
+
+ _rb15_exit_programming_mode(radio)
+
+
+def _split(rf, f1, f2):
+ """Returns False if the two freqs are in the same band (no split)
+ or True otherwise"""
+
+ # determine if the two freqs are in the same band
+ for low, high in rf.valid_bands:
+ if f1 >= low and f1 <= high and \
+ f2 >= low and f2 <= high:
+ # if the two freqs are on the same Band this is not a split
+ return False
+
+ # if you get here is because the freq pairs are split
+ return True
+
+
+class RB15RadioBase(chirp_common.CloneModeRadio):
+ """RETEVIS RB15 BASE"""
+ VENDOR = "Retevis"
+ BAUD_RATE = 9600
+
+ BLOCK_SIZE = 0x10
+ magic = "21" + "\x05\x10" + "x"
+
+ VALID_BANDS = [(400000000, 520000000)]
+
+ _ranges = [
+ (0x0150, 0x07A0),
+ ]
+ _memsize = 0x07A0
+
+ _frs = _pmr = False
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_rx_dtcs = True
+ rf.has_tuning_step = False
+ rf.can_odd_split = True
+ rf.has_name = False
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.valid_duplexes = ["", "-", "+", "split", "off"]
+ rf.valid_modes = ["FM", "NFM"] # 25 KHz, 12.5 KHz.
+ rf.valid_dtcs_codes = RB15_DTCS
+ rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = _STEP_LIST
+ rf.valid_bands = self.VALID_BANDS
+
+ return rf
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ data = do_download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = data
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ do_upload(self)
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ def _get_tone(self, _mem, mem):
+ """Decode both the encode and decode CTSS/DCS codes from
+ the memory channel and stuff them into the UI
+ memory channel row.
+ """
+ txtone = short2tone(_mem.encQT)
+ rxtone = short2tone(_mem.decQT)
+ pt = "N"
+ pr = "N"
+
+ if txtone == "----":
+ txmode = ""
+ elif txtone[0] == "D":
+ mem.dtcs = int(txtone[1:4])
+ if txtone[4] == "I":
+ pt = "R"
+ txmode = "DTCS"
+ else:
+ mem.rtone = float(txtone)
+ txmode = "Tone"
+
+ if rxtone == "----":
+ rxmode = ""
+ elif rxtone[0] == "D":
+ mem.rx_dtcs = int(rxtone[1:4])
+ if rxtone[4] == "I":
+ pr = "R"
+ rxmode = "DTCS"
+ else:
+ mem.ctone = float(rxtone)
+ rxmode = "Tone"
+
+ if txmode == "Tone" and len(rxmode) == 0:
+ mem.tmode = "Tone"
+ elif (txmode == rxmode and txmode == "Tone" and
+ mem.rtone == mem.ctone):
+ mem.tmode = "TSQL"
+ elif (txmode == rxmode and txmode == "DTCS" and
+ mem.dtcs == mem.rx_dtcs):
+ mem.tmode = "DTCS"
+ elif (len(rxmode) + len(txmode)) > 0:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ mem.dtcs_polarity = pt + pr
+
+ LOG.debug("_get_tone: Got TX %s (%i) RX %s (%i)" %
+ (txmode, _mem.encQT, rxmode, _mem.decQT))
+
+ def _set_tone(self, mem, _mem):
+ """Update the memory channel block CTCC/DCS tones
+ from the UI fields
+ """
+ def _set_dcs(code, pol):
+ val = int("%i" % code, 8) | 0x4000
+ if pol == "R":
+ val = int("%i" % code, 8) | 0x8000
+ return val
+
+ rx_mode = tx_mode = None
+ rxtone = txtone = 0x0000
+
+ if mem.tmode == "Tone":
+ tx_mode = "Tone"
+ txtone = int(mem.rtone * 10)
+ elif mem.tmode == "TSQL":
+ rx_mode = tx_mode = "Tone"
+ rxtone = txtone = int(mem.ctone * 10)
+ elif mem.tmode == "DTCS":
+ tx_mode = rx_mode = "DTCS"
+ txtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ rxtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[1])
+ elif mem.tmode == "Cross":
+ tx_mode, rx_mode = mem.cross_mode.split("->")
+ if tx_mode == "DTCS":
+ txtone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
+ elif tx_mode == "Tone":
+ txtone = int(mem.rtone * 10)
+ if rx_mode == "DTCS":
+ rxtone = _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[1])
+ elif rx_mode == "Tone":
+ rxtone = int(mem.ctone * 10)
+
+ _mem.decQT = rxtone
+ _mem.encQT = txtone
+
+ LOG.debug("Set TX %s (%i) RX %s (%i)" %
+ (tx_mode, _mem.encQT, rx_mode, _mem.decQT))
+
+ def get_memory(self, number):
+ mem = chirp_common.Memory()
+ _mem = self._memobj.channels[number - 1]
+ mem.number = number
+
+ mem.freq = int(_mem.rxfreq) * 10
+
+ # We'll consider any blank (i.e. 0MHz frequency) to be empty
+ if mem.freq == 0:
+ mem.empty = True
+ return mem
+
+ if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
+ mem.freq = 0
+ mem.empty = True
+ return mem
+
+ if _mem.get_raw() == ("\xFF" * 16):
+ LOG.debug("Initializing empty memory")
+ _mem.set_raw("\x00" * 16)
+
+ # Freq and offset
+ mem.freq = int(_mem.rxfreq) * 10
+ # tx freq can be blank
+ if _mem.get_raw()[4] == "\xFF":
+ # TX freq not set
+ mem.offset = 0
+ mem.duplex = "off"
+ else:
+ # TX freq set
+ offset = (int(_mem.txfreq) * 10) - mem.freq
+ if offset != 0:
+ if _split(self.get_features(), mem.freq, int(
+ _mem.txfreq) * 10):
+ mem.duplex = "split"
+ mem.offset = int(_mem.txfreq) * 10
+ elif offset < 0:
+ mem.offset = abs(offset)
+ mem.duplex = "-"
+ elif offset > 0:
+ mem.offset = offset
+ mem.duplex = "+"
+ else:
+ mem.offset = 0
+
+ mem.mode = _mem.isnarrow and "NFM" or "FM"
+
+ self._get_tone(_mem, mem)
+
+ mem.power = self.POWER_LEVELS[_mem.lowpower]
+
+ if not _mem.scan:
+ mem.skip = "S"
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ rs = RadioSetting("bcl", "BCL",
+ RadioSettingValueList(
+ LIST_BCL, LIST_BCL[_mem.bcl]))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("encode", "Encode",
+ RadioSettingValueBoolean(_mem.encode))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ LOG.debug("Setting %i(%s)" % (mem.number, mem.extd_number))
+ _mem = self._memobj.channels[mem.number - 1]
+
+ # if empty memory
+ if mem.empty:
+ _mem.set_raw("\xFF" * 8 + "\x00" * 5 + "\xFF" * 3)
+ return
+
+ if self._frs:
+ if mem.number >= 1 and mem.number <= 22:
+ FRS_FREQ = int(FRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = FRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ if mem.number >= 8 and mem.number <= 14:
+ mem.power = self.POWER_LEVELS[1]
+ elif self._pmr:
+ if mem.number >= 1 and mem.number <= 16:
+ PMR_FREQ = int(PMR_FREQS[mem.number - 1] * 1000000)
+ mem.freq = PMR_FREQ
+ mem.duplex = ''
+ mem.offset = 0
+ mem.mode = "NFM"
+
+ _mem.rxfreq = mem.freq / 10
+
+ if mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw("\xFF")
+ elif mem.duplex == "split":
+ _mem.txfreq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.txfreq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.txfreq = mem.freq / 10
+
+ _mem.scan = mem.skip != "S"
+ _mem.isnarrow = mem.mode == "NFM"
+
+ self._set_tone(mem, _mem)
+
+ _mem.lowpower = mem.power == self.POWER_LEVELS[1]
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ sidekey = RadioSettingGroup("sidekey", "Side Key Settings")
+ voxset = RadioSettingGroup("vox", "VOX Settings")
+ top = RadioSettings(basic, sidekey, voxset)
+
+ voice = RadioSetting("voice", "Language", RadioSettingValueList(
+ LIST_VOICE, LIST_VOICE[_settings.voice]))
+ basic.append(voice)
+
+ beep = RadioSetting("beep", "Key Beep",
+ RadioSettingValueBoolean(_settings.beep))
+ basic.append(beep)
+
+ volume = RadioSetting("volume", "Volume Level",
+ RadioSettingValueInteger(
+ 0, 7, _settings.volume))
+ basic.append(volume)
+
+ save = RadioSetting("save", "Battery Save",
+ RadioSettingValueList(
+ LIST_SAVE, LIST_SAVE[_settings.save]))
+ basic.append(save)
+
+ backlight = RadioSetting("backlight", "Backlight",
+ RadioSettingValueList(
+ LIST_BACKLIGHT,
+ LIST_BACKLIGHT[_settings.backlight]))
+ basic.append(backlight)
+
+ vibrate = RadioSetting("vibrate", "Vibrate",
+ RadioSettingValueBoolean(_settings.vibrate))
+ basic.append(vibrate)
+
+ autolock = RadioSetting("autolock", "Auto Lock",
+ RadioSettingValueBoolean(_settings.autolock))
+ basic.append(autolock)
+
+ calltone = RadioSetting("calltone", "Call Tone",
+ RadioSettingValueInteger(
+ 1, 10, _settings.calltone))
+ basic.append(calltone)
+
+ roger = RadioSetting("roger", "Roger Tone",
+ RadioSettingValueList(
+ LIST_ROGER, LIST_ROGER[_settings.roger]))
+ basic.append(roger)
+
+ squelch = RadioSetting("squelch", "Squelch Level",
+ RadioSettingValueInteger(
+ 0, 10, _settings.squelch))
+ basic.append(squelch)
+
+ def apply_tot_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(
+ setting.value) + " from list")
+ val = str(setting.value)
+ index = TOT_CHOICES.index(val)
+ val = TOT_VALUES[index]
+ obj.set_value(val)
+
+ if _settings.tot in TOT_VALUES:
+ idx = TOT_VALUES.index(_settings.tot)
+ else:
+ idx = TOT_VALUES.index(0x78)
+ rs = RadioSettingValueList(TOT_CHOICES, TOT_CHOICES[idx])
+ rset = RadioSetting("tot", "Time-out Timer", rs)
+ rset.set_apply_callback(apply_tot_listvalue, _settings.tot)
+ basic.append(rset)
+
+ # Side Key Settings
+ def apply_skey_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(
+ setting.value) + " from list")
+ val = str(setting.value)
+ index = SKEY_CHOICES.index(val)
+ val = SKEY_VALUES[index]
+ obj.set_value(val)
+
+ # Side Key (Upper) - Short Press
+ if _settings.skeyus in SKEY_VALUES:
+ idx = SKEY_VALUES.index(_settings.skeyus)
+ else:
+ idx = SKEY_VALUES.index(0x01)
+ rs = RadioSettingValueList(SKEY_CHOICES, SKEY_CHOICES[idx])
+ rset = RadioSetting("skeyus", "Side Key(upper) - Short Press", rs)
+ rset.set_apply_callback(apply_skey_listvalue, _settings.skeyus)
+ sidekey.append(rset)
+
+ # Side Key (Upper) - Long Press
+ if _settings.skeyul in SKEY_VALUES:
+ idx = SKEY_VALUES.index(_settings.skeyul)
+ else:
+ idx = SKEY_VALUES.index(0x04)
+ rs = RadioSettingValueList(SKEY_CHOICES, SKEY_CHOICES[idx])
+ rset = RadioSetting("skeyul", "Side Key(upper) - Long Press", rs)
+ rset.set_apply_callback(apply_skey_listvalue, _settings.skeyul)
+ sidekey.append(rset)
+
+ # Side Key (Lower) - Short Press
+ if _settings.skeyds in SKEY_VALUES:
+ idx = SKEY_VALUES.index(_settings.skeyds)
+ else:
+ idx = SKEY_VALUES.index(0x03)
+ rs = RadioSettingValueList(SKEY_CHOICES, SKEY_CHOICES[idx])
+ rset = RadioSetting("skeyds", "Side Key(lower) - Short Press", rs)
+ rset.set_apply_callback(apply_skey_listvalue, _settings.skeyds)
+ sidekey.append(rset)
+
+ # Side Key (Lower) - Long Press
+ if _settings.skeyul in SKEY_VALUES:
+ idx = SKEY_VALUES.index(_settings.skeydl)
+ else:
+ idx = SKEY_VALUES.index(0x14)
+ rs = RadioSettingValueList(SKEY_CHOICES, SKEY_CHOICES[idx])
+ rset = RadioSetting("skeydl", "Side Key(lower) - Long Press", rs)
+ rset.set_apply_callback(apply_skey_listvalue, _settings.skeydl)
+ sidekey.append(rset)
+
+ # VOX Settings
+ vox = RadioSetting("vox", "VOX",
+ RadioSettingValueBoolean(_settings.vox))
+ voxset.append(vox)
+
+ voxl = RadioSetting("voxl", "VOX Level",
+ RadioSettingValueInteger(
+ 0, 10, _settings.voxl))
+ voxset.append(voxl)
+
+ voxd = RadioSetting("voxd", "VOX Delay (seconde)",
+ RadioSettingValueList(
+ LIST_VOXD, LIST_VOXD[_settings.voxd]))
+ voxset.append(voxd)
+
+ return top
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+@directory.register
+class RB15Radio(RB15RadioBase):
+ """RETEVIS RB15"""
+ VENDOR = "Retevis"
+ MODEL = "RB15"
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _ranges = [
+ (0x0150, 0x07A0),
+ ]
+ _memsize = 0x07A0
+
+ _upper = 22
+ _frs = True
+
+
+@directory.register
+class RB615RadioBase(RB15RadioBase):
+ """RETEVIS RB615"""
+ VENDOR = "Retevis"
+ MODEL = "RB615"
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=0.50),
+ chirp_common.PowerLevel("Low", watts=0.49)]
+
+ _ranges = [
+ (0x0150, 0x07A0),
+ ]
+ _memsize = 0x07A0
+
+ _upper = 16
+ _pmr = True
diff --git a/chirp/drivers/retevis_rb17p.py b/chirp/drivers/retevis_rb17p.py
new file mode 100644
index 0000000..321c628
--- /dev/null
+++ b/chirp/drivers/retevis_rb17p.py
@@ -0,0 +1,602 @@
+# Copyright 2022 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import os
+import struct
+import unittest
+import logging
+
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueInteger, RadioSettingValueList, \
+ RadioSettingValueBoolean, RadioSettings
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+#seekto 0x1000;
+struct {
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ lbcd rxtone[2];
+ lbcd txtone[2];
+ u8 unknown1:4,
+ compander:1,
+ unknown2:1,
+ highpower:1,
+ unknown3:1;
+ u8 unknown4:3,
+ wide:1,
+ scan:1,
+ unknown4:1,
+ bcl:2;
+ u8 unknown6[2];
+} memory[128];
+#seekto 0x0810;
+struct {
+ u8 unknown01:5,
+ dualwatch:1,
+ workmode:2;
+ u8 scanmode:2,
+ unknown02:3,
+ autokeylock:1,
+ unknown03:2;
+ u8 unknown04:1,
+ beep:1,
+ unknown05:1,
+ voice:1,
+ unknown06:1,
+ noaa:1,
+ batterysave:2;
+ u8 squelchlevel;
+ u8 unknown07:5,
+ timeouttimer:2,
+ unknown08:1;
+ u8 alarmtype:1,
+ voxdelay:3,
+ voxlevel:4;
+ u8 unknown10:2,
+ backlight:2,
+ unknown11:4;
+ u8 unknown12[3];
+ u8 unknown13:3,
+ rogerbeep:1,
+ unknown14:1,
+ sidekey:3;
+} settings;
+#seekto 0x0010;
+struct {
+ char name[10]; // 10-character Alpha Tag
+} names[128];
+
+"""
+
+CMD_ACK = "\x06"
+
+ALARMTYPE_LIST = ["Local & Remote", "Local"]
+BACKLIGHT_LIST = ["5 seconds", "10 seconds", "30 seconds", "Always"]
+BATTERYSAVE_LIST = ["Off", "1:4", "1:8"]
+SCANMODE_LIST = ["Time Operated", "Carrier Operated", "Search"]
+SIDEKEY_LIST = ["Off", "Scan", "VOX", "2nd PTT", "NOAA", "Monitor"]
+TIMEOUTTIMER_LIST = ["60 seconds", "120 seconds", "180 seconds"]
+VOXDELAY_LIST = ["0.3", "0.5", "1", "1.5", "2", "2.5"]
+VOXLEVEL_LIST = ["Off", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+WORKMODE_LIST = ["Frequencies", "Channel Numbers", "Names"]
+
+SETTING_LISTS = {
+ "alarmtype": ALARMTYPE_LIST,
+ "backlight": BACKLIGHT_LIST,
+ "batterysave": BATTERYSAVE_LIST,
+ "scanmode": SCANMODE_LIST,
+ "sidekey": SIDEKEY_LIST,
+ "timeouttimer": TIMEOUTTIMER_LIST,
+ "voxdelay": VOXDELAY_LIST,
+ "voxlevel": VOXLEVEL_LIST,
+ "workmode": WORKMODE_LIST
+}
+
+BCL = ["Off", "Carrier", "QT/DCS"]
+
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+
+
+def _enter_programming_mode(radio):
+ serial = radio.pipe
+
+ try:
+ serial.write("\x02")
+ time.sleep(0.01)
+ serial.write(radio._magic)
+ ack = serial.read(1)
+ except:
+ raise errors.RadioError("Error communicating with radio")
+
+ if not ack:
+ raise errors.RadioError("No response from radio")
+ elif ack != CMD_ACK:
+ raise errors.RadioError("Radio refused to enter programming mode")
+
+ try:
+ serial.write("M" + "\x02")
+ ident = serial.read(8)
+ except:
+ raise errors.RadioError("Error communicating with radio")
+
+ if not ident.startswith(radio._fingerprint):
+ LOG.debug(util.hexprint(ident))
+ raise errors.RadioError("Radio returned unknown identification string")
+
+ try:
+ serial.write(CMD_ACK)
+ ack = serial.read(1)
+ except:
+ raise errors.RadioError("Error communicating with radio")
+
+ if ack != CMD_ACK:
+ raise errors.RadioError("Radio refused to enter programming mode")
+
+
+def _read_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">cHb", 'R', block_addr, block_size)
+ expectedresponse = "W" + cmd[1:]
+ LOG.debug("Reading block %04x..." % (block_addr))
+
+ try:
+ serial.write(cmd)
+ response = serial.read(4 + block_size)
+ if response[:4] != expectedresponse:
+ raise Exception("Error reading block %04x." % (block_addr))
+
+ block_data = response[4:]
+ except:
+ raise errors.RadioError("Failed to read block at %04x" % block_addr)
+
+ return block_data
+
+
+def _write_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">cHb", 'W', block_addr, block_size)
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
+
+ LOG.debug("Writing Data:")
+ LOG.debug(util.hexprint(cmd + data))
+
+ try:
+ serial.write(cmd + data)
+ if serial.read(1) != CMD_ACK:
+ raise Exception("No ACK")
+ except:
+ raise errors.RadioError("Failed to send block "
+ "to radio at %04x" % block_addr)
+
+
+def do_download(radio):
+ LOG.debug("download")
+ _enter_programming_mode(radio)
+
+ data = ""
+
+ status = chirp_common.Status()
+ status.msg = "Cloning from radio"
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+
+ block = _read_block(radio, addr, radio.BLOCK_SIZE)
+ data += block
+
+ LOG.debug("Address: %04x" % addr)
+ LOG.debug(util.hexprint(block))
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ status = chirp_common.Status()
+ status.msg = "Uploading to radio"
+
+ _enter_programming_mode(radio)
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for start_addr, end_addr, block_size in radio._ranges:
+ for addr in range(start_addr, end_addr, block_size):
+ status.cur = addr + block_size
+ radio.status_fn(status)
+ _write_block(radio, addr, block_size)
+
+
+class RB17P_Base(chirp_common.CloneModeRadio):
+ """Base class for Retevis RB17P"""
+ VENDOR = "Retevis"
+ MODEL = "RB17P Base"
+ BAUD_RATE = 9600
+ BLOCK_SIZE = 0x40
+
+ VALID_BANDS = [(400000000, 470000000)]
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PGA588"
+ _fingerprint = "\xFF" * 8
+ _upper = 128
+ _gmrs = True
+ _ranges = [(0x0000, 0x1800, 0x40),
+ ]
+ _memsize = 0x1800
+ _valid_chars = chirp_common.CHARSET_ALPHANUMERIC + \
+ "`~!@#$%^&*()-=_+[]\\{}|;':\",./<>?"
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.valid_modes = ["NFM", "FM"] # 12.5 KHz, 25 kHz.
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_duplexes = ["", "-", "+", "split", "off"]
+ rf.valid_power_levels = self.POWER_LEVELS
+ rf.can_odd_split = True
+ rf.has_rx_dtcs = True
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.valid_cross_modes = [
+ "Tone->Tone",
+ "DTCS->",
+ "->DTCS",
+ "Tone->DTCS",
+ "DTCS->Tone",
+ "->Tone",
+ "DTCS->DTCS"]
+ rf.has_tuning_step = False
+ rf.has_bank = False
+ rf.has_name = True
+ rf.valid_name_length = 10
+ rf.valid_characters = self._valid_chars
+ rf.memory_bounds = (1, 128)
+ rf.valid_bands = self.VALID_BANDS
+ rf.valid_tuning_steps = chirp_common.TUNING_STEPS
+
+ return rf
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def sync_in(self):
+ self._mmap = do_download(self)
+ self.process_mmap()
+
+ def sync_out(self):
+ do_upload(self)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ def _decode_tone(self, val):
+ val = int(val)
+ if val == 16665:
+ return '', None, None
+ elif val >= 12000:
+ return 'DTCS', val - 12000, 'R'
+ elif val >= 8000:
+ return 'DTCS', val - 8000, 'N'
+ else:
+ return 'Tone', val / 10.0, None
+
+ def _encode_tone(self, memval, mode, value, pol):
+ if mode == '':
+ memval[0].set_raw(0xFF)
+ memval[1].set_raw(0xFF)
+ elif mode == 'Tone':
+ memval.set_value(int(value * 10))
+ elif mode == 'DTCS':
+ flag = 0x80 if pol == 'N' else 0xC0
+ memval.set_value(value)
+ memval[1].set_bits(flag)
+ else:
+ raise Exception("Internal error: invalid mode `%s'" % mode)
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number - 1]
+ _nam = self._memobj.names[number - 1]
+
+ mem = chirp_common.Memory()
+
+ mem.number = number
+ mem.freq = int(_mem.rxfreq) * 10
+
+ # We'll consider any blank (i.e. 0MHz frequency) to be empty
+ if mem.freq == 0:
+ mem.empty = True
+ return mem
+
+ if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
+ mem.freq = 0
+ mem.empty = True
+ return mem
+
+ if _mem.txfreq.get_raw() == "\xFF\xFF\xFF\xFF":
+ mem.duplex = "off"
+ mem.offset = 0
+ elif int(_mem.rxfreq) == int(_mem.txfreq):
+ mem.duplex = ""
+ mem.offset = 0
+ else:
+ mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
+ mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
+
+ for char in _nam.name:
+ if str(char) == "\xFF":
+ char = " " # may have 0xFF mid-name
+ mem.name += str(char)
+ mem.name = mem.name.rstrip()
+
+ mem.mode = _mem.wide and "FM" or "NFM"
+
+ mem.skip = not _mem.scan and "S" or ""
+
+ txtone = self._decode_tone(_mem.txtone)
+ rxtone = self._decode_tone(_mem.rxtone)
+ chirp_common.split_tone_decode(mem, txtone, rxtone)
+
+ mem.power = self.POWER_LEVELS[1 - _mem.highpower]
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+ rs = RadioSetting("bcl", "Busy Channel Lockout",
+ RadioSettingValueList(BCL, BCL[_mem.bcl]))
+ mem.extra.append(rs)
+ rs = RadioSetting("compander", "Compander",
+ RadioSettingValueBoolean(_mem.compander))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[mem.number - 1]
+ _nam = self._memobj.names[mem.number - 1]
+
+ if mem.empty:
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
+ _nam.set_raw("\xFF" * (_nam.size() // 8))
+
+ return
+
+ _mem.set_raw("\x00" * (_mem.size() // 8))
+
+ if self._gmrs:
+ if float(mem.freq) / 1000000 in GMRS_FREQS1:
+ mem.duplex == ''
+ mem.offset = 0
+ elif float(mem.freq) / 1000000 in GMRS_FREQS2:
+ mem.duplex == ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ elif float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.duplex == ''
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
+ _mem.rxfreq = mem.freq / 10
+
+ if mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw("\xFF")
+ elif mem.duplex == "split":
+ _mem.txfreq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.txfreq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.txfreq = mem.freq / 10
+
+ _namelength = self.get_features().valid_name_length
+ for i in range(_namelength):
+ try:
+ _nam.name[i] = mem.name[i]
+ except IndexError:
+ _nam.name[i] = "\xFF"
+
+ txtone, rxtone = chirp_common.split_tone_encode(mem)
+ self._encode_tone(_mem.txtone, *txtone)
+ self._encode_tone(_mem.rxtone, *rxtone)
+
+ if self.MODEL != "T18" and self.MODEL != "RB18":
+ _mem.highpower = mem.power == self.POWER_LEVELS[0]
+
+ _mem.wide = mem.mode == "FM"
+ _mem.scan = mem.skip == ""
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), int(setting.value))
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ top = RadioSettings(basic)
+
+ # Menu 01 - Work Mode
+ rs = RadioSetting("workmode", "Work Mode",
+ RadioSettingValueList(
+ WORKMODE_LIST,
+ WORKMODE_LIST[(_settings.workmode) - 1]))
+ basic.append(rs)
+
+ # Menu 04 - Squelch
+ rs = RadioSetting("squelchlevel", "Squelch level",
+ RadioSettingValueInteger(
+ 0, 9, _settings.squelchlevel))
+ basic.append(rs)
+
+ # Menu 05 - Battery Save
+ rs = RadioSetting("batterysave", "Battery Save",
+ RadioSettingValueList(
+ BATTERYSAVE_LIST,
+ BATTERYSAVE_LIST[_settings.batterysave]))
+ basic.append(rs)
+
+ # Menu 06 - Dual Watch
+ rs = RadioSetting("dualwatch", "Dual Watch",
+ RadioSettingValueBoolean(_settings.dualwatch))
+ basic.append(rs)
+
+ # Menu 07 - Backlight Duration[s]
+ rs = RadioSetting("backlight", "Backlight Duration",
+ RadioSettingValueList(
+ BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.backlight]))
+ basic.append(rs)
+
+ # Menu 09 - Beep Tone
+ rs = RadioSetting("beep", "Key Beep",
+ RadioSettingValueBoolean(_settings.beep))
+ basic.append(rs)
+
+ # Menu 10 - Voice Annunciation
+ rs = RadioSetting("voice", "Voice prompts",
+ RadioSettingValueBoolean(_settings.voice))
+ basic.append(rs)
+
+ # Menu 11 - Time out Timer[s]
+ rs = RadioSetting("timeouttimer", "Timeout timer",
+ RadioSettingValueList(
+ TIMEOUTTIMER_LIST,
+ TIMEOUTTIMER_LIST[
+ (_settings.timeouttimer) - 1]))
+ basic.append(rs)
+
+ # Menu 12 - Roger Tone
+ rs = RadioSetting("rogerbeep", "Roger beep",
+ RadioSettingValueBoolean(_settings.rogerbeep))
+ basic.append(rs)
+
+ # Menu 13 - SideKey
+ rs = RadioSetting("sidekey", "Side Key",
+ RadioSettingValueList(
+ SIDEKEY_LIST,
+ SIDEKEY_LIST[_settings.sidekey]))
+ basic.append(rs)
+
+ # Menu 14 - Auto Key Lock
+ rs = RadioSetting("autokeylock", "Auto Key Lock",
+ RadioSettingValueBoolean(_settings.autokeylock))
+ basic.append(rs)
+
+ # Menu 17 - NOAA
+ rs = RadioSetting("noaa", "NOAA",
+ RadioSettingValueBoolean(_settings.noaa))
+ basic.append(rs)
+
+ # Scan Mode
+ rs = RadioSetting("scanmode", "Scan mode",
+ RadioSettingValueList(
+ SCANMODE_LIST,
+ SCANMODE_LIST[_settings.scanmode]))
+ basic.append(rs)
+
+ # Alarm Type
+ rs = RadioSetting("alarmtype", "Alarm Type",
+ RadioSettingValueList(
+ ALARMTYPE_LIST,
+ ALARMTYPE_LIST[_settings.alarmtype]))
+ basic.append(rs)
+
+ # VOX Level
+ rs = RadioSetting("voxlevel", "Vox level",
+ RadioSettingValueList(
+ VOXLEVEL_LIST,
+ VOXLEVEL_LIST[_settings.voxlevel]))
+ basic.append(rs)
+
+ # VOX Delay
+ rs = RadioSetting("voxdelay", "Vox delay",
+ RadioSettingValueList(
+ VOXDELAY_LIST,
+ VOXDELAY_LIST[_settings.voxdelay]))
+ basic.append(rs)
+
+ return top
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif setting == "timeouttimer":
+ setattr(obj, setting, int(element.value) + 1)
+ elif setting == "workmode":
+ setattr(obj, setting, int(element.value) + 1)
+ else:
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # Radios that have always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+@directory.register
+class RB17PRadio(RB17P_Base):
+ """Retevis RB17P"""
+ VENDOR = "Retevis"
+ MODEL = "RB17P"
+ _gmrs = True
+ _ranges = [(0x0010, 0x0510, 0x40),
+ (0x0810, 0x0830, 0x30),
+ (0x1000, 0x1800, 0x40)
+ ]
diff --git a/chirp/drivers/retevis_rt1.py b/chirp/drivers/retevis_rt1.py
index 96baa13..59e6263 100644
--- a/chirp/drivers/retevis_rt1.py
+++ b/chirp/drivers/retevis_rt1.py
@@ -75,6 +75,8 @@ struct {
u8 k1longp; // Key 1 Long Press
u8 k2longp; // Key 2 Long Press
u8 lpt; // Long Press Time
+ u8 unknown7:6,
+ txtone:2; // TX Tone
} settings;
#seekto 0x0170;
@@ -102,6 +104,7 @@ LIST_SSAVE = ["Off"] + ["%s" % x for x in range(1, 7)]
LIST_PRIORITYCH = ["Off"] + ["%s" % x for x in range(1, 17)]
LIST_SCANSPEED = ["%s" % x for x in range(100, 550, 50)]
LIST_SCANDELAY = ["%s" % x for x in range(3, 31)]
+LIST_TXTONE = ["Off", "BOT", "EOT", "Both"]
SETTING_LISTS = {
"lpt": LIST_LPT,
@@ -117,6 +120,7 @@ SETTING_LISTS = {
"prioritych": LIST_PRIORITYCH,
"scanspeed": LIST_SCANSPEED,
"scandelay": LIST_SCANDELAY,
+ "txtone": LIST_TXTONE,
}
# Retevis RT1 fingerprints
@@ -304,7 +308,7 @@ def do_upload(radio):
bands = ["VHF", "UHF"]
image_band = radio_band = "unknown"
- for i in range(0,2):
+ for i in range(0, 2):
if image_model == MODELS[i]:
image_band = bands[i]
if radio_model == MODELS[i]:
@@ -333,7 +337,7 @@ def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
rid = data[0x0170:0x0176]
- return rid.startswith("PXT8K")
+ return rid.startswith(b"PXT8K")
@directory.register
@@ -368,6 +372,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
rf.valid_power_levels = RT1_POWER_LEVELS
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_modes = ["NFM", "FM"] # 12.5 KHz, 25 kHz.
+ rf.valid_dtcs_codes = RT1_DTCS
rf.memory_bounds = (1, 16)
rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
if self._mmap is None:
@@ -488,7 +493,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -672,8 +677,8 @@ class RT1Radio(chirp_common.CloneModeRadio):
val = _settings.scanspeed
rs = RadioSetting("scanspeed", "Scan Speed[ms]",
RadioSettingValueList(
- LIST_SCANSPEED,
- LIST_SCANSPEED[val]))
+ LIST_SCANSPEED,
+ LIST_SCANSPEED[val]))
basic.append(rs)
if _settings.scandelay > 27:
@@ -686,6 +691,12 @@ class RT1Radio(chirp_common.CloneModeRadio):
LIST_SCANDELAY[val]))
basic.append(rs)
+ rs = RadioSetting("txtone", "Tx Tone",
+ RadioSettingValueList(
+ LIST_TXTONE,
+ LIST_TXTONE[_settings.txtone]))
+ basic.append(rs)
+
return top
def set_settings(self, settings):
@@ -726,7 +737,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -738,7 +749,7 @@ class RT1Radio(chirp_common.CloneModeRadio):
# testing the file data size
if len(filedata) in [0x0400, ]:
match_size = True
-
+
# testing the model fingerprint
match_model = model_match(cls, filedata)
diff --git a/chirp/drivers/retevis_rt21.py b/chirp/drivers/retevis_rt21.py
index 856b33e..3309f54 100644
--- a/chirp/drivers/retevis_rt21.py
+++ b/chirp/drivers/retevis_rt21.py
@@ -1,4 +1,4 @@
-# Copyright 2016 Jim Unroe <rock.unroe@gmail.com>
+# Copyright 2021-2022 Jim Unroe <rock.unroe@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,95 +18,477 @@ import os
import struct
import logging
-from chirp import chirp_common, directory, memmap
-from chirp import bitwise, errors, util
-from chirp.settings import RadioSetting, RadioSettingGroup, \
- RadioSettingValueInteger, RadioSettingValueList, \
- RadioSettingValueBoolean, RadioSettings
+from chirp import (
+ bitwise,
+ chirp_common,
+ directory,
+ errors,
+ memmap,
+ util,
+)
+from chirp.settings import (
+ RadioSetting,
+ RadioSettingGroup,
+ RadioSettings,
+ RadioSettingValueBoolean,
+ RadioSettingValueInteger,
+ RadioSettingValueList,
+ RadioSettingValueString,
+)
LOG = logging.getLogger(__name__)
MEM_FORMAT = """
#seekto 0x0010;
struct {
- lbcd rxfreq[4];
- lbcd txfreq[4];
- ul16 rx_tone;
- ul16 tx_tone;
- u8 unknown1:3,
- bcl:2, // Busy Lock
+ lbcd rxfreq[4]; // RX Frequency 0-3
+ lbcd txfreq[4]; // TX Frequency 4-7
+ ul16 rx_tone; // PL/DPL Decode 8-9
+ ul16 tx_tone; // PL/DPL Encode A-B
+ u8 unknown1:3, // C
+ bcl:2, // Busy Lock
unknown2:3;
- u8 unknown3:2,
- highpower:1, // Power Level
- wide:1, // Bandwidth
+ u8 unknown3:2, // D
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
unknown4:4;
- u8 scramble_type:4,
+ u8 unknown7:1, // E
+ scramble_type:3, // Scramble Type
unknown5:4;
- u8 unknown6:4,
- scramble_type2:4;
+ u8 unknown6:5,
+ scramble_type2:3; // Scramble Type 2 F
} memory[16];
#seekto 0x011D;
struct {
u8 unused:4,
- pf1:4; // Programmable Function Key 1
+ pf1:4; // Programmable Function Key 1
} keys;
#seekto 0x012C;
struct {
- u8 use_scramble; // Scramble Enable
+ u8 use_scramble; // Scramble Enable
u8 unknown1[2];
- u8 voice; // Voice Annunciation
- u8 tot; // Time-out Timer
- u8 totalert; // Time-out Timer Pre-alert
+ u8 voice; // Voice Annunciation
+ u8 tot; // Time-out Timer
+ u8 totalert; // Time-out Timer Pre-alert
u8 unknown2[2];
- u8 squelch; // Squelch Level
- u8 save; // Battery Saver
+ u8 squelch; // Squelch Level
+ u8 save; // Battery Saver
u8 unknown3[3];
- u8 use_vox; // VOX Enable
- u8 vox; // VOX Gain
+ u8 use_vox; // VOX Enable
+ u8 vox; // VOX Gain
} settings;
#seekto 0x017E;
-u8 skipflags[2]; // SCAN_ADD
+u8 skipflags[2]; // SCAN_ADD
"""
-CMD_ACK = "\x06"
-BLOCK_SIZE = 0x10
+MEM_FORMAT_RB17A = """
+struct memory {
+ lbcd rxfreq[4]; // 0-3
+ lbcd txfreq[4]; // 4-7
+ ul16 rx_tone; // 8-9
+ ul16 tx_tone; // A-B
+ u8 unknown1:1, // C
+ compander:1, // Compand
+ bcl:2, // Busy Channel Lock-out
+ cdcss:1, // Cdcss Mode
+ scramble_type:3; // Scramble Type
+ u8 unknown2:4, // D
+ middlepower:1, // Power Level-Middle
+ unknown3:1, //
+ highpower:1, // Power Level-High/Low
+ wide:1; // Bandwidth
+ u8 unknown4; // E
+ u8 unknown5; // F
+};
+
+#seekto 0x0010;
+ struct memory lomems[16];
+
+#seekto 0x0200;
+ struct memory himems[14];
+
+#seekto 0x011D;
+struct {
+ u8 pf1; // 011D PF1 Key
+ u8 topkey; // 011E Top Key
+} keys;
+
+#seekto 0x012C;
+struct {
+ u8 use_scramble; // 012C Scramble Enable
+ u8 channel; // 012D Channel Number
+ u8 alarm; // 012E Alarm Type
+ u8 voice; // 012F Voice Annunciation
+ u8 tot; // 0130 Time-out Timer
+ u8 totalert; // 0131 Time-out Timer Pre-alert
+ u8 unknown2[2];
+ u8 squelch; // 0134 Squelch Level
+ u8 save; // 0135 Battery Saver
+ u8 unknown3[3];
+ u8 use_vox; // 0139 VOX Enable
+ u8 vox; // 013A VOX Gain
+} settings;
+
+#seekto 0x017E;
+u8 skipflags[4]; // Scan Add
+"""
+
+MEM_FORMAT_RB26 = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4]; // RX Frequency 0-3
+ lbcd txfreq[4]; // TX Frequency 4-7
+ ul16 rx_tone; // PL/DPL Decode 8-9
+ ul16 tx_tone; // PL/DPL Encode A-B
+ u8 compander:1, // Compander C
+ unknown1:1, //
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
+ bcl:1, // Busy Lock OFF=0 ON=1
+ unknown2:3; //
+ u8 reserved[3]; // Reserved D-F
+} memory[30];
+
+#seekto 0x002D;
+struct {
+ u8 unknown_1:1, // 002D
+ chnumberd:1, // Channel Number Disable
+ gain:1, // MIC Gain
+ savem:1, // Battery Save Mode
+ save:1, // Battery Save
+ beep:1, // Beep
+ voice:1, // Voice Prompts
+ unknown_2:1; //
+ u8 squelch; // Squelch 002E
+ u8 tot; // Time-out Timer 002F
+ u8 channel_4[13]; // 0030-003C
+ u8 unknown_3[3]; // 003D-003F
+ u8 channel_5[13]; // 0040-004C
+ u8 unknown_4; // 004D
+ u8 unknown_5[2]; // 004E-004F
+ u8 channel_6[13]; // 0050-005C
+ u8 unknown_6; // 005D
+ u8 unknown_7[2]; // 005E-005F
+ u8 channel_7[13]; // 0060-006C
+ u8 warn; // Warn Mode 006D
+ u8 pf1; // Key Set PF1 006E
+ u8 pf2; // Key Set PF2 006F
+ u8 channel_8[13]; // 0070-007C
+ u8 unknown_8; // 007D
+ u8 tail; // QT/DQT Tail(inverted) 007E
+} settings;
+
+#seekto 0x01F0;
+u8 skipflags[4]; // Scan Add
+
+#seekto 0x029F;
+struct {
+ u8 chnumber; // Channel Number 029F
+} settings2;
+
+#seekto 0x031D;
+struct {
+ u8 unused:7, // 031D
+ vox:1; // Vox
+ u8 voxl; // Vox Level 031E
+ u8 voxd; // Vox Delay 031F
+} settings3;
+"""
+
+MEM_FORMAT_RT76 = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4]; // RX Frequency 0-3
+ lbcd txfreq[4]; // TX Frequency 4-7
+ ul16 rx_tone; // PL/DPL Decode 8-9
+ ul16 tx_tone; // PL/DPL Encode A-B
+ u8 compander:1, // Compander C
+ hop:1, // Frequency Hop
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
+ scramble:4; // Scramble
+ u8 reserved[3]; // Reserved D-F
+} memory[30];
+
+#seekto 0x002D;
+struct {
+ u8 unknown_1:1, // 002D
+ chnumberd:1, // Channel Number Disable
+ gain:1, // MIC Gain ---
+ savem:1, // Battery Save Mode ---
+ save:1, // Battery Save ---
+ beep:1, // Beep ---
+ voice:2; // Voice Prompts ---
+ u8 squelch; // Squelch 002E ---
+ u8 tot; // Time-out Timer 002F ---
+ u8 channel_4[13]; // 0030-003C
+ u8 unused:7, // 003D
+ vox:1; // Vox ---
+ u8 voxl; // Vox Level 003E ---
+ u8 voxd; // Vox Delay 003F ---
+ u8 channel_5[13]; // 0040-004C
+ u8 unknown_4; // 004D
+ u8 unknown_5[2]; // 004E-004F
+ u8 channel_6[13]; // 0050-005C
+ u8 chnumber; // Channel Number 005D ---
+ u8 unknown_7[2]; // 005E-005F
+ u8 channel_7[13]; // 0060-006C
+ u8 warn; // 006D ---
+ u8 scan; // 006E
+ u8 unknown_8; // 006F
+ u8 channel_8[13]; // 0070-007C
+ u8 unknown_9[3]; // 007D-007F
+ u8 channel_9[13]; // 0080-008C
+ u8 unknown_a; // 008D
+ u8 tailmode; // DCS Tail Mode 008E
+ u8 hop; // Hop Mode 008F
+} settings;
+
+#seekto 0x004E;
+u8 skipflags[2]; // SCAN_ADD
+"""
+
+MEM_FORMAT_RT29 = """
+#seekto 0x0010;
+struct {
+ lbcd rxfreq[4]; // RX Frequency 0-3
+ lbcd txfreq[4]; // TX Frequency 4-7
+ ul16 rx_tone; // PL/DPL Decode 8-9
+ ul16 tx_tone; // PL/DPL Encode A-B
+ u8 unknown1:2, // C
+ compander:1, // Compander
+ bcl:2, // Busy Lock
+ unknown2:3;
+ u8 unknown3:1, // D
+ txpower:2, // Power Level
+ wide:1, // Bandwidth
+ unknown4:3,
+ cdcss:1; // Cdcss Mode
+ u8 unknown5; // E
+ u8 unknown6:5,
+ scramble_type:3; // Scramble Type F
+} memory[16];
+
+#seekto 0x011D;
+struct {
+ u8 unused1:4,
+ pf1:4; // Programmable Function Key 1
+ u8 unused2:4,
+ pf2:4; // Programmable Function Key 2
+} keys;
+
+#seekto 0x012C;
+struct {
+ u8 use_scramble; // Scramble Enable
+ u8 unknown1[2];
+ u8 voice; // Voice Annunciation
+ u8 tot; // Time-out Timer
+ u8 totalert; // Time-out Timer Pre-alert
+ u8 unknown2[2];
+ u8 squelch; // Squelch Level
+ u8 save; // Battery Saver
+ u8 unknown3[3];
+ u8 use_vox; // VOX Enable
+ u8 vox; // VOX Gain
+ u8 voxd; // Vox Delay
+} settings;
+
+#seekto 0x017E;
+u8 skipflags[2]; // SCAN_ADD
+
+#seekto 0x01B8;
+u8 fingerprint[5]; // Fingerprint
+"""
-RT21_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
- chirp_common.PowerLevel("High", watts=2.50)]
+MEM_FORMAT_RT19 = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4]; // RX Frequency 0-3
+ lbcd txfreq[4]; // TX Frequency 4-7
+ ul16 rx_tone; // PL/DPL Decode 8-9
+ ul16 tx_tone; // PL/DPL Encode A-B
+ u8 function:2, // Function C
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
+ unknown_1:1, //
+ scramble_type:3; // Scramble #
+ u8 reserved[3]; // Reserved D-F
+} memory[%d];
+
+#seekto 0x002D;
+struct {
+ u8 bootsel:1, // Boot Select 002D
+ unknown_1:2, //
+ savem:1, // Battery Save Mode
+ save:1, // Battery Save
+ beep:1, // Beep
+ voice:2; // Voice Prompts
+ u8 squelch; // Squelch 002E
+ u8 tot; // Time-out Timer 002F
+ u8 channel_4[13]; // 0030-003C
+ u8 unused:7, // 003D
+ vox:1; // Vox
+ u8 voxl; // Vox Level 003E
+ u8 voxd; // Vox Delay 003F
+ u8 channel_5[13]; // 0040-004C
+ u8 unknown_4; // 004D
+ u8 unknown_5[2]; // 004E-004F
+ u8 channel_6[13]; // 0050-005C
+ u8 unknown_6; // 005D
+ u8 unknown_7[2]; // 005E-005F
+ u8 channel_7[13]; // 0060-006C
+ u8 voicel:4, // Voice Level 006D
+ unknown_9:3 //
+ warn:1; // Warn Mode
+} settings;
+#seekto 0x%X;
+struct {
+ u8 freqhop; // Frequency Hop
+} freqhops[%d];
+"""
-RT21_DTCS = sorted(chirp_common.DTCS_CODES +
- [17, 50, 55, 135, 217, 254, 305, 645, 765])
+MEM_FORMAT_RT40B = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4]; // RX Frequency 0-3
+ lbcd txfreq[4]; // TX Frequency 4-7
+ ul16 rx_tone; // PL/DPL Decode 8-9
+ ul16 tx_tone; // PL/DPL Encode A-B
+ u8 compander:1, // Compander C
+ unknown1:1, //
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
+ unknown2:4; //
+ u8 reserved[3]; // Reserved D-F
+} memory[%d];
+
+#seekto 0x002D;
+struct {
+ u8 unknown_1:1, // 002D
+ unknown_2:1, //
+ savem:2, // Battery Save Mode
+ save:1, // Battery Save
+ beep:1, // Beep
+ voice:2; // Voice Prompts
+ u8 squelch; // Squelch 002E
+ u8 tot; // Time-out Timer 002F
+ u8 channel_4[13]; // 0030-003C
+ u8 unknown_3:7, // 003D
+ vox:1; // Vox
+ u8 voxl; // Vox Level 003E
+ u8 voxd; // Vox Delay 003F
+ u8 channel_5[13]; // 0040-004C
+ u8 unknown_4[2]; // 004D-004F
+ u8 channel_6[13]; // 0050-005C
+ u8 chnumber; // Channel Number 005D
+ u8 unknown_5[2]; // 005E-005F
+ u8 channel_7[13]; // 0060-006C
+ u8 unknown_6:7, // 006D
+ pttstone:1; // PTT Start Tone
+ u8 unknown_7:7, // 006E
+ pttetone:1; // PTT End Tone
+} settings;
+
+#seekto 0x00AD;
+u8 skipflags[3]; // SCAN_ADD
+"""
+
+CMD_ACK = "\x06"
+ALARM_LIST = ["Local Alarm", "Remote Alarm"]
BCL_LIST = ["Off", "Carrier", "QT/DQT"]
-SCRAMBLE_LIST = ["Scramble 1", "Scramble 2", "Scramble 3", "Scramble 4",
- "Scramble 5", "Scramble 6", "Scramble 7", "Scramble 8"]
-TIMEOUTTIMER_LIST = ["%s seconds" % x for x in range(15, 615, 15)]
+BOOTSEL_LIST = ["Channel Mode", "Voice Mode"]
+CDCSS_LIST = ["Normal Code", "Special Code 2", "Special Code 1"]
+CDCSS2_LIST = ["Normal Code", "Special Code"] # RT29 UHF and RT29 VHF
+FREQHOP_LIST = ["Off", "Hopping 1", "Hopping 2", "Hopping 3"]
+FUNCTION_LIST = ["Off", "Scramble", "Compand"]
+GAIN_LIST = ["Standard", "Enhanced"]
+HOP_LIST = ["Mode A", "Mode B", "Mode C", "Mode D", "Mode E"]
+PFKEY_LIST = ["None", "Monitor", "Lamp", "Warn", "VOX", "VOX Delay",
+ "Key Lock", "Scan"]
+SAVE_LIST = ["Standard", "Super"]
+SAVEM_LIST = ["1-5", "1-8", "1-10", "1-15"]
+SCRAMBLE_LIST = ["OFF"] + ["%s" % x for x in range(1, 9)]
+TAIL_LIST = ["134.4 Hz", "55 Hz"]
+TIMEOUTTIMER_LIST = ["Off"] + ["%s seconds" % x for x in range(15, 615, 15)]
TOTALERT_LIST = ["Off"] + ["%s seconds" % x for x in range(1, 11)]
VOICE_LIST = ["Off", "Chinese", "English"]
+VOICE_LIST2 = ["Off", "English"]
+VOICE_LIST3 = VOICE_LIST2 + ["Chinese"]
VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 17)]
+VOXD_LIST = ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"]
+VOXL_LIST = ["OFF"] + ["%s" % x for x in range(1, 10)]
+WARN_LIST = ["OFF", "Native Warn", "Remote Warn"]
PF1_CHOICES = ["None", "Monitor", "Scan", "Scramble", "Alarm"]
PF1_VALUES = [0x0F, 0x04, 0x06, 0x08, 0x0C]
+PF1_17A_CHOICES = ["None", "Monitor", "Scan", "Scramble"]
+PF1_17A_VALUES = [0x0F, 0x04, 0x06, 0x08]
+PFKEY23_CHOICES = ["None", "Monitor", "Warn", "VOX", "VOX Delay", "Scan"]
+PFKEY23_VALUES = [0x00, 0x01, 0x03, 0x04, 0x05, 0x07]
+PFKEY_CHOICES = ["None", "Monitor", "Scan", "Scramble", "VOX", "Alarm"]
+PFKEY_VALUES = [0x0F, 0x04, 0x06, 0x08, 0x09, 0x0A]
+TOPKEY_CHOICES = ["None", "Alarming"]
+TOPKEY_VALUES = [0xFF, 0x0C]
SETTING_LISTS = {
+ "alarm": ALARM_LIST,
"bcl": BCL_LIST,
+ "bootsel": BOOTSEL_LIST,
+ "cdcss": CDCSS_LIST,
+ "cdcss": CDCSS2_LIST,
+ "freqhop": FREQHOP_LIST,
+ "function": FUNCTION_LIST,
+ "gain": GAIN_LIST,
+ "hop": HOP_LIST,
+ "pfkey": PFKEY_LIST,
+ "save": SAVE_LIST,
+ "savem": SAVEM_LIST,
"scramble": SCRAMBLE_LIST,
+ "tail": TAIL_LIST,
"tot": TIMEOUTTIMER_LIST,
"totalert": TOTALERT_LIST,
"voice": VOICE_LIST,
+ "voice": VOICE_LIST2,
+ "voice": VOICE_LIST3,
"vox": VOX_LIST,
+ "voxd": VOXD_LIST,
+ "voxl": VOXL_LIST,
+ "warn": WARN_LIST,
}
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
-def _rt21_enter_programming_mode(radio):
+FRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3
+
+PMR_FREQS1 = [446.00625, 446.01875, 446.03125, 446.04375, 446.05625,
+ 446.06875, 446.08125, 446.09375]
+PMR_FREQS2 = [446.10625, 446.11875, 446.13125, 446.14375, 446.15625,
+ 446.16875, 446.18125, 446.19375]
+PMR_FREQS = PMR_FREQS1 + PMR_FREQS2
+
+
+def _enter_programming_mode(radio):
serial = radio.pipe
+ _magic = radio._magic
+
try:
- serial.write("PRMZUNE")
+ serial.write(_magic)
+ if radio._echo:
+ chew = serial.read(len(_magic)) # Chew the echo
ack = serial.read(1)
+ if ack == "\x00":
+ ack = serial.read(1)
except:
raise errors.RadioError("Error communicating with radio")
@@ -117,16 +499,29 @@ def _rt21_enter_programming_mode(radio):
try:
serial.write("\x02")
+ if radio._echo:
+ serial.read(1) # Chew the echo
ident = serial.read(8)
except:
raise errors.RadioError("Error communicating with radio")
- if not ident.startswith("P3207"):
- LOG.debug(util.hexprint(ident))
- raise errors.RadioError("Radio returned unknown identification string")
+ # check if ident is OK
+ itis = False
+ for fp in radio._fingerprint:
+ if fp in ident:
+ # got it!
+ itis = True
+
+ break
+
+ if itis is False:
+ LOG.debug("Incorrect model ID, got this:\n\n" + util.hexprint(ident))
+ raise errors.RadioError("Radio identification failed.")
try:
serial.write(CMD_ACK)
+ if radio._echo:
+ serial.read(1) # Chew the echo
ack = serial.read(1)
except:
raise errors.RadioError("Error communicating with radio")
@@ -135,51 +530,61 @@ def _rt21_enter_programming_mode(radio):
raise errors.RadioError("Radio refused to enter programming mode")
-def _rt21_exit_programming_mode(radio):
+def _exit_programming_mode(radio):
serial = radio.pipe
try:
serial.write("E")
+ if radio._echo:
+ chew = serial.read(1) # Chew the echo
except:
raise errors.RadioError("Radio refused to exit programming mode")
-def _rt21_read_block(radio, block_addr, block_size):
+def _read_block(radio, block_addr, block_size):
serial = radio.pipe
- cmd = struct.pack(">cHb", 'R', block_addr, BLOCK_SIZE)
+ cmd = struct.pack(">cHb", 'R', block_addr, block_size)
expectedresponse = "W" + cmd[1:]
LOG.debug("Reading block %04x..." % (block_addr))
try:
serial.write(cmd)
- response = serial.read(4 + BLOCK_SIZE)
+ if radio._echo:
+ serial.read(4) # Chew the echo
+ response = serial.read(4 + block_size)
if response[:4] != expectedresponse:
raise Exception("Error reading block %04x." % (block_addr))
block_data = response[4:]
- serial.write(CMD_ACK)
- ack = serial.read(1)
+ if block_addr != 0 or radio._ack_1st_block:
+ serial.write(CMD_ACK)
+ if radio._echo:
+ serial.read(1) # Chew the echo
+ ack = serial.read(1)
except:
raise errors.RadioError("Failed to read block at %04x" % block_addr)
- if ack != CMD_ACK:
- raise Exception("No ACK reading block %04x." % (block_addr))
+ if block_addr != 0 or radio._ack_1st_block:
+ if ack != CMD_ACK:
+ raise Exception("No ACK reading block %04x." % (block_addr))
return block_data
-def _rt21_write_block(radio, block_addr, block_size):
+def _write_block(radio, block_addr, block_size):
serial = radio.pipe
- cmd = struct.pack(">cHb", 'W', block_addr, BLOCK_SIZE)
- data = radio.get_mmap()[block_addr:block_addr + BLOCK_SIZE]
+ cmd = struct.pack(">cHb", 'W', block_addr, block_size)
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
LOG.debug("Writing Data:")
LOG.debug(util.hexprint(cmd + data))
try:
serial.write(cmd + data)
+ if radio._echo:
+ serial.read(4 + len(data)) # Chew the echo
if serial.read(1) != CMD_ACK:
raise Exception("No ACK")
except:
@@ -189,7 +594,7 @@ def _rt21_write_block(radio, block_addr, block_size):
def do_download(radio):
LOG.debug("download")
- _rt21_enter_programming_mode(radio)
+ _enter_programming_mode(radio)
data = ""
@@ -199,17 +604,17 @@ def do_download(radio):
status.cur = 0
status.max = radio._memsize
- for addr in range(0, radio._memsize, BLOCK_SIZE):
- status.cur = addr + BLOCK_SIZE
+ for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
radio.status_fn(status)
- block = _rt21_read_block(radio, addr, BLOCK_SIZE)
+ block = _read_block(radio, addr, radio.BLOCK_SIZE)
data += block
LOG.debug("Address: %04x" % addr)
LOG.debug(util.hexprint(block))
- _rt21_exit_programming_mode(radio)
+ _exit_programming_mode(radio)
return memmap.MemoryMap(data)
@@ -218,25 +623,25 @@ def do_upload(radio):
status = chirp_common.Status()
status.msg = "Uploading to radio"
- _rt21_enter_programming_mode(radio)
+ _enter_programming_mode(radio)
status.cur = 0
status.max = radio._memsize
for start_addr, end_addr in radio._ranges:
- for addr in range(start_addr, end_addr, BLOCK_SIZE):
- status.cur = addr + BLOCK_SIZE
+ for addr in range(start_addr, end_addr, radio.BLOCK_SIZE_UP):
+ status.cur = addr + radio.BLOCK_SIZE_UP
radio.status_fn(status)
- _rt21_write_block(radio, addr, BLOCK_SIZE)
+ _write_block(radio, addr, radio.BLOCK_SIZE_UP)
- _rt21_exit_programming_mode(radio)
+ _exit_programming_mode(radio)
def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
rid = data[0x01B8:0x01BE]
- return rid.startswith("P3207")
+ return rid.startswith(b"P3207")
@directory.register
@@ -245,6 +650,23 @@ class RT21Radio(chirp_common.CloneModeRadio):
VENDOR = "Retevis"
MODEL = "RT21"
BAUD_RATE = 9600
+ BLOCK_SIZE = 0x10
+ BLOCK_SIZE_UP = 0x10
+
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [17, 50, 645])
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.50),
+ chirp_common.PowerLevel("Low", watts=1.00)]
+
+ VALID_BANDS = [(400000000, 480000000)]
+
+ _magic = "PRMZUNE"
+ _fingerprint = ["P3207s\xF8\xFF", ]
+ _upper = 16
+ _ack_1st_block = True
+ _skipflags = True
+ _reserved = False
+ _gmrs = _frs = _pmr = False
+ _echo = False
_ranges = [
(0x0000, 0x0400),
@@ -261,16 +683,21 @@ class RT21Radio(chirp_common.CloneModeRadio):
rf.has_tuning_step = False
rf.can_odd_split = True
rf.has_name = False
- rf.valid_skips = ["", "S"]
+ if self.MODEL == "RT76" or \
+ self.MODEL == "RT19" or self.MODEL == "RT619":
+ rf.valid_skips = []
+ else:
+ rf.valid_skips = ["", "S"]
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
"->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
- rf.valid_power_levels = RT21_POWER_LEVELS
+ rf.valid_power_levels = self.POWER_LEVELS
rf.valid_duplexes = ["", "-", "+", "split", "off"]
- rf.valid_modes = ["NFM", "FM"] # 12.5 KHz, 25 kHz.
- rf.memory_bounds = (1, 16)
+ rf.valid_modes = ["FM", "NFM"] # 25 KHz, 12.5 kHz.
+ rf.valid_dtcs_codes = self.DTCS_CODES
+ rf.memory_bounds = (1, self._upper)
rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
- rf.valid_bands = [(400000000, 480000000)]
+ rf.valid_bands = self.VALID_BANDS
return rf
@@ -278,11 +705,31 @@ class RT21Radio(chirp_common.CloneModeRadio):
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
def sync_in(self):
- self._mmap = do_download(self)
+ """Download from radio"""
+ try:
+ data = do_download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = data
self.process_mmap()
def sync_out(self):
- do_upload(self)
+ """Upload to radio"""
+ try:
+ do_upload(self)
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
def get_raw_memory(self, number):
return repr(self._memobj.memory[number - 1])
@@ -293,6 +740,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
pol = (val & 0x8000) and "R" or "N"
return code, pol
+ tpol = False
if _mem.tx_tone != 0xFFFF and _mem.tx_tone > 0x2000:
tcode, tpol = _get_dcs(_mem.tx_tone)
mem.dtcs = tcode
@@ -303,6 +751,7 @@ class RT21Radio(chirp_common.CloneModeRadio):
else:
txmode = ""
+ rpol = False
if _mem.rx_tone != 0xFFFF and _mem.rx_tone > 0x2000:
rcode, rpol = _get_dcs(_mem.rx_tone)
mem.rx_dtcs = rcode
@@ -323,24 +772,35 @@ class RT21Radio(chirp_common.CloneModeRadio):
mem.tmode = "Cross"
mem.cross_mode = "%s->%s" % (txmode, rxmode)
- if mem.tmode == "DTCS":
- mem.dtcs_polarity = "%s%s" % (tpol, rpol)
+ # always set it even if no dtcs is used
+ mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
LOG.debug("Got TX %s (%i) RX %s (%i)" %
(txmode, _mem.tx_tone, rxmode, _mem.rx_tone))
def get_memory(self, number):
- bitpos = (1 << ((number - 1) % 8))
- bytepos = ((number - 1) / 8)
- LOG.debug("bitpos %s" % bitpos)
- LOG.debug("bytepos %s" % bytepos)
-
- _mem = self._memobj.memory[number - 1]
- _skp = self._memobj.skipflags[bytepos]
+ if self._skipflags:
+ bitpos = (1 << ((number - 1) % 8))
+ bytepos = ((number - 1) / 8)
+ LOG.debug("bitpos %s" % bitpos)
+ LOG.debug("bytepos %s" % bytepos)
+ _skp = self._memobj.skipflags[bytepos]
mem = chirp_common.Memory()
mem.number = number
+
+ if self.MODEL == "RB17A":
+ if mem.number < 17:
+ _mem = self._memobj.lomems[number - 1]
+ else:
+ _mem = self._memobj.himems[number - 17]
+ else:
+ _mem = self._memobj.memory[number - 1]
+
+ if self._reserved:
+ _rsvd = _mem.reserved.get_raw()
+
mem.freq = int(_mem.rxfreq) * 10
# We'll consider any blank (i.e. 0MHz frequency) to be empty
@@ -353,10 +813,6 @@ class RT21Radio(chirp_common.CloneModeRadio):
mem.empty = True
return mem
- if _mem.get_raw() == ("\xFF" * 16):
- LOG.debug("Initializing empty memory")
- _mem.set_raw("\x00" * 13 + "\x30\x8F\xF8")
-
if int(_mem.rxfreq) == int(_mem.txfreq):
mem.duplex = ""
mem.offset = 0
@@ -368,28 +824,101 @@ class RT21Radio(chirp_common.CloneModeRadio):
self._get_tone(_mem, mem)
- mem.power = RT21_POWER_LEVELS[_mem.highpower]
+ if self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ # set the power level
+ if _mem.txpower == self.TXPOWER_LOW:
+ mem.power = self.POWER_LEVELS[2]
+ elif _mem.txpower == self.TXPOWER_MED:
+ mem.power = self.POWER_LEVELS[1]
+ elif _mem.txpower == self.TXPOWER_HIGH:
+ mem.power = self.POWER_LEVELS[0]
+ else:
+ LOG.error('%s: get_mem: unhandled power level: 0x%02x' %
+ (mem.name, _mem.txpower))
+ else:
+ mem.power = self.POWER_LEVELS[1 - _mem.highpower]
- mem.skip = "" if (_skp & bitpos) else "S"
- LOG.debug("mem.skip %s" % mem.skip)
+ if self._skipflags:
+ mem.skip = "" if (_skp & bitpos) else "S"
+ LOG.debug("mem.skip %s" % mem.skip)
mem.extra = RadioSettingGroup("Extra", "extra")
- rs = RadioSetting("bcl", "Busy Channel Lockout",
- RadioSettingValueList(
- BCL_LIST, BCL_LIST[_mem.bcl]))
- mem.extra.append(rs)
-
- rs = RadioSetting("scramble_type", "Scramble Type",
- RadioSettingValueList(SCRAMBLE_LIST,
- SCRAMBLE_LIST[_mem.scramble_type - 8]))
- mem.extra.append(rs)
+ if self.MODEL == "RT21" or self.MODEL == "RB17A" or \
+ self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ rs = RadioSettingValueList(BCL_LIST, BCL_LIST[_mem.bcl])
+ rset = RadioSetting("bcl", "Busy Channel Lockout", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueInteger(1, 8, _mem.scramble_type + 1)
+ rset = RadioSetting("scramble_type", "Scramble Type", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "RB17A":
+ rs = RadioSettingValueList(CDCSS_LIST, CDCSS_LIST[_mem.cdcss])
+ rset = RadioSetting("cdcss", "Cdcss Mode", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ rs = RadioSettingValueList(CDCSS2_LIST,
+ CDCSS2_LIST[_mem.cdcss])
+ rset = RadioSetting("cdcss", "Cdcss Mode", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "RB17A" or self.MODEL == "RT29_UHF" or \
+ self.MODEL == "RT29_VHF":
+ rs = RadioSettingValueBoolean(_mem.compander)
+ rset = RadioSetting("compander", "Compander", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "RB26" or self.MODEL == "RT76" \
+ or self.MODEL == "RB23" or self.MODEL == "AR-63":
+ if self.MODEL == "RB26" or self.MODEL == "RB23":
+ rs = RadioSettingValueBoolean(_mem.bcl)
+ rset = RadioSetting("bcl", "Busy Channel Lockout", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(_mem.compander)
+ rset = RadioSetting("compander", "Compander", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "AR-63":
+ rs = RadioSettingValueList(SCRAMBLE_LIST,
+ SCRAMBLE_LIST[_mem.scramble])
+ rset = RadioSetting("scramble", "Scramble", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(not _mem.hop)
+ rset = RadioSetting("hop", "Frequency Hop", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "RT19" or self.MODEL == "RT619":
+ _freqhops = self._memobj.freqhops[number - 1]
+
+ rs = RadioSettingValueList(FUNCTION_LIST,
+ FUNCTION_LIST[_mem.function])
+ rset = RadioSetting("function", "Function", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueInteger(1, 8, _mem.scramble_type + 1)
+ rset = RadioSetting("scramble_type", "Scramble Type", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueList(FREQHOP_LIST,
+ FREQHOP_LIST[_freqhops.freqhop])
+ rset = RadioSetting("freqhop", "Frequency Hop", rs)
+ mem.extra.append(rset)
+
+ if self.MODEL == "RT40B":
+ rs = RadioSettingValueBoolean(_mem.compander)
+ rset = RadioSetting("compander", "Compander", rs)
+ mem.extra.append(rset)
return mem
def _set_tone(self, mem, _mem):
def _set_dcs(code, pol):
- val = int("%i" % code, 8) + 0x2800
+ val = int("%i" % code, 8) + 0x2000
if pol == "R":
val += 0x8000
return val
@@ -426,19 +955,80 @@ class RT21Radio(chirp_common.CloneModeRadio):
(tx_mode, _mem.tx_tone, rx_mode, _mem.rx_tone))
def set_memory(self, mem):
- bitpos = (1 << ((mem.number - 1) % 8))
- bytepos = ((mem.number - 1) / 8)
- LOG.debug("bitpos %s" % bitpos)
- LOG.debug("bytepos %s" % bytepos)
+ if self._skipflags:
+ bitpos = (1 << ((mem.number - 1) % 8))
+ bytepos = ((mem.number - 1) / 8)
+ LOG.debug("bitpos %s" % bitpos)
+ LOG.debug("bytepos %s" % bytepos)
+ _skp = self._memobj.skipflags[bytepos]
+
+ if self.MODEL == "RB17A":
+ if mem.number < 17:
+ _mem = self._memobj.lomems[mem.number - 1]
+ else:
+ _mem = self._memobj.himems[mem.number - 17]
+ elif self.MODEL == "RT19" or self.MODEL == "RT619":
+ _mem = self._memobj.memory[mem.number - 1]
+ _freqhops = self._memobj.freqhops[mem.number - 1]
+ else:
+ _mem = self._memobj.memory[mem.number - 1]
- _mem = self._memobj.memory[mem.number - 1]
- _skp = self._memobj.skipflags[bytepos]
+ if self._reserved:
+ _rsvd = _mem.reserved.get_raw()
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ if self.MODEL == "RB26" or self.MODEL == "RT76" \
+ or self.MODEL == "RB23" \
+ or self.MODEL == "RT40B":
+ _mem.set_raw("\xFF" * 13 + _rsvd)
+ elif self.MODEL == "RT19" or self.MODEL == "RT619":
+ _mem.set_raw("\xFF" * 13 + _rsvd)
+ _freqhops.freqhop.set_raw("\x00")
+ elif self.MODEL == "AR-63":
+ _mem.set_raw("\xFF" * 13 + _rsvd)
+ else:
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
+
return
- _mem.set_raw("\x00" * 13 + "\x00\x8F\xF8")
+ if self.MODEL == "RB17A":
+ _mem.set_raw("\x00" * 14 + "\xFF\xFF")
+ elif self._reserved:
+ _mem.set_raw("\x00" * 13 + _rsvd)
+ elif self.MODEL == "AR-63":
+ _mem.set_raw("\x00" * 13 + _rsvd)
+ else:
+ _mem.set_raw("\x00" * 13 + "\x30\x8F\xF8")
+
+ if self._gmrs:
+ if mem.number >= 1 and mem.number <= 30:
+ GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = GMRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ if mem.number > 22:
+ mem.duplex = '+'
+ mem.offset = 5000000
+ if self._frs:
+ if mem.number >= 1 and mem.number <= 22:
+ FRS_FREQ = int(FRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = FRS_FREQ
+ mem.mode = "NFM"
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.power = self.POWER_LEVELS[1]
+ if self._pmr:
+ PMR_FREQ = int(PMR_FREQS[mem.number - 1] * 1000000)
+ mem.freq = PMR_FREQ
+ mem.duplex = ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
_mem.rxfreq = mem.freq / 10
@@ -458,81 +1048,422 @@ class RT21Radio(chirp_common.CloneModeRadio):
self._set_tone(mem, _mem)
- _mem.highpower = mem.power == RT21_POWER_LEVELS[1]
-
- if mem.skip != "S":
- _skp |= bitpos
+ if self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ # set the power level
+ if mem.power == self.POWER_LEVELS[2]:
+ _mem.txpower = self.TXPOWER_LOW
+ elif mem.power == self.POWER_LEVELS[1]:
+ _mem.txpower = self.TXPOWER_MED
+ elif mem.power == self.POWER_LEVELS[0]:
+ _mem.txpower = self.TXPOWER_HIGH
+ else:
+ LOG.error('%s: set_mem: unhandled power level: %s' %
+ (mem.name, mem.power))
else:
- _skp &= ~bitpos
- LOG.debug("_skp %s" % _skp)
+ _mem.highpower = mem.power == self.POWER_LEVELS[0]
+
+ if self._skipflags:
+ if mem.skip != "S":
+ _skp |= bitpos
+ else:
+ _skp &= ~bitpos
+ LOG.debug("_skp %s" % _skp)
for setting in mem.extra:
if setting.get_name() == "scramble_type":
- setattr(_mem, setting.get_name(), int(setting.value) + 8)
- setattr(_mem, "scramble_type2", int(setting.value) + 8)
+ setattr(_mem, setting.get_name(), int(setting.value) - 1)
+ if self.MODEL == "RT21":
+ setattr(_mem, "scramble_type2", int(setting.value) - 1)
+ elif setting.get_name() == "freqhop":
+ setattr(_freqhops, setting.get_name(), setting.value)
+ elif setting.get_name() == "hop":
+ setattr(_mem, setting.get_name(), not int(setting.value))
else:
setattr(_mem, setting.get_name(), setting.value)
def get_settings(self):
- _keys = self._memobj.keys
_settings = self._memobj.settings
basic = RadioSettingGroup("basic", "Basic Settings")
top = RadioSettings(basic)
- rs = RadioSetting("tot", "Time-out timer",
- RadioSettingValueList(
- TIMEOUTTIMER_LIST,
- TIMEOUTTIMER_LIST[_settings.tot - 1]))
- basic.append(rs)
-
- rs = RadioSetting("totalert", "TOT Pre-alert",
- RadioSettingValueList(
- TOTALERT_LIST,
- TOTALERT_LIST[_settings.totalert]))
- basic.append(rs)
-
- rs = RadioSetting("squelch", "Squelch Level",
- RadioSettingValueInteger(0, 9, _settings.squelch))
- basic.append(rs)
-
- rs = RadioSetting("voice", "Voice Annumciation",
- RadioSettingValueList(
- VOICE_LIST, VOICE_LIST[_settings.voice]))
- basic.append(rs)
-
- rs = RadioSetting("save", "Battery Saver",
- RadioSettingValueBoolean(_settings.save))
- basic.append(rs)
-
- rs = RadioSetting("use_scramble", "Scramble",
- RadioSettingValueBoolean(_settings.use_scramble))
- basic.append(rs)
-
- rs = RadioSetting("use_vox", "VOX",
- RadioSettingValueBoolean(_settings.use_vox))
- basic.append(rs)
-
- rs = RadioSetting("vox", "VOX Gain",
- RadioSettingValueList(
- VOX_LIST, VOX_LIST[_settings.vox]))
- basic.append(rs)
-
- def apply_pf1_listvalue(setting, obj):
- LOG.debug("Setting value: "+ str(setting.value) + " from list")
- val = str(setting.value)
- index = PF1_CHOICES.index(val)
- val = PF1_VALUES[index]
- obj.set_value(val)
-
- if _keys.pf1 in PF1_VALUES:
- idx = PF1_VALUES.index(_keys.pf1)
- else:
- idx = LIST_DTMF_SPECIAL_VALUES.index(0x04)
- rs = RadioSetting("keys.pf1", "PF1 Key Function",
- RadioSettingValueList(PF1_CHOICES,
- PF1_CHOICES[idx]))
- rs.set_apply_callback(apply_pf1_listvalue, _keys.pf1)
- basic.append(rs)
+ if self.MODEL == "RT21" or self.MODEL == "RB17A" or \
+ self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ _keys = self._memobj.keys
+
+ rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
+ TIMEOUTTIMER_LIST[_settings.tot])
+ rset = RadioSetting("tot", "Time-out timer", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(TOTALERT_LIST,
+ TOTALERT_LIST[_settings.totalert])
+ rset = RadioSetting("totalert", "TOT Pre-alert", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueInteger(0, 9, _settings.squelch)
+ rset = RadioSetting("squelch", "Squelch Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOICE_LIST, VOICE_LIST[_settings.voice])
+ rset = RadioSetting("voice", "Voice Annumciation", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RB17A":
+ rs = RadioSettingValueList(ALARM_LIST,
+ ALARM_LIST[_settings.alarm])
+ rset = RadioSetting("alarm", "Alarm Type", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.save)
+ rset = RadioSetting("save", "Battery Saver", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.use_scramble)
+ rset = RadioSetting("use_scramble", "Scramble", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.use_vox)
+ rset = RadioSetting("use_vox", "VOX", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox])
+ rset = RadioSetting("vox", "VOX Gain", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ rs = RadioSettingValueList(VOXD_LIST,
+ VOXD_LIST[_settings.voxd])
+ rset = RadioSetting("voxd", "Vox Delay", rs)
+ basic.append(rset)
+
+ def apply_pf1_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(
+ setting.value) + " from list")
+ val = str(setting.value)
+ index = PF1_CHOICES.index(val)
+ val = PF1_VALUES[index]
+ obj.set_value(val)
+
+ if self.MODEL == "RT21":
+ if _keys.pf1 in PF1_VALUES:
+ idx = PF1_VALUES.index(_keys.pf1)
+ else:
+ idx = LIST_DTMF_SPECIAL_VALUES.index(0x04)
+ rs = RadioSettingValueList(PF1_CHOICES, PF1_CHOICES[idx])
+ rset = RadioSetting("keys.pf1", "PF1 Key Function", rs)
+ rset.set_apply_callback(apply_pf1_listvalue, _keys.pf1)
+ basic.append(rset)
+
+ def apply_pf1_17a_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(
+ setting.value) + " from list")
+ val = str(setting.value)
+ index = PF1_17A_CHOICES.index(val)
+ val = PF1_17A_VALUES[index]
+ obj.set_value(val)
+
+ if self.MODEL == "RB17A":
+ if _keys.pf1 in PF1_17A_VALUES:
+ idx = PF1_17A_VALUES.index(_keys.pf1)
+ else:
+ idx = LIST_DTMF_SPECIAL_VALUES.index(0x04)
+ rs = RadioSettingValueList(PF1_17A_CHOICES,
+ PF1_17A_CHOICES[idx])
+ rset = RadioSetting("keys.pf1", "PF1 Key Function", rs)
+ rset.set_apply_callback(apply_pf1_17a_listvalue, _keys.pf1)
+ basic.append(rset)
+
+ def apply_topkey_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = TOPKEY_CHOICES.index(val)
+ val = TOPKEY_VALUES[index]
+ obj.set_value(val)
+
+ if self.MODEL == "RB17A":
+ if _keys.topkey in TOPKEY_VALUES:
+ idx = TOPKEY_VALUES.index(_keys.topkey)
+ else:
+ idx = TOPKEY_VALUES.index(0x0C)
+ rs = RadioSettingValueList(TOPKEY_CHOICES, TOPKEY_CHOICES[idx])
+ rset = RadioSetting("keys.topkey", "Top Key Function", rs)
+ rset.set_apply_callback(apply_topkey_listvalue, _keys.topkey)
+ basic.append(rset)
+
+ def apply_pfkey_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = PFKEY_CHOICES.index(val)
+ val = PFKEY_VALUES[index]
+ obj.set_value(val)
+
+ if self.MODEL == "RT29_UHF" or self.MODEL == "RT29_VHF":
+ if _keys.pf1 in PFKEY_VALUES:
+ idx = PFKEY_VALUES.index(_keys.pf1)
+ else:
+ idx = PFKEY_VALUES.index(0x04)
+ rs = RadioSettingValueList(PFKEY_CHOICES, PFKEY_CHOICES[idx])
+ rset = RadioSetting("keys.pf1", "PF1 Key Function", rs)
+ rset.set_apply_callback(apply_pfkey_listvalue, _keys.pf1)
+ basic.append(rset)
+
+ if _keys.pf2 in PFKEY_VALUES:
+ idx = PFKEY_VALUES.index(_keys.pf2)
+ else:
+ idx = PFKEY_VALUES.index(0x0A)
+ rs = RadioSettingValueList(PFKEY_CHOICES, PFKEY_CHOICES[idx])
+ rset = RadioSetting("keys.pf2", "PF2 Key Function", rs)
+ rset.set_apply_callback(apply_pfkey_listvalue, _keys.pf2)
+ basic.append(rset)
+
+ if self.MODEL == "RB26" or self.MODEL == "RT76" \
+ or self.MODEL == "RB23" \
+ or self.MODEL == "RT19" or self.MODEL == "RT619" \
+ or self.MODEL == "AR-63" \
+ or self.MODEL == "RT40B":
+ if self.MODEL == "RB26" or self.MODEL == "RB23":
+ _settings2 = self._memobj.settings2
+ _settings3 = self._memobj.settings3
+
+ rs = RadioSettingValueInteger(0, 9, _settings.squelch)
+ rset = RadioSetting("squelch", "Squelch Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
+ TIMEOUTTIMER_LIST[_settings.tot])
+ rset = RadioSetting("tot", "Time-out timer", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RT19" or self.MODEL == "RT619":
+ rs = RadioSettingValueList(VOICE_LIST,
+ VOICE_LIST[_settings.voice])
+ rset = RadioSetting("voice", "Voice Prompts", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(BOOTSEL_LIST,
+ BOOTSEL_LIST[_settings.bootsel])
+ rset = RadioSetting("bootsel", "Boot Select", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueInteger(1, 10, _settings.voicel + 1)
+ rset = RadioSetting("voicel", "Voice Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.vox)
+ rset = RadioSetting("vox", "Vox Function", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXL_LIST,
+ VOXL_LIST[_settings.voxl])
+ rset = RadioSetting("voxl", "Vox Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXD_LIST,
+ VOXD_LIST[_settings.voxd])
+ rset = RadioSetting("voxd", "Vox Delay", rs)
+ basic.append(rset)
+
+ if self.MODEL == "AR-63":
+ rs = RadioSettingValueList(VOICE_LIST,
+ VOICE_LIST[_settings.voice])
+ rset = RadioSetting("voice", "Voice Prompts", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RT76":
+ rs = RadioSettingValueList(VOICE_LIST3,
+ VOICE_LIST3[_settings.voice])
+ rset = RadioSetting("voice", "Voice Annumciation", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RB26" or self.MODEL == "RB23":
+ rs = RadioSettingValueList(VOICE_LIST2,
+ VOICE_LIST2[_settings.voice])
+ rset = RadioSetting("voice", "Voice Annumciation", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RB26":
+ rs = RadioSettingValueBoolean(not _settings.chnumberd)
+ rset = RadioSetting("chnumberd", "Channel Number Enable", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.save)
+ rset = RadioSetting("save", "Battery Save", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.beep)
+ rset = RadioSetting("beep", "Beep", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RB26" or self.MODEL == "RB23":
+ rs = RadioSettingValueBoolean(not _settings.tail)
+ rset = RadioSetting("tail", "QT/DQT Tail", rs)
+ basic.append(rset)
+
+ if self.MODEL != "AR-63" and self.MODEL != "RT40B":
+ rs = RadioSettingValueList(SAVE_LIST,
+ SAVE_LIST[_settings.savem])
+ rset = RadioSetting("savem", "Battery Save Mode", rs)
+ basic.append(rset)
+
+ if self.MODEL != "RT19" and self.MODEL != "RT619" and \
+ self.MODEL != "AR-63" and \
+ self.MODEL != "RT40B":
+ rs = RadioSettingValueList(GAIN_LIST,
+ GAIN_LIST[_settings.gain])
+ rset = RadioSetting("gain", "MIC Gain", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(WARN_LIST,
+ WARN_LIST[_settings.warn])
+ rset = RadioSetting("warn", "Warn Mode", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RB26" or self.MODEL == "RB23":
+ rs = RadioSettingValueBoolean(_settings3.vox)
+ rset = RadioSetting("settings3.vox", "Vox Function", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXL_LIST,
+ VOXL_LIST[_settings3.voxl])
+ rset = RadioSetting("settings3.voxl", "Vox Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXD_LIST,
+ VOXD_LIST[_settings3.voxd])
+ rset = RadioSetting("settings3.voxd", "Vox Delay", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RB26":
+ rs = RadioSettingValueList(PFKEY_LIST,
+ PFKEY_LIST[_settings.pf1])
+ rset = RadioSetting("pf1", "PF1 Key Set", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(PFKEY_LIST,
+ PFKEY_LIST[_settings.pf2])
+ rset = RadioSetting("pf2", "PF2 Key Set", rs)
+ basic.append(rset)
+ elif self.MODEL == "RB23":
+ def apply_pfkey_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = PFKEY23_CHOICES.index(val)
+ val = PFKEY23_VALUES[index]
+ obj.set_value(val)
+
+ if _settings.pf1 in PFKEY23_VALUES:
+ idx = PFKEY23_VALUES.index(_settings.pf1)
+ else:
+ idx = PFKEY23_VALUES.index(0x01)
+ rs = RadioSettingValueList(PFKEY23_CHOICES,
+ PFKEY23_CHOICES[idx])
+ rset = RadioSetting("settings.pf1", "PF1 Key Function", rs)
+ rset.set_apply_callback(apply_pfkey_listvalue,
+ _settings.pf1)
+ basic.append(rset)
+
+ if _settings.pf2 in PFKEY23_VALUES:
+ idx = PFKEY23_VALUES.index(_settings.pf2)
+ else:
+ idx = PFKEY23_VALUES.index(0x03)
+ rs = RadioSettingValueList(PFKEY23_CHOICES,
+ PFKEY23_CHOICES[idx])
+ rset = RadioSetting("settings.pf2", "PF2 Key Function", rs)
+ rset.set_apply_callback(apply_pfkey_listvalue,
+ _settings.pf2)
+ basic.append(rset)
+
+ rs = RadioSettingValueInteger(1, 30, _settings2.chnumber + 1)
+ rset = RadioSetting("settings2.chnumber", "Channel Number", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RT76":
+ rs = RadioSettingValueBoolean(_settings.vox)
+ rset = RadioSetting("vox", "Vox Function", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXL_LIST,
+ VOXL_LIST[_settings.voxl])
+ rset = RadioSetting("voxl", "Vox Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXD_LIST,
+ VOXD_LIST[_settings.voxd])
+ rset = RadioSetting("voxd", "Vox Delay", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueInteger(1, 30, _settings.chnumber + 1)
+ rset = RadioSetting("chnumber", "Channel Number", rs)
+ basic.append(rset)
+
+ if self.MODEL == "AR-63":
+ rs = RadioSettingValueBoolean(_settings.warn)
+ rset = RadioSetting("warn", "Warn", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.scan)
+ rset = RadioSetting("scan", "Scan", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(HOP_LIST,
+ HOP_LIST[_settings.hop])
+ rset = RadioSetting("hop", "Hop Mode", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(TAIL_LIST,
+ TAIL_LIST[_settings.tailmode])
+ rset = RadioSetting("tailmode", "DCS Tail Mode", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.vox)
+ rset = RadioSetting("vox", "Vox Function", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXL_LIST,
+ VOXL_LIST[_settings.voxl])
+ rset = RadioSetting("voxl", "Vox Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXD_LIST,
+ VOXD_LIST[_settings.voxd])
+ rset = RadioSetting("voxd", "Vox Delay", rs)
+ basic.append(rset)
+
+ if self.MODEL == "RT40B":
+ rs = RadioSettingValueList(VOICE_LIST,
+ VOICE_LIST[_settings.voice])
+ rset = RadioSetting("voice", "Voice Prompts", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(SAVEM_LIST,
+ SAVEM_LIST[_settings.savem])
+ rset = RadioSetting("savem", "Battery Save Mode", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.pttstone)
+ rset = RadioSetting("pttstone", "PTT Start Tone", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.pttetone)
+ rset = RadioSetting("pttetone", "PTT End Tone", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueBoolean(_settings.vox)
+ rset = RadioSetting("vox", "Vox Function", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXL_LIST,
+ VOXL_LIST[_settings.voxl])
+ rset = RadioSetting("voxl", "Vox Level", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueList(VOXD_LIST,
+ VOXD_LIST[_settings.voxd])
+ rset = RadioSetting("voxd", "Vox Delay", rs)
+ basic.append(rset)
return top
@@ -556,29 +1487,330 @@ class RT21Radio(chirp_common.CloneModeRadio):
if element.has_apply_callback():
LOG.debug("Using apply callback")
element.run_apply_callback()
- elif setting == "tot":
- setattr(obj, setting, int(element.value) + 1)
+ elif setting == "channel":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "chnumber":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "chnumberd":
+ setattr(obj, setting, not int(element.value))
+ elif setting == "tail":
+ setattr(obj, setting, not int(element.value))
+ elif setting == "voicel":
+ setattr(obj, setting, int(element.value) - 1)
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
-
+
@classmethod
def match_model(cls, filedata, filename):
- match_size = False
- match_model = False
+ if cls.MODEL == "RT21":
+ # The RT21 is pre-metadata, so do old-school detection
+ match_size = False
+ match_model = False
- # testing the file data size
- if len(filedata) in [0x0400, ]:
- match_size = True
+ # testing the file data size
+ if len(filedata) in [0x0400, ]:
+ match_size = True
- # testing the model fingerprint
- match_model = model_match(cls, filedata)
+ # testing the model fingerprint
+ match_model = model_match(cls, filedata)
- if match_size and match_model:
- return True
+ if match_size and match_model:
+ return True
+ else:
+ return False
else:
+ # Radios that have always been post-metadata, so never do
+ # old-school detection
return False
+
+@directory.register
+class RB17ARadio(RT21Radio):
+ """RETEVIS RB17A"""
+ VENDOR = "Retevis"
+ MODEL = "RB17A"
+ BAUD_RATE = 9600
+ BLOCK_SIZE = 0x40
+ BLOCK_SIZE_UP = 0x10
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PROA8US"
+ _fingerprint = ["P3217s\xF8\xFF", ]
+ _upper = 30
+ _skipflags = True
+ _reserved = False
+ _gmrs = True
+
+ _ranges = [
+ (0x0000, 0x0300),
+ ]
+ _memsize = 0x0300
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RB17A, self._mmap)
+
+
+@directory.register
+class RB26Radio(RT21Radio):
+ """RETEVIS RB26"""
+ VENDOR = "Retevis"
+ MODEL = "RB26"
+ BAUD_RATE = 9600
+ BLOCK_SIZE = 0x20
+ BLOCK_SIZE_UP = 0x10
+
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=3.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PHOGR" + "\x01" + "0"
+ _fingerprint = ["P32073" + "\x02\xFF", ]
+ _upper = 30
+ _ack_1st_block = False
+ _skipflags = True
+ _reserved = True
+ _gmrs = True
+
+ _ranges = [
+ (0x0000, 0x0320),
+ ]
+ _memsize = 0x0320
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RB26, self._mmap)
+
+
+@directory.register
+class RT76Radio(RT21Radio):
+ """RETEVIS RT76"""
+ VENDOR = "Retevis"
+ MODEL = "RT76"
+ BAUD_RATE = 9600
+ BLOCK_SIZE = 0x20
+ BLOCK_SIZE_UP = 0x10
+
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PHOGR\x14\xD4"
+ _fingerprint = ["P32073" + "\x02\xFF", ]
+ _upper = 30
+ _ack_1st_block = False
+ _skipflags = False
+ _reserved = True
+ _gmrs = True
+
+ _ranges = [
+ (0x0000, 0x01E0),
+ ]
+ _memsize = 0x01E0
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RT76, self._mmap)
+
+
+@directory.register
+class RT29UHFRadio(RT21Radio):
+ """RETEVIS RT29UHF"""
+ VENDOR = "Retevis"
+ MODEL = "RT29_UHF"
+ BLOCK_SIZE = 0x40
+ BLOCK_SIZE_UP = 0x10
+
+ TXPOWER_MED = 0x00
+ TXPOWER_HIGH = 0x01
+ TXPOWER_LOW = 0x02
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=10.00),
+ chirp_common.PowerLevel("Mid", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=1.00)]
+
+ _magic = "PROHRAM"
+ _fingerprint = ["P3207" + "\x13\xF8\xFF", ] # UHF model
+ _upper = 16
+ _skipflags = True
+ _reserved = False
+
+ _ranges = [
+ (0x0000, 0x0300),
+ ]
+ _memsize = 0x0400
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RT29, self._mmap)
+
+
+@directory.register
+class RT29VHFRadio(RT29UHFRadio):
+ """RETEVIS RT29VHF"""
+ VENDOR = "Retevis"
+ MODEL = "RT29_VHF"
+
+ TXPOWER_MED = 0x00
+ TXPOWER_HIGH = 0x01
+ TXPOWER_LOW = 0x02
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=10.00),
+ chirp_common.PowerLevel("Mid", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=1.00)]
+
+ VALID_BANDS = [(136000000, 174000000)]
+
+ _magic = "PROHRAM"
+ _fingerprint = ["P2207" + "\x01\xF8\xFF", ] # VHF model
+
+
+@directory.register
+class RB23Radio(RT21Radio):
+ """RETEVIS RB23"""
+ VENDOR = "Retevis"
+ MODEL = "RB23"
+ BLOCK_SIZE = 0x20
+ BLOCK_SIZE_UP = 0x10
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PHOGR" + "\x01" + "0"
+ _fingerprint = ["P32073" + "\x02\xFF", ]
+ _upper = 30
+ _ack_1st_block = False
+ _skipflags = True
+ _reserved = True
+ _gmrs = True
+
+ _ranges = [
+ (0x0000, 0x0320),
+ ]
+ _memsize = 0x0320
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RB26, self._mmap)
+
+
+@directory.register
+class RT19Radio(RT21Radio):
+ """RETEVIS RT19"""
+ VENDOR = "Retevis"
+ MODEL = "RT19"
+ BLOCK_SIZE = 0x20
+ BLOCK_SIZE_UP = 0x10
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PHOGRQ^"
+ _fingerprint = ["P32073" + "\x02\xFF", ]
+ _upper = 22
+ _mem_params = (_upper, # number of channels
+ 0x160, # memory start
+ _upper # number of freqhops
+ )
+ _ack_1st_block = False
+ _skipflags = False
+ _reserved = True
+ _frs = True
+
+ _ranges = [
+ (0x0000, 0x0180),
+ ]
+ _memsize = 0x0180
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RT19 % self._mem_params,
+ self._mmap)
+
+
+@directory.register
+class RT619Radio(RT19Radio):
+ """RETEVIS RT619"""
+ VENDOR = "Retevis"
+ MODEL = "RT619"
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=0.50),
+ chirp_common.PowerLevel("Low", watts=0.49)]
+
+ _magic = "PHOGRS]"
+ _fingerprint = ["P32073" + "\x02\xFF", ]
+ _upper = 16
+ _mem_params = (_upper, # number of channels
+ 0x100, # memory start
+ _upper # number of freqhops
+ )
+ _pmr = True
+
+ _ranges = [
+ (0x0000, 0x0120),
+ ]
+ _memsize = 0x0120
+
+
+@directory.register
+class AR63Radio(RT21Radio):
+ """ABBREE AR-63"""
+ VENDOR = "Abbree"
+ MODEL = "AR-63"
+ BLOCK_SIZE = 0x20
+ BLOCK_SIZE_UP = 0x10
+
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=3.00),
+ chirp_common.PowerLevel("Low", watts=1.00)]
+
+ _magic = "PHOGR\xF5\x9A"
+ _fingerprint = ["P32073" + "\x02\xFF",
+ "P32073" + "\x03\xFF", ]
+ _upper = 16
+ _ack_1st_block = False
+ _skipflags = True
+ _reserved = True
+ _gmrs = False
+
+ _ranges = [
+ (0x0000, 0x0140),
+ ]
+ _memsize = 0x0140
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RT76, self._mmap)
+
+
+@directory.register
+class RT40BRadio(RT21Radio):
+ """RETEVIS RT40B"""
+ VENDOR = "Retevis"
+ MODEL = "RT40B"
+ BLOCK_SIZE = 0x20
+ BLOCK_SIZE_UP = 0x10
+
+ DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
+ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ VALID_BANDS = [(400000000, 480000000)]
+
+ _magic = "PHOGRH" + "\x5C"
+ _fingerprint = ["P32073" + "\x02\xFF", ]
+ _upper = 22
+ _mem_params = (_upper, # number of channels
+ )
+ _ack_1st_block = False
+ _skipflags = True
+ _reserved = True
+ _gmrs = True
+ _echo = True
+
+ _ranges = [
+ (0x0000, 0x0160),
+ ]
+ _memsize = 0x0160
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT_RT40B % self._mem_params,
+ self._mmap)
diff --git a/chirp/drivers/retevis_rt22.py b/chirp/drivers/retevis_rt22.py
index 9edb9c4..ec3e6e5 100644
--- a/chirp/drivers/retevis_rt22.py
+++ b/chirp/drivers/retevis_rt22.py
@@ -1,4 +1,4 @@
-# Copyright 2016 Jim Unroe <rock.unroe@gmail.com>
+# Copyright 2016-2020 Jim Unroe <rock.unroe@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,37 +30,44 @@ LOG = logging.getLogger(__name__)
MEM_FORMAT = """
#seekto 0x0010;
struct {
- lbcd rxfreq[4];
- lbcd txfreq[4];
- ul16 rx_tone;
- ul16 tx_tone;
- u8 unknown1;
- u8 unknown3:2,
- highpower:1, // Power Level
- wide:1, // Bandwidth
- unknown4:4;
+ lbcd rxfreq[4];
+ lbcd txfreq[4];
+ ul16 rx_tone;
+ ul16 tx_tone;
+ u8 unknown1;
+ u8 unknown3:2,
+ highpower:1, // Power Level
+ wide:1, // Bandwidth
+ unknown4:2,
+ signal:1, // Signal
+ bcl:1; // BCL
u8 unknown5[2];
} memory[16];
#seekto 0x012F;
struct {
u8 voice; // Voice Annunciation
- u8 tot; // Time-out Timer
+ u8 tot; // Time-out Timer
u8 unknown1[3];
u8 squelch; // Squelch Level
- u8 save; // Battery Saver
- u8 beep; // Beep
+ u8 save; // Battery Saver
+ u8 beep; // Beep
u8 unknown2[2];
u8 vox; // VOX
u8 voxgain; // VOX Gain
- u8 voxdelay; // VOX Delay
+ u8 voxdelay; // VOX Delay
u8 unknown3[2];
- u8 pf2key; // PF2 Key
+ u8 pf2key; // PF2 Key
} settings;
#seekto 0x017E;
u8 skipflags[2]; // SCAN_ADD
+#seekto 0x0200;
+struct {
+ char id_0x200[8]; // Radio ID @ 0x0200
+} radio;
+
#seekto 0x0300;
struct {
char line1[32];
@@ -76,10 +83,16 @@ RT22_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=2.00),
RT22_DTCS = sorted(chirp_common.DTCS_CODES + [645])
PF2KEY_LIST = ["Scan", "Local Alarm", "Remote Alarm"]
-TIMEOUTTIMER_LIST = [""] + ["%s seconds" % x for x in range(15, 615, 15)]
+TIMEOUTTIMER_LIST = ["Off"] + ["%s seconds" % x for x in range(15, 615, 15)]
VOICE_LIST = ["Off", "Chinese", "English"]
VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 17)]
-VOXDELAY_LIST = ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"]
+VOXDELAY_LIST = ["0.5 | Off",
+ "1.0 | 0",
+ "1.5 | 1",
+ "2.0 | 2",
+ "2.5 | 3",
+ "3.0 | 4",
+ "--- | 5"]
SETTING_LISTS = {
"pf2key": PF2KEY_LIST,
@@ -93,6 +106,21 @@ VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
"`{|}!\"#$%&'()*+,-./:;<=>?@[]^_"
+def _ident_from_data(data):
+ return data[0x1B8:0x1C0]
+
+
+def _ident_from_image(radio):
+ return _ident_from_data(radio.get_mmap())
+
+
+def _get_radio_model(radio):
+ block = _rt22_read_block(radio, 0x360, 0x10)
+ block = _rt22_read_block(radio, 0x1B8, 0x10)
+ version = block[0:8]
+ return version
+
+
def _rt22_enter_programming_mode(radio):
serial = radio.pipe
@@ -160,6 +188,8 @@ def _rt22_enter_programming_mode(radio):
_rt22_exit_programming_mode(radio)
raise errors.RadioError("Radio refused to enter programming mode")
+ return ident
+
def _rt22_exit_programming_mode(radio):
serial = radio.pipe
@@ -188,6 +218,7 @@ def _rt22_read_block(radio, block_addr, block_size):
block_data = response[4:]
+ time.sleep(0.005)
serial.write(CMD_ACK)
ack = serial.read(1)
except:
@@ -201,11 +232,23 @@ def _rt22_read_block(radio, block_addr, block_size):
return block_data
-def _rt22_write_block(radio, block_addr, block_size):
+def _rt22_write_block(radio, block_addr, block_size, _requires_patch=False,
+ _radio_id=""):
serial = radio.pipe
cmd = struct.pack(">cHb", 'W', block_addr, block_size)
- data = radio.get_mmap()[block_addr:block_addr + block_size]
+ if _requires_patch:
+ mmap = radio.get_mmap()
+ data = mmap[block_addr:block_addr + block_size]
+
+ # For some radios (RT-622 & RT22FRS) memory at 0x1b8 reads as 0, but
+ # radio ID should be written instead
+ if block_addr == 0x1b8:
+ for fp in _radio_id:
+ if fp in mmap[0:len(_radio_id)]:
+ data = mmap[0:len(_radio_id)] + data[len(_radio_id):]
+ else:
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
LOG.debug("Writing Data:")
LOG.debug(util.hexprint(cmd + data))
@@ -227,7 +270,8 @@ def _rt22_write_block(radio, block_addr, block_size):
def do_download(radio):
LOG.debug("download")
- _rt22_enter_programming_mode(radio)
+ radio_ident = _rt22_enter_programming_mode(radio)
+ LOG.info("Radio Ident is %s" % repr(radio_ident))
data = ""
@@ -258,7 +302,17 @@ def do_upload(radio):
status = chirp_common.Status()
status.msg = "Uploading to radio"
- _rt22_enter_programming_mode(radio)
+ radio_ident = _rt22_enter_programming_mode(radio)
+ LOG.info("Radio Ident is %s" % repr(radio_ident))
+
+ image_ident = _ident_from_image(radio)
+ LOG.info("Image Ident is %s" % repr(image_ident))
+
+ # Determine if upload requires patching
+ if image_ident == "\x00\x00\x00\x00\x00\x00\xFF\xFF":
+ patch_block = True
+ else:
+ patch_block = False
status.cur = 0
status.max = radio._memsize
@@ -267,7 +321,8 @@ def do_upload(radio):
for addr in range(start_addr, end_addr, block_size):
status.cur = addr + block_size
radio.status_fn(status)
- _rt22_write_block(radio, addr, block_size)
+ _rt22_write_block(radio, addr, block_size, patch_block,
+ radio_ident)
_rt22_exit_programming_mode(radio)
@@ -277,7 +332,7 @@ def model_match(cls, data):
if len(data) == 0x0408:
rid = data[0x0400:0x0408]
- return rid.startswith(cls.MODEL)
+ return rid.startswith(cls.MODEL.encode())
else:
return False
@@ -297,7 +352,8 @@ class RT22Radio(chirp_common.CloneModeRadio):
]
_memsize = 0x0400
_block_size = 0x40
- _fileid = ["P32073", "P3" + "\x00\x00\x00" + "3"]
+ _fileid = ["P32073", "P3" + "\x00\x00\x00" + "3", "P3207!",
+ "\x00\x00\x00\x00\x00\x00\xF8\xFF"]
def get_features(self):
rf = chirp_common.RadioFeatures()
@@ -316,6 +372,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
rf.valid_power_levels = RT22_POWER_LEVELS
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_modes = ["NFM", "FM"] # 12.5 KHz, 25 kHz.
+ rf.valid_dtcs_codes = RT22_DTCS
rf.memory_bounds = (1, 16)
rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
rf.valid_bands = [(400000000, 520000000)]
@@ -437,6 +494,17 @@ class RT22Radio(chirp_common.CloneModeRadio):
mem.skip = "" if (_skp & bitpos) else "S"
LOG.debug("mem.skip %s" % mem.skip)
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ if self.MODEL == "RT22FRS" or self.MODEL == "RT622":
+ rs = RadioSettingValueBoolean(_mem.bcl)
+ rset = RadioSetting("bcl", "Busy Channel Lockout", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(_mem.signal)
+ rset = RadioSetting("signal", "Signal", rs)
+ mem.extra.append(rset)
+
return mem
def _set_tone(self, mem, _mem):
@@ -487,7 +555,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
_skp = self._memobj.skipflags[bytepos]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -516,6 +584,9 @@ class RT22Radio(chirp_common.CloneModeRadio):
_skp &= ~bitpos
LOG.debug("_skp %s" % _skp)
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
def get_settings(self):
_settings = self._memobj.settings
_message = self._memobj.embedded_msg
@@ -551,7 +622,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
VOX_LIST, VOX_LIST[_settings.voxgain]))
basic.append(rs)
- rs = RadioSetting("voxdelay", "VOX Delay Time",
+ rs = RadioSetting("voxdelay", "VOX Delay Time (Old | New)",
RadioSettingValueList(
VOXDELAY_LIST,
VOXDELAY_LIST[_settings.voxdelay]))
@@ -574,15 +645,17 @@ class RT22Radio(chirp_common.CloneModeRadio):
filtered += " "
return filtered
- rs = RadioSetting("embedded_msg.line1", "Embedded Message 1",
- RadioSettingValueString(0, 32, _filter(
- _message.line1)))
- basic.append(rs)
+ val = str(self._memobj.radio.id_0x200)
+ if val == "\xFF" * 8:
+ rs = RadioSetting("embedded_msg.line1", "Embedded Message 1",
+ RadioSettingValueString(0, 32, _filter(
+ _message.line1)))
+ basic.append(rs)
- rs = RadioSetting("embedded_msg.line2", "Embedded Message 2",
- RadioSettingValueString(0, 32, _filter(
- _message.line2)))
- basic.append(rs)
+ rs = RadioSetting("embedded_msg.line2", "Embedded Message 2",
+ RadioSettingValueString(0, 32, _filter(
+ _message.line2)))
+ basic.append(rs)
return top
@@ -605,7 +678,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -617,7 +690,7 @@ class RT22Radio(chirp_common.CloneModeRadio):
# testing the file data size
if len(filedata) in [0x0408, ]:
match_size = True
-
+
# testing the model fingerprint
match_model = model_match(cls, filedata)
@@ -626,25 +699,41 @@ class RT22Radio(chirp_common.CloneModeRadio):
else:
return False
+
@directory.register
class KDC1(RT22Radio):
"""WLN KD-C1"""
VENDOR = "WLN"
MODEL = "KD-C1"
+
@directory.register
class ZTX6(RT22Radio):
"""Zastone ZT-X6"""
VENDOR = "Zastone"
MODEL = "ZT-X6"
+
@directory.register
class LT316(RT22Radio):
"""Luiton LT-316"""
VENDOR = "LUITON"
MODEL = "LT-316"
+
@directory.register
class TDM8(RT22Radio):
VENDOR = "TID"
MODEL = "TD-M8"
+
+
+@directory.register
+class RT22FRS(RT22Radio):
+ VENDOR = "Retevis"
+ MODEL = "RT22FRS"
+
+
+@directory.register
+class RT622(RT22Radio):
+ VENDOR = "Retevis"
+ MODEL = "RT622"
diff --git a/chirp/drivers/retevis_rt23.py b/chirp/drivers/retevis_rt23.py
index d424131..bfe17b5 100644
--- a/chirp/drivers/retevis_rt23.py
+++ b/chirp/drivers/retevis_rt23.py
@@ -386,6 +386,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
rf.valid_power_levels = RT23_POWER_LEVELS
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_modes = ["FM", "NFM"] # 25 KHz, 12.5 KHz.
+ rf.valid_dtcs_codes = RT23_DTCS
rf.memory_bounds = (1, 128)
rf.valid_tuning_steps = _STEP_LIST
rf.valid_bands = [
@@ -500,7 +501,8 @@ class RT23Radio(chirp_common.CloneModeRadio):
# TX freq set
offset = (int(_mem.txfreq) * 10) - mem.freq
if offset != 0:
- if _split(self.get_features(), mem.freq, int(_mem.txfreq) * 10):
+ if _split(self.get_features(), mem.freq, int(
+ _mem.txfreq) * 10):
mem.duplex = "split"
mem.offset = int(_mem.txfreq) * 10
elif offset < 0:
@@ -543,7 +545,8 @@ class RT23Radio(chirp_common.CloneModeRadio):
rs = RadioSetting("signaling", "Optional Signaling",
RadioSettingValueList(LIST_SIGNALING,
- LIST_SIGNALING[_mem.signaling]))
+ LIST_SIGNALING[
+ _mem.signaling]))
mem.extra.append(rs)
return mem
@@ -645,8 +648,9 @@ class RT23Radio(chirp_common.CloneModeRadio):
RadioSettingValueBoolean(_settings.beep))
basic.append(beep)
- color = RadioSetting("color", "Background Color", RadioSettingValueList(
- LIST_COLOR, LIST_COLOR[_settings.color - 1]))
+ color = RadioSetting("color", "Background Color",
+ RadioSettingValueList(
+ LIST_COLOR, LIST_COLOR[_settings.color - 1]))
basic.append(color)
vot = RadioSetting("vot", "VOX Delay Time", RadioSettingValueList(
@@ -693,7 +697,6 @@ class RT23Radio(chirp_common.CloneModeRadio):
0, 7, _filter(_msg.line1)))
basic.append(ponmsg)
-
scans = RadioSetting("scans", "Scan Mode", RadioSettingValueList(
LIST_SCANS, LIST_SCANS[_settings.scans]))
basic.append(scans)
@@ -706,7 +709,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
RadioSettingValueBoolean(_settings.name))
basic.append(name)
- rptrl = RadioSetting("rptrl", "Repeater TX Delay",
+ rptrl = RadioSetting("rptrl", "Repeater TX Delay",
RadioSettingValueList(LIST_RPTRL, LIST_RPTRL[
_settings.rptrl]))
basic.append(rptrl)
@@ -716,7 +719,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
basic.append(rptspk)
rptptt = RadioSetting("rptptt", "Repeater PTT Switch",
- RadioSettingValueBoolean(_settings.rptptt))
+ RadioSettingValueBoolean(_settings.rptptt))
basic.append(rptptt)
rptmod = RadioSetting("rptmod", "Repeater Mode",
@@ -730,7 +733,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
basic.append(volmod)
dst = RadioSetting("dst", "DTMF Side Tone",
- RadioSettingValueBoolean(_settings.dst))
+ RadioSettingValueBoolean(_settings.dst))
basic.append(dst)
txsel = RadioSetting("txsel", "Priority TX Channel",
@@ -742,7 +745,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
RadioSettingValueBoolean(_settings.ste))
basic.append(ste)
- #advanced
+ # advanced
if _settings.pf1 > 0x0A:
val = 0x00
else:
@@ -762,31 +765,31 @@ class RT23Radio(chirp_common.CloneModeRadio):
advanced.append(pf2)
# other
- _limit = str(int(_mem.limits.vhf.lower) / 10)
+ _limit = str(int(_mem.limits.vhf.lower) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.vhf.lower", "VHF low", val)
other.append(rs)
- _limit = str(int(_mem.limits.vhf.upper) / 10)
+ _limit = str(int(_mem.limits.vhf.upper) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.vhf.upper", "VHF high", val)
other.append(rs)
- _limit = str(int(_mem.limits.uhf.lower) / 10)
+ _limit = str(int(_mem.limits.uhf.lower) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.uhf.lower", "UHF low", val)
other.append(rs)
- _limit = str(int(_mem.limits.uhf.upper) / 10)
+ _limit = str(int(_mem.limits.uhf.upper) // 10)
val = RadioSettingValueString(0, 3, _limit)
val.set_mutable(False)
rs = RadioSetting("limits.uhf.upper", "UHF high", val)
other.append(rs)
- #work mode
+ # work mode
vfomr_a = RadioSetting("vfomr_a", "Display Mode A",
RadioSettingValueList(
LIST_VFOMR, LIST_VFOMR[_settings.vfomr_a]))
@@ -807,7 +810,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
1, 128, _settings.mrchb))
workmode.append(mrchb)
- #fm radio
+ # fm radio
vfomr_fm = RadioSetting("vfomr_fm", "FM Radio Display Mode",
RadioSettingValueList(
LIST_VFOMRFM, LIST_VFOMRFM[
@@ -846,7 +849,7 @@ class RT23Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/retevis_rt26.py b/chirp/drivers/retevis_rt26.py
index 3840575..b10e331 100644
--- a/chirp/drivers/retevis_rt26.py
+++ b/chirp/drivers/retevis_rt26.py
@@ -103,7 +103,7 @@ struct {
u8 code3_len; // Stun Code length
u8 code3[5]; // Stun Code
u8 unknown9[10];
- u8 code1[8]; // PTT ID(beggining of TX)
+ u8 code1[8]; // PTT ID(beginning of TX)
u8 code2[8]; // PTT ID(end of TX)
} dtmf;
@@ -119,12 +119,12 @@ NUMERIC_CHARSET = list("0123456789")
DTMF_CHARSET = NUMERIC_CHARSET + list("ABCD*#")
RT26_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5.00),
- chirp_common.PowerLevel("High", watts=10.00)]
+ chirp_common.PowerLevel("High", watts=10.00)]
RT26_DTCS = sorted(chirp_common.DTCS_CODES + [645])
LIST_PTTID = ["Off", "BOT", "EOT", "Both"]
-LIST_SHORT_PRESS = ["Off", "Monitor On/Off", "", "Scan", "Alarm",
+LIST_SHORT_PRESS = ["Off", "Monitor On/Off", "", "Scan", "Alarm",
"Power High/Low"]
LIST_LONG_PRESS = ["Off", "Monitor On/Off", "Monitor(momentary)",
"Scan", "Alarm", "Power High/Low"]
@@ -159,18 +159,18 @@ SETTING_LISTS = {
"scandelay": LIST_SCANDELAY,
"digtime": LIST_DIGTIME,
"digdelay": LIST_DIGDELAY,
- "starhash" : LIST_STARHASH,
- "codespace" : LIST_CODESPACE,
- "groupcode" : LIST_GROUPCODE,
- "resettime" : LIST_RESETTIME,
- "decodeto" : LIST_DECODETO,
- "stuntype" : LIST_STUNTYPE,
+ "starhash": LIST_STARHASH,
+ "codespace": LIST_CODESPACE,
+ "groupcode": LIST_GROUPCODE,
+ "resettime": LIST_RESETTIME,
+ "decodeto": LIST_DECODETO,
+ "stuntype": LIST_STUNTYPE,
}
# Retevis RT26 fingerprints
RT26_UHF_fp = "PDK80" + "\xF3\x00\x00" # RT26 UHF model
-MODELS = [RT26_UHF_fp,]
+MODELS = [RT26_UHF_fp, ]
def _model_from_data(data):
@@ -359,7 +359,7 @@ def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
rid = data[0x0170:0x0176]
- return rid.startswith("PDK80")
+ return rid.startswith(b"PDK80")
@directory.register
@@ -392,6 +392,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
rf.valid_power_levels = RT26_POWER_LEVELS
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_modes = ["NFM", "FM"] # 12.5 KHz, 25 kHz.
+ rf.valid_dtcs_codes = RT26_DTCS
rf.memory_bounds = (1, 16)
rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
rf.valid_bands = [(400000000, 520000000)]
@@ -505,7 +506,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
_mem = self._memobj.memory[mem.number - 1]
if mem.empty:
- _mem.set_raw("\xFF" * (_mem.size() / 8))
+ _mem.set_raw("\xFF" * (_mem.size() // 8))
return
_mem.rxfreq = mem.freq / 10
@@ -710,8 +711,8 @@ class RT26Radio(chirp_common.CloneModeRadio):
val = _settings.scanspeed
rs = RadioSetting("scanspeed", "Scan Speed[ms]",
RadioSettingValueList(
- LIST_SCANSPEED,
- LIST_SCANSPEED[val]))
+ LIST_SCANSPEED,
+ LIST_SCANSPEED[val]))
basic.append(rs)
if _settings.scandelay > 27:
@@ -842,7 +843,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
LIST_STUNTYPE[_mem.dtmf.stuntype]))
dtmf.append(rs)
- ## setup stun entry
+ # setup stun entry
objname = "code3"
strname = "Stun Code"
dtmfsetting = getattr(_mem.dtmf, objname)
@@ -897,7 +898,7 @@ class RT26Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/retevis_rt76p.py b/chirp/drivers/retevis_rt76p.py
new file mode 100644
index 0000000..09a643c
--- /dev/null
+++ b/chirp/drivers/retevis_rt76p.py
@@ -0,0 +1,1009 @@
+# Copyright 2021-2022 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import logging
+import os
+import struct
+import time
+
+from chirp import (
+ bitwise,
+ chirp_common,
+ directory,
+ errors,
+ memmap,
+ util,
+)
+from chirp.settings import (
+ RadioSetting,
+ RadioSettingGroup,
+ RadioSettings,
+ RadioSettingValueBoolean,
+ RadioSettingValueFloat,
+ RadioSettingValueInteger,
+ RadioSettingValueList,
+ RadioSettingValueString,
+)
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ lbcd rxfreq[4]; // 0-3
+ lbcd txfreq[4]; // 4-7
+ ul16 rxtone; // 8-9
+ ul16 txtone; // A-B
+ u8 unknown1:4, // C
+ scode:4; // Signal
+ u8 unknown2:6, // D
+ pttid:2; // PTT-ID
+ u8 unknown3:7, // E
+ lowpower:1; // Power Level 0 = High, 1 = Low
+ u8 ani:1, // F ANI
+ narrow:1, // Bandwidth 0 = Wide, 1 = Narrow
+ unknown4:2,
+ bcl:1, // BCL
+ scan:1, // Scan 0 = Skip, 1 = Scan
+ unknown5:1,
+ compand:1; // Compand
+} memory[128];
+
+#seekto 0x0C00;
+struct {
+ char name[10]; // 10-character Alpha Tag
+ u8 unused[6];
+} names[128];
+
+#seekto 0x1A00;
+struct {
+ u8 unknown:4, // 1A00
+ squelch:4; // Squelch Level
+ u8 unknown_1a01:7, // 1A01
+ save:1; // Save Mode
+ u8 unknown_1a02:4, // 1A04
+ vox:4; // 1A02 VOX Level
+ u8 unknown_1a03:4, // 1A03
+ abr:4; // Auto Backlight Time-out
+ u8 unknown_1a04:7, // 1A04
+ tdr:1; // Dual Standby
+ u8 tot; // 1A05 Time-out Timer
+ u8 unknown_1a06:7, // 1A06
+ beep:1; // Beep
+ u8 unknown_1a07:7, // 1A07
+ voice:1; // Voice Switch
+ u8 unknown_1a08:7, // 1A08
+ language:1; // Language
+ u8 unknown_1a09:6, // 1A09
+ dtmfst:2; // DTMF ST
+ u8 unknown_101a:6, // 1A0A
+ scmode:2; // Scan Mode
+ u8 unknown_1a0a; // 1A0B
+ u8 pttlt; // 1A0C PTT Delay
+ u8 unknown_1a0d:6, // 1A0D
+ mdfa:2; // Channel A Display
+ u8 unknown_1a0e:6, // 1A0E
+ mdfb:2; // Channel B Display
+ u8 unknown_1a0f:7, // 1A0F
+ bcl:1; // BCL
+ u8 unknown_1a10:7, // 1A10
+ autolock:1; // AutoLock
+ u8 unknown_1a11:6, // 1A11
+ almod:2; // Alarm Mode
+ u8 unknown_1a12:7, // 1A12
+ alarm:1; // Alarm Sound
+ u8 unknown_1a13:6, // 1A13
+ tdrab:2; // Tx Under TDR Start
+ u8 unknown_1a14:7, // 1A14
+ ste:1; // Tail Noise Clear
+ u8 unknown_1a15:4, // 1A15
+ rpste:4; // Pass Repeat Noise
+ u8 unknown_1a16:4, // 1A16
+ rptrl:4; // Pass Repeat Noise
+ u8 unknown_1a17:7, // 1A17
+ roger:1; // Roger
+ u8 unknown_1a18; // 1A18
+ u8 unknown_1a19:7, // 1A19
+ fmradio:1; // FM Radio (inverted)
+ u8 unknown_1a1a:7, // 1A1A
+ workmode:1; // Work Mode
+ u8 unknown_1a1b:7, // 1A1B
+ kblock:1; // KB_Lock
+ u8 unknown_1a1c:6, // 1A1C
+ pwronmsg:2; // Pwr On Msg
+ u8 unknown_1a1d; // 1A1D
+ u8 unknown_1a1e:6, // 1A1E
+ tone:2; // Tone
+ u8 unknown_1a1f; // 1A1F
+ u8 unknown_1a20[7]; // 1A20-1A26
+ u8 unknown_1a27:6, // 1A27
+ wtled:2; // Wait Backlight Color
+ u8 unknown_1a28:6, // 1A28
+ rxled:2; // Rx Backlight Color
+ u8 unknown_1a29:6, // 1A29
+ txled:2; // Tx Backlight Color
+} settings;
+
+#seekto 0x1A80;
+struct {
+ u8 shortp; // 1A80 Skey Short
+ u8 longp; // 1A81 Skey Long
+} skey;
+
+#seekto 0x1B00;
+struct {
+ u8 code[6]; // 6-character PTT-ID Code
+ u8 unused[10];
+} pttid[15];
+
+#seekto 0x1BF0;
+struct {
+ u8 code[6]; // ANI Code
+ u8 unknown111;
+ u8 dtmfon; // DTMF Speed (on time)
+ u8 dtmfoff; // DTMR Speed (off time)
+ u8 unused222[7];
+ u8 killword[6]; // Kill Word
+ u8 unused333[2];
+ u8 revive[6]; // Revive
+ u8 unused444[2];
+} dtmf;
+
+#seekto 0x1FE0;
+struct {
+ char line1[16]; // Power-on Message Line 1
+ char line2[16]; // Power-on Message Line 2
+} poweron_msg;
+"""
+
+
+CMD_ACK = "\x06"
+
+RT76P_DTCS = sorted(chirp_common.DTCS_CODES + [645])
+
+DTMF_CHARS = "0123456789 *#ABCD"
+
+ALMOD_LIST = ["On Site", "Send Sound", "Send Code"]
+BACKLIGHT_LIST = ["Off", "Blue", "Orange", "Purple"]
+DTMFSPEED_LIST = ["%s ms" % x for x in range(50, 2010, 10)]
+DTMFST_LIST = ["Off", "KeyBboard Side Tone", "ANI Side Tone", "KB ST + ANI ST"]
+LANGUAGE_LIST = ["English", "China"]
+MDF_LIST = ["Name", "Frequency", "Number"]
+OFF1TO10_LIST = ["Off"] + ["%s" % x for x in range(1, 11)]
+PTTID_LIST = ["Off", "BOT", "EOT", "Both"]
+PTTIDCODE_LIST = ["%s" % x for x in range(1, 16)]
+PWRONMSG_LIST = ["Picture", "Message", "Voltage"]
+RPSTE_LIST = ["Off"] + ["%s" % x for x in range(100, 1100, 100)]
+SCMODE_LIST = ["Time (TO)", "Carrier (CO)", "Search (SE)"]
+TDRAB_LIST = ["Off", "A Band", "B Band"]
+TIMEOUTTIMER_LIST = ["%s seconds" % x for x in range(15, 615, 15)]
+TONE_LIST = ["1000Hz", "1450Hz", "1750Hz", "2100Hz"]
+VOICE_LIST = ["Off", "On"]
+WORKMODE_LIST = ["VFO Mode", "Channel Mode"]
+
+SKEY_CHOICES = ["FM", "Tx Power", "Moni", "Scan", "Offline", "Weather"]
+SKEY_VALUES = [0x07, 0x0A, 0x05, 0x1C, 0x0B, 0x0C]
+
+
+SETTING_LISTS = {
+ "abr": OFF1TO10_LIST,
+ "almod": ALMOD_LIST,
+ "dtmfspeed": DTMFSPEED_LIST,
+ "language": LANGUAGE_LIST,
+ "mdfa": MDF_LIST,
+ "mdfb": MDF_LIST,
+ "pttid": PTTID_LIST,
+ "rpste": RPSTE_LIST,
+ "rptrl": RPSTE_LIST,
+ "rxled": BACKLIGHT_LIST,
+ "scode": PTTIDCODE_LIST,
+ "scmode": SCMODE_LIST,
+ "tdrab": TDRAB_LIST,
+ "tot": TIMEOUTTIMER_LIST,
+ "tone": TONE_LIST,
+ "txled": BACKLIGHT_LIST,
+ "voice": VOICE_LIST,
+ "vox": OFF1TO10_LIST,
+ "workmode": WORKMODE_LIST,
+ "wtled": BACKLIGHT_LIST,
+ }
+
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+
+
+def _rt76p_enter_programming_mode(radio):
+ serial = radio.pipe
+
+ exito = False
+ for i in range(0, 5):
+ serial.write(radio._magic)
+ ack = serial.read(1)
+
+ try:
+ if ack == CMD_ACK:
+ exito = True
+ break
+ except:
+ LOG.debug("Attempt #%s, failed, trying again" % i)
+ pass
+
+ # check if we had EXITO
+ if exito is False:
+ msg = "The radio did not accept program mode after five tries.\n"
+ msg += "Check you interface cable and power cycle your radio."
+ raise errors.RadioError(msg)
+
+ try:
+ serial.write("F")
+ ident = serial.read(8)
+ except:
+ raise errors.RadioError("Error communicating with radio")
+
+ if not ident == radio._fingerprint:
+ LOG.debug(util.hexprint(ident))
+ raise errors.RadioError("Radio returned unknown identification string")
+
+
+def _rt76p_exit_programming_mode(radio):
+ serial = radio.pipe
+ try:
+ serial.write("E")
+ except:
+ raise errors.RadioError("Radio refused to exit programming mode")
+
+
+def _rt76p_read_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">cHb", 'R', block_addr, block_size)
+ expectedresponse = "R" + cmd[1:]
+ LOG.debug("Reading block %04x..." % (block_addr))
+
+ try:
+ serial.write(cmd)
+ response = serial.read(4 + block_size)
+ if response[:4] != expectedresponse:
+ raise Exception("Error reading block %04x." % (block_addr))
+
+ block_data = response[4:]
+ except:
+ raise errors.RadioError("Failed to read block at %04x" % block_addr)
+
+ return block_data
+
+
+def _rt76p_write_block(radio, block_addr, block_size):
+ serial = radio.pipe
+
+ cmd = struct.pack(">cHb", 'W', block_addr, block_size)
+ data = radio.get_mmap()[block_addr:block_addr + block_size]
+
+ LOG.debug("Writing Data:")
+ LOG.debug(util.hexprint(cmd + data))
+
+ try:
+ serial.write(cmd + data)
+ if serial.read(1) != CMD_ACK:
+ raise Exception("No ACK")
+ except:
+ raise errors.RadioError("Failed to send block "
+ "to radio at %04x" % block_addr)
+
+
+def do_download(radio):
+ serial = radio.pipe
+ LOG.debug("download")
+ _rt76p_enter_programming_mode(radio)
+
+ data = ""
+
+ status = chirp_common.Status()
+ status.msg = "Cloning from radio"
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
+ status.cur = addr + radio.BLOCK_SIZE
+ radio.status_fn(status)
+
+ block = _rt76p_read_block(radio, addr, radio.BLOCK_SIZE)
+ data += block
+
+ LOG.debug("Address: %04x" % addr)
+ LOG.debug(util.hexprint(block))
+
+ _rt76p_exit_programming_mode(radio)
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ status = chirp_common.Status()
+ status.msg = "Uploading to radio"
+
+ _rt76p_enter_programming_mode(radio)
+
+ status.cur = 0
+ status.max = radio._memsize
+
+ for start_addr, end_addr in radio._ranges:
+ for addr in range(start_addr, end_addr, radio.BLOCK_SIZE_UP):
+ status.cur = addr + radio.BLOCK_SIZE_UP
+ radio.status_fn(status)
+ _rt76p_write_block(radio, addr, radio.BLOCK_SIZE_UP)
+
+ _rt76p_exit_programming_mode(radio)
+
+
+@directory.register
+class RT76PRadio(chirp_common.CloneModeRadio):
+ """RETEVIS RT76P"""
+ VENDOR = "Retevis"
+ MODEL = "RT76P"
+ BAUD_RATE = 9600
+ BLOCK_SIZE = 0x40
+ BLOCK_SIZE_UP = 0x20
+
+ RT76P_POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+ _magic = "PROGROMCD2U"
+ _fingerprint = "\x01\x36\x01\x74\x04\x00\x05\x20"
+
+ _ranges = [
+ (0x0000, 0x0820),
+ (0x0C00, 0x1400),
+ (0x1A00, 0x1C20),
+ ]
+ _memsize = 0x2000
+ _valid_chars = chirp_common.CHARSET_ALPHANUMERIC + \
+ "`~!@#$%^&*()-=_+[]\\{}|;':\",./<>?"
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_rx_dtcs = True
+ rf.has_tuning_step = False
+ rf.can_odd_split = True
+ rf.has_name = True
+ rf.valid_name_length = 10
+ rf.valid_characters = self._valid_chars
+ rf.valid_skips = ["", "S"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
+ rf.valid_power_levels = self.RT76P_POWER_LEVELS
+ rf.valid_duplexes = ["", "-", "+", "split", "off"]
+ rf.valid_modes = ["FM", "NFM"] # 25 kHz, 12.5 KHz.
+ rf.valid_dtcs_codes = RT76P_DTCS
+ rf.memory_bounds = (1, 128)
+ rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 20., 25., 50.]
+ rf.valid_bands = [(136000000, 174000000),
+ (400000000, 480000000)]
+ return rf
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ data = do_download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = data
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ do_upload(self)
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ def _is_txinh(self, _mem):
+ raw_tx = ""
+ for i in range(0, 4):
+ raw_tx += _mem.txfreq[i].get_raw()
+ return raw_tx == "\xFF\xFF\xFF\xFF"
+
+ def get_memory(self, number):
+ _mem = self._memobj.memory[number - 1]
+ _nam = self._memobj.names[number - 1]
+
+ mem = chirp_common.Memory()
+ mem.number = number
+
+ if _mem.get_raw()[0] == "\xff":
+ mem.empty = True
+ return mem
+
+ mem.freq = int(_mem.rxfreq) * 10
+
+ if self._is_txinh(_mem):
+ # TX freq not set
+ mem.duplex = "off"
+ mem.offset = 0
+ else:
+ # TX freq set
+ offset = (int(_mem.txfreq) * 10) - mem.freq
+ if offset != 0:
+ if offset > 0:
+ mem.duplex = "+"
+ mem.offset = 5000000
+ else:
+ mem.duplex = ""
+ mem.offset = 0
+
+ for char in _nam.name:
+ if str(char) == "\xFF":
+ char = " " # may have 0xFF mid-name
+ mem.name += str(char)
+ mem.name = mem.name.rstrip()
+
+ dtcs_pol = ["N", "N"]
+
+ if _mem.txtone in [0, 0xFFFF]:
+ txmode = ""
+ elif _mem.txtone >= 0x0258:
+ txmode = "Tone"
+ mem.rtone = int(_mem.txtone) / 10.0
+ elif _mem.txtone <= 0x0258:
+ txmode = "DTCS"
+ if _mem.txtone > 0x69:
+ index = _mem.txtone - 0x6A
+ dtcs_pol[0] = "R"
+ else:
+ index = _mem.txtone - 1
+ mem.dtcs = RT76P_DTCS[index]
+ else:
+ LOG.warn("Bug: txtone is %04x" % _mem.txtone)
+
+ if _mem.rxtone in [0, 0xFFFF]:
+ rxmode = ""
+ elif _mem.rxtone >= 0x0258:
+ rxmode = "Tone"
+ mem.ctone = int(_mem.rxtone) / 10.0
+ elif _mem.rxtone <= 0x0258:
+ rxmode = "DTCS"
+ if _mem.rxtone >= 0x6A:
+ index = _mem.rxtone - 0x6A
+ dtcs_pol[1] = "R"
+ else:
+ index = _mem.rxtone - 1
+ mem.rx_dtcs = RT76P_DTCS[index]
+ else:
+ LOG.warn("Bug: rxtone is %04x" % _mem.rxtone)
+
+ if txmode == "Tone" and not rxmode:
+ mem.tmode = "Tone"
+ elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
+ mem.tmode = "TSQL"
+ elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
+ mem.tmode = "DTCS"
+ elif rxmode or txmode:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ mem.dtcs_polarity = "".join(dtcs_pol)
+
+ if not _mem.scan:
+ mem.skip = "S"
+
+ mem.power = self.RT76P_POWER_LEVELS[_mem.lowpower]
+
+ mem.mode = _mem.narrow and "NFM" or "FM"
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ # BCL (Busy Channel Lockout)
+ rs = RadioSettingValueBoolean(_mem.bcl)
+ rset = RadioSetting("bcl", "BCL", rs)
+ mem.extra.append(rset)
+
+ # PTT-ID
+ rs = RadioSettingValueList(PTTID_LIST, PTTID_LIST[_mem.pttid])
+ rset = RadioSetting("pttid", "PTT ID", rs)
+ mem.extra.append(rset)
+
+ # Signal (DTMF Encoder Group #)
+ rs = RadioSettingValueList(PTTIDCODE_LIST, PTTIDCODE_LIST[_mem.scode])
+ rset = RadioSetting("scode", "PTT ID Code", rs)
+ mem.extra.append(rset)
+
+ # Compand
+ rs = RadioSettingValueBoolean(_mem.compand)
+ rset = RadioSetting("compand", "Compand", rs)
+ mem.extra.append(rset)
+
+ # ANI
+ rs = RadioSettingValueBoolean(_mem.ani)
+ rset = RadioSetting("ani", "ANI", rs)
+ mem.extra.append(rset)
+
+ return mem
+
+ def set_memory(self, mem):
+ _mem = self._memobj.memory[mem.number - 1]
+ _nam = self._memobj.names[mem.number - 1]
+
+ if mem.empty:
+ _mem.set_raw("\xff" * 16)
+ _nam.set_raw("\xff" * 16)
+ return
+
+ _mem.set_raw("\x00" * 16)
+
+ if float(mem.freq) / 1000000 in GMRS_FREQS1:
+ mem.duplex == ''
+ mem.offset = 0
+ elif float(mem.freq) / 1000000 in GMRS_FREQS2:
+ mem.duplex == ''
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = self.POWER_LEVELS[1]
+ elif float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.duplex == ''
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
+ _mem.rxfreq = mem.freq / 10
+
+ if mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.txfreq[i].set_raw("\xFF")
+ elif mem.duplex == "split":
+ _mem.txfreq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.txfreq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.txfreq = mem.freq / 10
+
+ _namelength = self.get_features().valid_name_length
+ for i in range(_namelength):
+ try:
+ _nam.name[i] = mem.name[i]
+ except IndexError:
+ _nam.name[i] = "\xFF"
+
+ rxmode = txmode = ""
+ if mem.tmode == "Tone":
+ _mem.txtone = int(mem.rtone * 10)
+ _mem.rxtone = 0
+ elif mem.tmode == "TSQL":
+ _mem.txtone = int(mem.ctone * 10)
+ _mem.rxtone = int(mem.ctone * 10)
+ elif mem.tmode == "DTCS":
+ rxmode = txmode = "DTCS"
+ _mem.txtone = RT76P_DTCS.index(mem.dtcs) + 1
+ _mem.rxtone = RT76P_DTCS.index(mem.dtcs) + 1
+ elif mem.tmode == "Cross":
+ txmode, rxmode = mem.cross_mode.split("->", 1)
+ if txmode == "Tone":
+ _mem.txtone = int(mem.rtone * 10)
+ elif txmode == "DTCS":
+ _mem.txtone = RT76P_DTCS.index(mem.dtcs) + 1
+ else:
+ _mem.txtone = 0
+ if rxmode == "Tone":
+ _mem.rxtone = int(mem.ctone * 10)
+ elif rxmode == "DTCS":
+ _mem.rxtone = RT76P_DTCS.index(mem.rx_dtcs) + 1
+ else:
+ _mem.rxtone = 0
+ else:
+ _mem.rxtone = 0
+ _mem.txtone = 0
+
+ if txmode == "DTCS" and mem.dtcs_polarity[0] == "R":
+ _mem.txtone += 0x69
+ if rxmode == "DTCS" and mem.dtcs_polarity[1] == "R":
+ _mem.rxtone += 0x69
+
+ _mem.scan = mem.skip != "S"
+ _mem.narrow = mem.mode == "NFM"
+
+ _mem.lowpower = mem.power == self.RT76P_POWER_LEVELS[1]
+
+ for setting in mem.extra:
+ if setting.get_name() == "scramble_type":
+ setattr(_mem, setting.get_name(), int(setting.value) + 8)
+ setattr(_mem, "scramble_type2", int(setting.value) + 8)
+ else:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def get_settings(self):
+ _dtmf = self._memobj.dtmf
+ _settings = self._memobj.settings
+ _skey = self._memobj.skey
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ group = RadioSettings(basic)
+
+ # Menu 00: Squelch (Squelch Level)
+ rs = RadioSettingValueInteger(0, 9, _settings.squelch)
+ rset = RadioSetting("squelch", "Squelch Level", rs)
+ basic.append(rset)
+
+ # Menu 01: Step (VFO setting)
+ # Menu 02: Tx Power (VFO setting - not available)
+
+ # Menu 03: Power save (Save Mode)
+ rs = RadioSettingValueBoolean(_settings.save)
+ rset = RadioSetting("save", "Power Save", rs)
+ basic.append(rset)
+
+ # Menu 04: Vox Level (VOX)
+ rs = RadioSettingValueList(OFF1TO10_LIST, OFF1TO10_LIST[_settings.vox])
+ rset = RadioSetting("vox", "VOX Level", rs)
+ basic.append(rset)
+
+ # Menu 05: Bandwidth
+
+ # Menu 06: Backlight (Auto Backlight)
+ rs = RadioSettingValueList(OFF1TO10_LIST,
+ OFF1TO10_LIST[_settings.abr])
+ rset = RadioSetting("abr", "Backlight Time-out", rs)
+ basic.append(rset)
+
+ # Menu 07: Dual Standby (TDR)
+ rs = RadioSettingValueBoolean(_settings.tdr)
+ rset = RadioSetting("tdr", "Dual Standby", rs)
+ basic.append(rset)
+
+ # Menu 08: Beep Prompt
+ rs = RadioSettingValueBoolean(_settings.beep)
+ rset = RadioSetting("beep", "Beep Prompt", rs)
+ basic.append(rset)
+
+ # Menu 09: Voice (Voice Switch)
+ rs = RadioSettingValueBoolean(_settings.voice)
+ rset = RadioSetting("voice", "Voice Prompts", rs)
+ basic.append(rset)
+
+ # Menu 10: Tx over time (Time Out)
+ rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
+ TIMEOUTTIMER_LIST[_settings.tot - 1])
+ rset = RadioSetting("tot", "Time-out Timer", rs)
+ basic.append(rset)
+
+ # Menu 11: Rx DCS
+ # Menu 12: Rx CTCSS
+ # Menu 13: Tx DCS
+ # Menu 14: Tx CTCSS
+ # Menu 15: Voice Compand
+
+ # Menu 16: DTMFST (DTMF ST)
+ rs = RadioSettingValueList(DTMFST_LIST, DTMFST_LIST[_settings.dtmfst])
+ rset = RadioSetting("dtmfst", "DTMF Side Tone", rs)
+ basic.append(rset)
+
+ # Mneu 17: R-TONE (Tone)
+ rs = RadioSettingValueList(TONE_LIST, TONE_LIST[_settings.tone])
+ rset = RadioSetting("tone", "Tone-burst Frequency", rs)
+ basic.append(rset)
+
+ # Menu 18: S-CODE
+
+ # Menu 19: Scan Mode
+ rs = RadioSettingValueList(SCMODE_LIST, SCMODE_LIST[_settings.scmode])
+ rset = RadioSetting("scmode", "Scan Resume Method", rs)
+ basic.append(rset)
+
+ # Menu 20: ANI Match
+ # Menu 21: PTT-ID
+
+ # Menu 22: MDF-A (Channle_A Display)
+ rs = RadioSettingValueList(MDF_LIST, MDF_LIST[_settings.mdfa])
+ rset = RadioSetting("mdfa", "Memory Display Format A", rs)
+ basic.append(rset)
+
+ # Menu 23: MDF-B (Channle_B Display)
+ rs = RadioSettingValueList(MDF_LIST, MDF_LIST[_settings.mdfb])
+ rset = RadioSetting("mdfb", "Memory Display Format B", rs)
+ basic.append(rset)
+
+ # Menu 24: Busy Lockout
+
+ # Menu 25: Key Auto Lock (AutoLock)
+ rs = RadioSettingValueBoolean(_settings.autolock)
+ rset = RadioSetting("autolock", "Keypad Auto Lock", rs)
+ basic.append(rset)
+
+ # Menu 26: WT-LED (Wait Backlight)
+ rs = RadioSettingValueList(BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.wtled])
+ rset = RadioSetting("wtled", "Wait Backlight Color", rs)
+ basic.append(rset)
+
+ # Menu 27: RX-LED (Rx Backlight)
+ rs = RadioSettingValueList(BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.rxled])
+ rset = RadioSetting("rxled", "RX Backlight Color", rs)
+ basic.append(rset)
+
+ # Menu 28: TX-LED (Tx Backlight)
+ rs = RadioSettingValueList(BACKLIGHT_LIST,
+ BACKLIGHT_LIST[_settings.txled])
+ rset = RadioSetting("txled", "TX Backlight Color", rs)
+ basic.append(rset)
+
+ # Menu 29: Alarm Mode
+ rs = RadioSettingValueList(ALMOD_LIST, ALMOD_LIST[_settings.almod])
+ rset = RadioSetting("almod", "Alarm Mode", rs)
+ basic.append(rset)
+
+ # Menu 30: TAIL (Tail Noise Clear)
+ rs = RadioSettingValueBoolean(_settings.ste)
+ rset = RadioSetting("ste", "Squelch Tail Eliminate", rs)
+ basic.append(rset)
+
+ # Menu 31: PROGRE (Roger)
+ rs = RadioSettingValueBoolean(_settings.roger)
+ rset = RadioSetting("roger", "Roger Beep", rs)
+ basic.append(rset)
+
+ # Menu 32: Language
+ rs = RadioSettingValueList(LANGUAGE_LIST,
+ LANGUAGE_LIST[_settings.language])
+ rset = RadioSetting("language", "Language", rs)
+ basic.append(rset)
+
+ # Menu 33: OPENMGS (Pwr On Msg)
+ rs = RadioSettingValueList(PWRONMSG_LIST,
+ PWRONMSG_LIST[_settings.pwronmsg])
+ rset = RadioSetting("pwronmsg", "Power On Message", rs)
+ basic.append(rset)
+
+ dtmfchars = "0123456789ABCD*#"
+
+ # Menu 34: ANI ID (display only)
+ _codeobj = self._memobj.dtmf.code
+ _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 6, _code, False)
+ val.set_charset(dtmfchars)
+ val.set_mutable(False)
+ rs = RadioSetting("dtmf.code", "Query ANI ID", val)
+ basic.append(rs)
+
+ # Menu 35: Reset
+
+ advanced = RadioSettingGroup("advanced", "Advanced Settings")
+ group.append(advanced)
+
+ # Work Mode
+ rs = RadioSettingValueList(WORKMODE_LIST,
+ WORKMODE_LIST[_settings.workmode])
+ rset = RadioSetting("workmode", "Work Mode", rs)
+ advanced.append(rset)
+
+ # PTT Delay
+ rs = RadioSettingValueInteger(0, 30, _settings.pttlt)
+ rset = RadioSetting("pttlt", "PTT ID Delay", rs)
+ advanced.append(rset)
+
+ def apply_skey_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) + " from list")
+ val = str(setting.value)
+ index = SKEY_CHOICES.index(val)
+ val = SKEY_VALUES[index]
+ obj.set_value(val)
+
+ # Skey Short
+ if _skey.shortp in SKEY_VALUES:
+ idx = SKEY_VALUES.index(_skey.shortp)
+ else:
+ idx = SKEY_VALUES.index(0x0C)
+ rs = RadioSettingValueList(SKEY_CHOICES, SKEY_CHOICES[idx])
+ rset = RadioSetting("skey.shortp", "Side Key (Short Press)", rs)
+ rset.set_apply_callback(apply_skey_listvalue, _skey.shortp)
+ advanced.append(rset)
+
+ # Skey Long
+ if _skey.longp in SKEY_VALUES:
+ idx = SKEY_VALUES.index(_skey.longp)
+ else:
+ idx = SKEY_VALUES.index(0x0C)
+ rs = RadioSettingValueList(SKEY_CHOICES, SKEY_CHOICES[idx])
+ rset = RadioSetting("skey.longp", "Side Key (Long Press)", rs)
+ rset.set_apply_callback(apply_skey_listvalue, _skey.longp)
+ advanced.append(rset)
+
+ # Pass Repeat Noise
+ rs = RadioSettingValueList(RPSTE_LIST, RPSTE_LIST[_settings.rpste])
+ rset = RadioSetting("rpste", "Squelch Tail Eliminate (repeater)", rs)
+ advanced.append(rset)
+
+ # Pass Repeat Noise
+ rs = RadioSettingValueList(RPSTE_LIST, RPSTE_LIST[_settings.rptrl])
+ rset = RadioSetting("rptrl", "STE Repeater Delay", rs)
+ advanced.append(rset)
+
+ # KB_Lock
+ rs = RadioSettingValueBoolean(_settings.kblock)
+ rset = RadioSetting("kblock", "Keypad Lock", rs)
+ advanced.append(rset)
+
+ # FM Radio Enable
+ rs = RadioSettingValueBoolean(not _settings.fmradio)
+ rset = RadioSetting("fmradio", "Broadcast FM Radio", rs)
+ advanced.append(rset)
+
+ # Alarm Sound
+ rs = RadioSettingValueBoolean(_settings.alarm)
+ rset = RadioSetting("alarm", "Alarm Sound", rs)
+ advanced.append(rset)
+
+ # Tx Under TDR Start
+ rs = RadioSettingValueList(TDRAB_LIST, TDRAB_LIST[_settings.tdrab])
+ rset = RadioSetting("tdrab", "Dual Standby TX Priority", rs)
+ advanced.append(rset)
+
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in chirp_common.CHARSET_ASCII:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
+
+ _msg = self._memobj.poweron_msg
+ rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
+ RadioSettingValueString(
+ 0, 16, _filter(_msg.line1)))
+ advanced.append(rs)
+ rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
+ RadioSettingValueString(
+ 0, 16, _filter(_msg.line2)))
+ advanced.append(rs)
+
+ dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
+ group.append(dtmf)
+
+ def apply_code(setting, obj, length):
+ code = []
+ for j in range(0, length):
+ try:
+ code.append(DTMF_CHARS.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.code = code
+
+ for i in range(0, 15):
+ _codeobj = self._memobj.pttid[i].code
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 6, _code, False)
+ val.set_charset(DTMF_CHARS)
+ pttid = RadioSetting("pttid/%i.code" % i,
+ "Signal Code %i" % (i + 1), val)
+ pttid.set_apply_callback(apply_code, self._memobj.pttid[i], 6)
+ dtmf.append(pttid)
+
+ _codeobj = self._memobj.dtmf.killword
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 6, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.killword", "Kill Word", val)
+ rs.set_apply_callback(apply_code, self._memobj.dtmf, 6)
+ dtmf.append(rs)
+
+ _codeobj = self._memobj.dtmf.revive
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 6, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.revive", "Revive Word", val)
+ rs.set_apply_callback(apply_code, self._memobj.dtmf, 6)
+ dtmf.append(rs)
+
+ _codeobj = self._memobj.dtmf.code
+ _code = "".join([DTMF_CHARS[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 6, _code, False)
+ val.set_charset(DTMF_CHARS)
+ rs = RadioSetting("dtmf.code", "ANI Code", val)
+ rs.set_apply_callback(apply_code, self._memobj.dtmf, 6)
+ dtmf.append(rs)
+
+ if _dtmf.dtmfon > 0xC3:
+ val = 0x00
+ else:
+ val = _dtmf.dtmfon
+ rs = RadioSetting("dtmf.dtmfon", "DTMF Speed (on)",
+ RadioSettingValueList(DTMFSPEED_LIST,
+ DTMFSPEED_LIST[val]))
+ dtmf.append(rs)
+
+ if _dtmf.dtmfoff > 0xC3:
+ val = 0x00
+ else:
+ val = _dtmf.dtmfoff
+ rs = RadioSetting("dtmf.dtmfoff", "DTMF Speed (off)",
+ RadioSettingValueList(DTMFSPEED_LIST,
+ DTMFSPEED_LIST[val]))
+ dtmf.append(rs)
+
+ return group
+
+ def set_settings(self, settings):
+ _settings = self._memobj.settings
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = _settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif setting == "fmradio":
+ setattr(obj, setting, not int(element.value))
+ elif setting == "tot":
+ setattr(obj, setting, int(element.value) + 1)
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
diff --git a/chirp/drivers/retevis_rt87.py b/chirp/drivers/retevis_rt87.py
new file mode 100644
index 0000000..0717424
--- /dev/null
+++ b/chirp/drivers/retevis_rt87.py
@@ -0,0 +1,1042 @@
+# Copyright 2021 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""Retevis RT87 radio management module"""
+
+import logging
+import struct
+
+from chirp import (
+ bitwise,
+ chirp_common,
+ directory,
+ errors,
+ memmap,
+ util,
+)
+from chirp.settings import (
+ RadioSetting,
+ RadioSettingGroup,
+ RadioSettings,
+ RadioSettingValueBoolean,
+ RadioSettingValueInteger,
+ RadioSettingValueList,
+ RadioSettingValueString,
+)
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+struct memory {
+ bbcd rx_freq[4];
+ bbcd tx_freq[4];
+ lbcd rx_tone[2];
+ lbcd tx_tone[2];
+ u8 unknown10:2,
+ pttid:2,
+ unknown11:1,
+ highpower:1,
+ option:2;
+ u8 optsigtype:3,
+ unknown20:1,
+ narrow:1,
+ vox:1,
+ bcl:2;
+ u8 unknown31:1,
+ scanadd:1,
+ unknown32:3,
+ scrambler:3;
+ u8 unknown4;
+};
+
+struct name {
+ char name[10];
+};
+
+#seekto 0x0010;
+struct memory channels[128];
+
+#seekto 0x0830;
+struct {
+ u8 scanmode:2, // Scan Modes (Time, Carrier, Seek) [17]
+ autolock:1, // Auto Keypad Lock (Off, On) [18]
+ unknown_0830:2,
+ manager:1, // Manager (Off, On)
+ unknown_08301:2;
+ u8 batterydis:1, // Battery Display (Voltage, Icon) [20]
+ unknown_0831:1,
+ sidetone:1, // Side Tone (Off, On)
+ unknown_08311:1,
+ chnameshow:1, // Display Channel Names (Off, On) [25]
+ voice:1, // Voice Prompt (Off, On) [19]
+ beep:1 // Beep (Off, On) [09]
+ batterysave:1; // Battery Save aka Receiver Saver (Off, On) [16]
+ u8 unknown_0832:3,
+ manual:1, // Manual (Disabled, Enabled)
+ cancelcodesql:1, // Cancel Code Squelch When Press PTT (Disabled,
+ // Enabled)
+ ani:1, // Automatic Number Identity (Off, On) [10]
+ roger:1, // Roger Time (Off, On) [14]
+ dwatch:1; // Inhibit Receiver When Radio Working (Disabled, [15]
+ // aka Dual Watch/Monitor Enabled)
+ u8 unknown_0833:2,
+ txsel:1, // Priority Transmit (Edit, Busy) [02]
+ dwait:1, // Dual Wait/Standby (Off, On) [06]
+ unknown_08331:1,
+ dtmfsig:1, // DTMF Signaling (Code Squelch, Selective Call)
+ msgmode:2; // Message Mode (Off, DC, MSG, Image) [23]
+ u8 unk_0834:4,
+ squelch:4; // Squelch Level (0 - 9) [05]
+ u8 unk_0835:4,
+ tot:4; // Time-out Timer (Off, 30sec, 60sec, 90sec, [11]
+ // 120sec, 150sec, 180sec,
+ // 210sec, 240sec, 270sec)
+ u8 unknown_0836:2,
+ voxdelaytime:2, // VOX Delay Time (1sec, 2sec, 3sec, 4sec)
+ voxgainlevel:4; // VOX Gain Level (1 - 8) [03]
+ u8 unknown_0837;
+ u8 unknown_0838;
+ u8 unknown_0839;
+ u8 lamp:5, // Lamp 00000 Off [07]
+ // 00001 On
+ // 00010 5s
+ // 00100 10s (default)
+ // 01000 20s
+ // 10000 30s
+ brightness:3; // Brightness 000 Off [08]
+ // 001 1
+ // 010 2
+ // 011 3
+ // 100 4
+ // 101 5
+ // 110 6 (default)
+ // 111 7
+ u8 unknown_083B:1,
+ pf1:3, // PF1 (Off, Reverse, Opt Call, 1750Hz, A/B) [21]
+ unknown_083B1:1,
+ pf2:3; // PF2 (Off, Reverse, Opt Call, 1750Hz, A/B) [22]
+ u8 unknown_083c; // factory = 05, reset = FF
+ u8 unknown_083d; // factory = 12, reset = FF
+ u8 unknown_083e; // factory = 50, reset = FF
+ u8 stunmode; // Stun Mode (Stun Rx/Tx, Stun Tx, Normal)
+} settings;
+
+#seekto 0x08C0;
+struct {
+ char line1[16]; // PowerOn Message Line 1 (16 characters)
+ char line2[16]; // PowerOn Message Line 2 (16 characters)
+ char line3[16]; // PowerOn Message Line 3 (16 characters)
+ char line4[16]; // PowerOn Message Line 4 (16 characters)
+} poweron_msg;
+
+#seekto 0x0D20;
+struct {
+ u8 unknown_0d20:4,
+ autoresettimer:4; // Auto Reset Timer[s]
+ u8 delay; // Digit Delay
+ u8 unknown_0d22:4,
+ dtmflen:4; // DTMF Code Length
+ u8 unknown_0d23;
+ u8 unknown_0d24:4,
+ intcode:4; // Intermediate Code
+ u8 unknown_0d25:4,
+ groupcode:4; // Group Code
+} optsig;
+
+#seekto 0x0D30;
+struct {
+ u8 mskid[2]; // MSK ID Code
+} msk;
+
+#seekto 0x0D38;
+struct {
+ u8 mskcall[2]; // MSK CallList
+ u8 unused[2];
+} msklist[10];
+
+#seekto 0x0D90;
+struct {
+ u8 bot[7]; // PTT-ID BOT (Beginning of Transmission)
+ u8 unused_0d97;
+ u8 eot[7]; // PTT-ID EOT (End of Transmission) "0123456789ABCD#* "
+ u8 unused_0d9f;
+} pttid;
+
+#seekto 0x0DA8;
+struct {
+ char code[7]; // Local Name
+} msk_name;
+
+#seekto 0x0DB0;
+struct {
+ u8 code[16]; // MSK CallList
+} dtmfenc[10];
+
+#seekto 0x0E50;
+struct {
+ u8 stunid[4]; // Stun/Wake-Up ID Code
+} stun;
+
+#seekto 0x1900;
+struct name names[128];
+"""
+
+
+# Radio supports UPPER/lower case and symbols
+CHARSET_ASCII_PLUS = chirp_common.CHARSET_ALPHANUMERIC + \
+ "!\"#$%&'()*+,-./:;<=>?@[\]^_`"
+
+POWER_LEVELS = [chirp_common.PowerLevel('Low', watts=1),
+ chirp_common.PowerLevel('High', watts=4)]
+
+VALID_BANDS = [(136000000, 174000000),
+ (400000000, 480000000)]
+
+RT87_DTCS = sorted(chirp_common.DTCS_CODES + [645])
+
+NUMERIC_CHARSET = list("0123456789")
+DTMF_CHARSET = NUMERIC_CHARSET + list("ABCD*#")
+
+LIST_BATTERY = ["Volt", "Icon"]
+LIST_BCL = ["Off", "Carrier", "QT/DQT"]
+LIST_BRIGHTNESS = ["Off"] + ["%s" % x for x in range(1, 8)]
+LIST_DTMFLEN = ["%s" % x for x in range(30, 160, 10)]
+LIST_DTMFSIG = ["Code Squelch", "Selective Call"]
+LIST_INTCODE = list(DTMF_CHARSET)
+LIST_OPTION = ["Off", "Compand", "Scramble"]
+LIST_POWERON = ["Off", "Voltage", "Message", "Picture"]
+LIST_PTTID = ["Off", "BOT", "EOT", "Both"]
+LIST_RESET = ["Off", "1 second"] + ["%s seconds" % x for x in range(2, 16)]
+LIST_SCNREV = ["Time Operated", "Carrier Operated", "Seek"]
+LIST_SIDEKEY = ["Off", "Reverse", "Opt Call", "1750 Hz", "A/B"]
+LIST_TOT = ["Off"] + ["%s seconds" % x for x in range(30, 300, 30)]
+LIST_TXSEL = ["Edit", "Busy"]
+LIST_VFOMR = ["Frequency (VFO)", "Channel (MR)"]
+LIST_VOXDELAYTIME = ["1 second", "2 seconds", "3 seconds", "4 seconds"]
+
+LED_CHOICES = ["Off", "On", "5 seconds", "10 seconds", "20 seconds",
+ "30 seconcds"]
+LED_VALUES = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10]
+
+DELAY_CHOICES = ["%s ms" % x for x in range(300, 1250, 50)]
+DELAY_VALUES = [x for x in range(0, 95, 5)]
+
+STUN_CHOICES = ["Stun Rx/Tx", "Stun Tx", "Normal"]
+STUN_VALUES = [0x55, 0xAA, 0xFF]
+
+GROUP_CHOICES = ["Off", "A", "B", "C", "D", "*", "#"]
+GROUP_VALUES = [0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F]
+
+
+def _identify(radio):
+ try:
+ magic = radio._MAGIC
+ radio.pipe.write(magic)
+ echo = radio.pipe.read(len(magic)) # Chew the echoed response
+
+ if magic != echo:
+ LOG.debug("expecting echo\n%s\n", util.hexprint(magic))
+ LOG.debug("got echo\n%s\n", util.hexprint(echo))
+ raise Exception("Got false echo. Expected: '{}', got: '{}'."
+ .format(magic, echo))
+
+ ack = radio.pipe.read(2)
+ if ack != "\x06\x30":
+ raise errors.RadioError("Radio did not ACK first command: %r" %
+ ack)
+ except:
+ LOG.exception('')
+ raise errors.RadioError("Unable to communicate with the radio")
+
+
+def _download(radio):
+ _identify(radio)
+ data = []
+ for i in range(0, 0x2000, 0x40):
+ msg = struct.pack('>cHb', 'R', i, 0x40)
+ radio.pipe.write(msg)
+ echo = radio.pipe.read(len(msg)) # Chew the echoed response
+
+ if msg != echo:
+ LOG.debug("expecting echo\n%s\n", util.hexprint(msg))
+ LOG.debug("got echo\n%s\n", util.hexprint(echo))
+ raise Exception("Got false echo. Expected: '{}', got: '{}'."
+ .format(msg, echo))
+
+ block = radio.pipe.read(0x40 + 4)
+ if len(block) != (0x40 + 4):
+ raise errors.RadioError("Radio sent a short block (%02x/%02x)" % (
+ len(block), 0x44))
+ data += block[4:]
+
+ if radio.status_fn:
+ status = chirp_common.Status()
+ status.cur = i
+ status.max = 0x2000
+ status.msg = "Cloning from radio"
+ radio.status_fn(status)
+
+ radio.pipe.write("E")
+
+ return memmap.MemoryMap(data)
+
+
+def _upload(radio):
+ _identify(radio)
+
+ for start_addr, end_addr, block_size in radio._ranges:
+ for addr in range(start_addr, end_addr, block_size):
+ msg = struct.pack('>cHb', 'W', addr, block_size)
+ msg += radio._mmap[addr:(addr + block_size)]
+ radio.pipe.write(msg)
+ radio.pipe.read(block_size + 4)
+ ack = radio.pipe.read(1)
+ if ack != '\x06':
+ raise errors.RadioError('Radio did not ACK block %i (0x%04x)'
+ % (addr, addr))
+
+ if radio.status_fn:
+ status = chirp_common.Status()
+ status.cur = addr
+ status.max = 0x2000
+ status.msg = "Cloning to radio"
+ radio.status_fn(status)
+
+ radio.pipe.write("E")
+
+
+def _split(rf, f1, f2):
+ """Returns False if the two freqs are in the same band (no split)
+ or True otherwise"""
+
+ # determine if the two freqs are in the same band
+ for low, high in rf.valid_bands:
+ if f1 >= low and f1 <= high and \
+ f2 >= low and f2 <= high:
+ # if the two freqs are on the same Band this is not a split
+ return False
+
+ # if you get here is because the freq pairs are split
+ return True
+
+
+class Rt87BaseRadio(chirp_common.CloneModeRadio):
+ VENDOR = "Retevis"
+ MODEL = "RT87 Base"
+ BAUD_RATE = 9600
+ _MAGIC = "PGM2017"
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ # General
+ rf.has_bank = False
+ rf.has_rx_dtcs = True
+ rf.has_tuning_step = False
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_settings = True
+ # Attributes
+ rf.valid_modes = ["FM", "NFM"]
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_duplexes = ['', '-', '+', 'split', 'off']
+ rf.valid_tuning_steps = [0.5, 2.5, 5, 6.25, 10, 12.5, 25, 37.5, 50,
+ 100]
+ rf.valid_bands = VALID_BANDS
+ rf.valid_skips = ["", "S"]
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_characters = CHARSET_ASCII_PLUS
+ rf.valid_name_length = 10
+ rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
+
+ rf.memory_bounds = (1, 128)
+ rf.can_odd_split = True
+ return rf
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ data = _download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = data
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ _upload(self)
+ except:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def get_raw_memory(self, number):
+ return (repr(self._memobj.channels[number - 1]) +
+ repr(self._memobj.names[number - 1]))
+
+ def _get_memobjs(self, number):
+ return (self._memobj.channels[number - 1],
+ self._memobj.names[number - 1])
+
+ def _decode_tone(self, toneval):
+ pol = "N"
+ rawval = (toneval[1].get_bits(0xFF) << 8) | toneval[0].get_bits(0xFF)
+
+ if toneval[0].get_bits(0xFF) == 0xFF:
+ mode = ""
+ val = 0
+ elif toneval[1].get_bits(0xC0) == 0xC0:
+ mode = "DTCS"
+ val = int("%x" % (rawval & 0x3FFF))
+ pol = "R"
+ elif toneval[1].get_bits(0x80):
+ mode = "DTCS"
+ val = int("%x" % (rawval & 0x3FFF))
+ else:
+ mode = "Tone"
+ val = int(toneval) / 10.0
+
+ return mode, val, pol
+
+ def _encode_tone(self, _toneval, mode, val, pol):
+ toneval = 0
+ if mode == "Tone":
+ toneval = int("%i" % (val * 10), 16)
+ elif mode == "DTCS":
+ toneval = int("%i" % val, 16)
+ toneval |= 0x8000
+ if pol == "R":
+ toneval |= 0x4000
+ else:
+ toneval = 0xFFFF
+
+ _toneval[0].set_raw(toneval & 0xFF)
+ _toneval[1].set_raw((toneval >> 8) & 0xFF)
+
+ def _is_txinh(self, _mem):
+ raw_tx = ""
+ for i in range(0, 4):
+ raw_tx += _mem.tx_freq[i].get_raw()
+ return raw_tx == "\xFF\xFF\xFF\xFF"
+
+ def _bbcd2num(self, bcdarr, strlen=8):
+ # doing bbcd
+ LOG.debug(bcdarr.get_value())
+ string = ''.join("%02X" % b for b in bcdarr)
+ LOG.debug("@_bbcd2num, received: %s" % string)
+ if strlen <= 8:
+ string = string[:strlen]
+ return string
+
+ def _num2bbcd(self, value, strlen=8):
+ numstr = value.get_value()
+ numstr = str.ljust(numstr.strip(), strlen, "F")
+ bcdarr = list(bytearray.fromhex(numstr))
+ LOG.debug("@_num2bbcd, sending: %s" % bcdarr)
+ return bcdarr
+
+ def get_memory(self, number):
+ _mem, _name = self._get_memobjs(number)
+
+ mem = chirp_common.Memory()
+
+ if isinstance(number, str):
+ mem.number = SPECIALS[number]
+ mem.extd_number = number
+ else:
+ mem.number = number
+
+ if _mem.get_raw().startswith("\xFF\xFF\xFF\xFF"):
+ mem.empty = True
+ return mem
+
+ mem.freq = int(_mem.rx_freq) * 10
+
+ if self._is_txinh(_mem):
+ # TX freq not set
+ mem.duplex = "off"
+ mem.offset = 0
+ else:
+ # TX freq set
+ offset = (int(_mem.tx_freq) * 10) - mem.freq
+ if offset != 0:
+ if _split(self.get_features(), mem.freq, int(
+ _mem.tx_freq) * 10):
+ mem.duplex = "split"
+ mem.offset = int(_mem.tx_freq) * 10
+ elif offset < 0:
+ mem.offset = abs(offset)
+ mem.duplex = "-"
+ elif offset > 0:
+ mem.offset = offset
+ mem.duplex = "+"
+ else:
+ mem.offset = 0
+
+ txmode, txval, txpol = self._decode_tone(_mem.tx_tone)
+ rxmode, rxval, rxpol = self._decode_tone(_mem.rx_tone)
+
+ chirp_common.split_tone_decode(mem,
+ (txmode, txval, txpol),
+ (rxmode, rxval, rxpol))
+
+ mem.mode = 'NFM' if _mem.narrow else 'FM'
+ mem.skip = '' if _mem.scanadd else 'S'
+ mem.power = POWER_LEVELS[int(_mem.highpower)]
+ mem.name = str(_name.name).rstrip('\xFF ')
+
+ # Extra
+ mem.extra = RadioSettingGroup("extra", "Extra")
+
+ rs = RadioSettingValueList(LIST_BCL, LIST_BCL[_mem.bcl])
+ rset = RadioSetting("bcl", "BCL", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueList(LIST_PTTID, LIST_PTTID[_mem.pttid])
+ rset = RadioSetting("pttid", "PTT-ID", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_mem.vox))
+ rset = RadioSetting("vox", "VOX", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueList(LIST_OPTION, LIST_OPTION[_mem.option])
+ rset = RadioSetting("option", "Option", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueInteger(1, 8, _mem.scrambler + 1)
+ rset = RadioSetting("scrambler", "Compander/Scrambler", rs)
+ mem.extra.append(rset)
+
+ return mem
+
+ def set_memory(self, mem):
+ _mem, _name = self._get_memobjs(mem.number)
+ if mem.empty:
+ _mem.set_raw('\xFF' * 16)
+ _name.set_raw('\xFF' * 10)
+ return
+ _mem.set_raw('\x00' * 16)
+
+ _mem.rx_freq = mem.freq / 10
+
+ if mem.duplex == "off":
+ for i in range(0, 4):
+ _mem.tx_freq[i].set_raw("\xFF")
+ elif mem.duplex == "split":
+ _mem.tx_freq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.tx_freq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.tx_freq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.tx_freq = mem.freq / 10
+
+ (txmode, txval, txpol), (rxmode, rxval, rxpol) = \
+ chirp_common.split_tone_encode(mem)
+
+ self._encode_tone(_mem.tx_tone, txmode, txval, txpol)
+ self._encode_tone(_mem.rx_tone, rxmode, rxval, rxpol)
+
+ _mem.narrow = mem.mode == 'NFM'
+ _mem.scanadd = mem.skip != 'S'
+ _mem.highpower = POWER_LEVELS.index(mem.power) if mem.power else 1
+ _name.name = mem.name.rstrip(' ').ljust(10, '\xFF')
+
+ # extra settings
+ for setting in mem.extra:
+ if setting == "scrambler":
+ setattr(_mem, setting.get_name(), element.value - 1)
+ else:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def _get_settings(self):
+ _msg = self._memobj.poweron_msg
+ _optsig = self._memobj.optsig
+ _settings = self._memobj.settings
+ _stun = self._memobj.stun
+ _msk = self._memobj.msk
+ _mskname = self._memobj.msk_name
+
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ group = RadioSettings(basic)
+
+ # Menu 01: SCAN
+
+ # Menu 02: TX.SEL aka PRI
+ rs = RadioSettingValueList(LIST_TXSEL,
+ LIST_TXSEL[_settings.txsel])
+ rset = RadioSetting("txsel", "Priority Transmit", rs)
+ basic.append(rset)
+
+ # Menu 03: VOX (VOX Gain Level)
+ rs = RadioSettingValueInteger(1, 8, _settings.voxgainlevel + 1)
+ rset = RadioSetting("voxgainlevel", "VOX Gain Level", rs)
+ basic.append(rset)
+
+ # Function Setting: VOX Delay Time
+ rs = RadioSettingValueList(LIST_VOXDELAYTIME,
+ LIST_VOXDELAYTIME[_settings.voxdelaytime])
+ rset = RadioSetting("voxdelaytime", "VOX Delay Time", rs)
+ basic.append(rset)
+
+ # Menu 04: TX POW (TX Power)
+
+ # Menu 05: SQL (Squelch Level)
+ rs = RadioSettingValueInteger(0, 9, _settings.squelch)
+ rset = RadioSetting("squelch", "Squelch Level", rs)
+ basic.append(rset)
+
+ # Menu 06: D.WAIT aka DW (Dual Wait/Standby)
+ rs = RadioSettingValueBoolean(bool(_settings.dwait))
+ rset = RadioSetting("dwait", "Dual Wait/Standby", rs)
+ basic.append(rset)
+
+ # Menu 07: LED (Backlight Time)
+ def apply_lamp_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = LED_CHOICES.index(val)
+ val = LED_VALUES[index]
+ obj.set_value(val)
+
+ if _settings.lamp in LED_VALUES:
+ idx = LED_VALUES.index(_settings.lamp)
+ else:
+ idx = LED_VALUES.index(0x04)
+ rs = RadioSettingValueList(LED_CHOICES, LED_CHOICES[idx])
+ rset = RadioSetting("settings.lamp", "Backlight Time", rs)
+ rset.set_apply_callback(apply_lamp_listvalue, _settings.lamp)
+ basic.append(rset)
+
+ # Menu 08: BRIGHT (Backlight Brightness)
+ rs = RadioSettingValueList(LIST_BRIGHTNESS,
+ LIST_BRIGHTNESS[_settings.brightness])
+ rset = RadioSetting("brightness", "Backlight Brightness", rs)
+ basic.append(rset)
+
+ # Menu 09: BEEP (Key Beep)
+ rs = RadioSettingValueBoolean(bool(_settings.beep))
+ rset = RadioSetting("beep", "Key Beep", rs)
+ basic.append(rset)
+
+ # Menu 10: ANI (Automatic Number Identification)
+ rs = RadioSettingValueBoolean(bool(_settings.ani))
+ rset = RadioSetting("ani", "ANI", rs)
+ basic.append(rset)
+
+ # Menu 11: TOT (Transmitter Time-out Timer)
+ rs = RadioSettingValueList(LIST_TOT,
+ LIST_TOT[_settings.tot])
+ rset = RadioSetting("tot", "Time-Out Timer", rs)
+ basic.append(rset)
+
+ # Menu 12: BUSY LOCK
+ # Menu 13: VOX SW
+
+ # Menu 14: ROGER (Transmit Ended Beep)
+ rs = RadioSettingValueBoolean(bool(_settings.roger))
+ rset = RadioSetting("roger", "Roger Beep", rs)
+ basic.append(rset)
+
+ # Menu 15: DW (Dual Watch/Monitor)
+ rs = RadioSettingValueBoolean(bool(_settings.dwatch))
+ rset = RadioSetting("dwatch", "Dual Watch/Monitor", rs)
+ basic.append(rset)
+
+ # Menu 16: RX SAVE (Battery Save)
+ rs = RadioSettingValueBoolean(bool(_settings.batterysave))
+ rset = RadioSetting("batterysave", "Battery Save", rs)
+ basic.append(rset)
+
+ # Menu 17: SCN-REV (Scan Mode)
+ rs = RadioSettingValueList(LIST_SCNREV,
+ LIST_SCNREV[_settings.scanmode])
+ rset = RadioSetting("scanmode", "Scan Mode", rs)
+ basic.append(rset)
+
+ # Menu 18: AUTOLK (Auto Keypad Lock)
+ rs = RadioSettingValueBoolean(bool(_settings.autolock))
+ rset = RadioSetting("autolock", "Auto Keypad Lock", rs)
+ basic.append(rset)
+
+ # Menu 19: VOICE (Voice Prompt)
+ rs = RadioSettingValueBoolean(bool(_settings.voice))
+ rset = RadioSetting("voice", "Voice Prompt", rs)
+ basic.append(rset)
+
+ # Menu 20: BATT SHOW (Battery Display Method)
+ rs = RadioSettingValueList(LIST_BATTERY,
+ LIST_BATTERY[_settings.batterydis])
+ rset = RadioSetting("batterydis", "Battery Display Method", rs)
+ basic.append(rset)
+
+ # Menu 21: PF1 (Side-Key 1)
+ rs = RadioSettingValueList(LIST_SIDEKEY,
+ LIST_SIDEKEY[_settings.pf1])
+ rset = RadioSetting("pf1", "Side Key Function 1", rs)
+ basic.append(rset)
+
+ # Menu 22: PF2 (Side-Key 2)
+ rs = RadioSettingValueList(LIST_SIDEKEY,
+ LIST_SIDEKEY[_settings.pf2])
+ rset = RadioSetting("pf2", "Side Key Function 2", rs)
+ basic.append(rset)
+
+ # Menu 23: OPN.SET (Power-On Display)
+ rs = RadioSettingValueList(LIST_POWERON,
+ LIST_POWERON[_settings.msgmode])
+ rset = RadioSetting("msgmode", "Power-On Display Method", rs)
+ basic.append(rset)
+
+ # Menu 24: PON.MSG (Power-On Message Editing)
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in CHARSET_ASCII_PLUS:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
+
+ rs = RadioSettingValueString(0, 16, _filter(_msg.line1))
+ rset = RadioSetting("poweron_msg.line1", "Power-On Message 1", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueString(0, 16, _filter(_msg.line2))
+ rset = RadioSetting("poweron_msg.line2", "Power-On Message 2", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueString(0, 16, _filter(_msg.line3))
+ rset = RadioSetting("poweron_msg.line3", "Power-On Message 3", rs)
+ basic.append(rset)
+
+ rs = RadioSettingValueString(0, 16, _filter(_msg.line4))
+ rset = RadioSetting("poweron_msg.line4", "Power-On Message 4", rs)
+ basic.append(rset)
+
+ # Menu 25: CHNAME SHOW (Channel Name Show)
+ rs = RadioSettingValueBoolean(bool(_settings.chnameshow))
+ rset = RadioSetting("chnameshow", "Display Channel Names", rs)
+ basic.append(rset)
+
+ # Menu 26: CH.NAME (Channel Name Editing)
+ # Menu 27: OFFSET (Repeater Shift)
+ # Menu 28: C-CDC (TX/RX Tone Coder)
+ # Menu 29: R-CDC (RX Tone Coder)
+ # Menu 30: T-CDC (TX Tone Coder)
+ # Menu 31: SFT-D (Shift Direction)
+ # Menu 32: STEP (STEP)
+ # Menu 33: N/W (Channel Spacing Select)
+ # Menu 34: CTCSS SCAN (CTCSS Scan)
+ # Menu 35: DCS SSCAN (DCS Scan)
+ # Menu 36: SCR.NO (Scrambler)
+ # Menu 37: APRO (Voice Compander/Scrambler)
+
+ pttid = RadioSettingGroup("pttid", "PTT ID Settings")
+ group.append(pttid)
+
+ # PTT ID Setting: BOT
+ _codeobj = self._memobj.pttid.bot
+ _code = "".join([DTMF_CHARSET[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 7, _code, False)
+ val.set_charset(DTMF_CHARSET)
+ rs = RadioSetting("pttid.bot", "PTT ID BOT Code", val)
+
+ def apply_bot_code(setting, obj):
+ value = []
+ for j in range(0, 7):
+ try:
+ value.append(DTMF_CHARSET.index(str(setting.value)[j]))
+ except IndexError:
+ value.append(0xFF)
+ obj.bot = value
+ rs.set_apply_callback(apply_bot_code, self._memobj.pttid)
+ pttid.append(rs)
+
+ # PTT ID Setting: EOT
+ _codeobj = self._memobj.pttid.eot
+ _code = "".join([DTMF_CHARSET[x] for x in _codeobj if int(x) < 0x1F])
+ val = RadioSettingValueString(0, 7, _code, False)
+ val.set_charset(DTMF_CHARSET)
+ rs = RadioSetting("pttid.eot", "PTT ID EOT Code", val)
+
+ def apply_eot_code(setting, obj):
+ value = []
+ for j in range(0, 7):
+ try:
+ value.append(DTMF_CHARSET.index(str(setting.value)[j]))
+ except IndexError:
+ value.append(0xFF)
+ obj.eot = value
+ rs.set_apply_callback(apply_eot_code, self._memobj.pttid)
+ pttid.append(rs)
+
+ # Optional Signal
+ optsig = RadioSettingGroup("optsig", "Option Signal")
+ group.append(optsig)
+
+ # Common Set
+ common = RadioSettingGroup("common", "Common Set")
+ optsig.append(common)
+
+ # Common Set: Digit Delay[ms] (broken in OEM software)
+ def apply_delay_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = DELAY_CHOICES.index(val)
+ val = DELAY_VALUES[index]
+ obj.set_value(val)
+
+ if _optsig.delay in DELAY_VALUES:
+ idx = DELAY_VALUES.index(_optsig.delay)
+ else:
+ idx = DELAY_VALUES.index(30)
+ rs = RadioSettingValueList(DELAY_CHOICES, DELAY_CHOICES[idx])
+ rset = RadioSetting("optsig.delay", "Digit Delay", rs)
+ rset.set_apply_callback(apply_delay_listvalue, _optsig.delay)
+ common.append(rset)
+
+ # Common Set: Auto Reset Timer[s]
+ rs = RadioSettingValueList(LIST_RESET,
+ LIST_RESET[_optsig.autoresettimer])
+ rset = RadioSetting("optsig.autoresettimer", "Auto Reset Timer", rs)
+ common.append(rset)
+
+ # Common Set: Side Tone
+ rs = RadioSettingValueBoolean(bool(_settings.sidetone))
+ rset = RadioSetting("sidetone", "Side Tone", rs)
+ common.append(rset)
+
+ # Common Set: Stun Mode
+ def apply_stun_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = STUN_CHOICES.index(val)
+ val = STUN_VALUES[index]
+ obj.set_value(val)
+
+ if _settings.stunmode in STUN_VALUES:
+ idx = STUN_VALUES.index(_settings.stunmode)
+ else:
+ idx = STUN_VALUES.index(0xFF)
+ rs = RadioSettingValueList(STUN_CHOICES, STUN_CHOICES[idx])
+ rset = RadioSetting("settings.stunmode", "Stun Mode", rs)
+ rset.set_apply_callback(apply_stun_listvalue, _settings.stunmode)
+ common.append(rset)
+
+ # Common Set: Stun/Wake-Up ID
+
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in NUMERIC_CHARSET:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
+
+ codesetting = getattr(_stun, "stunid")
+ codestr = self._bbcd2num(codesetting, 8)
+ code = RadioSettingValueString(0, 8, _filter(codestr))
+ code.set_charset(NUMERIC_CHARSET + list(" "))
+ rs = RadioSetting("stun.stunid", "Stun ID Code", code)
+ common.append(rs)
+
+ # Common Set: Manager
+ rs = RadioSettingValueBoolean(bool(_settings.manager))
+ rset = RadioSetting("manager", "Manager", rs)
+ common.append(rset)
+
+ # MSK
+ msk = RadioSettingGroup("msk", "MSK")
+ optsig.append(msk)
+
+ # MSK: ID Code
+ codesetting = getattr(_msk, "mskid")
+ codestr = self._bbcd2num(codesetting, 4)
+ code = RadioSettingValueString(0, 4, _filter(codestr))
+ code.set_charset(NUMERIC_CHARSET + list(" "))
+ rs = RadioSetting("msk.mskid", "MSK ID Code", code)
+ msk.append(rs)
+
+ # MSK: Local Name
+ rs = RadioSettingValueString(0, 7, _filter(_mskname.code))
+ rset = RadioSetting("msk_name.code", "Local Name", rs)
+ msk.append(rset)
+
+ # MSK: CallList
+ for i in range(0, 10):
+ codesetting = getattr(self._memobj.msklist[i], "mskcall")
+ codestr = self._bbcd2num(codesetting, 4)
+ code = RadioSettingValueString(0, 4, _filter(codestr))
+ code.set_charset(NUMERIC_CHARSET + list(" "))
+ code.set_mutable(False)
+ rs = RadioSetting("msklist/%i.mskcall" % i, "CallList %i" % i,
+ code)
+ msk.append(rs)
+
+ # DTMF
+ dtmf = RadioSettingGroup("dtmf", "DTMF")
+ optsig.append(dtmf)
+
+ # DTMF: Encode
+
+ for i in range(0, 10):
+ _codeobj = self._memobj.dtmfenc[i].code
+ _code = "".join([DTMF_CHARSET[x] for x in _codeobj if
+ int(x) < 0x1F])
+ val = RadioSettingValueString(0, 16, _code, False)
+ val.set_charset(DTMF_CHARSET)
+ rs = RadioSetting("dtmfenc/%i.code" % i,
+ "Encode %i" % i, val)
+
+ def apply_code(setting, obj):
+ code = []
+ for j in range(0, 16):
+ try:
+ code.append(DTMF_CHARSET.index(str(setting.value)[j]))
+ except IndexError:
+ code.append(0xFF)
+ obj.code = code
+ rs.set_apply_callback(apply_code, self._memobj.dtmfenc[i])
+ dtmf.append(rs)
+
+ # DTMF: DTMF Signaling
+ rs = RadioSettingValueList(LIST_DTMFSIG,
+ LIST_DTMFSIG[_settings.dtmfsig])
+ rset = RadioSetting("dtmfsig", "DTMF Signaling", rs)
+ dtmf.append(rset)
+
+ # DTMF: Intermediate Code
+ rs = RadioSettingValueList(LIST_INTCODE,
+ LIST_INTCODE[_optsig.intcode])
+ rset = RadioSetting("optsig.intcode", "Intermediate Code", rs)
+ dtmf.append(rset)
+
+ # DTMF: Group Code
+ def apply_group_listvalue(setting, obj):
+ LOG.debug("Setting value: " + str(setting.value) +
+ " from list")
+ val = str(setting.value)
+ index = GROUP_CHOICES.index(val)
+ val = GROUP_VALUES[index]
+ obj.set_value(val)
+
+ if _optsig.groupcode in GROUP_VALUES:
+ idx = GROUP_VALUES.index(_optsig.groupcode)
+ else:
+ idx = GROUP_VALUES.index(0x00)
+ rs = RadioSettingValueList(GROUP_CHOICES, GROUP_CHOICES[idx])
+ rset = RadioSetting("optsig.groupcode", "Group Code", rs)
+ rset.set_apply_callback(apply_group_listvalue, _optsig.groupcode)
+ dtmf.append(rset)
+
+ # DTMF: DTMF Code Length
+ rs = RadioSettingValueList(LIST_DTMFLEN,
+ LIST_DTMFLEN[_optsig.dtmflen - 3])
+ rset = RadioSetting("optsig.dtmflen", "DTMF Code Length", rs)
+ dtmf.append(rset)
+
+ return group
+
+ def get_settings(self):
+ try:
+ return self._get_settings()
+ except:
+ import traceback
+ LOG.error("failed to parse settings")
+ traceback.print_exc()
+ return None
+
+ def set_settings(self, settings):
+ _mem = self._memobj
+ _settings = self._memobj.settings
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = _settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("using apply callback")
+ element.run_apply_callback()
+ elif setting == "voxgainlevel":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "stunid":
+ numstr = self._num2bbcd(element.value, 8)
+ setattr(_mem.stun, setting, numstr)
+ elif setting == "mskid":
+ numstr = self._num2bbcd(element.value, 4)
+ setattr(_mem.msk, setting, numstr)
+ elif setting == "dtmflen":
+ setattr(obj, setting, int(element.value) + 3)
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+
+@directory.register
+class RT87(Rt87BaseRadio):
+ VENDOR = "Retevis"
+ MODEL = "RT87"
+
+ _ranges = [
+ (0x0000, 0x0A00, 0x40),
+ (0x0BC0, 0x0C00, 0x08),
+ (0x0C00, 0x0F00, 0x40),
+ (0x1000, 0x2000, 0x40),
+ ]
diff --git a/chirp/drivers/retevis_rt98.py b/chirp/drivers/retevis_rt98.py
new file mode 100644
index 0000000..6520a99
--- /dev/null
+++ b/chirp/drivers/retevis_rt98.py
@@ -0,0 +1,1400 @@
+# Copyright 2021 Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import struct
+import time
+import logging
+
+from chirp import bitwise
+from chirp import chirp_common
+from chirp import directory
+from chirp import errors
+from chirp import memmap
+from chirp import util
+from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \
+ RadioSettingValueList, RadioSettingValueString, RadioSettingValueBoolean, \
+ RadioSettingValueInteger, RadioSettingValueString, \
+ RadioSettingValueFloat, InvalidValueError
+
+LOG = logging.getLogger(__name__)
+
+#
+# Chirp Driver for Retevis RT98 models: RT98V (136-174 Mhz)
+# RT98U (400-490 Mhz)
+#
+#
+#
+# Global Parameters
+#
+TONES = [62.5] + list(chirp_common.TONES)
+TMODES = ['', 'Tone', 'DTCS']
+DUPLEXES = ['', '+', '-']
+
+TXPOWER_LOW = 0x00
+TXPOWER_MED = 0x01
+TXPOWER_HIGH = 0x02
+
+DUPLEX_NOSPLIT = 0x00
+DUPLEX_POSSPLIT = 0x01
+DUPLEX_NEGSPLIT = 0x02
+
+CHANNEL_WIDTH_12d5kHz = 0x00
+CHANNEL_WIDTH_20kHz = 0x01
+CHANNEL_WIDTH_25kHz = 0x02
+
+TUNING_STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 30.0, 50.0]
+
+POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5),
+ chirp_common.PowerLevel("Mid", watts=10),
+ chirp_common.PowerLevel("High", watts=15)]
+
+PMR_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=0.5), ]
+
+FREENET_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1), ]
+
+PMR_FREQS = [446.00625, 446.01875, 446.03125, 446.04375,
+ 446.05625, 446.06875, 446.08125, 446.09375,
+ 446.10625, 446.11875, 446.13125, 446.14375,
+ 446.15625, 446.16875, 446.18125, 446.19375]
+
+FREENET_FREQS = [149.02500, 149.03750, 149.05000,
+ 149.08750, 149.10000, 149.11250]
+
+CROSS_MODES = ["Tone->Tone", "DTCS->", "->DTCS", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "DTCS->DTCS"]
+
+LIST_STEP = [str(x) for x in TUNING_STEPS]
+LIST_TIMEOUT = ["Off"] + ["%s min" % x for x in range(1, 31)]
+LIST_APO = ["Off", "30 min", "1 hr", "2 hrs"]
+LIST_SQUELCH = ["Off"] + ["Level %s" % x for x in range(1, 10)]
+LIST_DISPLAY_MODE = ["Channel", "Frequency", "Name"]
+LIST_AOP = ["Manual", "Auto"]
+LIST_STE_TYPE = ["Off", "Silent", "120 Degree", "180 Degree", "240 Degree"]
+LIST_STE_FREQ = ["Off", "55.2 Hz", "259.2 Hz"]
+LIST_VFOMR = ["MR", "VFO"]
+LIST_SCAN = ["TO", "CO", "SE"]
+
+LIST_PRIORITY_CH = ["Off", "Priority Channel 1", "Priority Channel 2",
+ "Priority Channel 1 + Priority Channel 2"]
+
+LIST_REVERT_CH = ["Selected", "Selected + TalkBack", "Priority Channel 1",
+ "Priority Channel 2", "Last Called", "Last Used",
+ "Priority Channel 1 + TalkBack",
+ "Priority Channel 2 + TalkBack"]
+
+LIST_TIME50 = ["0.1", "0.2", "0.3", "0.4", "0.5",
+ "0.6", "0.7", "0.8", "0.9", "1.0",
+ "1.1", "1.2", "1.3", "1.4", "1.5",
+ "1.6", "1.7", "1.8", "1.9", "2.0",
+ "2.1", "3.2", "2.3", "2.4", "2.5",
+ "2.6", "2.7", "2.8", "2.9", "3.0",
+ "3.1", "3.2", "3.3", "3.4", "3.5",
+ "3.6", "3.7", "3.8", "3.9", "4.0",
+ "4.1", "4.2", "4.3", "4.4", "4.5",
+ "4.6", "4.7", "4.8", "4.9", "5.0"]
+LIST_TIME46 = LIST_TIME50[4:]
+
+LIST_RT98V_MODES = ["FreeNet", "COM", "COMII"]
+LIST_RT98U_MODES = ["PMR", "COM", "COMII"]
+
+LIST_RT98V_FREQS = ["Rx(149 - 149.2 MHz) Tx(149 - 149.2 MHz)",
+ "Rx(136 - 174 MHz) Tx(136 - 174 MHz)",
+ "Rx(147 - 174 MHz) Tx(147 - 174 MHz)"]
+
+LIST_RT98U_FREQS = ["Rx(446 - 446.2 MHz) Tx(446 - 446.2 MHz)",
+ "Rx(400 - 470 MHz) Tx(400 - 470 MHz)",
+ "Rx(450 - 470 MHz) Tx(450 - 470 MHz)"]
+
+SETTING_LISTS = {
+ "tuning_step": LIST_STEP,
+ "timeout_timer": LIST_TIMEOUT,
+ "auto_power_off": LIST_APO,
+ "squelch": LIST_SQUELCH,
+ "display_mode": LIST_DISPLAY_MODE,
+ "auto_power_on": LIST_AOP,
+ "ste_type": LIST_STE_TYPE,
+ "ste_frequency": LIST_STE_FREQ,
+ "priority_ch": LIST_PRIORITY_CH,
+ "revert_ch": LIST_REVERT_CH,
+ "settings2.dropout_delay_time": LIST_TIME50,
+ "settings2.dwell_time": LIST_TIME50,
+ "settings2.look_back_time_a": LIST_TIME46,
+ "settings2.look_back_time_b": LIST_TIME46,
+ "settings3.vfomr": LIST_VFOMR,
+ "settings.scan": LIST_SCAN
+}
+
+# RT98 memory map
+# section: 1 Channel Bank
+# description of channel bank (199 channels , range 1-199)
+# Each 32 Byte (0x20 hex) record:
+# bytes:bit type description
+# ---------------------------------------------------------------------------
+# 4 bbcd freq[4] receive frequency in packed binary coded
+# decimal
+# 4 bbcd offset[4] transceive offset in packed binary coded
+# decimal (note: +/- direction set by
+# 'duplex' field)
+# 1 u8 unknown0
+# 1 u8
+# :1 reverse:1 reverse flag, 0=off, 1=on (reverses
+# transmit and receive frequencies)
+# :1 txoff:1 transmitt off flag, 0=transmit, 1=do not
+# transmit
+# :2 power:2 transmit power setting, value range 0-2,
+# 0=low, 1=middle, 2=high
+# :2 duplex:2 duplex settings, 0=simplex, 1=plus (+)
+# offset, 2=minus(-) offset (see offset field)
+# :2 channel_width:2 channel spacing, 0=12.5kHz, 1=20kHz, 2=25kHz
+# 1 u8
+# :2 unknown1:2
+# :1 talkaround:1 talkaround flag, 0=off, 1=on
+# (bypasses repeater)
+# :1 squelch_mode:1 squelch mode flag, 0=carrier, 1=ctcss/dcs
+# :1 rxdcsextra:1 use with rxcode for index of rx DCS to use
+# :1 rxinv:1 inverse DCS rx polarity flag, 0=N, 1=I
+# :1 txdcsextra:1 use with txcode for index of tx DCS to use
+# :1 txinv:1 inverse DCS tx polarity flag, 0=N, 1=I
+# 1 u8
+# :4 unknown2:4
+# :2 rxtmode:2 rx tone mode, value range 0-2, 0=none,
+# 1=CTCSS, 2=DCS (ctcss tone in field rxtone)
+# :2 txtmode:2 tx tone mode, value range 0-2, 0=none,
+# 1=CTCSS, 3=DCS (ctcss tone in field txtone)
+# 1 u8
+# :2 unknown3:2
+# :6 txtone:6 tx ctcss tone, menu index
+# 1 u8
+# :2 unknown4:2
+# :6 rxtone:6 rx ctcss tone, menu index
+# 1 u8 txcode ?, not used for ctcss
+# 1 u8 rxcode ?, not used for ctcss
+# 1 u8
+# :6 unknown5:6
+# :1 busychannellockout:1 busy channel lockout flag, 0=off, 1=enabled
+# :1 unknown6:1
+# 6 char name[6] 6 byte char string for channel name
+# 9 u8 unknown7[9]
+#
+MEM_FORMAT = """
+#seekto 0x0000;
+struct {
+ bbcd freq[4];
+ bbcd offset[4];
+ u8 unknown0;
+ u8 reverse:1,
+ tx_off:1,
+ txpower:2,
+ duplex:2,
+ channel_width:2;
+ u8 unknown1:2,
+ talkaround:1,
+ squelch_mode:1,
+ rxdcsextra:1,
+ rxinv:1,
+ txdcsextra:1,
+ txinv:1;
+ u8 unknown2:4,
+ rxtmode:2,
+ txtmode:2;
+ u8 unknown3:2,
+ txtone:6;
+ u8 unknown4:2,
+ rxtone:6;
+ u8 txcode;
+ u8 rxcode;
+ u8 unknown5:6,
+ busychannellockout:1,
+ unknown6:1;
+ char name[6];
+ u8 unknown7[9];
+} memory[199];
+"""
+
+# RT98 memory map
+# section: 2 and 3 Channel Set/Skip Flags
+#
+# Channel Set (starts 0x3240) : Channel Set bit is value 0 if a memory
+# location in the channel bank is active.
+# Channel Skip (starts 0x3260): Channel Skip bit is value 0 if a memory
+# location in the channel bank is active.
+#
+# Both flag maps are a total 24 bytes in length, aligned on 32 byte records.
+# bit = 0 channel not set/skip, 1 is channel set/no skip
+#
+# to index a channel:
+# cbyte = channel / 8 ;
+# cbit = channel % 8 ;
+# setflag = csetflag[cbyte].c[cbit] ;
+# skipflag = cskipflag[cbyte].c[cbit] ;
+#
+# channel range is 1-199, range is 32 bytes (last 7 unknown)
+#
+MEM_FORMAT = MEM_FORMAT + """
+#seekto 0x3240;
+struct {
+ bit c[8];
+} csetflag[32];
+
+#seekto 0x3260;
+struct {
+ bit c[8];
+} cskipflag[32];
+
+"""
+
+# RT98 memory map
+# section: 4 Startup Label
+#
+# bytes:bit type description
+# ---------------------------------------------------------------------------
+# 6 char start_label[6] label displayed at startup (usually
+# your call sign)
+#
+MEM_FORMAT = MEM_FORMAT + """
+#seekto 0x3300;
+struct {
+ char startname[6];
+} slabel;
+"""
+
+# RT98 memory map
+# section: 5, 6 and 7 Radio Options
+# used to set a number of radio options
+#
+# description of function setup options, starting at 0x3310 (settings3)
+#
+# bytes:bit type description
+# ---------------------------------------------------------------------------
+# 1 u8
+# :6 unknown:6
+# :2 bandlimit_3310:2 frequency ranges, range 0-2,
+# 0=freenet(vhf) or pmr(uhf), 1=com, 2=comii
+# rt98v - 00 FreeNet Rx(149 - 149.2 MHz) Tx(149 - 149.2 MHz)
+# 01 COM Rx(136 - 174 MHz) Tx(136 - 174 MHz)
+# 02 COMII Rx(147 - 174 MHz) Tx(147 - 174 MHz)
+# rt98u - 00 PMR Rx(446 - 446.2 MHz) Tx(446 - 446.2 MHz)
+# 01 COM Rx(400 - 470 MHz) Tx(400 - 470 MHz)
+# 02 COMII Rx(450 - 470 MHz) Tx(450 - 470 MHz)
+# 1 u8 ch_number; channel number, range 1-199
+# 1 u8
+# :7 unknown_3312:7
+# :1 vfomr:1 vfo/mr mode, range 0-1, 0=mr, 1=vfo
+# only S/N:1907***********
+#
+# description of function setup options, starting at 0x3340 (settings)
+#
+# bytes:bit type description
+# ---------------------------------------------------------------------------
+# 1 u8
+# :4 unknown_3340:4
+# :4 tuning_step:4 tuning step, menu index value from 0-8
+# 2.5, 5, 6.25, 10, 12.5, 20, 25, 30, 50
+# 1 u8
+# :7 unknown_3341:7
+# :1 beep:1 beep mode, range 0-1, 0=off, 1=on
+# 1 u8
+# :3 unknown_3342:3
+# :5 timeout_timer:5 timeout timer, range off (no timeout),
+# 1-30 minutes
+# 1 u8
+# :6 unknown_3343:6
+# :2 auto_power_off:2 auto power off, range 0-3, off, 30min,
+# 1hr, 2hr
+# 1 u8
+# :4 unknown_3344:4
+# :4 squelch:4 squelch level, range off, 1-9
+# 1 u8
+# :3 unknown_3345:3
+# :5 volume:5 volume level, range 1-30 (no zero)
+# 1 u8
+# :6 unknown_3346:6
+# :2 scan_revive:2 scan revive method, range 0-2, 0=to,
+# 1=co, 2=se
+# only S/N:1907***********
+# 1 u8 unknown_3347
+# 1 u8 0x3348 [12]
+# :6 unknown_3348:6
+# :2 display_mode display mode, range 0-2, 0=channel,
+# 1=frequency, 2=name
+# 1 u8
+# :7 unknown_3349:7
+# :1 auto_power_on:1 auto power on, range 0-1, 0=manual,
+# 1=auto
+# 1 u8
+# :3 unknown_334A:3
+# :5 mic_gain:5 mic gain, range 1-30 (no zero)
+# 1 u8
+# :5 unknown_334C:5
+# :3 ste_type:3 ste type, range 0-4, 0=off, 1=silent,
+# 2=120degree, 3=180degree, 4=240degree
+# 1 u8
+# :7 unknown_334D:7
+# :1 ste_frequency:1 ste frequency, range 0-2, 0=off,
+# 1=55.2Hz, 2=259.2Hz
+# 1 u8
+# :2 unknown_0x334E:2
+# :1 forbid_setting:1 forbid setting(optional function),
+# range 0-1, 0=disabled, 1=enabled
+# :1 forbid_initialize:1 forbid initialize operate, range 0-1,
+# 0=enabled, 1=disabled (inverted)
+# :1 save_chan_param:1 save channel parameters, range 0-1,
+# 0=disabled, 1=enabled
+# :1 forbid_chan_menu:1 forbid channel menu, range 0-1,
+# 0=disabled, 1=enabled
+# :1 sql_key_function:1 sql key function, range 0-1,
+# 0=squelch off momentary, 1=squelch off
+# :1 unknown:1
+#
+# description of function setup options, starting at 0x3380 (settings2)
+#
+# bytes:bit type description
+# ---------------------------------------------------------------------------
+# 1 u8
+# :7 unknown_3380:7
+# :1 scan_mode:1 scan mode, range 0-1, 0=off, 1=on
+# 1 u8
+# :6 unknown_3381:6
+# :2 priority_ch:2 priority channel, range 0-3, 0=off,
+# 1=priority channel 1,
+# 2=priority channel 2,
+# 3=priority channel 1 + priority channel 2
+# 1 u8 priority_ch1 priority channel 1 number, range 1-199
+# 1 u8 priority_ch2 priority channel 2 number, range 1-199
+# 1 u8
+# :4 unknown_3384:4
+# :4 revert_ch:4 revert channel, range 0-3, 0=selected,
+# 1=selected + talkback, 2=last called,
+# 3=last used
+# 1 u8 look_back_time_a look back time a, range 0-45
+# 1 u8 look_back_time_b look back time b, range 0-45
+# 1 u8 dropout_delay_time dropout delay time, range 0-49
+# 1 u8 dwell_time dwell time, range 0-49
+#
+MEM_FORMAT = MEM_FORMAT + """
+#seekto 0x3310;
+struct {
+ u8 bandlimit;
+ u8 ch_number;
+ u8 unknown_3312:7,
+ vfomr:1;
+} settings3;
+"""
+
+MEM_FORMAT = MEM_FORMAT + """
+#seekto 0x3340;
+struct {
+ u8 unknown_3340:4,
+ tuning_step:4;
+ u8 unknown_3341:7,
+ beep:1;
+ u8 unknown_3342:3,
+ timeout_timer:5;
+ u8 unknown_3343:6,
+ auto_power_off:2;
+ u8 unknown_3344:4,
+ squelch:4;
+ u8 unknown_3345:3,
+ volume:5;
+ u8 unknown_3346:6,
+ scan_resume:2;
+ u8 unknown_3347;
+ u8 unknown_3348:6,
+ display_mode:2;
+ u8 unknown_3349:7,
+ auto_power_on:1;
+ u8 unknown_334A:3,
+ mic_gain:5;
+ u8 unknown_334B;
+ u8 unknown_334C:5,
+ ste_type:3;
+ u8 unknown_334D:6,
+ ste_frequency:2;
+ u8 unknown_334E:1,
+ forbid_setting:1,
+ unknown1:1,
+ forbid_initialize:1,
+ save_chan_param:1,
+ forbid_chan_menu:1,
+ sql_key_function:1,
+ unknown2:1;
+} settings;
+"""
+
+MEM_FORMAT = MEM_FORMAT + """
+#seekto 0x3380;
+struct {
+ u8 unknown_3380:7,
+ scan_mode:1;
+ u8 unknown_3381:6,
+ priority_ch:2;
+ u8 priority_ch1;
+ u8 priority_ch2;
+ u8 unknown_3384:4,
+ revert_ch:4;
+ u8 look_back_time_a;
+ u8 look_back_time_b;
+ u8 dropout_delay_time;
+ u8 dwell_time;
+} settings2;
+"""
+
+# RT98 memory map
+# section: 8 Embedded Messages
+#
+# bytes:bit type description
+# ---------------------------------------------------------------------------
+# 6 char radio_type[5] radio type, vhf=rt98v, uhf=rt98u
+# 2 u8 unknown1[2]
+# 4 char mcu_version[4] mcu version, [x.xx]
+# 2 u8 unknown2[2]
+# 1 u8 mode rt98u mode: 0=pmr, 1=com, 2=comii
+# rt98v mode: 0=freenet, 1=com, 2=comii
+# 1 u8 unknown3
+# 10 u8 unused1[10]
+# 4 u8 unknown4[4]
+# 3 u8 unused2[3]
+# 16 u8 unknown5[16]
+# 10 char date_mfg[16] date manufactured, [yyyy-mm-dd]
+#
+MEM_FORMAT = MEM_FORMAT + """
+#seekto 0x3D00;
+struct {
+char radio_type[7];
+char mcu_version[4];
+u8 unknown2[2];
+u8 mode;
+u8 unknown3;
+u8 unused1[10];
+u8 unknown4[4];
+u8 unused2[3];
+u8 unknown5[16];
+char date_mfg[10];
+} embedded_msg;
+"""
+
+
+# Format for the version messages returned by the radio
+VER_FORMAT = '''
+u8 hdr;
+char model[7];
+u8 bandlimit;
+char version[6];
+u8 ack;
+'''
+
+
+# Radio supports upper case and symbols
+CHARSET_ASCII_PLUS = chirp_common.CHARSET_UPPER_NUMERIC + '- '
+
+# Band limits as defined by the band byte in ver_response, defined in Hz, for
+# VHF and UHF, used for RX and TX.
+RT98V_BAND_LIMITS = {0x00: [(149000000, 149200000)],
+ 0x01: [(136000000, 174000000)],
+ 0x02: [(147000000, 174000000)]}
+
+RT98U_BAND_LIMITS = {0x00: [(446000000, 446200000)],
+ 0x01: [(400000000, 470000000)],
+ 0x02: [(450000000, 470000000)]}
+
+
+# Get band limits from a band limit value
+def get_band_limits_Hz(radio_type, limit_value):
+ if str(radio_type).rstrip("\00") in ["RT98U", "AT-779U"]:
+ if limit_value not in RT98U_BAND_LIMITS:
+ limit_value = 0x01
+ LOG.warning('Unknown band limit value 0x%02x, default to 0x01')
+ bandlimitfrequencies = RT98U_BAND_LIMITS[limit_value]
+ elif str(radio_type).rstrip("\00") in ["RT98V", "AT-779V"]:
+ if limit_value not in RT98V_BAND_LIMITS:
+ limit_value = 0x01
+ LOG.warning('Unknown band limit value 0x%02x, default to 0x01')
+ bandlimitfrequencies = RT98V_BAND_LIMITS[limit_value]
+ return bandlimitfrequencies
+
+
+def _echo_write(radio, data):
+ try:
+ radio.pipe.write(data)
+ radio.pipe.read(len(data))
+ except Exception as e:
+ LOG.error("Error writing to radio: %s" % e)
+ raise errors.RadioError("Unable to write to radio")
+
+
+def _checksum(data):
+ cs = 0
+ for byte in data:
+ cs += ord(byte)
+ return cs % 256
+
+
+def _read(radio, length):
+ try:
+ data = radio.pipe.read(length)
+ except Exception as e:
+ _finish(radio)
+ LOG.error("Error reading from radio: %s" % e)
+ raise errors.RadioError("Unable to read from radio")
+
+ if len(data) != length:
+ _finish(radio)
+ LOG.error("Short read from radio (%i, expected %i)" %
+ (len(data), length))
+ LOG.debug(util.hexprint(data))
+ raise errors.RadioError("Short read from radio")
+ return data
+
+
+# strip trailing 0x00 to convert a string returned by bitwise.parse into a
+# python string
+def cstring_to_py_string(cstring):
+ return "".join(c for c in cstring if c != '\x00')
+
+
+# Check the radio version reported to see if it's one we support,
+# returns bool version supported, and the band index
+def check_ver(ver_response, allowed_types):
+ ''' Check the returned radio version is one we approve of '''
+
+ LOG.debug('ver_response = ')
+ LOG.debug(util.hexprint(ver_response))
+
+ resp = bitwise.parse(VER_FORMAT, ver_response)
+ verok = False
+
+ if resp.hdr == 0x49 and resp.ack == 0x06:
+ model, version = [cstring_to_py_string(bitwise.get_string(s)).strip()
+ for s in (resp.model, resp.version)]
+ LOG.debug('radio model: \'%s\' version: \'%s\'' %
+ (model, version))
+ LOG.debug('allowed_types = %s' % allowed_types)
+
+ if model in allowed_types:
+ LOG.debug('model in allowed_types')
+
+ if version in allowed_types[model]:
+ LOG.debug('version in allowed_types[model]')
+ verok = True
+ else:
+ _finish(radio)
+ raise errors.RadioError('Failed to parse version response')
+
+ return verok, str(resp.model), int(resp.bandlimit)
+
+
+def _ident(radio):
+ radio.pipe.timeout = 1
+ _echo_write(radio, "PROGRAM")
+ response = radio.pipe.read(3)
+ if response != "QX\06":
+ _finish(radio)
+ LOG.debug("Response was :\n%s" % util.hexprint(response))
+ raise errors.RadioError("Radio did not respond. Check connection.")
+ _echo_write(radio, "\x02")
+ ver_response = radio.pipe.read(16)
+ LOG.debug(util.hexprint(ver_response))
+
+ verok, model, bandlimit = check_ver(ver_response,
+ radio.ALLOWED_RADIO_TYPES)
+ if not verok:
+ _finish(radio)
+ raise errors.RadioError(
+ 'Radio version not in allowed list for %s-%s: %s' %
+ (radio.VENDOR, radio.MODEL, util.hexprint(ver_response)))
+
+ return model, bandlimit
+
+
+def _send(radio, cmd, addr, length, data=None):
+ frame = struct.pack(">cHb", cmd, addr, length)
+ if data:
+ frame += data
+ frame += chr(_checksum(frame[1:]))
+ frame += "\x06"
+ _echo_write(radio, frame)
+ LOG.debug("Sent:\n%s" % util.hexprint(frame))
+ if data:
+ result = radio.pipe.read(1)
+ if result != "\x06":
+ _finish(radio)
+ LOG.debug("Ack was: %s" % repr(result))
+ raise errors.RadioError("Radio did not accept block at %04x"
+ % addr)
+ return
+ result = _read(radio, length + 6)
+ LOG.debug("Got:\n%s" % util.hexprint(result))
+ header = result[0:4]
+ data = result[4:-2]
+ ack = result[-1]
+ if ack != "\x06":
+ _finish(radio)
+ LOG.debug("Ack was: %s" % repr(ack))
+ raise errors.RadioError("Radio NAK'd block at %04x" % addr)
+ _cmd, _addr, _length = struct.unpack(">cHb", header)
+ if _addr != addr or _length != _length:
+ _finish(radio)
+ LOG.debug("Expected/Received:")
+ LOG.debug(" Length: %02x/%02x" % (length, _length))
+ LOG.debug(" Addr: %04x/%04x" % (addr, _addr))
+ raise errors.RadioError("Radio send unexpected block")
+ cs = _checksum(result[1:-2])
+ if cs != ord(result[-2]):
+ _finish(radio)
+ LOG.debug("Calculated: %02x" % cs)
+ LOG.debug("Actual: %02x" % ord(result[-2]))
+ raise errors.RadioError("Block at 0x%04x failed checksum" % addr)
+ return data
+
+
+def _finish(radio):
+ endframe = "\x45\x4E\x44"
+ _echo_write(radio, endframe)
+ result = radio.pipe.read(1)
+ if result != "\x06":
+ LOG.error("Got:\n%s" % util.hexprint(result))
+ raise errors.RadioError("Radio did not finish cleanly")
+
+
+def do_download(radio):
+
+ _ident(radio)
+
+ _memobj = None
+ data = ""
+
+ for addr in range(0, radio._memsize, 0x10):
+ block = _send(radio, 'R', addr, 0x10)
+ data += block
+ status = chirp_common.Status()
+ status.cur = len(data)
+ status.max = radio._memsize
+ status.msg = "Downloading from radio"
+ radio.status_fn(status)
+
+ _finish(radio)
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ model, bandlimit = _ident(radio)
+ _embedded = radio._memobj.embedded_msg
+
+ if model != str(_embedded.radio_type):
+ LOG.warning('radio and image model types differ')
+ LOG.warning('model type (radio): %s' % str(model))
+ LOG.warning('model type (image): %s' % str(_embedded.radio_type))
+
+ _finish(radio)
+
+ msg = ("The upload was stopped because the radio type "
+ "of the image (%s) does not match that "
+ "of the radio (%s).")
+ raise errors.RadioError(msg % (str(_embedded.radio_type), str(model)))
+
+ if bandlimit != int(_embedded.mode):
+ if str(_embedded.radio_type).rstrip("\00") in ["RT98U", "AT-779U"]:
+ image_band_limits = LIST_RT98U_FREQS[int(_embedded.mode)]
+ if str(_embedded.radio_type).rstrip("\00") in ["RT98V", "AT-779V"]:
+ image_band_limits = LIST_RT98V_FREQS[int(_embedded.mode)]
+ if model in ["RT98U", "AT-779U"]:
+ radio_band_limits = LIST_RT98U_FREQS[int(bandlimit)]
+ if model in ["RT98V", "AT-779V"]:
+ radio_band_limits = LIST_RT98V_FREQS[int(bandlimit)]
+
+ LOG.warning('radio and image band limits differ')
+ LOG.warning('image band limits: %s' % image_band_limits)
+ LOG.warning('radio band limits: %s' % radio_band_limits)
+
+ _finish(radio)
+
+ msg = ("The upload was stopped because the band limits "
+ "of the image (%s) does not match that "
+ "of the radio (%s).")
+ raise errors.RadioError(msg % (image_band_limits, radio_band_limits))
+
+ try:
+ for start, end in radio._ranges:
+ for addr in range(start, end, 0x10):
+ block = radio._mmap[addr:addr+0x10]
+ _send(radio, 'W', addr, len(block), block)
+ status = chirp_common.Status()
+ status.cur = addr
+ status.max = end
+ status.msg = "Uploading to Radio"
+ radio.status_fn(status)
+ _finish(radio)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ _finish(radio)
+ raise errors.RadioError('Failed to upload to radio: %s' % e)
+
+
+#
+# The base class, extended for use with other models
+#
+class Rt98BaseRadio(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
+ """Retevis RT98 Base"""
+ VENDOR = "Retevis"
+ MODEL = "RT98 Base"
+ BAUD_RATE = 9600
+
+ _memsize = 0x3E00
+ _ranges = [(0x0000, 0x3310),
+ (0x3320, 0x3390)]
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = ("The Retevis RT98 driver is an beta version."
+ "Proceed with Caution and backup your data")
+ return rp
+
+ def get_features(self):
+ class FakeEmbedded(object):
+ mode = 0
+ radio_type = 'RT98U'
+
+ if self._memobj:
+ _embedded = self._memobj.embedded_msg
+ else:
+ # If we have no memory object, take defaults for unit
+ # test, make_supported, etc
+ _embedded = FakeEmbedded()
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.can_odd_split = True
+ rf.has_name = True
+ if _embedded.mode == 0: # PMR or FreeNet
+ rf.has_offset = False
+ else:
+ rf.has_offset = True
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_tuning_step = False
+ rf.has_dtcs = True
+ rf.has_rx_dtcs = True
+ rf.has_dtcs_polarity = True
+ rf.valid_skips = ["", "S"]
+ rf.memory_bounds = (1, 199)
+ rf.valid_name_length = 6
+ if _embedded.mode == 0: # PMR or FreeNet
+ rf.valid_duplexes = ['']
+ else:
+ rf.valid_duplexes = DUPLEXES + ['split', 'off']
+ rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "- "
+ if _embedded.mode == 0: # PMR or FreeNet
+ rf.valid_modes = ['NFM']
+ else:
+ rf.valid_modes = ['FM', 'NFM']
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = CROSS_MODES
+ if _embedded.mode == 0: # PMR or FreeNet
+ if str(_embedded.radio_type).rstrip("\00") == "RT98U":
+ rf.valid_power_levels = PMR_POWER_LEVELS
+ if str(_embedded.radio_type).rstrip("\00") == "RT98V":
+ rf.valid_power_levels = FREENET_POWER_LEVELS
+ else:
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_dtcs_codes = chirp_common.ALL_DTCS_CODES
+
+ try:
+ rf.valid_bands = get_band_limits_Hz(
+ str(_embedded.radio_type),
+ int(_embedded.mode))
+ except TypeError as e:
+ # If we're asked without memory loaded, assume the most permissive
+ rf.valid_bands = get_band_limits_Hz(str(_embedded.radio_type), 1)
+ except Exception as e:
+ LOG.error('Failed to get band limits for RT98: %s' % e)
+ rf.valid_bands = get_band_limits_Hz(str(_embedded.radio_type), 1)
+
+ rf.valid_tuning_steps = TUNING_STEPS
+ return rf
+
+ def validate_memory(self, mem):
+ _embedded = self._memobj.embedded_msg
+ msgs = ""
+ msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
+
+ # FreeNet and PMR radio types
+ if _embedded.mode == 0: # PMR or FreeNet
+ freq = float(mem.freq) / 1000000
+
+ # FreeNet
+ if str(_embedded.radio_type).rstrip("\00") == "RT98V":
+ if freq not in FREENET_FREQS:
+ _msg_freq = 'Memory location not a valid FreeNet frequency'
+ # warn user invalid frequency
+ msgs.append(chirp_common.ValidationError(_msg_freq))
+
+ # PMR
+ if str(_embedded.radio_type).rstrip("\00") == "RT98U":
+ if freq not in PMR_FREQS:
+ _msg_freq = 'Memory location not a valid PMR frequency'
+ # warn user invalid frequency
+ msgs.append(chirp_common.ValidationError(_msg_freq))
+
+ return msgs
+
+ # Do a download of the radio from the serial port
+ def sync_in(self):
+ self._mmap = do_download(self)
+ self.process_mmap()
+
+ # Do an upload of the radio to the serial port
+ def sync_out(self):
+ do_upload(self)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ # Return a raw representation of the memory object, which
+ # is very helpful for development
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ def _get_dcs_index(self, _mem, which):
+ base = getattr(_mem, '%scode' % which)
+ extra = getattr(_mem, '%sdcsextra' % which)
+ return (int(extra) << 8) | int(base)
+
+ def _set_dcs_index(self, _mem, which, index):
+ base = getattr(_mem, '%scode' % which)
+ extra = getattr(_mem, '%sdcsextra' % which)
+ base.set_value(index & 0xFF)
+ extra.set_value(index >> 8)
+
+ # Extract a high-level memory object from the low-level memory map
+ # This is called to populate a memory in the UI
+ def get_memory(self, number):
+ _embedded = self._memobj.embedded_msg
+ # Get a low-level memory object mapped to the image
+ _mem = self._memobj.memory[number - 1]
+
+ # get flag info
+ cbyte = (number - 1) / 8
+ cbit = 7 - ((number - 1) % 8)
+ setflag = self._memobj.csetflag[cbyte].c[cbit]
+ skipflag = self._memobj.cskipflag[cbyte].c[cbit]
+
+ mem = chirp_common.Memory()
+
+ mem.number = number # Set the memory number
+
+ # We'll consider any blank (i.e. 0MHz frequency) to be empty
+ if _mem.freq == 0:
+ mem.empty = True
+ return mem
+
+ if setflag == 0:
+ mem.empty = True
+ return mem
+
+ if _mem.get_raw()[0] == "\xFF":
+ mem.empty = True
+ return mem
+
+ # set the name
+ mem.name = str(_mem.name).rstrip() # Set the alpha tag
+
+ # Convert your low-level frequency and offset to Hertz
+ mem.freq = int(_mem.freq) * 10
+ mem.offset = int(_mem.offset) * 10
+
+ # Set the duplex flags
+ if _mem.duplex == DUPLEX_POSSPLIT:
+ mem.duplex = '+'
+ elif _mem.duplex == DUPLEX_NEGSPLIT:
+ mem.duplex = '-'
+ elif _mem.duplex == DUPLEX_NOSPLIT:
+ mem.duplex = ''
+ elif _mem.duplex == DUPLEX_ODDSPLIT:
+ mem.duplex = 'split'
+ else:
+ LOG.error('%s: get_mem: unhandled duplex: %02x' %
+ (mem.name, _mem.duplex))
+
+ # handle tx off
+ if _mem.tx_off:
+ mem.duplex = 'off'
+
+ # Set the channel width
+ if _mem.channel_width == CHANNEL_WIDTH_12d5kHz:
+ mem.mode = 'NFM'
+ elif _embedded.mode == 0: # PMR or FreeNet
+ LOG.info('PMR and FreeNet channels must be Channel Width 12.5kHz')
+ mem.mode = 'NFM'
+ elif _mem.channel_width == CHANNEL_WIDTH_25kHz:
+ mem.mode = 'FM'
+ elif _mem.channel_width == CHANNEL_WIDTH_20kHz:
+ LOG.info(
+ '%s: get_mem: promoting 20kHz channel width to 25kHz' %
+ mem.name)
+ mem.mode = 'FM'
+ else:
+ LOG.error('%s: get_mem: unhandled channel width: 0x%02x' %
+ (mem.name, _mem.channel_width))
+
+ # set the power level
+ if _embedded.mode == 0: # PMR or FreeNet
+ if str(_embedded.radio_type).rstrip("\00") == "RT98U":
+ LOG.info('using PMR power levels')
+ _levels = PMR_POWER_LEVELS
+ if str(_embedded.radio_type).rstrip("\00") == "RT98V":
+ LOG.info('using FreeNet power levels')
+ _levels = FREENET_POWER_LEVELS
+ else: # COM or COMII
+ LOG.info('using general power levels')
+ _levels = POWER_LEVELS
+
+ if _mem.txpower == TXPOWER_LOW:
+ mem.power = _levels[0]
+ elif _embedded.mode == 0: # PMR or FreeNet
+ LOG.info('FreeNet or PMR channel is not set to TX Power Low')
+ LOG.info('Setting channel to TX Power Low')
+ mem.power = _levels[0]
+ elif _mem.txpower == TXPOWER_MED:
+ mem.power = _levels[1]
+ elif _mem.txpower == TXPOWER_HIGH:
+ mem.power = _levels[2]
+ else:
+ LOG.error('%s: get_mem: unhandled power level: 0x%02x' %
+ (mem.name, _mem.txpower))
+
+ # CTCSS Tones and DTCS Codes
+ rxtone = txtone = None
+
+ rxmode = TMODES[_mem.rxtmode]
+ txmode = TMODES[_mem.txtmode]
+
+ if rxmode == "Tone":
+ rxtone = TONES[_mem.rxtone]
+ elif rxmode == "DTCS":
+ rxtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(
+ _mem, 'rx')]
+
+ if txmode == "Tone":
+ txtone = TONES[_mem.txtone]
+ elif txmode == "DTCS":
+ txtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(
+ _mem, 'tx')]
+
+ rxpol = _mem.rxinv and "R" or "N"
+ txpol = _mem.txinv and "R" or "N"
+
+ chirp_common.split_tone_decode(mem,
+ (txmode, txtone, txpol),
+ (rxmode, rxtone, rxpol))
+
+ # Check if this memory is in the scan enabled list
+ mem.skip = "S" if skipflag == 0 else ""
+
+ # Extra
+ mem.extra = RadioSettingGroup("extra", "Extra")
+
+ rs = RadioSettingValueBoolean(bool(_mem.busychannellockout))
+ rset = RadioSetting("busychannellockout", "Busy channel lockout", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_mem.reverse))
+ rset = RadioSetting("reverse", "Reverse", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_mem.talkaround))
+ rset = RadioSetting("talkaround", "Talk around", rs)
+ mem.extra.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_mem.squelch_mode))
+ rset = RadioSetting("squelch_mode", "Squelch mode", rs)
+ mem.extra.append(rset)
+
+ return mem
+
+ # Store details about a high-level memory to the memory map
+ # This is called when a user edits a memory in the UI
+ def set_memory(self, mem):
+ _embedded = self._memobj.embedded_msg
+ # Get a low-level memory object mapped to the image
+
+ _mem = self._memobj.memory[mem.number - 1]
+
+ cbyte = (mem.number - 1) / 8
+ cbit = 7 - ((mem.number - 1) % 8)
+
+ if mem.empty:
+ self._memobj.csetflag[cbyte].c[cbit] = 0
+ self._memobj.cskipflag[cbyte].c[cbit] = 0
+ _mem.set_raw('\xff' * (_mem.size() / 8))
+ return
+
+ _mem.set_raw('\x00' * (_mem.size() / 8))
+
+ # set the occupied bitfield
+ self._memobj.csetflag[cbyte].c[cbit] = 1
+ # set the scan add bitfield
+ self._memobj.cskipflag[cbyte].c[cbit] = 0 if (mem.skip == "S") else 1
+
+ _mem.freq = mem.freq / 10 # Convert to low-level frequency
+ _mem.offset = mem.offset / 10 # Convert to low-level frequency
+
+ # Store the alpha tag
+ _mem.name = mem.name.ljust(6)[:6] # Store the alpha tag
+
+ # Set duplex bitfields
+ if mem.duplex == '+':
+ _mem.duplex = DUPLEX_POSSPLIT
+ elif mem.duplex == '-':
+ _mem.duplex = DUPLEX_NEGSPLIT
+ elif mem.duplex == '':
+ _mem.duplex = DUPLEX_NOSPLIT
+ elif mem.duplex == 'split':
+ diff = mem.offset - mem.freq
+ _mem.duplex = DUPLEXES.index("-") \
+ if diff < 0 else DUPLEXES.index("+")
+ _mem.offset = abs(diff) / 10
+ else:
+ LOG.error('%s: set_mem: unhandled duplex: %s' %
+ (mem.name, mem.duplex))
+
+ # handle tx off
+ _mem.tx_off = 0
+ if mem.duplex == 'off':
+ _mem.tx_off = 1
+
+ # Set the channel width - remember we promote 20kHz channels to FM
+ # on import, so don't handle them here
+ if mem.mode == 'FM':
+ _mem.channel_width = CHANNEL_WIDTH_25kHz
+ elif mem.mode == 'NFM':
+ _mem.channel_width = CHANNEL_WIDTH_12d5kHz
+ else:
+ LOG.error('%s: set_mem: unhandled mode: %s' % (
+ mem.name, mem.mode))
+
+ # CTCSS Tones and DTCS Codes
+ ((txmode, txtone, txpol),
+ (rxmode, rxtone, rxpol)) = chirp_common.split_tone_encode(mem)
+
+ _mem.txtmode = TMODES.index(txmode)
+
+ _mem.rxtmode = TMODES.index(rxmode)
+
+ if txmode == "Tone":
+ _mem.txtone = TONES.index(txtone)
+ elif txmode == "DTCS":
+ self._set_dcs_index(_mem, 'tx',
+ chirp_common.ALL_DTCS_CODES.index(txtone))
+
+ _mem.squelch_mode = False
+ if rxmode == "Tone":
+ _mem.rxtone = TONES.index(rxtone)
+ _mem.squelch_mode = True
+ elif rxmode == "DTCS":
+ self._set_dcs_index(_mem, 'rx',
+ chirp_common.ALL_DTCS_CODES.index(rxtone))
+ _mem.squelch_mode = True
+
+ _mem.txinv = txpol == "R"
+ _mem.rxinv = rxpol == "R"
+
+ # set the power level
+ if mem.power == POWER_LEVELS[0]:
+ _mem.txpower = TXPOWER_LOW
+ elif mem.power == POWER_LEVELS[1]:
+ _mem.txpower = TXPOWER_MED
+ elif mem.power == POWER_LEVELS[2]:
+ _mem.txpower = TXPOWER_HIGH
+ else:
+ LOG.error('%s: set_mem: unhandled power level: %s' %
+ (mem.name, mem.power))
+
+ # extra settings
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def _get_settings(self):
+ _embedded = self._memobj.embedded_msg
+ _settings = self._memobj.settings
+ _settings2 = self._memobj.settings2
+ _settings3 = self._memobj.settings3
+ _slabel = self._memobj.slabel
+
+ function = RadioSettingGroup("function", "Function Setup")
+ group = RadioSettings(function)
+
+ # Function Setup
+ # MODE SET
+ rs = RadioSettingValueList(LIST_DISPLAY_MODE,
+ LIST_DISPLAY_MODE[_settings.display_mode])
+ rset = RadioSetting("display_mode", "Display Mode", rs)
+ function.append(rset)
+
+ if "AT-779" in str(_embedded.radio_type):
+ rs = RadioSettingValueList(LIST_VFOMR,
+ LIST_VFOMR[_settings3.vfomr])
+ rset = RadioSetting("settings3.vfomr", "VFO/MR", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueInteger(1, 199, _settings3.ch_number + 1)
+ rset = RadioSetting("settings3.ch_number", "Channel Number", rs)
+ function.append(rset)
+
+ # DISPLAY SET
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in chirp_common.CHARSET_ASCII:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
+
+ val = RadioSettingValueString(0, 6, _filter(_slabel.startname))
+ rs = RadioSetting("slabel.startname", "Startup Label", val)
+ function.append(rs)
+
+ # VOL SET
+ rs = RadioSettingValueBoolean(bool(_settings.beep))
+ rset = RadioSetting("beep", "Beep Prompt", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueInteger(1, 30, _settings.volume)
+ rset = RadioSetting("volume", "Volume Level", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueInteger(1, 16, _settings.mic_gain)
+ rset = RadioSetting("mic_gain", "Mic Gain", rs)
+ function.append(rset)
+
+ # ON/OFF SET
+ rs = RadioSettingValueList(LIST_APO,
+ LIST_APO[_settings.auto_power_off])
+ rset = RadioSetting("auto_power_off", "Auto Power Off", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueList(LIST_AOP, LIST_AOP[_settings.auto_power_on])
+ rset = RadioSetting("auto_power_on", "Power On Method", rs)
+ function.append(rset)
+
+ # STE SET
+ rs = RadioSettingValueList(LIST_STE_FREQ,
+ LIST_STE_FREQ[_settings.ste_frequency])
+ rset = RadioSetting("ste_frequency", "STE Frequency", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueList(LIST_STE_TYPE,
+ LIST_STE_TYPE[_settings.ste_type])
+ rset = RadioSetting("ste_type", "STE Type", rs)
+ function.append(rset)
+
+ # FUNCTION SET
+ rs = RadioSettingValueList(LIST_STEP, LIST_STEP[_settings.tuning_step])
+ rset = RadioSetting("tuning_step", "Tuning Step", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueList(LIST_SQUELCH,
+ LIST_SQUELCH[_settings.squelch])
+ rset = RadioSetting("squelch", "Squelch Level", rs)
+ function.append(rset)
+
+ if "AT-779" in str(_embedded.radio_type):
+ rs = RadioSettingValueList(LIST_SCAN,
+ LIST_SCAN[_settings.scan_resume])
+ rset = RadioSetting("scan_resume", "Frequency Scan", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_settings.sql_key_function))
+ rset = RadioSetting("sql_key_function", "SQL Key Function", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueList(LIST_TIMEOUT,
+ LIST_TIMEOUT[_settings.timeout_timer])
+ rset = RadioSetting("timeout_timer", "Timeout Timer", rs)
+ function.append(rset)
+
+ # uncategorized
+ rs = RadioSettingValueBoolean(bool(_settings.save_chan_param))
+ rset = RadioSetting("save_chan_param", "Save Channel Parameters", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_settings.forbid_chan_menu))
+ rset = RadioSetting("forbid_chan_menu", "Forbid Channel Menu", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(not _settings.forbid_initialize))
+ rset = RadioSetting("forbid_initialize", "Forbid Initialize", rs)
+ function.append(rset)
+
+ rs = RadioSettingValueBoolean(bool(_settings.forbid_setting))
+ rset = RadioSetting("forbid_setting", "Forbid Setting", rs)
+ function.append(rset)
+
+ # Information Of Scanning Channel
+ scanning = RadioSettingGroup("scanning", "Scanning Setup")
+ group.append(scanning)
+
+ rs = RadioSettingValueBoolean(bool(_settings2.scan_mode))
+ rset = RadioSetting("settings2.scan_mode", "Scan Mode", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueList(LIST_PRIORITY_CH,
+ LIST_PRIORITY_CH[_settings2.priority_ch])
+ rset = RadioSetting("settings2.priority_ch", "Priority Channel", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueInteger(1, 199, _settings2.priority_ch1 + 1)
+ rset = RadioSetting("settings2.priority_ch1", "Priority Channel 1", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueInteger(1, 199, _settings2.priority_ch2 + 1)
+ rset = RadioSetting("settings2.priority_ch2", "Priority Channel 2", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueList(LIST_REVERT_CH,
+ LIST_REVERT_CH[_settings2.revert_ch])
+ rset = RadioSetting("settings2.revert_ch", "Revert Channel", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueList(LIST_TIME46,
+ LIST_TIME46[_settings2.look_back_time_a])
+ rset = RadioSetting("settings2.look_back_time_a",
+ "Look Back Time A", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueList(LIST_TIME46,
+ LIST_TIME46[_settings2.look_back_time_b])
+ rset = RadioSetting("settings2.look_back_time_b",
+ "Look Back Time B", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueList(LIST_TIME50,
+ LIST_TIME50[_settings2.dropout_delay_time])
+ rset = RadioSetting("settings2.dropout_delay_time",
+ "Dropout Delay Time", rs)
+ scanning.append(rset)
+
+ rs = RadioSettingValueList(LIST_TIME50,
+ LIST_TIME50[_settings2.dwell_time])
+ rset = RadioSetting("settings2.dwell_time", "Dwell Time", rs)
+ scanning.append(rset)
+
+ # Embedded Message
+ embedded = RadioSettingGroup("embedded", "Embedded Message")
+ group.append(embedded)
+
+ rs = RadioSettingValueString(0, 7, _filter(_embedded.radio_type))
+ rs.set_mutable(False)
+ rset = RadioSetting("embedded_msg.radio_type", "Radio Type", rs)
+ embedded.append(rset)
+
+ if str(_embedded.radio_type).rstrip("\00") in ["RT98V", "AT-779V"]:
+ options = LIST_RT98V_MODES
+ else:
+ options = LIST_RT98U_MODES
+ rs = RadioSettingValueList(options, options[_embedded.mode])
+ rs.set_mutable(False)
+ rset = RadioSetting("embedded_msg.mode", "Mode", rs)
+ embedded.append(rset)
+
+ # frequency
+ if str(_embedded.radio_type).rstrip("\00") in ["RT98V", "AT-779V"]:
+ options = LIST_RT98V_FREQS
+ else:
+ options = LIST_RT98U_FREQS
+ rs = RadioSettingValueList(options, options[_settings3.bandlimit])
+ rs.set_mutable(False)
+ rset = RadioSetting("settings3.bandlimit", "Frequency", rs)
+ embedded.append(rset)
+
+ rs = RadioSettingValueString(0, 10, _filter(_embedded.date_mfg))
+ rs.set_mutable(False)
+ rset = RadioSetting("embedded_msg.date_mfg", "Production Date", rs)
+ embedded.append(rset)
+
+ rs = RadioSettingValueString(0, 4, _filter(_embedded.mcu_version))
+ rs.set_mutable(False)
+ rset = RadioSetting("embedded_msg.mcu_version", "MCU Version", rs)
+ embedded.append(rset)
+
+ return group
+
+ def get_settings(self):
+ try:
+ return self._get_settings()
+ except:
+ import traceback
+ LOG.error("failed to parse settings")
+ traceback.print_exc()
+ return None
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("using apply callback")
+ element.run_apply_callback()
+ elif setting == "ch_number":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "forbid_initialize":
+ setattr(obj, setting, not int(element.value))
+ elif setting == "priority_ch1":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "priority_ch2":
+ setattr(obj, setting, int(element.value) - 1)
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ # This radio has always been post-metadata, so never do
+ # old-school detection
+ return False
+
+
+@directory.register
+class Rt98Radio(Rt98BaseRadio):
+ """Retevis RT98"""
+ VENDOR = "Retevis"
+ MODEL = "RT98"
+ # Allowed radio types is a dict keyed by model of a list of version
+ # strings
+ ALLOWED_RADIO_TYPES = {'RT98V': ['V100'],
+ 'RT98U': ['V100'],
+ 'AT-779V': ['V100'],
+ 'AT-779U': ['V100']}
diff --git a/chirp/drivers/rfinder.py b/chirp/drivers/rfinder.py
index cedf835..e379d31 100644
--- a/chirp/drivers/rfinder.py
+++ b/chirp/drivers/rfinder.py
@@ -177,8 +177,6 @@ class RFinderParser:
def fetch_data(self, user, pw, coords, radius):
"""Fetches the data for a set of parameters"""
- LOG.debug(user)
- LOG.debug(pw)
args = {
"email": urllib.quote_plus(user),
"pass": hashlib.new("md5", pw).hexdigest(),
@@ -191,8 +189,6 @@ class RFinderParser:
_url = "https://www.rfinder.net/query.php?%s" % \
("&".join(["%s=%s" % (k, v) for k, v in args.items()]))
- LOG.debug("Query URL: %s" % _url)
-
f = urllib.urlopen(_url)
data = f.read()
f.close()
diff --git a/chirp/drivers/rh5r_v2.py b/chirp/drivers/rh5r_v2.py
index 01ffc96..5aa712c 100644
--- a/chirp/drivers/rh5r_v2.py
+++ b/chirp/drivers/rh5r_v2.py
@@ -129,13 +129,14 @@ class TYTTHUVF8_V2(chirp_common.CloneModeRadio):
VENDOR = "TYT"
MODEL = "TH-UVF8F"
BAUD_RATE = 9600
- _FILEID = 'OEMOEM \XFF'
+ _FILEID = b'OEMOEM \XFF'
def get_features(self):
rf = chirp_common.RadioFeatures()
rf.memory_bounds = (1, 128)
rf.has_bank = False
rf.has_ctone = True
+ rf.valid_tuning_steps = [5, 6.25, 10, 12.5]
rf.has_tuning_step = False
rf.has_cross = True
rf.has_rx_dtcs = True
@@ -163,11 +164,10 @@ class TYTTHUVF8_V2(chirp_common.CloneModeRadio):
@classmethod
def match_model(cls, filedata, filename):
- return (filedata.endswith("PGM2015") and
+ return (filedata.endswith(b"PGM2015") and
filedata[0x840:0x848] == cls._FILEID)
def process_mmap(self):
- print MEM_FORMAT
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
def get_raw_memory(self, number):
@@ -287,4 +287,4 @@ class TYTTHUVF8_V2(chirp_common.CloneModeRadio):
class RH5RV2(TYTTHUVF8_V2):
VENDOR = "Rugged"
MODEL = "RH5R-V2"
- _FILEID = 'RUGGED \xFF'
+ _FILEID = b'RUGGED \xFF'
diff --git a/chirp/drivers/tdxone_tdq8a.py b/chirp/drivers/tdxone_tdq8a.py
index 6793a9f..3da0494 100644
--- a/chirp/drivers/tdxone_tdq8a.py
+++ b/chirp/drivers/tdxone_tdq8a.py
@@ -138,13 +138,11 @@ struct {
"""
-##### MAGICS #########################################################
+# #### MAGICS #########################################################
# TDXone TD-Q8A magic string
MSTRING_TDQ8A = "\x02PYNCRAM"
-#STIMEOUT = 2
-
LIST_DTMF = ["QT", "QT+DTMF"]
LIST_VOICE = ["Off", "Chinese", "English"]
LIST_OFF1TO9 = ["Off"] + list("123456789")
@@ -174,10 +172,9 @@ LIST_RPSTE = ["Off"] + ["%s" % x for x in range(1, 11)]
LIST_SAVE = ["Off", "1:1", "1:2", "1:3", "1:4"]
LIST_SHIFTD = ["Off", "+", "-"]
LIST_STEDELAY = ["Off"] + ["%s ms" % x for x in range(100, 1100, 100)]
-#LIST_STEP = [str(x) for x in STEPS]
LIST_TXPOWER = ["High", "Low"]
-LIST_DTMF_SPECIAL_DIGITS = [ "*", "#", "A", "B", "C", "D"]
-LIST_DTMF_SPECIAL_VALUES = [ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
+LIST_DTMF_SPECIAL_DIGITS = ["*", "#", "A", "B", "C", "D"]
+LIST_DTMF_SPECIAL_VALUES = [0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ?+-*"
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
@@ -187,14 +184,6 @@ VALID_BANDS = [(136000000, 174000000),
(400000000, 520000000)]
-#def _clean_buffer(radio):
-# radio.pipe.timeout = 0.005
-# junk = radio.pipe.read(256)
-# radio.pipe.timeout = STIMEOUT
-# if junk:
-# LOG.debug("Got %i bytes of junk before starting" % len(junk))
-
-
def _rawrecv(radio, amount):
"""Raw read from the radio device"""
data = ""
@@ -252,12 +241,8 @@ def _recv(radio, addr, length):
def _do_ident(radio, magic):
"""Put the radio in PROGRAM mode"""
- # set the serial discipline
+ # set the serial discipline
radio.pipe.baudrate = 9600
- ####radio.pipe.timeout = STIMEOUT
-
- ## flush input buffer
- #_clean_buffer(radio)
# send request to enter program mode
_rawsend(radio, magic)
@@ -277,7 +262,7 @@ def _do_ident(radio, magic):
if not ident.startswith("P3107"):
# bad response
msg = "Unexpected response, got this:"
- msg += util.hexprint(ident)
+ msg += util.hexprint(ident)
LOG.debug(msg)
raise errors.RadioError("Unexpected response from radio.")
@@ -301,8 +286,8 @@ def _ident_radio(radio):
try:
data = _do_ident(radio, magic)
return data
- except errors.RadioError, e:
- print e
+ except errors.RadioError as e:
+ print(e)
error = e
time.sleep(2)
if error:
@@ -344,8 +329,6 @@ def _download(radio):
raise errors.RadioError(
"Radio refused to send block 0x%04x" % addr)
- ####time.sleep(0.05)
-
# aggregate the data
data += d
@@ -364,8 +347,6 @@ def _upload(radio):
# put radio in program mode
_ident_radio(radio)
-
-
addr = 0x0f80
frame = _make_frame("R", addr, radio._recv_block_size)
# DEBUG
@@ -387,8 +368,6 @@ def _upload(radio):
raise errors.RadioError(
"Radio refused to send block 0x%04x" % addr)
-
-
_ranges = radio._ranges
# UI progress
@@ -407,7 +386,6 @@ def _upload(radio):
frame = _make_frame("W", addr, radio._send_block_size, data)
_rawsend(radio, frame)
- #time.sleep(0.05)
# receiving the response
ack = _rawrecv(radio, 1)
@@ -426,8 +404,7 @@ def model_match(cls, data):
if len(data) == 0x2008:
rid = data[0x2000:0x2008]
- print rid
- return rid.startswith(cls.MODEL)
+ return rid.startswith(cls._model)
else:
return False
@@ -454,22 +431,13 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
VENDOR = "TDXone"
MODEL = "TD-Q8A"
- ####_fileid = [TDQ8A_fp1, ]
-
- _magic = [MSTRING_TDQ8A, MSTRING_TDQ8A,]
+ _model = b'TD-Q8A'
+ _magic = [MSTRING_TDQ8A, MSTRING_TDQ8A, ]
_magic_response_length = 8
_fw_ver_start = 0x1EF0
_recv_block_size = 0x40
_mem_size = 0x2000
- #_ranges = [(0x0000, 0x2000)]
- # same as radio
- #_ranges = [(0x0010, 0x0810),
- # (0x0F10, 0x0F30),
- # (0x1010, 0x1810),
- # (0x0E20, 0x0E60),
- # (0x1F10, 0x1F30)]
- # in increasing order
_ranges = [(0x0010, 0x0810),
(0x0E20, 0x0E60),
(0x0F10, 0x0F30),
@@ -477,14 +445,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
(0x1F10, 0x1F30)]
_send_block_size = 0x10
- #DTCS_CODES = sorted(chirp_common.DTCS_CODES + [645])
- #DTCS_CODES = sorted(chirp_common.ALL_DTCS_CODES)
- #POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
- # chirp_common.PowerLevel("High", watts=5.00)]
- #VALID_BANDS = [(136000000, 174000000),
- # (400000000, 520000000)]
-
-
@classmethod
def get_prompts(cls):
rp = chirp_common.RadioPrompts()
@@ -512,7 +472,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
"""))
return rp
-
def get_features(self):
"""Get the radio's features"""
@@ -524,31 +483,20 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
rf.has_name = True
rf.has_offset = True
rf.has_mode = True
- rf.has_dtcs = False #True
- rf.has_rx_dtcs = False #True
- rf.has_dtcs_polarity = False #True
+ rf.has_dtcs = False
+ rf.has_rx_dtcs = False
+ rf.has_dtcs_polarity = False
rf.has_ctone = True
rf.has_cross = True
rf.valid_modes = ["FM", "NFM"]
- #rf.valid_characters = self.VALID_CHARS
rf.valid_characters = CHARSET
rf.valid_name_length = 6
rf.valid_duplexes = ["", "-", "+", "split", "off"]
- #rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
- #rf.valid_cross_modes = [
- # "Tone->Tone",
- # "DTCS->",
- # "->DTCS",
- # "Tone->DTCS",
- # "DTCS->Tone",
- # "->Tone",
- # "DTCS->DTCS"]
rf.valid_tmodes = ['', 'Tone', 'TSQL', 'Cross']
rf.valid_cross_modes = [
"Tone->Tone",
"->Tone"]
rf.valid_skips = ["", "S"]
- #rf.valid_dtcs_codes = self.DTCS_CODES
rf.memory_bounds = (1, 128)
rf.valid_power_levels = POWER_LEVELS
rf.valid_tuning_steps = STEPS
@@ -556,12 +504,10 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
return rf
-
def process_mmap(self):
"""Process the mem map into the mem object"""
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
-
def sync_in(self):
"""Download from radio"""
try:
@@ -578,7 +524,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
self._mmap = memmap.MemoryMap(data)
self.process_mmap()
-
def sync_out(self):
"""Upload to radio"""
try:
@@ -590,14 +535,12 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
raise errors.RadioError('Unexpected error communicating '
'with the radio')
-
def _is_txinh(self, _mem):
raw_tx = ""
for i in range(0, 4):
raw_tx += _mem.txfreq[i].get_raw()
return raw_tx == "\xFF\xFF\xFF\xFF"
-
def _get_mem(self, number):
return self._memobj.memory[number - 1]
@@ -625,7 +568,8 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
# TX freq set
offset = (int(_mem.txfreq) * 10) - mem.freq
if offset != 0:
- if _split(self.get_features(), mem.freq, int(_mem.txfreq) * 10):
+ if _split(self.get_features(), mem.freq, int(
+ _mem.txfreq) * 10):
mem.duplex = "split"
mem.offset = int(_mem.txfreq) * 10
elif offset < 0:
@@ -645,8 +589,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
break
mem.name = mem.name.rstrip()
- #dtcs_pol = ["N", "N"]
-
if _mem.txtone in [0, 0xFFFF]:
txmode = ""
elif _mem.txtone >= 0x0258:
@@ -655,17 +597,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
else:
LOG.warn("Bug: txtone is %04x" % _mem.txtone)
- #elif _mem.txtone <= 0x0258:
- # txmode = "DTCS"
- # if _mem.txtone > 0x69:
- # index = _mem.txtone - 0x6A
- # dtcs_pol[0] = "R"
- # else:
- # index = _mem.txtone - 1
- # mem.dtcs = self.DTCS_CODES[index]
- #else:
- # LOG.warn("Bug: txtone is %04x" % _mem.txtone)
-
if _mem.rxtone in [0, 0xFFFF]:
rxmode = ""
elif _mem.rxtone >= 0x0258:
@@ -674,17 +605,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
else:
LOG.warn("Bug: rxtone is %04x" % _mem.rxtone)
- #elif _mem.rxtone <= 0x0258:
- # rxmode = "DTCS"
- # if _mem.rxtone >= 0x6A:
- # index = _mem.rxtone - 0x6A
- # dtcs_pol[1] = "R"
- # else:
- # index = _mem.rxtone - 1
- # mem.rx_dtcs = self.DTCS_CODES[index]
- #else:
- # LOG.warn("Bug: rxtone is %04x" % _mem.rxtone)
-
if txmode == "Tone" and not rxmode:
mem.tmode = "Tone"
elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
@@ -693,14 +613,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
mem.tmode = "Cross"
mem.cross_mode = "%s->%s" % (txmode, rxmode)
- #elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
- # mem.tmode = "DTCS"
- #elif rxmode or txmode:
- # mem.tmode = "Cross"
- # mem.cross_mode = "%s->%s" % (txmode, rxmode)
-
- #mem.dtcs_polarity = "".join(dtcs_pol)
-
if not _mem.scan:
mem.skip = "S"
@@ -721,7 +633,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
return mem
-
def _set_mem(self, number):
return self._memobj.memory[number - 1]
@@ -733,12 +644,11 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
_nam = self._get_nam(mem.number)
if mem.empty:
- _mem.set_raw("\xff" * 12 + "\xbf" +"\xff" * 3)
+ _mem.set_raw("\xff" * 12 + "\xbf" + "\xff" * 3)
_nam.set_raw("\xff" * 16)
return
- #_mem.set_raw("\x00" * 16)
- _mem.set_raw("\xff" * 12 + "\x9f" +"\xff" * 3)
+ _mem.set_raw("\xff" * 12 + "\x9f" + "\xff" * 3)
_mem.rxfreq = mem.freq / 10
@@ -768,33 +678,20 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
elif mem.tmode == "TSQL":
_mem.txtone = int(mem.ctone * 10)
_mem.rxtone = int(mem.ctone * 10)
- #elif mem.tmode == "DTCS":
- # rxmode = txmode = "DTCS"
- # _mem.txtone = self.DTCS_CODES.index(mem.dtcs) + 1
- # _mem.rxtone = self.DTCS_CODES.index(mem.dtcs) + 1
elif mem.tmode == "Cross":
txmode, rxmode = mem.cross_mode.split("->", 1)
if txmode == "Tone":
_mem.txtone = int(mem.rtone * 10)
- #elif txmode == "DTCS":
- # _mem.txtone = self.DTCS_CODES.index(mem.dtcs) + 1
else:
_mem.txtone = 0
if rxmode == "Tone":
_mem.rxtone = int(mem.ctone * 10)
- #elif rxmode == "DTCS":
- # _mem.rxtone = self.DTCS_CODES.index(mem.rx_dtcs) + 1
else:
_mem.rxtone = 0
else:
_mem.rxtone = 0
_mem.txtone = 0
- #if txmode == "DTCS" and mem.dtcs_polarity[0] == "R":
- # _mem.txtone += 0x69
- #if rxmode == "DTCS" and mem.dtcs_polarity[1] == "R":
- # _mem.rxtone += 0x69
-
_mem.scan = mem.skip != "S"
_mem.wide = mem.mode == "FM"
@@ -803,25 +700,17 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
for setting in mem.extra:
setattr(_mem, setting.get_name(), setting.value)
-
def get_settings(self):
- # """Translate the bit in the mem_struct into settings in the UI"""
+ """Translate the bit in the mem_struct into settings in the UI"""
_mem = self._memobj
basic = RadioSettingGroup("basic", "Basic Settings")
advanced = RadioSettingGroup("advanced", "Advanced Settings")
- #other = RadioSettingGroup("other", "Other Settings")
- #work = RadioSettingGroup("work", "Work Mode Settings")
- #fm_preset = RadioSettingGroup("fm_preset", "FM Preset")
- #dtmfe = RadioSettingGroup("dtmfe", "DTMF Encode Settings")
- #dtmfd = RadioSettingGroup("dtmfd", "DTMF Decode Settings")
- #service = RadioSettingGroup("service", "Service Settings")
- #top = RadioSettings(basic, advanced, other, work, fm_preset, dtmfe,
- # dtmfd, service)
top = RadioSettings(basic, advanced, )
# Basic settings
rs = RadioSetting("settings.beep", "Beep",
- RadioSettingValueBoolean(_mem.settings.beep))
+ RadioSettingValueBoolean(
+ _mem.settings.beep))
basic.append(rs)
if _mem.settings.squelcha > 0x09:
@@ -829,19 +718,19 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
else:
val = _mem.settings.squelcha
rs = RadioSetting("squelcha", "Squelch Level A",
- RadioSettingValueInteger(0, 9, _mem.settings.squelcha))
+ RadioSettingValueInteger(
+ 0, 9, _mem.settings.squelcha))
basic.append(rs)
-
if _mem.settings.squelchb > 0x09:
val = 0x00
else:
val = _mem.settings.squelchb
rs = RadioSetting("squelchb", "Squelch Level B",
- RadioSettingValueInteger(0, 9, _mem.settings.squelchb))
+ RadioSettingValueInteger(
+ 0, 9, _mem.settings.squelchb))
basic.append(rs)
-
if _mem.settings.voice > 0x02:
val = 0x01
else:
@@ -945,7 +834,8 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
rs = RadioSetting("settings.pttid", "When to send PTT ID",
RadioSettingValueList(LIST_PTTID,
- LIST_PTTID[_mem.settings.pttid]))
+ LIST_PTTID[
+ _mem.settings.pttid]))
basic.append(rs)
rs = RadioSetting("settings.dtmfst", "DTMF Sidetone",
@@ -1027,62 +917,6 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
return top
-
-
- """
- # Other settings
- def _filter(name):
- filtered = ""
- for char in str(name):
- if char in chirp_common.CHARSET_ASCII:
- filtered += char
- else:
- filtered += " "
- return filtered
-
- _msg = _mem.sixpoweron_msg
- val = RadioSettingValueString(0, 7, _filter(_msg.line1))
- val.set_mutable(False)
- rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", val)
- other.append(rs)
- val = RadioSettingValueString(0, 7, _filter(_msg.line2))
- val.set_mutable(False)
- rs = RadioSetting("sixpoweron_msg.line2", "6+Power-On Message 2", val)
- other.append(rs)
-
- _msg = _mem.poweron_msg
- rs = RadioSetting("poweron_msg.line1", "Power-On Message 1",
- RadioSettingValueString(
- 0, 7, _filter(_msg.line1)))
- other.append(rs)
- rs = RadioSetting("poweron_msg.line2", "Power-On Message 2",
- RadioSettingValueString(
- 0, 7, _filter(_msg.line2)))
- other.append(rs)
-
- # DTMF encode settings
-
- if _mem.ani.dtmfon > 0xC3:
- val = 0x03
- else:
- val = _mem.ani.dtmfon
- rs = RadioSetting("ani.dtmfon", "DTMF Speed (on)",
- RadioSettingValueList(LIST_DTMFSPEED,
- LIST_DTMFSPEED[val]))
- dtmfe.append(rs)
-
- if _mem.ani.dtmfoff > 0xC3:
- val = 0x03
- else:
- val = _mem.ani.dtmfoff
- rs = RadioSetting("ani.dtmfoff", "DTMF Speed (off)",
- RadioSettingValueList(LIST_DTMFSPEED,
- LIST_DTMFSPEED[val]))
- dtmfe.append(rs)
-
- """
-
-
def set_settings(self, settings):
_settings = self._memobj.settings
_mem = self._memobj
@@ -1117,7 +951,7 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -1131,11 +965,10 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
value = int(val.get_value() * 10)
LOG.debug("Setting fm_presets = %s" % (value))
self._memobj.fm_presets = value
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
-
@classmethod
def match_model(cls, filedata, filename):
match_size = False
@@ -1148,7 +981,7 @@ class TDXoneTDQ8A(chirp_common.CloneModeRadio,
# testing the model fingerprint
match_model = model_match(cls, filedata)
- #if match_size and match_model:
+ # if match_size and match_model:
if match_size and match_model:
return True
else:
diff --git a/chirp/drivers/template.py b/chirp/drivers/template.py
index 381b103..9802dc2 100644
--- a/chirp/drivers/template.py
+++ b/chirp/drivers/template.py
@@ -88,12 +88,16 @@ class TemplateRadio(chirp_common.CloneModeRadio):
# Do a download of the radio from the serial port
def sync_in(self):
self._mmap = do_download(self)
- self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+ self.process_mmap()
# Do an upload of the radio to the serial port
def sync_out(self):
do_upload(self)
+ # Convert the raw byte array into a memory object structure
+ def process_mmap(self):
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
# Return a raw representation of the memory object, which
# is very helpful for development
def get_raw_memory(self, number):
diff --git a/chirp/drivers/tg_uv2p.py b/chirp/drivers/tg_uv2p.py
new file mode 100644
index 0000000..85fb906
--- /dev/null
+++ b/chirp/drivers/tg_uv2p.py
@@ -0,0 +1,774 @@
+# Copyright 2013 Dan Smith <dsmith@danplanet.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This driver was derived from the:
+# Quansheng TG-UV2 Utility by Mike Nix <mnix@wanm.com.au>
+# (So thanks Mike!)
+
+import struct
+import logging
+import serial
+from chirp import chirp_common, directory, bitwise, memmap, errors, util
+from chirp.settings import RadioSetting, RadioSettingGroup, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueInteger, RadioSettingValueString, \
+ RadioSettingValueFloat, RadioSettingValueMap, RadioSettings
+from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+mem_format = """
+struct memory {
+ bbcd freq[4];
+ bbcd offset[4];
+ u8 rxtone;
+ u8 txtone;
+ u8 unknown1:2,
+ txtmode:2,
+ unknown2:2,
+ rxtmode:2;
+ u8 duplex;
+ u8 unknown3:3,
+ isnarrow:1,
+ unknown4:2,
+ not_scramble:1,
+ not_revfreq:1;
+ u8 flag3;
+ u8 step;
+ u8 power;
+};
+
+struct bandflag {
+ u8 scanadd:1,
+ unknown1:3,
+ band:4;
+};
+
+struct tguv2_config {
+ u8 unknown1;
+ u8 squelch;
+ u8 time_out_timer;
+ u8 priority_channel;
+
+ u8 unknown2:7,
+ keyunlocked:1;
+ u8 busy_lockout;
+ u8 vox;
+ u8 unknown3;
+
+ u8 beep_tone_disabled;
+ u8 display;
+ u8 step;
+ u8 unknown4;
+
+ u8 unknown5;
+ u8 rxmode;
+ u8 unknown6:7,
+ not_end_tone_elim:1;
+ u8 vfo_mode;
+};
+
+struct vfo {
+ u8 current;
+ u8 chan;
+ u8 memno;
+};
+
+struct name {
+ u8 name[6];
+ u8 unknown1[10];
+};
+
+#seekto 0x0000;
+char ident[32];
+u8 blank[16];
+
+struct memory channels[200];
+struct memory bands[5];
+
+#seekto 0x0D30;
+struct bandflag bandflags[200];
+
+#seekto 0x0E30;
+struct tguv2_config settings;
+struct vfo vfos[2];
+u8 unk5;
+u8 reserved2[9];
+u8 band_restrict;
+u8 txen350390;
+
+#seekto 0x0F30;
+struct name names[200];
+
+"""
+
+
+def do_ident(radio):
+ radio.pipe.timeout = 3
+ radio.pipe.stopbits = serial.STOPBITS_TWO
+ radio.pipe.write("\x02PnOGdAM")
+ for x in range(10):
+ ack = radio.pipe.read(1)
+ if ack == '\x06':
+ break
+ else:
+ raise errors.RadioError("Radio did not ack programming mode")
+ radio.pipe.write("\x40\x02")
+ ident = radio.pipe.read(8)
+ LOG.debug(util.hexprint(ident))
+ if not ident.startswith('P5555'):
+ raise errors.RadioError("Unsupported model")
+ radio.pipe.write("\x06")
+ ack = radio.pipe.read(1)
+ if ack != "\x06":
+ raise errors.RadioError("Radio did not ack ident")
+
+
+def do_status(radio, direction, addr):
+ status = chirp_common.Status()
+ status.msg = "Cloning %s radio" % direction
+ status.cur = addr
+ status.max = 0x2000
+ radio.status_fn(status)
+
+
+def do_download(radio):
+ do_ident(radio)
+ data = "TG-UV2+ Radio Program Data v1.0\x00"
+ data += ("\x00" * 16)
+
+ firstack = None
+ for i in range(0, 0x2000, 8):
+ frame = struct.pack(">cHB", "R", i, 8)
+ radio.pipe.write(frame)
+ result = radio.pipe.read(12)
+ if not (result[0] == "W" and frame[1:4] == result[1:4]):
+ LOG.debug(util.hexprint(result))
+ raise errors.RadioError("Invalid response for address 0x%04x" % i)
+ radio.pipe.write("\x06")
+ ack = radio.pipe.read(1)
+ if not firstack:
+ firstack = ack
+ else:
+ if not ack == firstack:
+ LOG.debug("first ack: %s ack received: %s",
+ util.hexprint(firstack), util.hexprint(ack))
+ raise errors.RadioError("Unexpected response")
+ data += result[4:]
+ do_status(radio, "from", i)
+
+ return memmap.MemoryMap(data)
+
+
+def do_upload(radio):
+ do_ident(radio)
+ data = radio._mmap[0x0030:]
+
+ for i in range(0, 0x2000, 8):
+ frame = struct.pack(">cHB", "W", i, 8)
+ frame += data[i:i + 8]
+ radio.pipe.write(frame)
+ ack = radio.pipe.read(1)
+ if ack != "\x06":
+ LOG.debug("Radio NAK'd block at address 0x%04x" % i)
+ raise errors.RadioError(
+ "Radio NAK'd block at address 0x%04x" % i)
+ LOG.debug("Radio ACK'd block at address 0x%04x" % i)
+ do_status(radio, "to", i)
+
+DUPLEX = ["", "+", "-"]
+TGUV2P_STEPS = [5, 6.25, 10, 12.5, 15, 20, 25, 30, 50, 100]
+CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_|* +-"
+POWER_LEVELS = [chirp_common.PowerLevel("High", watts=10),
+ chirp_common.PowerLevel("Med", watts=5),
+ chirp_common.PowerLevel("Low", watts=1)]
+POWER_LEVELS_STR = ["High", "Med", "Low"]
+VALID_BANDS = [(88000000, 108000000),
+ (136000000, 174000000),
+ (350000000, 390000000),
+ (400000000, 470000000),
+ (470000000, 520000000)]
+
+
+@directory.register
+class QuanshengTGUV2P(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
+ """Quansheng TG-UV2+"""
+ VENDOR = "Quansheng"
+ MODEL = "TG-UV2+"
+ BAUD_RATE = 9600
+
+ _memsize = 0x2000
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.experimental = \
+ ('Experimental version for TG-UV2/2+ radios '
+ 'Proceed at your own risk!')
+ rp.pre_download = _(dedent("""\
+ 1. Turn radio off.
+ 2. Connect cable to mic/spkr connector.
+ 3. Make sure connector is firmly connected.
+ 4. Turn radio on.
+ 5. Ensure that the radio is tuned to channel with no activity.
+ 6. Click OK to download image from device."""))
+ rp.pre_upload = _(dedent("""\
+ 1. Turn radio off.
+ 2. Connect cable to mic/spkr connector.
+ 3. Make sure connector is firmly connected.
+ 4. Turn radio on.
+ 5. Ensure that the radio is tuned to channel with no activity.
+ 6. Click OK to upload image to device."""))
+ return rp
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_cross = True
+ rf.has_rx_dtcs = True
+ rf.has_dtcs_polarity = True
+ rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
+ rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
+ "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
+ rf.valid_duplexes = DUPLEX
+ rf.can_odd_split = False
+ rf.valid_skips = ["", "S"]
+ rf.valid_characters = CHARSET
+ rf.valid_name_length = 6
+ rf.valid_tuning_steps = TGUV2P_STEPS
+ rf.valid_bands = VALID_BANDS
+
+ rf.valid_modes = ["FM", "NFM"]
+ rf.valid_power_levels = POWER_LEVELS
+ rf.has_ctone = True
+ rf.has_bank = False
+ rf.has_tuning_step = True
+ rf.memory_bounds = (0, 199)
+ return rf
+
+ def sync_in(self):
+ try:
+ self._mmap = do_download(self)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ self.process_mmap()
+
+ def sync_out(self):
+ try:
+ do_upload(self)
+ except errors.RadioError:
+ raise
+ except Exception as e:
+ raise errors.RadioError("Failed to communicate with radio: %s" % e)
+
+ def process_mmap(self):
+ self._memobj = bitwise.parse(mem_format, self._mmap)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.channels[number])
+
+ def _decode_tone(self, _mem, which):
+ def _get(field):
+ return getattr(_mem, "%s%s" % (which, field))
+
+ value = _get('tone')
+ tmode = _get('tmode')
+
+ if (value <= 104) and (tmode <= 3):
+ if tmode == 0:
+ mode = val = pol = None
+ elif tmode == 1:
+ mode = 'Tone'
+ val = chirp_common.TONES[value]
+ pol = None
+ else:
+ mode = 'DTCS'
+ val = chirp_common.DTCS_CODES[value]
+ pol = "N" if (tmode == 2) else "R"
+ else:
+ mode = val = pol = None
+
+ return mode, val, pol
+
+ def _encode_tone(self, _mem, which, mode, val, pol):
+ def _set(field, value):
+ setattr(_mem, "%s%s" % (which, field), value)
+
+ if (mode == "Tone"):
+ _set("tone", chirp_common.TONES.index(val))
+ _set("tmode", 0x01)
+ elif mode == "DTCS":
+ _set("tone", chirp_common.DTCS_CODES.index(val))
+ if pol == "N":
+ _set("tmode", 0x02)
+ else:
+ _set("tmode", 0x03)
+ else:
+ _set("tone", 0)
+ _set("tmode", 0)
+
+ def _get_memobjs(self, number):
+ if isinstance(number, str):
+ return (getattr(self._memobj, number.lower()), None)
+
+ else:
+ return (self._memobj.channels[number],
+ self._memobj.bandflags[number],
+ self._memobj.names[number].name)
+
+ def get_memory(self, number):
+ _mem, _bf, _nam = self._get_memobjs(number)
+ mem = chirp_common.Memory()
+ if isinstance(number, str):
+ mem.extd_number = number
+ else:
+ mem.number = number
+
+ if (_mem.freq.get_raw()[0] == "\xFF") or (_bf.band == "\x0F"):
+ mem.empty = True
+ return mem
+
+ mem.freq = int(_mem.freq) * 10
+
+ if _mem.offset.get_raw()[0] == "\xFF":
+ mem.offset = 0
+ else:
+ mem.offset = int(_mem.offset) * 10
+
+ chirp_common.split_tone_decode(
+ mem,
+ self._decode_tone(_mem, "tx"),
+ self._decode_tone(_mem, "rx"))
+
+ if 'step' in _mem and _mem.step > len(TGUV2P_STEPS):
+ _mem.step = 0x00
+ mem.tuning_step = TGUV2P_STEPS[_mem.step]
+ mem.duplex = DUPLEX[_mem.duplex]
+ mem.mode = _mem.isnarrow and "NFM" or "FM"
+ mem.skip = "" if bool(_bf.scanadd) else "S"
+ mem.power = POWER_LEVELS[_mem.power]
+
+ if _nam:
+ for char in _nam:
+ try:
+ mem.name += CHARSET[char]
+ except IndexError:
+ break
+ mem.name = mem.name.rstrip()
+
+ mem.extra = RadioSettingGroup("Extra", "extra")
+
+ rs = RadioSetting("not_scramble", "(not)SCRAMBLE",
+ RadioSettingValueBoolean(_mem.not_scramble))
+ mem.extra.append(rs)
+
+ rs = RadioSetting("not_revfreq", "(not)Reverse Duplex",
+ RadioSettingValueBoolean(_mem.not_revfreq))
+ mem.extra.append(rs)
+
+ return mem
+
+ def set_memory(self, mem):
+ _mem, _bf, _nam = self._get_memobjs(mem.number)
+
+ _bf.set_raw("\xFF")
+
+ if mem.empty:
+ _mem.set_raw("\xFF" * 16)
+ return
+
+ _mem.set_raw("\x00" * 12 + "\xFF" * 2 + "\x00"*2)
+
+ _bf.scanadd = int(mem.skip != "S")
+ _bf.band = 0x0F
+ for idx, ele in enumerate(VALID_BANDS):
+ if mem.freq >= ele[0] and mem.freq <= ele[1]:
+ _bf.band = idx
+
+ _mem.freq = mem.freq / 10
+ _mem.offset = mem.offset / 10
+
+ tx, rx = chirp_common.split_tone_encode(mem)
+ self._encode_tone(_mem, 'tx', *tx)
+ self._encode_tone(_mem, 'rx', *rx)
+
+ _mem.duplex = DUPLEX.index(mem.duplex)
+ _mem.isnarrow = mem.mode == "NFM"
+ _mem.step = TGUV2P_STEPS.index(mem.tuning_step)
+
+ if mem.power is None:
+ _mem.power = 0
+ else:
+ _mem.power = POWER_LEVELS.index(mem.power)
+
+ if _nam:
+ for i in range(0, 6):
+ try:
+ _nam[i] = CHARSET.index(mem.name[i])
+ except IndexError:
+ _nam[i] = 0xFF
+
+ for setting in mem.extra:
+ setattr(_mem, setting.get_name(), setting.value)
+
+ def get_settings(self):
+ _settings = self._memobj.settings
+ _vfoa = self._memobj.vfos[0]
+ _vfob = self._memobj.vfos[1]
+ _bandsettings = self._memobj.bands
+
+ cfg_grp = RadioSettingGroup("cfg_grp", "Configuration")
+ vfoa_grp = RadioSettingGroup(
+ "vfoa_grp", "VFO A Settings\n (Current Status, Read Only)")
+ vfob_grp = RadioSettingGroup(
+ "vfob_grp", "VFO B Settings\n (Current Status, Read Only)")
+
+ group = RadioSettings(cfg_grp, vfoa_grp, vfob_grp)
+ #
+ # Configuration Settings
+ #
+
+ # TX time out timer:
+ options = ["Off"] + ["%s min" % x for x in range(1, 10)]
+ rs = RadioSetting("time_out_timer", "TX Time Out Timer",
+ RadioSettingValueList(
+ options, options[_settings.time_out_timer]))
+ cfg_grp.append(rs)
+
+ # Display mode
+ options = ["Frequency", "Channel", "Name"]
+ rs = RadioSetting("display", "Channel Display Mode",
+ RadioSettingValueList(
+ options, options[_settings.display]))
+ cfg_grp.append(rs)
+
+ # Squelch level
+ rs = RadioSetting("squelch", "Squelch Level",
+ RadioSettingValueInteger(0, 9, _settings.squelch))
+ cfg_grp.append(rs)
+
+ # Vox level
+ mem_vals = list(range(10))
+ user_options = [str(x) for x in mem_vals]
+ user_options[0] = "Off"
+ options_map = list(zip(user_options, mem_vals))
+
+ rs = RadioSetting("vox", "VOX Level",
+ RadioSettingValueMap(options_map, _settings.vox))
+ cfg_grp.append(rs)
+
+ # Keypad beep
+ rs = RadioSetting("beep_tone_disabled", "Beep Prompt",
+ RadioSettingValueBoolean(
+ not _settings.beep_tone_disabled))
+ cfg_grp.append(rs)
+
+ # Dual watch/crossband
+ options = ["Dual Watch", "CrossBand", "Normal"]
+ if _settings.rxmode >= 2:
+ _rxmode = 2
+ else:
+ _rxmode = _settings.rxmode
+ rs = RadioSetting("rxmode", "Dual Watch/CrossBand Monitor",
+ RadioSettingValueList(
+ options, options[_rxmode]))
+ cfg_grp.append(rs)
+
+ # Busy channel lock
+ rs = RadioSetting("busy_lockout", "Busy Channel Lock",
+ RadioSettingValueBoolean(
+ not _settings.busy_lockout))
+ cfg_grp.append(rs)
+
+ # Keypad lock
+ rs = RadioSetting("keyunlocked", "Keypad Lock",
+ RadioSettingValueBoolean(
+ not _settings.keyunlocked))
+ cfg_grp.append(rs)
+
+ # Priority channel
+ mem_vals = list(range(200))
+ user_options = [str(x) for x in mem_vals]
+ mem_vals.insert(0, 0xFF)
+ user_options.insert(0, "Not Set")
+ options_map = list(zip(user_options, mem_vals))
+ if _settings.priority_channel >= 200:
+ _priority_ch = 0xFF
+ else:
+ _priority_ch = _settings.priority_channel
+ rs = RadioSetting(
+ "priority_channel",
+ "Priority Channel \n"
+ "Note: Unused channels,\nor channels "
+ "in the\nbroadcast FM band,\nwill not be set",
+ RadioSettingValueMap(options_map, _priority_ch))
+ cfg_grp.append(rs)
+
+ # Step
+ mem_vals = list(range(0, len(TGUV2P_STEPS)))
+ mem_vals.append(0xFF)
+ user_options = [(str(x) + " kHz") for x in TGUV2P_STEPS]
+ user_options.append("Unknown")
+ options_map = list(zip(user_options, mem_vals))
+
+ rs = RadioSetting("step", "Current (VFO?) step size",
+ RadioSettingValueMap(options_map, _settings.step))
+ cfg_grp.append(rs)
+
+ # End (Tail) tone elimination
+ mem_vals = [0, 1]
+ user_options = ["Tone Elimination On", "Tone Elimination Off"]
+ options_map = list(zip(user_options, mem_vals))
+
+ rs = RadioSetting("not_end_tone_elim", "Tx End Tone Elimination",
+ RadioSettingValueMap(options_map,
+ _settings.not_end_tone_elim))
+ cfg_grp.append(rs)
+
+ # VFO mode
+
+ if _settings.vfo_mode >= 1:
+ _vfo_mode = 0xFF
+ else:
+ _vfo_mode = _settings.vfo_mode
+ mem_vals = [0xFF, 0]
+ user_options = ["VFO Mode Enabled", "VFO Mode Disabled"]
+ options_map = list(zip(user_options, mem_vals))
+
+ rs = RadioSetting("vfo_mode", "VFO (CH only) mode",
+ RadioSettingValueMap(options_map, _vfo_mode))
+ cfg_grp.append(rs)
+
+ #
+ # VFO Settings
+ #
+
+ vfo_groups = [vfoa_grp, vfob_grp]
+ vfo_mem = [_vfoa, _vfob]
+ vfo_lower = ["vfoa", "vfob"]
+ vfo_upper = ["VFOA", "VFOB"]
+
+ for idx, vfo_group in enumerate(vfo_groups):
+
+ options = ["Channel", "Frequency"]
+ tempvar = 0 if (vfo_mem[idx].current < 200) else 1
+ rs = RadioSetting(vfo_lower[idx] + "_mode", vfo_upper[idx]+" Mode",
+ RadioSettingValueList(
+ options, options[tempvar]))
+ vfo_group.append(rs)
+
+ if tempvar == 0:
+ rs = RadioSetting(vfo_lower[idx] + "_ch",
+ vfo_upper[idx] + " Channel",
+ RadioSettingValueInteger(
+ 0, 199, vfo_mem[idx].current))
+ vfo_group.append(rs)
+ else:
+ band_num = vfo_mem[idx].current - 200
+ freq = int(_bandsettings[band_num].freq) * 10
+ offset = int(_bandsettings[band_num].offset) * 10
+ txtmode = _bandsettings[band_num].txtmode
+ rxtmode = _bandsettings[band_num].rxtmode
+
+ rs = RadioSetting(vfo_lower[idx] + "_freq",
+ vfo_upper[idx] + " Frequency",
+ RadioSettingValueFloat(
+ 0.0, 520.0, freq / 1000000.0,
+ precision=6))
+ vfo_group.append(rs)
+
+ if offset > 70e6:
+ offset = 0
+ rs = RadioSetting(vfo_lower[idx] + "_offset",
+ vfo_upper[idx] + " Offset",
+ RadioSettingValueFloat(
+ 0.0, 69.995, offset / 100000.0,
+ resolution=0.005))
+ vfo_group.append(rs)
+
+ rs = RadioSetting(vfo_lower[idx] + "_duplex",
+ vfo_upper[idx] + " Shift",
+ RadioSettingValueList(
+ DUPLEX,
+ DUPLEX[_bandsettings[band_num].duplex]))
+ vfo_group.append(rs)
+
+ rs = RadioSetting(
+ vfo_lower[idx] + "_step",
+ vfo_upper[idx] + " Step",
+ RadioSettingValueFloat(
+ 0.0, 1000.0,
+ TGUV2P_STEPS[_bandsettings[band_num].step],
+ resolution=0.25))
+ vfo_group.append(rs)
+
+ rs = RadioSetting(
+ vfo_lower[idx] + "_pwr",
+ vfo_upper[idx] + " Power",
+ RadioSettingValueList(
+ POWER_LEVELS_STR,
+ POWER_LEVELS_STR[_bandsettings[band_num].power]))
+ vfo_group.append(rs)
+
+ options = ["None", "Tone", "DTCS-N", "DTCS-I"]
+ rs = RadioSetting(vfo_lower[idx] + "_ttmode",
+ vfo_upper[idx]+" TX tone mode",
+ RadioSettingValueList(
+ options, options[txtmode]))
+ vfo_group.append(rs)
+ if txtmode == 1:
+ rs = RadioSetting(
+ vfo_lower[idx] + "_ttone",
+ vfo_upper[idx] + " TX tone",
+ RadioSettingValueFloat(
+ 0.0, 1000.0,
+ chirp_common.TONES[_bandsettings[band_num].txtone],
+ resolution=0.1))
+ vfo_group.append(rs)
+ elif txtmode >= 2:
+ txtone = _bandsettings[band_num].txtone
+ rs = RadioSetting(
+ vfo_lower[idx] + "_tdtcs",
+ vfo_upper[idx] + " TX DTCS",
+ RadioSettingValueInteger(
+ 0, 1000, chirp_common.DTCS_CODES[txtone]))
+ vfo_group.append(rs)
+
+ options = ["None", "Tone", "DTCS-N", "DTCS-I"]
+ rs = RadioSetting(vfo_lower[idx] + "_rtmode",
+ vfo_upper[idx] + " RX tone mode",
+ RadioSettingValueList(options,
+ options[rxtmode]))
+ vfo_group.append(rs)
+
+ if rxtmode == 1:
+ rs = RadioSetting(
+ vfo_lower[idx] + "_rtone",
+ vfo_upper[idx] + " RX tone",
+ RadioSettingValueFloat(
+ 0.0, 1000.0,
+ chirp_common.TONES[_bandsettings[band_num].rxtone],
+ resolution=0.1))
+ vfo_group.append(rs)
+ elif rxtmode >= 2:
+ rxtone = _bandsettings[band_num].rxtone
+ rs = RadioSetting(vfo_lower[idx] + "_rdtcs",
+ vfo_upper[idx] + " TX rTCS",
+ RadioSettingValueInteger(
+ 0, 1000,
+ chirp_common.DTCS_CODES[rxtone]))
+ vfo_group.append(rs)
+
+ options = ["FM", "NFM"]
+ rs = RadioSetting(
+ vfo_lower[idx] + "_fm",
+ vfo_upper[idx] + " FM BW ",
+ RadioSettingValueList(
+ options, options[_bandsettings[band_num].isnarrow]))
+ vfo_group.append(rs)
+
+ return group
+
+ def _validate_priority_ch(self, ch_num):
+ if ch_num == 0xFF:
+ return True
+ _mem, _bf, _nam = self._get_memobjs(ch_num)
+ if (_mem.freq.get_raw()[0] == "\xFF") or (_bf.band == "\x0F"):
+ return False
+ elif _bf.band == 0x00:
+ return False
+ else:
+ return True
+
+ def set_settings(self, settings):
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ if "vfoa" in element.get_name():
+ continue
+ if "vfob" in element.get_name():
+ continue
+ elif "." in element.get_name():
+ bits = element.get_name().split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = self._memobj.settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("using apply callback")
+ element.run_apply_callback()
+ elif setting == "beep_tone_disabled":
+ LOG.debug("Setting %s = %s" % (setting,
+ not int(element.value)))
+ setattr(obj, setting, not int(element.value))
+ elif setting == "busy_lockout":
+ LOG.debug("Setting %s = %s" % (setting,
+ not int(element.value)))
+ setattr(obj, setting, not int(element.value))
+ elif setting == "keyunlocked":
+ # keypad currently unlocked being set to locked
+ # and rx_mode is currently not "Normal":
+ if getattr(obj, "keyunlocked") and int(element.value) \
+ and (getattr(obj, "rxmode") != 0x02):
+ raise errors.InvalidValueError(
+ "Keypad lock not allowed in "
+ "Dual-Watch or CrossBand")
+ LOG.debug("Setting %s = %s" % (setting,
+ not int(element.value)))
+ setattr(obj, setting, not int(element.value))
+ elif setting == "rxmode":
+ # rx_mode was normal, now being set otherwise
+ # and keypad is locked:
+ if (getattr(obj, "rxmode") == 0x02) \
+ and (int(element.value) != 2) \
+ and not (getattr(obj, "keyunlocked")):
+ raise errors.InvalidValueError(
+ "Dual-Watch or CrossBand can not be set "
+ "when keypad is locked")
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ elif setting == "priority_channel":
+ _check = self._validate_priority_ch(int(element.value))
+ if _check:
+ LOG.debug("Setting %s = %s" % (setting,
+ element.value))
+ setattr(obj, setting, element.value)
+ else:
+ raise errors.InvalidValueError(
+ "Please select a valid priority channel:\n"
+ "A used memory channel which is not "
+ "in the Broadcast FM band (88-108MHz),\n"
+ "Or select 'Not Used'")
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return (filedata.startswith(b"TG-UV2+ Radio Program Data") and
+ len(filedata) == (cls._memsize + 0x30))
diff --git a/chirp/drivers/th350.py b/chirp/drivers/th350.py
index 39475db..b27c86b 100644
--- a/chirp/drivers/th350.py
+++ b/chirp/drivers/th350.py
@@ -295,6 +295,7 @@ class Th350Radio(BaofengUVB5):
rf.valid_modes = ["FM", "NFM"]
rf.valid_special_chans = list(self.SPECIALS.keys())
rf.valid_power_levels = POWER_LEVELS
+ rf.valid_tuning_steps = [5.0, 6.25, 10.0, 12.5, 20.0, 25.0]
rf.has_ctone = True
rf.has_bank = False
rf.has_tuning_step = False
diff --git a/chirp/drivers/th7800.py b/chirp/drivers/th7800.py
index 231030f..59027fc 100644
--- a/chirp/drivers/th7800.py
+++ b/chirp/drivers/th7800.py
@@ -218,7 +218,7 @@ class TYTTH7800Base(chirp_common.Radio):
"""get active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
enabled = bank[index] & mask
@@ -231,7 +231,7 @@ class TYTTH7800Base(chirp_common.Radio):
"""set active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
if enable:
@@ -536,7 +536,7 @@ class TYTTH7800Base(chirp_common.Radio):
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -631,7 +631,7 @@ def _upload(radio, memsize=0xF400, blocksize=0x80):
if data != radio._mmap[:radio._mmap_offset]:
raise errors.RadioError(
- "Model mis-match: \n%s\n%s" %
+ "Model mismatch: \n%s\n%s" %
(util.hexprint(data),
util.hexprint(radio._mmap[:radio._mmap_offset])))
# in the factory software they update the last program date when
@@ -701,8 +701,8 @@ class TYTTH7800Radio(TYTTH7800Base, chirp_common.CloneModeRadio,
# TYT used TH9800 as model for TH-7800 _AND_ TH-9800. Check
# for TH7800 in case they fix it or if users update the model
# in their own radio.
- if not (filedata[0xfe18:0xfe1e] == "TH9800" or
- filedata[0xfe18:0xfe1e] == "TH7800"):
+ if not (filedata[0xfe18:0xfe1e] == b"TH9800" or
+ filedata[0xfe18:0xfe1e] == b"TH7800"):
return False
# TH-7800 bandlimits differ from TH-9800. First band Invalid
# (zero).
@@ -726,7 +726,7 @@ class TYTTH7800Radio(TYTTH7800Base, chirp_common.CloneModeRadio,
def sync_in(self):
try:
self._mmap = _download(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
self.process_mmap()
@@ -734,6 +734,6 @@ class TYTTH7800Radio(TYTTH7800Base, chirp_common.CloneModeRadio,
def sync_out(self):
try:
_upload(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
diff --git a/chirp/drivers/th9000.py b/chirp/drivers/th9000.py
index ad2d7eb..4cfb0d1 100644
--- a/chirp/drivers/th9000.py
+++ b/chirp/drivers/th9000.py
@@ -32,44 +32,46 @@ from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \
LOG = logging.getLogger(__name__)
#
-# Chirp Driver for TYT TH-9000D (models: 2M (144 Mhz), 1.25M (220 Mhz) and 70cm (440 Mhz) radios)
+# Chirp Driver for TYT TH-9000D (models: 2M (144 Mhz), 1.25M (220 Mhz)
+# and 70cm (440 Mhz) radios)
#
-# Version 1.0
+# Version 1.0
#
# - Skip channels
#
-# Global Parameters
+# Global Parameters
#
MMAPSIZE = 16384
TONES = [62.5] + list(chirp_common.TONES)
-TMODES = ['','Tone','DTCS','']
-DUPLEXES = ['','err','-','+'] # index 2 not used
-MODES = ['WFM','FM','NFM'] # 25k, 20k,15k bw
-TUNING_STEPS=[ 5.0, 6.25, 8.33, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0 ] # index 0-9
-POWER_LEVELS=[chirp_common.PowerLevel("High", watts=65),
- chirp_common.PowerLevel("Mid", watts=25),
- chirp_common.PowerLevel("Low", watts=10)]
+TMODES = ['', 'Tone', 'DTCS', '']
+DUPLEXES = ['', 'err', '-', '+'] # index 2 not used
+MODES = ['WFM', 'FM', 'NFM'] # 25k, 20k,15k bw
+TUNING_STEPS = [5.0, 6.25, 8.33, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0]
+# index 0-9
+POWER_LEVELS = [chirp_common.PowerLevel("High", watts=65),
+ chirp_common.PowerLevel("Mid", watts=25),
+ chirp_common.PowerLevel("Low", watts=10)]
CROSS_MODES = chirp_common.CROSS_MODES
-APO_LIST = [ "Off","30 min","1 hr","2 hrs" ]
-BGCOLOR_LIST = ["Blue","Orange","Purple"]
-BGBRIGHT_LIST = ["%s" % x for x in range(1,32)]
-SQUELCH_LIST = ["Off"] + ["Level %s" % x for x in range(1,20)]
-TIMEOUT_LIST = ["Off"] + ["%s min" % x for x in range(1,30)]
-TXPWR_LIST = ["60W","25W"] # maximum power for Hi setting
-TBSTFREQ_LIST = ["1750Hz","2100Hz","1000Hz","1450Hz"]
-BEEP_LIST = ["Off","On"]
+APO_LIST = ["Off", "30 min", "1 hr", "2 hrs"]
+BGCOLOR_LIST = ["Blue", "Orange", "Purple"]
+BGBRIGHT_LIST = ["%s" % x for x in range(1, 32)]
+SQUELCH_LIST = ["Off"] + ["Level %s" % x for x in range(1, 20)]
+TIMEOUT_LIST = ["Off"] + ["%s min" % x for x in range(1, 30)]
+TXPWR_LIST = ["60W", "25W"] # maximum power for Hi setting
+TBSTFREQ_LIST = ["1750Hz", "2100Hz", "1000Hz", "1450Hz"]
+BEEP_LIST = ["Off", "On"]
SETTING_LISTS = {
"auto_power_off": APO_LIST,
- "bg_color" : BGCOLOR_LIST,
- "bg_brightness" : BGBRIGHT_LIST,
- "squelch" : SQUELCH_LIST,
- "timeout_timer" : TIMEOUT_LIST,
+ "bg_color": BGCOLOR_LIST,
+ "bg_brightness": BGBRIGHT_LIST,
+ "squelch": SQUELCH_LIST,
+ "timeout_timer": TIMEOUT_LIST,
"choose_tx_power": TXPWR_LIST,
- "tbst_freq" : TBSTFREQ_LIST,
- "voice_prompt" : BEEP_LIST
+ "tbst_freq": TBSTFREQ_LIST,
+ "voice_prompt": BEEP_LIST
}
MEM_FORMAT = """
@@ -80,35 +82,37 @@ struct {
u8 unknown0001[16];
} fidhdr;
"""
-#Overall Memory Map:
+# Overall Memory Map:
#
# Memory Map (Range 0x0100-3FF0, step 0x10):
#
-# Field Start End Size
-# (hex) (hex) (hex)
-#
-# 1 Channel Set Flag 0100 011F 20
-# 2 Channel Skip Flag 0120 013F 20
-# 3 Blank/Unknown 0140 01EF B0
+# Field Start End Size
+# (hex) (hex) (hex)
+#
+# 1 Channel Set Flag 0100 011F 20
+# 2 Channel Skip Flag 0120 013F 20
+# 3 Blank/Unknown 0140 01EF B0
# 4 Unknown 01F0 01FF 10
-# 5 TX/RX Range 0200 020F 10
-# 6 Bootup Passwd 0210 021F 10
+# 5 TX/RX Range 0200 020F 10
+# 6 Bootup Passwd 0210 021F 10
# 7 Options, Radio 0220 023F 20
-# 8 Unknown 0240 019F
+# 8 Unknown 0240 019F
# 8B Startup Label 03E0 03E7 07
-# 9 Channel Bank 2000 38FF 1900
-# Channel 000 2000 201F 20
-# Channel 001 2020 202F 20
-# ...
-# Channel 199 38E0 38FF 20
-# 10 Blank/Unknown 3900 3FFF 6FF 14592 16383 1792
+# 9 Channel Bank 2000 38FF 1900
+# Channel 000 2000 201F 20
+# Channel 001 2020 202F 20
+# ...
+# Channel 199 38E0 38FF 20
+# 10 Blank/Unknown 3900 3FFF 6FF 14592 16383 1792
# Total Map Size 16128 (2^8 = 16384)
#
-# TH9000/220 memory map
+# TH9000/220 memory map
# section: 1 and 2: Channel Set/Skip Flags
-#
-# Channel Set (starts 0x100) : Channel Set bit is value 0 if a memory location in the channel bank is active.
-# Channel Skip (starts 0x120): Channel Skip bit is value 0 if a memory location in the channel bank is active.
+#
+# Channel Set (starts 0x100) : Channel Set bit is value 0 if a memory
+# location in the channel bank is active.
+# Channel Skip (starts 0x120): Channel Skip bit is value 0 if a memory
+# location in the channel bank is active.
#
# Both flag maps are a total 24 bytes in length, aligned on 32 byte records.
# bit = 0 channel set/no skip, 1 is channel not set/skip
@@ -140,10 +144,10 @@ struct {
u8 unknown0120[7];
} ropt0120;
"""
-# TH9000 memory map
+# TH9000 memory map
# section: 5 TX/RX Range
# used to set the TX/RX range of the radio (e.g. 222-228Mhz for 220 meter)
-# possible to set range for tx/rx
+# possible to set range for tx/rx
#
MEM_FORMAT = MEM_FORMAT + """
#seekto 0x0200;
@@ -154,7 +158,7 @@ struct {
bbcd rxrangehi[4];
} freqrange;
"""
-# TH9000 memory map
+# TH9000 memory map
# section: 6 bootup_passwd
# used to set bootup passwd (see boot_passwd checkbox option)
#
@@ -162,8 +166,9 @@ struct {
#
# bytes:bit type description
# ---------------------------------------------------------------------------
-# 6 u8 bootup_passwd[6] bootup passwd, 6 chars, numberic chars 30-39 , see boot_passwd checkbox to set
-# 10 u8 unknown;
+# 6 u8 bootup_passwd[6] bootup passwd, 6 chars, numeric chars
+# 30-39 , see boot_passwd checkbox to set
+# 10 u8 unknown;
#
MEM_FORMAT = MEM_FORMAT + """
@@ -173,27 +178,35 @@ struct {
u8 unknown2010[10];
} ropt0210;
"""
-# TH9000/220 memory map
-# section: 7 Radio Options
-# used to set a number of radio options
+# TH9000/220 memory map
+# section: 7 Radio Options
+# used to set a number of radio options
#
# bytes:bit type description
# ---------------------------------------------------------------------------
-# 1 u8 display_mode display mode, range 0-2, 0=freq,1=channel,2=name (selecting name affects vfo_mr)
-# 1 u8 vfo_mr; vfo_mr , 0=vfo, mr=1
-# 1 u8 unknown;
+# 1 u8 display_mode display mode, range 0-2, 0=freq,1=channel,
+# 2=name (selecting name affects vfo_mr)
+# 1 u8 vfo_mr; vfo_mr , 0=vfo, mr=1
+# 1 u8 unknown;
# 1 u8 squelch; squelch level, range 0-19, hex for menu
-# 1 u8 unknown[2];
-# 1 u8 channel_lock; if display_mode[channel] selected, then lock=1,no lock =0
-# 1 u8 unknown;
-# 1 u8 bg_brightness ; background brightness, range 0-21, hex, menu index
-# 1 u8 unknown;
-# 1 u8 bg_color ; bg color, menu index, blue 0 , orange 1, purple 2
-# 1 u8 tbst_freq ; tbst freq , menu 0 = 1750Hz, 1=2100 , 2=1000 , 3=1450hz
-# 1 u8 timeout_timer; timeout timer, hex, value = minutes, 0= no timeout
-# 1 u8 unknown;
-# 1 u8 auto_power_off; auto power off, range 0-3, off,30min, 1hr, 2hr, hex menu index
-# 1 u8 voice_prompt; voice prompt, value 0,1 , Beep ON = 1, Beep Off = 2
+# 1 u8 unknown[2];
+# 1 u8 channel_lock; if display_mode[channel] selected, then
+# lock=1,no lock =0
+# 1 u8 unknown;
+# 1 u8 bg_brightness ; background brightness, range 0-21, hex,
+# menu index
+# 1 u8 unknown;
+# 1 u8 bg_color ; bg color, menu index, blue 0 , orange 1,
+# purple 2
+# 1 u8 tbst_freq ; tbst freq , menu 0 = 1750Hz, 1=2100 ,
+# 2=1000 , 3=1450hz
+# 1 u8 timeout_timer; timeout timer, hex, value = minutes,
+# 0= no timeout
+# 1 u8 unknown;
+# 1 u8 auto_power_off; auto power off, range 0-3, off,30min, 1hr,
+# 2hr, hex menu index
+# 1 u8 voice_prompt; voice prompt, value 0,1 , Beep ON = 1,
+# Beep Off = 2
#
# description of function setup options, starting at 0x0230
#
@@ -201,9 +214,11 @@ struct {
# ---------------------------------------------------------------------------
# 1 u8 // 0
# :4 unknown:6
-# :1 elim_sql_tail:1 eliminate squelsh tail when no ctcss checkbox (1=checked)
-# :1 sql_key_function "squelch off" 1 , "squelch momentary off" 0 , menu index
-# 2 u8 unknown[2] /1-2
+# :1 elim_sql_tail:1 eliminate squelsh tail when no ctcss checkbox
+# (1=checked)
+# :1 sql_key_function "squelch off" 1 , "squelch momentary off" 0 ,
+# menu index
+# 2 u8 unknown[2] /1-2
# 1 u8 // 3
# :4 unknown:4
# :1 inhibit_init_ops:1 //bit 5
@@ -212,33 +227,33 @@ struct {
# :1 unknown:1
# 1 u8 tail_elim_type menu , (off=0,120=1,180=2), // 4
# 1 u8 choose_tx_power menu , (60w=0,25w=1) // 5
-# 2 u8 unknown[2]; // 6-7
+# 2 u8 unknown[2]; // 6-7
# 1 u8 bootup_passwd_flag checkbox 1=on, 0=off // 8
-# 7 u8 unknown[7]; // 9-F
+# 7 u8 unknown[7]; // 9-F
#
MEM_FORMAT = MEM_FORMAT + """
#seekto 0x0220;
struct {
- u8 display_mode;
- u8 vfo_mr;
- u8 unknown0220A;
- u8 squelch;
- u8 unknown0220B[2];
- u8 channel_lock;
- u8 unknown0220C;
- u8 bg_brightness;
- u8 unknown0220D;
+ u8 display_mode;
+ u8 vfo_mr;
+ u8 unknown0220A;
+ u8 squelch;
+ u8 unknown0220B[2];
+ u8 channel_lock;
+ u8 unknown0220C;
+ u8 bg_brightness;
+ u8 unknown0220D;
u8 bg_color;
u8 tbst_freq;
u8 timeout_timer;
u8 unknown0220E;
u8 auto_power_off;
- u8 voice_prompt;
+ u8 voice_prompt;
u8 unknown0230A:6,
elim_sql_tail:1,
sql_key_function:1;
u8 unknown0230B[2];
- u8 unknown0230C:4,
+ u8 unknown0230C:4,
inhibit_init_ops:1,
unknown0230D:1,
inhibit_setup_bg_chk:1,
@@ -250,12 +265,13 @@ struct {
u8 unknown0230G[7];
} settings;
"""
-# TH9000 memory map
-# section: 8B Startup Label
+# TH9000 memory map
+# section: 8B Startup Label
#
# bytes:bit type description
# ---------------------------------------------------------------------------
-# 7 char start_label[7] label displayed at startup (usually your call sign)
+# 7 char start_label[7] label displayed at startup (usually your call
+# sign)
#
MEM_FORMAT = MEM_FORMAT + """
#seekto 0x03E0;
@@ -263,14 +279,17 @@ struct {
char startname[7];
} slabel;
"""
-# TH9000/220 memory map
+# TH9000/220 memory map
# section: 9 Channel Bank
# description of channel bank (200 channels , range 0-199)
# Each 32 Byte (0x20 hex) record:
# bytes:bit type description
# ---------------------------------------------------------------------------
-# 4 bbcd freq[4] receive frequency in packed binary coded decimal
-# 4 bbcd offset[4] transmit offset in packed binary coded decimal (note: plus/minus direction set by 'duplex' field)
+# 4 bbcd freq[4] receive frequency in packed binary coded
+# decimal
+# 4 bbcd offset[4] transmit offset in packed binary coded decimal
+# (note: plus/minus direction set by 'duplex'
+# field)
# 1 u8
# :4 unknown:4
# :4 tuning_step:4 tuning step, menu index value from 0-9
@@ -279,36 +298,48 @@ struct {
# :4 unknown:4 not yet decoded, used for DCS coding?
# :2 channel_width:2 channel spacing, menu index value from 0-3
# 25,20,12.5
-# :1 reverse:1 reverse flag, 0=off, 1=on (reverses tx and rx freqs)
-# :1 txoff:1 transmitt off flag, 0=transmit , 1=do not transmit
+# :1 reverse:1 reverse flag, 0=off, 1=on (reverses tx and
+# rx freqs)
+# :1 txoff:1 transmitt off flag, 0=transmit ,
+# 1=do not transmit
+# 1 u8
+# :1 talkaround:1 talkaround flag, 0=off, 1=on (bypasses
+# repeater)
+# :1 compander:1 compander flag, 0=off, 1=on (turns on/off
+# voice compander option)
+# :2 unknown:2
+# :2 power:2 tx power setting, value range 0-2, 0=hi,
+# 1=med, 2=lo
+# :2 duplex:2 duplex settings, 0=simplex,
+# 2= minus(-) offset, 3= plus (+) offset
+# (see offset field)
+#
# 1 u8
-# :1 talkaround:1 talkaround flag, 0=off, 1=on (bypasses repeater)
-# :1 compander:1 compander flag, 0=off, 1=on (turns on/off voice compander option)
-# :2 unknown:2
-# :2 power:2 tx power setting, value range 0-2, 0=hi,1=med,2=lo
-# :2 duplex:2 duplex settings, 0=simplex,2= minus(-) offset, 3= plus (+) offset (see offset field)
-#
-# 1 u8
# :4 unknown:4
-# :2 rxtmode:2 rx tone mode, value range 0-2, 0=none, 1=CTCSS, 2=DCS (ctcss tone in field rxtone)
-# :2 txtmode:2 tx tone mode, value range 0-2, 0=none, 1=CTCSS, 3=DCS (ctcss tone in field txtone)
-# 1 u8
+# :2 rxtmode:2 rx tone mode, value range 0-2, 0=none,
+# 1=CTCSS, 2=DCS (ctcss tone in field rxtone)
+# :2 txtmode:2 tx tone mode, value range 0-2, 0=none,
+# 1=CTCSS, 3=DCS (ctcss tone in field txtone)
+# 1 u8
# :2 unknown:2
# :6 txtone:6 tx ctcss tone, menu index
-# 1 u8
-# :2 unknown:2
+# 1 u8
+# :2 unknown:2
# :6 rxtone:6 rx ctcss tone, menu index
# 1 u8 txcode ?, not used for ctcss
# 1 u8 rxcode ?, not used for ctcss
# 3 u8 unknown[3]
# 7 char name[7] 7 byte char string for channel name
-# 1 u8
+# 1 u8
# :6 unknown:6,
-# :2 busychannellockout:2 busy channel lockout option , 0=off, 1=repeater, 2=busy (lock out tx if channel busy)
+# :2 busychannellockout:2 busy channel lockout option ,
+# 0=off, 1=repeater, 2=busy
+# (lock out tx if channel busy)
# 4 u8 unknownI[4];
-# 1 u8
-# :7 unknown:7
-# :1 scrambler:1 scrambler flag, 0=off, 1=on (turns on tyt scrambler option)
+# 1 u8
+# :7 unknown:7
+# :1 scrambler:1 scrambler flag, 0=off, 1=on (turns on tyt
+# scrambler option)
#
MEM_FORMAT = MEM_FORMAT + """
#seekto 0x2000;
@@ -344,15 +375,16 @@ struct {
busychannellockout:2;
u8 unknown2000I[4];
u8 unknown2000J:7,
- scrambler:1;
+ scrambler:1;
} memory[200] ;
"""
+
def _echo_write(radio, data):
try:
radio.pipe.write(data)
radio.pipe.read(len(data))
- except Exception, e:
+ except Exception as e:
LOG.error("Error writing to radio: %s" % e)
raise errors.RadioError("Unable to write to radio")
@@ -363,37 +395,38 @@ def _checksum(data):
cs += ord(byte)
return cs % 256
+
def _read(radio, length):
try:
data = radio.pipe.read(length)
- except Exception, e:
- LOG.error( "Error reading from radio: %s" % e)
+ except Exception as e:
+ LOG.error("Error reading from radio: %s" % e)
raise errors.RadioError("Unable to read from radio")
if len(data) != length:
- LOG.error( "Short read from radio (%i, expected %i)" % (len(data),
- length))
+ LOG.error("Short read from radio (%i, expected %i)" % (len(data),
+ length))
LOG.debug(util.hexprint(data))
raise errors.RadioError("Short read from radio")
return data
-
def _ident(radio):
radio.pipe.timeout = 1
- _echo_write(radio,"PROGRAM")
+ _echo_write(radio, "PROGRAM")
response = radio.pipe.read(3)
if response != "QX\06":
- LOG.debug( "Response was :\n%s" % util.hexprint(response))
+ LOG.debug("Response was :\n%s" % util.hexprint(response))
raise errors.RadioError("Unsupported model")
_echo_write(radio, "\x02")
response = radio.pipe.read(16)
LOG.debug(util.hexprint(response))
if response[1:8] != "TH-9000":
- LOG.error( "Looking for:\n%s" % util.hexprint("TH-9000"))
- LOG.error( "Response was:\n%s" % util.hexprint(response))
+ LOG.error("Looking for:\n%s" % util.hexprint("TH-9000"))
+ LOG.error("Response was:\n%s" % util.hexprint(response))
raise errors.RadioError("Unsupported model")
+
def _send(radio, cmd, addr, length, data=None):
frame = struct.pack(">cHb", cmd, addr, length)
if data:
@@ -405,8 +438,9 @@ def _send(radio, cmd, addr, length, data=None):
if data:
result = radio.pipe.read(1)
if result != "\x06":
- LOG.debug( "Ack was: %s" % repr(result))
- raise errors.RadioError("Radio did not accept block at %04x" % addr)
+ LOG.debug("Ack was: %s" % repr(result))
+ raise errors.RadioError(
+ "Radio did not accept block at %04x" % addr)
return
result = _read(radio, length + 6)
LOG.debug("Got:\n%s" % util.hexprint(result))
@@ -418,14 +452,14 @@ def _send(radio, cmd, addr, length, data=None):
raise errors.RadioError("Radio NAK'd block at %04x" % addr)
_cmd, _addr, _length = struct.unpack(">cHb", header)
if _addr != addr or _length != _length:
- LOG.debug( "Expected/Received:")
+ LOG.debug("Expected/Received:")
LOG.debug(" Length: %02x/%02x" % (length, _length))
- LOG.debug( " Addr: %04x/%04x" % (addr, _addr))
+ LOG.debug(" Addr: %04x/%04x" % (addr, _addr))
raise errors.RadioError("Radio send unexpected block")
cs = _checksum(result[1:-2])
if cs != ord(result[-2]):
- LOG.debug( "Calculated: %02x" % cs)
- LOG.debug( "Actual: %02x" % ord(result[-2]))
+ LOG.debug("Calculated: %02x" % cs)
+ LOG.debug("Actual: %02x" % ord(result[-2]))
raise errors.RadioError("Block at 0x%04x failed checksum" % addr)
return data
@@ -435,10 +469,11 @@ def _finish(radio):
_echo_write(radio, endframe)
result = radio.pipe.read(1)
# TYT radios acknowledge the "endframe" command, Luiton radios do not.
- if result != "" and result != "\x06":
- LOG.error( "Got:\n%s" % util.hexprint(result))
+ if result != "" and result != "\x06":
+ LOG.error("Got:\n%s" % util.hexprint(result))
raise errors.RadioError("Radio did not finish cleanly")
+
def do_download(radio):
_ident(radio)
@@ -446,9 +481,9 @@ def do_download(radio):
_memobj = None
data = ""
- for start,end in radio._ranges:
- for addr in range(start,end,0x10):
- block = _send(radio,'R',addr,0x10)
+ for start, end in radio._ranges:
+ for addr in range(start, end, 0x10):
+ block = _send(radio, 'R', addr, 0x10)
data += block
status = chirp_common.Status()
status.cur = len(data)
@@ -460,16 +495,17 @@ def do_download(radio):
return memmap.MemoryMap(data)
+
def do_upload(radio):
_ident(radio)
- for start,end in radio._ranges:
- for addr in range(start,end,0x10):
+ for start, end in radio._ranges:
+ for addr in range(start, end, 0x10):
if addr < 0x0100:
continue
- block = radio._mmap[addr:addr+0x10]
- _send(radio,'W',addr,len(block),block)
+ block = radio._mmap[addr:addr + 0x10]
+ _send(radio, 'W', addr, len(block), block)
status = chirp_common.Status()
status.cur = addr
status.max = end
@@ -477,7 +513,6 @@ def do_upload(radio):
radio.status_fn(status)
_finish(radio)
-
#
@@ -486,14 +521,13 @@ def do_upload(radio):
class Th9000Radio(chirp_common.CloneModeRadio,
chirp_common.ExperimentalRadio):
"""TYT TH-9000"""
- VENDOR = "TYT"
- MODEL = "TH9000 Base"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000 Base"
+ BAUD_RATE = 9600
valid_freq = [(900000000, 999000000)]
-
_memsize = MMAPSIZE
- _ranges = [(0x0000,0x4000)]
+ _ranges = [(0x0000, 0x4000)]
@classmethod
def get_prompts(cls):
@@ -509,17 +543,18 @@ class Th9000Radio(chirp_common.CloneModeRadio,
rf.has_cross = True
rf.has_tuning_step = False
rf.has_rx_dtcs = True
- rf.valid_skips = ["","S"]
- rf.memory_bounds = (0, 199)
+ rf.valid_skips = ["", "S"]
+ rf.memory_bounds = (0, 199)
rf.valid_name_length = 7
rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + "-"
rf.valid_modes = MODES
- rf.valid_tmodes = ['','Tone','TSQL','DTCS','Cross']
- rf.valid_cross_modes = ['Tone->DTCS','DTCS->Tone',
- '->Tone','->DTCS','Tone->Tone']
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = ['Tone->DTCS', 'DTCS->Tone',
+ '->Tone', '->DTCS', 'Tone->Tone']
rf.valid_power_levels = POWER_LEVELS
rf.valid_dtcs_codes = chirp_common.ALL_DTCS_CODES
rf.valid_bands = self.valid_freq
+ rf.valid_tuning_steps = TUNING_STEPS
return rf
# Do a download of the radio from the serial port
@@ -534,14 +569,13 @@ class Th9000Radio(chirp_common.CloneModeRadio,
def process_mmap(self):
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
-
- # Return a raw representation of the memory object, which
+ # Return a raw representation of the memory object, which
# is very helpful for development
def get_raw_memory(self, number):
return repr(self._memobj.memory[number])
# not working yet
- def _get_dcs_index(self, _mem,which):
+ def _get_dcs_index(self, _mem, which):
base = getattr(_mem, '%scode' % which)
extra = getattr(_mem, '%sdcsextra' % which)
return (int(extra) << 8) | int(base)
@@ -552,7 +586,6 @@ class Th9000Radio(chirp_common.CloneModeRadio,
base.set_value(index & 0xFF)
extra.set_value(index >> 8)
-
# Extract a high-level memory object from the low-level memory map
# This is called to populate a memory in the UI
def get_memory(self, number):
@@ -560,10 +593,10 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_mem = self._memobj.memory[number]
# get flag info
- cbyte = number / 8 ;
- cbit = 7 - (number % 8) ;
- setflag = self._memobj.csetflag[cbyte].c[cbit];
- skipflag = self._memobj.cskipflag[cbyte].c[cbit];
+ cbyte = number // 8
+ cbit = 7 - (number % 8)
+ setflag = self._memobj.csetflag[cbyte].c[cbit]
+ skipflag = self._memobj.cskipflag[cbyte].c[cbit]
mem = chirp_common.Memory()
@@ -573,31 +606,37 @@ class Th9000Radio(chirp_common.CloneModeRadio,
mem.empty = True
return mem
- mem.freq = int(_mem.freq) * 100
+ mem.freq = int(_mem.freq) * 100
+
+ # compensate for 6.25 and 12.5 kHz tuning steps, add 500 Hz if needed
+ lastdigit = int(_mem.freq) % 10
+ if (lastdigit == 2 or lastdigit == 7):
+ mem.freq += 50
+
mem.offset = int(_mem.offset) * 100
- mem.name = str(_mem.name).rstrip() # Set the alpha tag
+ # Set the alpha tag
+ mem.name = self.filter_name(str(_mem.name).rstrip())
mem.duplex = DUPLEXES[_mem.duplex]
mem.mode = MODES[_mem.channel_width]
mem.power = POWER_LEVELS[_mem.power]
rxtone = txtone = None
-
rxmode = TMODES[_mem.rxtmode]
txmode = TMODES[_mem.txtmode]
-
-
# doesn't work
if rxmode == "Tone":
rxtone = TONES[_mem.rxtone]
elif rxmode == "DTCS":
- rxtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(_mem,'rx')]
+ rxtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(
+ _mem, 'rx')]
if txmode == "Tone":
txtone = TONES[_mem.txtone]
elif txmode == "DTCS":
- txtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(_mem,'tx')]
+ txtone = chirp_common.ALL_DTCS_CODES[self._get_dcs_index(
+ _mem, 'tx')]
rxpol = _mem.rxinv and "R" or "N"
txpol = _mem.txinv and "R" or "N"
@@ -608,7 +647,6 @@ class Th9000Radio(chirp_common.CloneModeRadio,
mem.skip = "S" if skipflag == 1 else ""
-
# We'll consider any blank (i.e. 0MHz frequency) to be empty
if mem.freq == 0:
mem.empty = True
@@ -622,16 +660,16 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_mem = self._memobj.memory[mem.number]
- cbyte = mem.number / 8
- cbit = 7 - (mem.number % 8)
+ cbyte = mem.number // 8
+ cbit = 7 - (mem.number % 8)
if mem.empty:
self._memobj.csetflag[cbyte].c[cbit] = 1
self._memobj.cskipflag[cbyte].c[cbit] = 1
return
- self._memobj.csetflag[cbyte].c[cbit] = 0
- self._memobj.cskipflag[cbyte].c[cbit] = 1 if (mem.skip == "S") else 0
+ self._memobj.csetflag[cbyte].c[cbit] = 0
+ self._memobj.cskipflag[cbyte].c[cbit] = 1 if (mem.skip == "S") else 0
_mem.set_raw("\x00" * 32)
@@ -641,7 +679,6 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_mem.name = mem.name.ljust(7)[:7] # Store the alpha tag
_mem.duplex = DUPLEXES.index(mem.duplex)
-
try:
_mem.channel_width = MODES.index(mem.mode)
except ValueError:
@@ -657,17 +694,18 @@ class Th9000Radio(chirp_common.CloneModeRadio,
if txmode == "Tone":
_mem.txtone = TONES.index(txtone)
elif txmode == "DTCS":
- self._set_dcs_index(_mem,'tx',chirp_common.ALL_DTCS_CODES.index(txtone))
+ self._set_dcs_index(_mem, 'tx',
+ chirp_common.ALL_DTCS_CODES.index(txtone))
if rxmode == "Tone":
_mem.rxtone = TONES.index(rxtone)
elif rxmode == "DTCS":
- self._set_dcs_index(_mem, 'rx', chirp_common.ALL_DTCS_CODES.index(rxtone))
+ self._set_dcs_index(_mem, 'rx',
+ chirp_common.ALL_DTCS_CODES.index(rxtone))
_mem.txinv = txpol == "R"
_mem.rxinv = rxpol == "R"
-
if mem.power:
_mem.power = POWER_LEVELS.index(mem.power)
else:
@@ -678,9 +716,9 @@ class Th9000Radio(chirp_common.CloneModeRadio,
_freqrange = self._memobj.freqrange
_slabel = self._memobj.slabel
- basic = RadioSettingGroup("basic","Global Settings")
- freqrange = RadioSettingGroup("freqrange","Frequency Ranges")
- top = RadioSettingGroup("top","All Settings",basic,freqrange)
+ basic = RadioSettingGroup("basic", "Global Settings")
+ freqrange = RadioSettingGroup("freqrange", "Frequency Ranges")
+ top = RadioSettingGroup("top", "All Settings", basic, freqrange)
settings = RadioSettings(top)
def _filter(name):
@@ -691,66 +729,78 @@ class Th9000Radio(chirp_common.CloneModeRadio,
else:
filtered += ""
return filtered
-
- val = RadioSettingValueString(0,7,_filter(_slabel.startname))
- rs = RadioSetting("startname","Startup Label",val)
+
+ val = RadioSettingValueString(0, 7, _filter(_slabel.startname))
+ rs = RadioSetting("startname", "Startup Label", val)
basic.append(rs)
- rs = RadioSetting("bg_color","LCD Color",
- RadioSettingValueList(BGCOLOR_LIST, BGCOLOR_LIST[_settings.bg_color]))
+ rs = RadioSetting("bg_color", "LCD Color",
+ RadioSettingValueList(BGCOLOR_LIST, BGCOLOR_LIST[
+ _settings.bg_color]))
basic.append(rs)
- rs = RadioSetting("bg_brightness","LCD Brightness",
- RadioSettingValueList(BGBRIGHT_LIST, BGBRIGHT_LIST[_settings.bg_brightness]))
+ rs = RadioSetting("bg_brightness", "LCD Brightness",
+ RadioSettingValueList(BGBRIGHT_LIST, BGBRIGHT_LIST[
+ _settings.bg_brightness]))
basic.append(rs)
- rs = RadioSetting("squelch","Squelch Level",
- RadioSettingValueList(SQUELCH_LIST, SQUELCH_LIST[_settings.squelch]))
+ rs = RadioSetting("squelch", "Squelch Level",
+ RadioSettingValueList(SQUELCH_LIST, SQUELCH_LIST[
+ _settings.squelch]))
basic.append(rs)
- rs = RadioSetting("timeout_timer","Timeout Timer (TOT)",
- RadioSettingValueList(TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout_timer]))
+ rs = RadioSetting("timeout_timer", "Timeout Timer (TOT)",
+ RadioSettingValueList(TIMEOUT_LIST, TIMEOUT_LIST[
+ _settings.timeout_timer]))
basic.append(rs)
- rs = RadioSetting("auto_power_off","Auto Power Off (APO)",
- RadioSettingValueList(APO_LIST, APO_LIST[_settings.auto_power_off]))
+ rs = RadioSetting("auto_power_off", "Auto Power Off (APO)",
+ RadioSettingValueList(APO_LIST, APO_LIST[
+ _settings.auto_power_off]))
basic.append(rs)
- rs = RadioSetting("voice_prompt","Beep Prompt",
- RadioSettingValueList(BEEP_LIST, BEEP_LIST[_settings.voice_prompt]))
+ rs = RadioSetting("voice_prompt", "Beep Prompt",
+ RadioSettingValueList(BEEP_LIST, BEEP_LIST[
+ _settings.voice_prompt]))
basic.append(rs)
- rs = RadioSetting("tbst_freq","Tone Burst Frequency",
- RadioSettingValueList(TBSTFREQ_LIST, TBSTFREQ_LIST[_settings.tbst_freq]))
+ rs = RadioSetting("tbst_freq", "Tone Burst Frequency",
+ RadioSettingValueList(TBSTFREQ_LIST, TBSTFREQ_LIST[
+ _settings.tbst_freq]))
basic.append(rs)
- rs = RadioSetting("choose_tx_power","Max Level of TX Power",
- RadioSettingValueList(TXPWR_LIST, TXPWR_LIST[_settings.choose_tx_power]))
+ rs = RadioSetting("choose_tx_power", "Max Level of TX Power",
+ RadioSettingValueList(TXPWR_LIST, TXPWR_LIST[
+ _settings.choose_tx_power]))
basic.append(rs)
- (flow,fhigh) = self.valid_freq[0]
- flow /= 1000
+ (flow, fhigh) = self.valid_freq[0]
+ flow /= 1000
fhigh /= 1000
- fmidrange = (fhigh- flow)/2
+ fmidrange = (fhigh - flow) / 2
- rs = RadioSetting("txrangelow","TX Freq, Lower Limit (khz)", RadioSettingValueInteger(flow,
- flow + fmidrange,
- int(_freqrange.txrangelow)/10))
+ rs = RadioSetting("txrangelow", "TX Freq, Lower Limit (khz)",
+ RadioSettingValueInteger(
+ flow, flow + fmidrange,
+ int(_freqrange.txrangelow) / 10))
freqrange.append(rs)
- rs = RadioSetting("txrangehi","TX Freq, Upper Limit (khz)", RadioSettingValueInteger(fhigh-fmidrange,
- fhigh,
- int(_freqrange.txrangehi)/10))
+ rs = RadioSetting("txrangehi", "TX Freq, Upper Limit (khz)",
+ RadioSettingValueInteger(
+ fhigh-fmidrange, fhigh,
+ int(_freqrange.txrangehi) / 10))
freqrange.append(rs)
- rs = RadioSetting("rxrangelow","RX Freq, Lower Limit (khz)", RadioSettingValueInteger(flow,
- flow+fmidrange,
- int(_freqrange.rxrangelow)/10))
+ rs = RadioSetting("rxrangelow", "RX Freq, Lower Limit (khz)",
+ RadioSettingValueInteger(
+ flow, flow+fmidrange,
+ int(_freqrange.rxrangelow) / 10))
freqrange.append(rs)
- rs = RadioSetting("rxrangehi","RX Freq, Upper Limit (khz)", RadioSettingValueInteger(fhigh-fmidrange,
- fhigh,
- int(_freqrange.rxrangehi)/10))
+ rs = RadioSetting("rxrangehi", "RX Freq, Upper Limit (khz)",
+ RadioSettingValueInteger(
+ fhigh-fmidrange, fhigh,
+ int(_freqrange.rxrangehi) / 10))
freqrange.append(rs)
return settings
@@ -760,93 +810,159 @@ class Th9000Radio(chirp_common.CloneModeRadio,
return self._get_settings()
except:
import traceback
- LOG.error( "failed to parse settings")
+ LOG.error("failed to parse settings")
traceback.print_exc()
return None
- def set_settings(self,settings):
+ def set_settings(self, settings):
_settings = self._memobj.settings
for element in settings:
- if not isinstance(element,RadioSetting):
+ if not isinstance(element, RadioSetting):
self.set_settings(element)
continue
else:
try:
name = element.get_name()
- if name in ["txrangelow","txrangehi","rxrangelow","rxrangehi"]:
- LOG.debug( "setting %s = %s" % (name,int(element.value)*10))
- setattr(self._memobj.freqrange,name,int(element.value)*10)
+ if name in ["txrangelow", "txrangehi", "rxrangelow",
+ "rxrangehi"]:
+ LOG.debug("setting %s = %s" % (name,
+ int(element.value) * 10))
+ setattr(self._memobj.freqrange, name,
+ int(element.value) * 10)
continue
if name in ["startname"]:
- LOG.debug( "setting %s = %s" % (name, element.value))
- setattr(self._memobj.slabel,name,element.value)
+ LOG.debug("setting %s = %s" % (name, element.value))
+ setattr(self._memobj.slabel, name, element.value)
continue
obj = _settings
setting = element.get_name()
if element.has_apply_callback():
- LOG.debug( "using apply callback")
+ LOG.debug("using apply callback")
element.run_apply_callback()
else:
- LOG.debug( "Setting %s = %s" % (setting, element.value))
+ LOG.debug("Setting %s = %s" % (setting,
+ element.value))
setattr(obj, setting, element.value)
- except Exception, e:
- LOG.debug( element.get_name())
+ except Exception as e:
+ LOG.debug(element.get_name())
raise
@classmethod
def match_model(cls, filedata, filename):
- if MMAPSIZE == len(filedata):
- (flow,fhigh) = cls.valid_freq[0]
- flow /= 1000000
- fhigh /= 1000000
-
- txmin=ord(filedata[0x200])*100 + (ord(filedata[0x201])>>4)*10 + ord(filedata[0x201])%16
- txmax=ord(filedata[0x204])*100 + (ord(filedata[0x205])>>4)*10 + ord(filedata[0x205])%16
- rxmin=ord(filedata[0x208])*100 + (ord(filedata[0x209])>>4)*10 + ord(filedata[0x209])%16
- rxmax=ord(filedata[0x20C])*100 + (ord(filedata[0x20D])>>4)*10 + ord(filedata[0x20D])%16
+ return False
- if ( rxmin >= flow and rxmax <= fhigh and txmin >= flow and txmax <= fhigh ):
- return True
+def match_orig_model(cls, filedata, filename):
+ # This old-style file detection should only be used for the
+ # original TYT TH9000 classes for compatibility
+ if cls.VENDOR != 'TYT' or 'TH9000_' not in cls.MODEL:
return False
-# Declaring Aliases (Clones of the real radios)
-class LT580VHF(chirp_common.Alias):
- VENDOR = "LUITON"
- MODEL = "LT-580_VHF"
+ if MMAPSIZE == len(filedata):
+ (flow, fhigh) = cls.valid_freq[0]
+ flow /= 1000000
+ fhigh /= 1000000
+ txmin = filedata[0x200] * 100 + (filedata[0x201] >> 4) \
+ * 10 + filedata[0x201] % 16
+ txmax = filedata[0x204] * 100 + (filedata[0x205] >> 4) \
+ * 10 + filedata[0x205] % 16
+ rxmin = filedata[0x208] * 100 + (filedata[0x209] >> 4) \
+ * 10 + filedata[0x209] % 16
+ rxmax = filedata[0x20C] * 100 + (filedata[0x20D] >> 4) \
+ * 10 + filedata[0x20D] % 16
-class LT580UHF(chirp_common.Alias):
- VENDOR = "LUITON"
- MODEL = "LT-580_UHF"
+ if (rxmin >= flow and rxmax <= fhigh and txmin >= flow and
+ txmax <= fhigh):
+ return True
+
+ return False
@directory.register
class Th9000220Radio(Th9000Radio):
"""TYT TH-9000 220"""
- VENDOR = "TYT"
- MODEL = "TH9000_220"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000_220"
+ BAUD_RATE = 9600
valid_freq = [(220000000, 260000000)]
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return match_orig_model(cls, filedata, filename)
+
+
@directory.register
class Th9000144Radio(Th9000220Radio):
"""TYT TH-9000 144"""
- VENDOR = "TYT"
- MODEL = "TH9000_144"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000_144"
+ BAUD_RATE = 9600
valid_freq = [(136000000, 174000000)]
- ALIASES = [LT580VHF, ]
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return match_orig_model(cls, filedata, filename)
+
@directory.register
class Th9000440Radio(Th9000220Radio):
"""TYT TH-9000 440"""
- VENDOR = "TYT"
- MODEL = "TH9000_440"
- BAUD_RATE = 9600
+ VENDOR = "TYT"
+ MODEL = "TH9000_440"
+ BAUD_RATE = 9600
+ valid_freq = [(400000000, 490000000)]
+
+ @classmethod
+ def match_model(cls, filedata, filename):
+ return match_orig_model(cls, filedata, filename)
+
+
+@directory.register
+class Lt580VHFRadio(Th9000144Radio):
+ """Luiton LT-580 VHF"""
+ VENDOR = "LUITON"
+ MODEL = "LT-580_VHF"
+
+
+@directory.register
+class Lt580UHFRadio(Th9000440Radio):
+ """Luiton LT-580 UHF"""
+ VENDOR = "LUITON"
+ MODEL = "LT-580_UHF"
+
+
+@directory.register
+class RT9000DVHFRadio(Th9000Radio):
+ """Retevis RT9000D VHF"""
+ VENDOR = "Retevis"
+ MODEL = "RT9000D_136-174"
+ valid_freq = [(136000000, 174000000)]
+
+
+@directory.register
+class RT9000D220Radio(Th9000Radio):
+ """Retevis RT9000D 220"""
+ VENDOR = "Retevis"
+ MODEL = "RT9000D_220-260"
+ valid_freq = [(220000000, 260000000)]
+
+
+@directory.register
+class RT9000DUHFRadio(Th9000Radio):
+ """Retevis RT9000D UHF"""
+ VENDOR = "Retevis"
+ MODEL = "RT9000D_400-490"
valid_freq = [(400000000, 490000000)]
- ALIASES = [LT580UHF, ]
+
+
+@directory.register
+class RT9000D6688Radio(Th9000Radio):
+ """Retevis RT9000D 66-88"""
+ VENDOR = "Retevis"
+ MODEL = "RT9000D_66-88"
+ valid_freq = [(66000000, 88000000)]
diff --git a/chirp/drivers/th9800.py b/chirp/drivers/th9800.py
index 2dba301..027324f 100644
--- a/chirp/drivers/th9800.py
+++ b/chirp/drivers/th9800.py
@@ -170,6 +170,34 @@ STEPS = [2.5, 5.0, 6.25, 7.5, 8.33, 10.0, 12.5,
15.0, 20.0, 25.0, 30.0, 50.0, 100.0]
+def isValidDate(month, day, year):
+ today = date.today()
+
+ monthlist1 = [1, 3, 5, 7, 8, 10, 12] # monthlist for months with 31 days.
+ monthlist2 = [4, 6, 9, 11] # monthlist for months with 30 days.
+ monthlist3 = [2, ] # monthlist for month with 28 days.
+
+ if month in monthlist1:
+ max1 = 31
+ elif month in monthlist2:
+ max1 = 30
+ elif month in monthlist3:
+ if ((year % 4) == 0 and (year % 100) != 0 or (year % 400) == 0):
+ max1 = 29
+ else:
+ max1 = 28
+ if(month < 1 or month > 12):
+ LOG.debug("Invalid 'Last Program Date: Month'")
+ return False
+ elif(day < 1 or day > max1):
+ LOG.debug("Invalid 'Last Program Date: Day'")
+ return False
+ elif(year < 2014 or year > today.year):
+ LOG.debug("Invalid 'Last Program Date: Year'")
+ return False
+ return True
+
+
class TYTTH9800Base(chirp_common.Radio):
"""Base class for TYT TH-9800"""
VENDOR = "TYT"
@@ -209,7 +237,7 @@ class TYTTH9800Base(chirp_common.Radio):
"""get active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
enabled = bank[index] & mask
@@ -222,7 +250,7 @@ class TYTTH9800Base(chirp_common.Radio):
"""set active flag for channel active,
scan enable, or priority banks"""
bank = getattr(self._memobj, banktype)
- index = (num - 1) / 8
+ index = (num - 1) // 8
bitpos = (num - 1) % 8
mask = 2**bitpos
if enable:
@@ -511,9 +539,9 @@ class TYTTH9800Base(chirp_common.Radio):
basic.append(RadioSetting(
"p4", "P4 Function",
RadioSettingValueList(MICKEYFUNC, MICKEYFUNC[_settings.p4])))
-# opts = ["0", "1"]
-# basic.append(RadioSetting("x", "Desc",
-# RadioSettingValueList(opts, opts[_settings.x])))
+ # opts = ["0", "1"]
+ # basic.append(RadioSetting("x", "Desc",
+ # RadioSettingValueList(opts, opts[_settings.x])))
def _filter(name):
filtered = ""
@@ -539,8 +567,16 @@ class TYTTH9800Base(chirp_common.Radio):
rs = RadioSetting("code", "Model Code", rsvs)
info.append(rs)
- progdate = "%d/%d/%d" % (_info.prog_mon, _info.prog_day,
- _info.prog_yr)
+ mm = int(_info.prog_mon)
+ dd = int(_info.prog_day)
+ yy = int(_info.prog_yr)
+
+ Valid_Date = isValidDate(mm, dd, yy)
+
+ if Valid_Date:
+ progdate = "%d/%d/%d" % (mm, dd, yy)
+ else:
+ progdate = "Invalid"
rsvs = RadioSettingValueString(0, 10, progdate)
rsvs.set_mutable(False)
rs = RadioSetting("progdate", "Last Program Date", rsvs)
@@ -598,7 +634,7 @@ class TYTTH9800Base(chirp_common.Radio):
LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -693,7 +729,7 @@ def _upload(radio, memsize=0xF400, blocksize=0x80):
if data != radio._mmap[:radio._mmap_offset]:
raise errors.RadioError(
- "Model mis-match: \n%s\n%s" %
+ "Model mismatch: \n%s\n%s" %
(util.hexprint(data),
util.hexprint(radio._mmap[:radio._mmap_offset])))
# in the factory software they update the last program date when
@@ -704,10 +740,16 @@ def _upload(radio, memsize=0xF400, blocksize=0x80):
d = today.day
_info = radio._memobj.info
- ly = _info.prog_yr
- lm = _info.prog_mon
- ld = _info.prog_day
- LOG.debug("Updating last program date:%d/%d/%d" % (lm, ld, ly))
+ ly = int(_info.prog_yr)
+ lm = int(_info.prog_mon)
+ ld = int(_info.prog_day)
+
+ Valid_Date = isValidDate(lm, ld, ly)
+
+ if Valid_Date:
+ LOG.debug("Updating last program date:%d/%d/%d" % (lm, ld, ly))
+ else:
+ LOG.debug("Updating last program date: Invalid")
LOG.debug(" to today:%d/%d/%d" % (m, d, y))
_info.prog_yr = y
@@ -761,7 +803,7 @@ class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio,
if len(filedata) != cls._memsize:
return False
# TYT set this model for TH-7800 _AND_ TH-9800
- if not filedata[0xfe18:0xfe1e] == "TH9800":
+ if not filedata[0xfe18:0xfe1e] == b"TH9800":
return False
# TH-9800 bandlimits differ from TH-7800. First band is used
# (non-zero).
@@ -785,7 +827,7 @@ class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio,
def sync_in(self):
try:
self._mmap = _download(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
self.process_mmap()
@@ -793,6 +835,6 @@ class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio,
def sync_out(self):
try:
_upload(self)
- except Exception, e:
+ except Exception as e:
raise errors.RadioError(
"Failed to communicate with the radio: %s" % e)
diff --git a/chirp/drivers/th_uv8000.py b/chirp/drivers/th_uv8000.py
index 3897d54..2e496ca 100644
--- a/chirp/drivers/th_uv8000.py
+++ b/chirp/drivers/th_uv8000.py
@@ -1,5 +1,6 @@
# Copyright 2019: Rick DeWitt (RJD), <aa0rd@yahoo.com>
# Version 1.0 for TYT-UV8000D/E
+# 1.1 Fixes issue #8339, Priority chan OFF (0)
# Thanks to Damon Schaefer (K9CQB) and the Loudoun County, VA ARES
# club for the donated radio.
# And thanks to Ian Harris (VA3IHX) for decoding the memory map.
@@ -622,7 +623,7 @@ class THUV8000Radio(chirp_common.CloneModeRadio):
if isinstance(number, str):
return self._get_special(number)
elif number < 0:
- # I can't stop delete operation from loosing extd_number but
+ # I can't stop delete operation from losing extd_number but
# I know how to get it back
return self._get_special(self.SPECIAL_MEMORIES_REV[number])
else:
@@ -886,7 +887,7 @@ class THUV8000Radio(chirp_common.CloneModeRadio):
# All mem.extra << Once the channel is defined
for setting in mem.extra:
- # Overide list strings with signed value
+ # Override list strings with signed value
if setting.get_name() == "ptt":
sx = str(setting.value)
for i in range(0, 4):
@@ -1250,10 +1251,8 @@ class THUV8000Radio(chirp_common.CloneModeRadio):
scn.append(rset)
val = _sets.prichan
- if val <= 0:
- val = 1
- rx = RadioSettingValueInteger(1, 128, val)
- rset = RadioSetting("setstuf.prichan", "Priority Channel", rx)
+ rx = RadioSettingValueInteger(0, 128, val)
+ rset = RadioSetting("setstuf.prichan", "Priority Channel (0:Off)", rx)
scn.append(rset)
# FM Broadcast Settings
@@ -1276,7 +1275,7 @@ class THUV8000Radio(chirp_common.CloneModeRadio):
rx = RadioSettingValueBoolean(bool(_sets.rxinhib))
rset = RadioSetting("setstuf.rxinhib",
- "Rcvr Will Interupt FM (DW)", rx)
+ "Rcvr Will Interrupt FM (DW)", rx)
fmb.append(rset)
_fmfrq = self._memobj.fm_stations
@@ -1486,6 +1485,6 @@ class THUV8000Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/th_uv88.py b/chirp/drivers/th_uv88.py
new file mode 100644
index 0000000..e941a45
--- /dev/null
+++ b/chirp/drivers/th_uv88.py
@@ -0,0 +1,1112 @@
+# Version 1.0 for TYT-UV88
+# Initial radio protocol decode, channels and memory layout
+# by James Berry <james@coppermoth.com>, Summer 2020
+# Additional configuration and help, Jim Unroe <rock.unroe@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.
+
+import time
+import struct
+import logging
+import re
+import math
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
+from textwrap import dedent
+
+LOG = logging.getLogger(__name__)
+
+MEM_FORMAT = """
+struct chns {
+ ul32 rxfreq;
+ ul32 txfreq;
+ ul16 scramble:4
+ rxtone:12; //decode:12
+ ul16 decodeDSCI:1
+ encodeDSCI:1
+ unk1:1
+ unk2:1
+ txtone:12; //encode:12
+ u8 power:2
+ wide:2
+ b_lock:2
+ unk3:2;
+ u8 unk4:3
+ signal:2
+ displayName:1
+ unk5:2;
+ u8 unk6:2
+ pttid:2
+ step:4; // not required
+ u8 name[6];
+};
+
+struct vfo {
+ ul32 rxfreq;
+ ul32 txfreq; // displayed as an offset
+ ul16 scramble:4
+ rxtone:12; //decode:12
+ ul16 decodeDSCI:1
+ encodeDSCI:1
+ unk1:1
+ unk2:1
+ txtone:12; //encode:12
+ u8 power:2
+ wide:2
+ b_lock:2
+ unk3:2;
+ u8 unk4:3
+ signal:2
+ displayName:1
+ unk5:2;
+ u8 unk6:2
+ pttid:2
+ step:4;
+ u8 name[6];
+};
+
+struct chname {
+ u8 extra_name[10];
+};
+
+#seekto 0x0000;
+struct chns chan_mem[199];
+
+#seekto 0x1960;
+struct chname chan_name[199];
+
+#seekto 0x1180;
+struct {
+ u8 bitmap[26]; // one bit for each channel marked in use
+} chan_avail;
+
+#seekto 0x11A0;
+struct {
+ u8 bitmap[26]; // one bit for each channel skipped
+} chan_skip;
+
+#seekto 0x1140;
+struct {
+ u8 autoKeylock:1, // 0x1140 [18] *OFF, On
+ unk_bit6_5:1, //
+ vfomrmodeb:1, // *VFO B, MR B
+ vfomrmode:1, // *VFO, MR
+ unk_bit3_0:4; //
+ u8 mrAch; // 0x1141 MR A Channel #
+ u8 mrBch; // 0x1142 MR B Channel #
+ u8 unk_bit7_3:5, //
+ ab:1, // * A, B
+ unk_bit1_0:2; //
+} workmodesettings;
+
+#seekto 0x1160;
+struct {
+ u8 introScreen1[12]; // 0x1160 *Intro Screen Line 1(truncated to 12 alpha
+ // text characters)
+ u8 offFreqVoltage : 3, // 0x116C unknown referred to in code but not on
+ // screen
+ unk_bit4 : 1, //
+ sqlLevel : 4; // [05] *OFF, 1-9
+ u8 beep : 1 // 0x116D [09] *OFF, On
+ callKind : 2, // code says 1750,2100,1000,1450 as options
+ // not on screen
+ introScreen: 2, // [20] *OFF, Voltage, Char String
+ unkstr2: 2, //
+ txChSelect : 1; // [02] *Last CH, Main CH
+ u8 autoPowOff : 3, // 0x116E not on screen? OFF, 30Min, 1HR, 2HR
+ unk : 1, //
+ tot : 4; // [11] *OFF, 30 Second, 60 Second, 90 Second,
+ // ... , 270 Second
+ u8 unk_bit7:1, // 0x116F
+ roger:1, // [14] *OFF, On
+ dailDef:1, // Unknown - 'Volume, Frequency'
+ language:1, // ?Chinese, English (English only FW BQ1.38+)
+ unk_bit3:1, //
+ endToneElim:1, // *OFF, Frequency
+ unkCheckBox1:1, //
+ unkCheckBox2:1; //
+ u8 scanResumeTime : 2, // 0x1170 2S, 5S, 10S, 15S (not on screen)
+ disMode : 2, // [33] *Frequency, Channel, Name
+ scanType: 2, // [17] *To, Co, Se
+ ledMode: 2; // [07] *Off, On, Auto
+ u8 unky; // 0x1171
+ u8 str6; // 0x1172 Has flags to do with logging - factory
+ // enabled (bits 16,64,128)
+ u8 unk; // 0x1173
+ u8 swAudio : 1, // 0x1174 [19] *OFF, On
+ radioMoni : 1, // [34] *OFF, On
+ keylock : 1, // [18] *OFF, On
+ dualWait : 1, // [06] *OFF, On
+ unk_bit3 : 1, //
+ light : 3; // [08] *1, 2, 3, 4, 5, 6, 7
+ u8 voxSw : 1, // 0x1175 [13] *OFF, On
+ voxDelay: 4, // *0.5S, 1.0S, 1.5S, 2.0S, 2.5S, 3.0S, 3.5S,
+ // 4.0S, 4.5S, 5.0S
+ voxLevel : 3; // [03] *1, 2, 3, 4, 5, 6, 7
+ u8 str9 : 4, // 0x1176
+ saveMode : 2, // [16] *OFF, 1:1, 1:2, 1:4
+ keyMode : 2; // [32] *ALL, PTT, KEY, Key & Side Key
+ u8 unk2; // 0x1177
+ u8 unk3; // 0x1178
+ u8 unk4; // 0x1179
+ u8 name2[6]; // 0x117A unused
+} basicsettings;
+
+#seekto 0x191E;
+struct {
+ u8 unknown191e:4, //
+ region:4; // 0x191E Radio Region (read only)
+ // 0 = Unlocked TX: 136-174 MHz / 400-480 MHz
+ // 2-3 = Unknown
+ // 3 = EU TX: 144-146 MHz / 430-440 MHz
+ // 4 = US TX: 144-148 MHz / 420-450 MHz
+ // 5-15 = Unknown
+} settings2;
+
+#seekto 0x1940;
+struct {
+ char name1[15]; // Intro Screen Line 1 (16 alpha text characters)
+ u8 unk1;
+ char name2[15]; // Intro Screen Line 2 (16 alpha text characters)
+ u8 unk2;
+} openradioname;
+
+struct fm_chn {
+ ul32 rxfreq;
+};
+
+#seekto 0x2180;
+struct fm_chn fm_stations[24];
+
+#seekto 0x021E0;
+struct {
+ u8 fmset[4];
+} fmmap;
+
+#seekto 0x21E4;
+struct {
+ ul32 fmcur;
+} fmfrqs;
+
+"""
+
+MEM_SIZE = 0x22A0
+BLOCK_SIZE = 0x20
+STIMEOUT = 2
+BAUDRATE = 57600
+
+# Channel power: 3 levels
+POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00),
+ chirp_common.PowerLevel("Mid", watts=2.50),
+ chirp_common.PowerLevel("Low", watts=0.50)]
+
+SCRAMBLE_LIST = ["OFF", "1", "2", "3", "4", "5", "6", "7", "8"]
+B_LOCK_LIST = ["OFF", "Sub", "Carrier"]
+OPTSIG_LIST = ["OFF", "DTMF", "2TONE", "5TONE"]
+PTTID_LIST = ["Off", "BOT", "EOT", "Both"]
+STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0, 50.0, 100.0]
+LIST_STEPS = [str(x) for x in STEPS]
+
+
+def _clean_buffer(radio):
+ radio.pipe.timeout = 0.005
+ junk = radio.pipe.read(256)
+ radio.pipe.timeout = STIMEOUT
+ if junk:
+ LOG.debug("Got %i bytes of junk before starting" % len(junk))
+
+
+def _rawrecv(radio, amount):
+ """Raw read from the radio device"""
+ data = ""
+ try:
+ data = radio.pipe.read(amount)
+ except Exception:
+ _exit_program_mode(radio)
+ msg = "Generic error reading data from radio; check your cable."
+ raise errors.RadioError(msg)
+
+ if len(data) != amount:
+ _exit_program_mode(radio)
+ msg = "Error reading from radio: not the amount of data we want."
+ raise errors.RadioError(msg)
+
+ return data
+
+
+def _rawsend(radio, data):
+ """Raw send to the radio device"""
+ try:
+ radio.pipe.write(data)
+ except Exception:
+ raise errors.RadioError("Error sending data to radio")
+
+
+def _make_read_frame(addr, length):
+ frame = "\xFE\xFE\xEE\xEF\xEB"
+ """Pack the info in the header format"""
+ frame += struct.pack(">ih", addr, length)
+
+ frame += "\xFD"
+ # Return the data
+ return frame
+
+
+def _make_write_frame(addr, length, data=""):
+ frame = "\xFE\xFE\xEE\xEF\xE4"
+
+ """Pack the info in the header format"""
+ output = struct.pack(">ih", addr, length)
+ # Add the data if set
+ if len(data) != 0:
+ output += data
+
+ frame += output
+ frame += _calculate_checksum(output)
+
+ frame += "\xFD"
+ # Return the data
+ return frame
+
+
+def _calculate_checksum(data):
+ num = 0
+ for x in range(0, len(data)):
+ num = (num + ord(data[x])) % 256
+
+ if num == 0:
+ return chr(0)
+
+ return chr(256 - num)
+
+
+def _recv(radio, addr, length):
+ """Get data from the radio """
+
+ data = _rawrecv(radio, length)
+
+ # DEBUG
+ LOG.info("Response:")
+ LOG.debug(util.hexprint(data))
+
+ return data
+
+
+def _do_ident(radio):
+ """Put the radio in PROGRAM mode & identify it"""
+ radio.pipe.baudrate = BAUDRATE
+ radio.pipe.parity = "N"
+ radio.pipe.timeout = STIMEOUT
+
+ # Flush input buffer
+ _clean_buffer(radio)
+
+ # Ident radio
+ magic = radio._magic0
+ _rawsend(radio, magic)
+ ack = _rawrecv(radio, 36)
+
+ if not ack.startswith(radio._fingerprint) or not ack.endswith("\xFD"):
+ _exit_program_mode(radio)
+ if ack:
+ LOG.debug(repr(ack))
+ raise errors.RadioError("Radio did not respond as expected (A)")
+
+ return True
+
+
+def _exit_program_mode(radio):
+ # This may be the last part of a read
+ magic = radio._magic5
+ _rawsend(radio, magic)
+ _clean_buffer(radio)
+
+
+def _download(radio):
+ """Get the memory map"""
+
+ # Put radio in program mode and identify it
+ _do_ident(radio)
+
+ # Enter read mode
+ magic = radio._magic2
+ _rawsend(radio, magic)
+ ack = _rawrecv(radio, 7)
+ if ack != "\xFE\xFE\xEF\xEE\xE6\x00\xFD":
+ _exit_program_mode(radio)
+ if ack:
+ LOG.debug(repr(ack))
+ raise errors.RadioError("Radio did not respond to enter read mode")
+
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = MEM_SIZE / BLOCK_SIZE
+ status.msg = "Cloning from radio..."
+ radio.status_fn(status)
+
+ data = ""
+ for addr in range(0, MEM_SIZE, BLOCK_SIZE):
+ frame = _make_read_frame(addr, BLOCK_SIZE)
+ # DEBUG
+ LOG.debug("Frame=" + util.hexprint(frame))
+
+ # Sending the read request
+ _rawsend(radio, frame)
+
+ # Now we read data
+ d = _recv(radio, addr, BLOCK_SIZE + 13)
+
+ LOG.debug("Response Data= " + util.hexprint(d))
+
+ if not d.startswith("\xFE\xFE\xEF\xEE\xE4"):
+ LOG.warning("Incorrect start")
+ if not d.endswith("\xFD"):
+ LOG.warning("Incorrect end")
+ # could validate the block data
+
+ # Aggregate the data
+ data += d[11:-2]
+
+ # UI Update
+ status.cur = addr / BLOCK_SIZE
+ status.msg = "Cloning from radio..."
+ radio.status_fn(status)
+
+ _exit_program_mode(radio)
+
+ return data
+
+
+def _upload(radio):
+ """Upload procedure"""
+ # Put radio in program mode and identify it
+ _do_ident(radio)
+
+ magic = radio._magic3
+ _rawsend(radio, magic)
+ ack = _rawrecv(radio, 7)
+ if ack != "\xFE\xFE\xEF\xEE\xE6\x00\xFD":
+ _exit_program_mode(radio)
+ if ack:
+ LOG.debug(repr(ack))
+ raise errors.RadioError("Radio did not respond to enter write mode")
+
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ status.max = MEM_SIZE / BLOCK_SIZE
+ status.msg = "Cloning to radio..."
+ radio.status_fn(status)
+
+ # The fun starts here
+ for addr in range(0, MEM_SIZE, BLOCK_SIZE):
+ # Official programmer skips writing these memory locations
+ if addr >= 0x1680 and addr < 0x1940:
+ continue
+
+ # Sending the data
+ data = radio.get_mmap()[addr:addr + BLOCK_SIZE]
+
+ frame = _make_write_frame(addr, BLOCK_SIZE, data)
+ LOG.warning("Frame:%s:" % util.hexprint(frame))
+ _rawsend(radio, frame)
+
+ ack = _rawrecv(radio, 7)
+ LOG.debug("Response Data= " + util.hexprint(ack))
+
+ if not ack.startswith("\xFE\xFE\xEF\xEE\xE6\x00\xFD"):
+ LOG.warning("Unexpected response")
+ _exit_program_mode(radio)
+ msg = "Bad ack writing block 0x%04x" % addr
+ raise errors.RadioError(msg)
+
+ # UI Update
+ status.cur = addr / BLOCK_SIZE
+ status.msg = "Cloning to radio..."
+ radio.status_fn(status)
+
+ _exit_program_mode(radio)
+
+
+def _do_map(chn, sclr, mary):
+ """Set or Clear the chn (1-128) bit in mary[] word array map"""
+ # chn is 1-based channel, sclr:1 = set, 0= = clear, 2= return state
+ # mary[] is u8 array, but the map is by nibbles
+ ndx = int(math.floor((chn - 1) / 8))
+ bv = (chn - 1) % 8
+ msk = 1 << bv
+ mapbit = sclr
+ if sclr == 1: # Set the bit
+ mary[ndx] = mary[ndx] | msk
+ elif sclr == 0: # clear
+ mary[ndx] = mary[ndx] & (~ msk) # ~ is complement
+ else: # return current bit state
+ mapbit = 0
+ if (mary[ndx] & msk) > 0:
+ mapbit = 1
+ return mapbit
+
+
+@directory.register
+class THUV88Radio(chirp_common.CloneModeRadio):
+ """TYT UV88 Radio"""
+ VENDOR = "TYT"
+ MODEL = "TH-UV88"
+ MODES = ['WFM', 'FM', 'NFM']
+ TONES = chirp_common.TONES
+ DTCS_CODES = chirp_common.DTCS_CODES
+ NAME_LENGTH = 10
+ DTMF_CHARS = list("0123456789ABCD*#")
+ # 136-174, 400-480
+ VALID_BANDS = [(136000000, 174000000), (400000000, 480000000)]
+
+ # Valid chars on the LCD
+ VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
+ "`!\"#$%&'()*+,-./:;<=>?@[]^_"
+
+ _magic0 = "\xFE\xFE\xEE\xEF\xE0" + "UV88" + "\xFD"
+ _magic2 = "\xFE\xFE\xEE\xEF\xE2" + "UV88" + "\xFD"
+ _magic3 = "\xFE\xFE\xEE\xEF\xE3" + "UV88" + "\xFD"
+ _magic5 = "\xFE\xFE\xEE\xEF\xE5" + "UV88" + "\xFD"
+ _fingerprint = "\xFE\xFE\xEF\xEE\xE1" + "UV88"
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.info = \
+ (cls.VENDOR + ' ' + cls.MODEL + '\n')
+
+ rp.pre_download = _(dedent("""\
+ This is an early stage beta driver
+ """))
+ rp.pre_upload = _(dedent("""\
+ This is an early stage beta driver - upload at your own risk
+ """))
+ return rp
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.has_settings = True
+ rf.has_bank = False
+ rf.has_comment = False
+ rf.has_tuning_step = False # Not as chan feature
+ rf.valid_tuning_steps = STEPS
+ rf.can_odd_split = True
+ rf.has_name = True
+ rf.has_offset = True
+ rf.has_mode = True
+ rf.has_dtcs = True
+ rf.has_rx_dtcs = True
+ rf.has_dtcs_polarity = True
+ rf.has_ctone = True
+ rf.has_cross = True
+ rf.has_sub_devices = False
+ rf.valid_name_length = self.NAME_LENGTH
+ rf.valid_modes = self.MODES
+ rf.valid_characters = self.VALID_CHARS
+ rf.valid_duplexes = ["", "-", "+", "split", "off"]
+ rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
+ rf.valid_cross_modes = ["Tone->Tone", "DTCS->", "->DTCS",
+ "Tone->DTCS", "DTCS->Tone", "->Tone",
+ "DTCS->DTCS"]
+ rf.valid_skips = []
+ rf.valid_power_levels = POWER_LEVELS
+ rf.valid_dtcs_codes = chirp_common.ALL_DTCS_CODES # this is just to
+ # get it working, not sure this is right
+ rf.valid_bands = self.VALID_BANDS
+ rf.memory_bounds = (1, 199)
+ rf.valid_skips = ["", "S"]
+ return rf
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ data = _download(self)
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = memmap.MemoryMap(data)
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+
+ try:
+ _upload(self)
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+ self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+
+ def get_raw_memory(self, number):
+ return repr(self._memobj.memory[number - 1])
+
+ def set_memory(self, memory):
+ """A value in a UI column for chan 'number' has been modified."""
+ # update all raw channel memory values (_mem) from UI (mem)
+ _mem = self._memobj.chan_mem[memory.number - 1]
+ _name = self._memobj.chan_name[memory.number - 1]
+
+ if memory.empty:
+ _do_map(memory.number, 0, self._memobj.chan_avail.bitmap)
+ return
+
+ _do_map(memory.number, 1, self._memobj.chan_avail.bitmap)
+
+ if memory.skip == "":
+ _do_map(memory.number, 1, self._memobj.chan_skip.bitmap)
+ else:
+ _do_map(memory.number, 0, self._memobj.chan_skip.bitmap)
+
+ return self._set_memory(memory, _mem, _name)
+
+ def get_memory(self, number):
+ # radio first channel is 1, mem map is base 0
+ _mem = self._memobj.chan_mem[number - 1]
+ _name = self._memobj.chan_name[number - 1]
+ mem = chirp_common.Memory()
+ mem.number = number
+
+ # Determine if channel is empty
+
+ if _do_map(number, 2, self._memobj.chan_avail.bitmap) == 0:
+ mem.empty = True
+ return mem
+
+ if _do_map(mem.number, 2, self._memobj.chan_skip.bitmap) > 0:
+ mem.skip = ""
+ else:
+ mem.skip = "S"
+
+ return self._get_memory(mem, _mem, _name)
+
+ def _get_memory(self, mem, _mem, _name):
+ """Convert raw channel memory data into UI columns"""
+ mem.extra = RadioSettingGroup("extra", "Extra")
+
+ mem.empty = False
+ # This function process both 'normal' and Freq up/down' entries
+ mem.freq = int(_mem.rxfreq) * 10
+
+ if _mem.txfreq == 0xFFFFFFFF:
+ # TX freq not set
+ mem.duplex = "off"
+ mem.offset = 0
+ elif abs(int(_mem.rxfreq) * 10 - int(_mem.txfreq) * 10) > 25000000:
+ mem.duplex = "split"
+ mem.offset = int(_mem.txfreq) * 10
+ elif int(_mem.rxfreq) == int(_mem.txfreq):
+ mem.duplex = ""
+ mem.offset = 0
+ else:
+ mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) \
+ and "-" or "+"
+ mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
+
+ mem.name = ""
+ for i in range(6): # 0 - 6
+ mem.name += chr(_mem.name[i])
+ for i in range(10):
+ mem.name += chr(_name.extra_name[i])
+
+ mem.name = mem.name.rstrip() # remove trailing spaces
+
+ # ########## TONE ##########
+
+ if _mem.txtone > 2600:
+ # All off
+ txmode = ""
+ elif _mem.txtone > 511:
+ txmode = "Tone"
+ mem.rtone = int(_mem.txtone) / 10.0
+ else:
+ # DTSC
+ txmode = "DTCS"
+ mem.dtcs = int(format(int(_mem.txtone), 'o'))
+
+ if _mem.rxtone > 2600:
+ rxmode = ""
+ elif _mem.rxtone > 511:
+ rxmode = "Tone"
+ mem.ctone = int(_mem.rxtone) / 10.0
+ else:
+ rxmode = "DTCS"
+ mem.rx_dtcs = int(format(int(_mem.rxtone), 'o'))
+
+ mem.dtcs_polarity = ("N", "R")[_mem.encodeDSCI] + (
+ "N", "R")[_mem.decodeDSCI]
+
+ mem.tmode = ""
+ if txmode == "Tone" and not rxmode:
+ mem.tmode = "Tone"
+ elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
+ mem.tmode = "TSQL"
+ elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
+ mem.tmode = "DTCS"
+ elif rxmode or txmode:
+ mem.tmode = "Cross"
+ mem.cross_mode = "%s->%s" % (txmode, rxmode)
+
+ # ########## TONE ##########
+
+ mem.mode = self.MODES[_mem.wide]
+ mem.power = POWER_LEVELS[int(_mem.power)]
+
+ b_lock = RadioSetting("b_lock", "B_Lock",
+ RadioSettingValueList(B_LOCK_LIST,
+ B_LOCK_LIST[_mem.b_lock]))
+ mem.extra.append(b_lock)
+
+ b_lock = RadioSetting("step", "Step",
+ RadioSettingValueList(LIST_STEPS,
+ LIST_STEPS[_mem.step]))
+ mem.extra.append(b_lock)
+
+ scramble_value = _mem.scramble
+ if scramble_value >= 8: # Looks like OFF is 0x0f ** CONFIRM
+ scramble_value = 0
+ scramble = RadioSetting("scramble", "Scramble",
+ RadioSettingValueList(SCRAMBLE_LIST,
+ SCRAMBLE_LIST[
+ scramble_value]))
+ mem.extra.append(scramble)
+
+ optsig = RadioSetting("signal", "Optional signaling",
+ RadioSettingValueList(
+ OPTSIG_LIST,
+ OPTSIG_LIST[_mem.signal]))
+ mem.extra.append(optsig)
+
+ rs = RadioSetting("pttid", "PTT ID",
+ RadioSettingValueList(PTTID_LIST,
+ PTTID_LIST[_mem.pttid]))
+ mem.extra.append(rs)
+
+ return mem
+
+ def _set_memory(self, mem, _mem, _name):
+ # """Convert UI column data (mem) into MEM_FORMAT memory (_mem)."""
+
+ _mem.rxfreq = mem.freq / 10
+ if mem.duplex == "off":
+ _mem.txfreq = 0xFFFFFFFF
+ elif mem.duplex == "split":
+ _mem.txfreq = mem.offset / 10
+ elif mem.duplex == "+":
+ _mem.txfreq = (mem.freq + mem.offset) / 10
+ elif mem.duplex == "-":
+ _mem.txfreq = (mem.freq - mem.offset) / 10
+ else:
+ _mem.txfreq = _mem.rxfreq
+
+ out_name = mem.name.ljust(16)
+
+ for i in range(6): # 0 - 6
+ _mem.name[i] = ord(out_name[i])
+ for i in range(10):
+ _name.extra_name[i] = ord(out_name[i+6])
+
+ if mem.name != "":
+ _mem.displayName = 1 # Name only displayed if this is set on
+ else:
+ _mem.displayName = 0
+
+ rxmode = ""
+ txmode = ""
+
+ if mem.tmode == "Tone":
+ txmode = "Tone"
+ elif mem.tmode == "TSQL":
+ rxmode = "Tone"
+ txmode = "TSQL"
+ elif mem.tmode == "DTCS":
+ rxmode = "DTCSSQL"
+ txmode = "DTCS"
+ elif mem.tmode == "Cross":
+ txmode, rxmode = mem.cross_mode.split("->", 1)
+
+ if mem.dtcs_polarity[1] == "N":
+ _mem.decodeDSCI = 0
+ else:
+ _mem.decodeDSCI = 1
+
+ if rxmode == "":
+ _mem.rxtone = 0xFFF
+ elif rxmode == "Tone":
+ _mem.rxtone = int(float(mem.ctone) * 10)
+ elif rxmode == "DTCSSQL":
+ _mem.rxtone = int(str(mem.dtcs), 8)
+ elif rxmode == "DTCS":
+ _mem.rxtone = int(str(mem.rx_dtcs), 8)
+
+ if mem.dtcs_polarity[0] == "N":
+ _mem.encodeDSCI = 0
+ else:
+ _mem.encodeDSCI = 1
+
+ if txmode == "":
+ _mem.txtone = 0xFFF
+ elif txmode == "Tone":
+ _mem.txtone = int(float(mem.rtone) * 10)
+ elif txmode == "TSQL":
+ _mem.txtone = int(float(mem.ctone) * 10)
+ elif txmode == "DTCS":
+ _mem.txtone = int(str(mem.dtcs), 8)
+
+ _mem.wide = self.MODES.index(mem.mode)
+ _mem.power = 0 if mem.power is None else POWER_LEVELS.index(mem.power)
+
+ for element in mem.extra:
+ setattr(_mem, element.get_name(), element.value)
+
+ return
+
+ def get_settings(self):
+ """Translate the MEM_FORMAT structs into setstuf in the UI"""
+ _settings = self._memobj.basicsettings
+ _settings2 = self._memobj.settings2
+ _workmode = self._memobj.workmodesettings
+
+ basic = RadioSettingGroup("basic", "Basic Settings")
+ group = RadioSettings(basic)
+
+ # Menu 02 - TX Channel Select
+ options = ["Last Channel", "Main Channel"]
+ rx = RadioSettingValueList(options, options[_settings.txChSelect])
+ rset = RadioSetting("basicsettings.txChSelect",
+ "Priority Transmit", rx)
+ basic.append(rset)
+
+ # Menu 03 - VOX Level
+ rx = RadioSettingValueInteger(1, 7, _settings.voxLevel + 1)
+ rset = RadioSetting("basicsettings.voxLevel", "Vox Level", rx)
+ basic.append(rset)
+
+ # Menu 05 - Squelch Level
+ options = ["OFF"] + ["%s" % x for x in range(1, 10)]
+ rx = RadioSettingValueList(options, options[_settings.sqlLevel])
+ rset = RadioSetting("basicsettings.sqlLevel", "Squelch Level", rx)
+ basic.append(rset)
+
+ # Menu 06 - Dual Wait
+ rx = RadioSettingValueBoolean(_settings.dualWait)
+ rset = RadioSetting("basicsettings.dualWait", "Dual Wait/Standby", rx)
+ basic.append(rset)
+
+ # Menu 07 - LED Mode
+ options = ["Off", "On", "Auto"]
+ rx = RadioSettingValueList(options, options[_settings.ledMode])
+ rset = RadioSetting("basicsettings.ledMode", "LED Display Mode", rx)
+ basic.append(rset)
+
+ # Menu 08 - Light
+ options = ["%s" % x for x in range(1, 8)]
+ rx = RadioSettingValueList(options, options[_settings.light])
+ rset = RadioSetting("basicsettings.light",
+ "Background Light Color", rx)
+ basic.append(rset)
+
+ # Menu 09 - Beep
+ rx = RadioSettingValueBoolean(_settings.beep)
+ rset = RadioSetting("basicsettings.beep", "Keypad Beep", rx)
+ basic.append(rset)
+
+ # Menu 11 - TOT
+ options = ["Off"] + ["%s seconds" % x for x in range(30, 300, 30)]
+ rx = RadioSettingValueList(options, options[_settings.tot])
+ rset = RadioSetting("basicsettings.tot",
+ "Transmission Time-out Timer", rx)
+ basic.append(rset)
+
+ # Menu 13 - VOX Switch
+ rx = RadioSettingValueBoolean(_settings.voxSw)
+ rset = RadioSetting("basicsettings.voxSw", "Vox Switch", rx)
+ basic.append(rset)
+
+ # Menu 14 - Roger
+ rx = RadioSettingValueBoolean(_settings.roger)
+ rset = RadioSetting("basicsettings.roger", "Roger Beep", rx)
+ basic.append(rset)
+
+ # Menu 16 - Save Mode
+ options = ["Off", "1:1", "1:2", "1:4"]
+ rx = RadioSettingValueList(options, options[_settings.saveMode])
+ rset = RadioSetting("basicsettings.saveMode", "Battery Save Mode", rx)
+ basic.append(rset)
+
+ # Menu 17 - Scan Type
+ if self.MODEL == "QRZ-1":
+ options = ["Time", "Carrier", "Stop"]
+ else:
+ options = ["CO", "TO", "SE"]
+ rx = RadioSettingValueList(options, options[_settings.scanType])
+ rset = RadioSetting("basicsettings.scanType", "Scan Type", rx)
+ basic.append(rset)
+
+ # Menu 18 - Key Lock
+ rx = RadioSettingValueBoolean(_settings.keylock)
+ rset = RadioSetting("basicsettings.keylock", "Auto Key Lock", rx)
+ basic.append(rset)
+
+ if self.MODEL != "QRZ-1":
+ # Menu 19 - SW Audio
+ rx = RadioSettingValueBoolean(_settings.swAudio)
+ rset = RadioSetting("basicsettings.swAudio", "Voice Prompts", rx)
+ basic.append(rset)
+
+ # Menu 20 - Intro Screen
+ options = ["Off", "Voltage", "Character String"]
+ rx = RadioSettingValueList(options, options[_settings.introScreen])
+ rset = RadioSetting("basicsettings.introScreen", "Intro Screen", rx)
+ basic.append(rset)
+
+ # Menu 32 - Key Mode
+ options = ["ALL", "PTT", "KEY", "Key & Side Key"]
+ rx = RadioSettingValueList(options, options[_settings.keyMode])
+ rset = RadioSetting("basicsettings.keyMode", "Key Lock Mode", rx)
+ basic.append(rset)
+
+ # Menu 33 - Display Mode
+ options = ['Frequency', 'Channel #', 'Name']
+ rx = RadioSettingValueList(options, options[_settings.disMode])
+ rset = RadioSetting("basicsettings.disMode", "Display Mode", rx)
+ basic.append(rset)
+
+ # Menu 34 - FM Dual Wait
+ rx = RadioSettingValueBoolean(_settings.radioMoni)
+ rset = RadioSetting("basicsettings.radioMoni", "Radio Monitor", rx)
+ basic.append(rset)
+
+ advanced = RadioSettingGroup("advanced", "Advanced Settings")
+ group.append(advanced)
+
+ # software only
+ options = ['Off', 'Frequency']
+ rx = RadioSettingValueList(options, options[_settings.endToneElim])
+ rset = RadioSetting("basicsettings.endToneElim", "End Tone Elim", rx)
+ advanced.append(rset)
+
+ # software only
+ name = ""
+ for i in range(15): # 0 - 15
+ name += chr(int(self._memobj.openradioname.name1[i]))
+ name = name.rstrip() # remove trailing spaces
+
+ rx = RadioSettingValueString(0, 15, name)
+ rset = RadioSetting("openradioname.name1", "Intro Line 1", rx)
+ advanced.append(rset)
+
+ # software only
+ name = ""
+ for i in range(15): # 0 - 15
+ name += chr(int(self._memobj.openradioname.name2[i]))
+ name = name.rstrip() # remove trailing spaces
+
+ rx = RadioSettingValueString(0, 15, name)
+ rset = RadioSetting("openradioname.name2", "Intro Line 2", rx)
+ advanced.append(rset)
+
+ # software only
+ options = ['0.5S', '1.0S', '1.5S', '2.0S', '2.5S', '3.0S', '3.5S',
+ '4.0S', '4.5S', '5.0S']
+ rx = RadioSettingValueList(options, options[_settings.voxDelay])
+ rset = RadioSetting("basicsettings.voxDelay", "VOX Delay", rx)
+ advanced.append(rset)
+
+ options = ['Unlocked', 'Unknown 1', 'Unknown 2', 'EU', 'US']
+ # extend option list with unknown description for values 5 - 15.
+ for ix in range(len(options), _settings2.region + 1):
+ item_to_add = 'Unknown {region_code}'.format(region_code=ix)
+ options.append(item_to_add)
+ # log unknown region codes greater than 4
+ if _settings2.region > 4:
+ LOG.debug("Unknown region code: {value}".
+ format(value=_settings2.region))
+ rx = RadioSettingValueList(options, options[_settings2.region])
+ rx.set_mutable(False)
+ rset = RadioSetting("settings2.region", "Region", rx)
+ advanced.append(rset)
+
+ workmode = RadioSettingGroup("workmode", "Work Mode Settings")
+ group.append(workmode)
+
+ # Toggle with [#] key
+ options = ["Frequency", "Channel"]
+ rx = RadioSettingValueList(options, options[_workmode.vfomrmode])
+ rset = RadioSetting("workmodesettings.vfomrmode", "VFO/MR Mode", rx)
+ workmode.append(rset)
+
+ # Toggle with [#] key
+ options = ["Frequency", "Channel"]
+ rx = RadioSettingValueList(options, options[_workmode.vfomrmodeb])
+ rset = RadioSetting("workmodesettings.vfomrmodeb",
+ "VFO/MR Mode B (BQ1.41+)", rx)
+ workmode.append(rset)
+
+ # Toggle with [A/B] key
+ options = ["B", "A"]
+ rx = RadioSettingValueList(options, options[_workmode.ab])
+ rset = RadioSetting("workmodesettings.ab", "A/B Select", rx)
+ workmode.append(rset)
+
+ rx = RadioSettingValueInteger(1, 199, _workmode.mrAch + 1)
+ rset = RadioSetting("workmodesettings.mrAch", "MR A Channel #", rx)
+ workmode.append(rset)
+
+ rx = RadioSettingValueInteger(1, 199, _workmode.mrBch + 1)
+ rset = RadioSetting("workmodesettings.mrBch", "MR B Channel #", rx)
+ workmode.append(rset)
+
+ fmb = RadioSettingGroup("fmradioc", "FM Radio Settings")
+ group.append(fmb)
+
+ def myset_mask(setting, obj, atrb, nx):
+ if bool(setting.value): # Enabled = 1
+ vx = 1
+ else:
+ vx = 0
+ _do_map(nx + 1, vx, self._memobj.fmmap.fmset)
+ return
+
+ def myset_fmfrq(setting, obj, atrb, nx):
+ """ Callback to set xx.x FM freq in memory as xx.x * 100000"""
+ # in-valid even KHz freqs are allowed; to satisfy run_tests
+ vx = float(str(setting.value))
+ vx = int(vx * 100000)
+ setattr(obj[nx], atrb, vx)
+ return
+
+ def myset_freq(setting, obj, atrb, mult):
+ """ Callback to set frequency by applying multiplier"""
+ value = int(float(str(setting.value)) * mult)
+ setattr(obj, atrb, value)
+ return
+
+ _fmx = self._memobj.fmfrqs
+
+ # FM Broadcast Manual Settings
+ val = _fmx.fmcur
+ val = val / 100000.0
+ if val < 64.0 or val > 108.0:
+ val = 100.7
+ rx = RadioSettingValueFloat(64.0, 108.0, val, 0.1, 1)
+ rset = RadioSetting("fmfrqs.fmcur", "Manual FM Freq (MHz)", rx)
+ rset.set_apply_callback(myset_freq, _fmx, "fmcur", 100000)
+ fmb.append(rset)
+
+ _fmfrq = self._memobj.fm_stations
+ _fmap = self._memobj.fmmap
+
+ # FM Broadcast Presets Settings
+ for j in range(0, 24):
+ val = _fmfrq[j].rxfreq
+ if val < 6400000 or val > 10800000:
+ val = 88.0
+ fmset = False
+ else:
+ val = (float(int(val)) / 100000)
+ # get fmmap bit value: 1 = enabled
+ ndx = int(math.floor((j) / 8))
+ bv = j % 8
+ msk = 1 << bv
+ vx = _fmap.fmset[ndx]
+ fmset = bool(vx & msk)
+ rx = RadioSettingValueBoolean(fmset)
+ rset = RadioSetting("fmmap.fmset/%d" % j,
+ "FM Preset %02d" % (j + 1), rx)
+ rset.set_apply_callback(myset_mask, _fmap, "fmset", j)
+ fmb.append(rset)
+
+ rx = RadioSettingValueFloat(64.0, 108.0, val, 0.1, 1)
+ rset = RadioSetting("fm_stations/%d.rxfreq" % j,
+ " Preset %02d Freq" % (j + 1), rx)
+ # This callback uses the array index
+ rset.set_apply_callback(myset_fmfrq, _fmfrq, "rxfreq", j)
+ fmb.append(rset)
+
+ return group # END get_settings()
+
+ def set_settings(self, settings):
+ _settings = self._memobj.basicsettings
+ _mem = self._memobj
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = _settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif setting == "mrAch" or setting == "mrBch":
+ setattr(obj, setting, int(element.value) - 1)
+ elif setting == "voxLevel":
+ setattr(obj, setting, int(element.value) - 1)
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s" % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+
+
+@directory.register
+class RT85(THUV88Radio):
+ VENDOR = "Retevis"
+ MODEL = "RT85"
+
+
+@directory.register
+class QRZ1(THUV88Radio):
+ VENDOR = "Explorer"
+ MODEL = "QRZ-1"
+
+ _magic0 = "\xFE\xFE\xEE\xEF\xE0" + "UV78" + "\xFD"
+ _magic2 = "\xFE\xFE\xEE\xEF\xE2" + "UV78" + "\xFD"
+ _magic3 = "\xFE\xFE\xEE\xEF\xE3" + "UV78" + "\xFD"
+ _magic5 = "\xFE\xFE\xEE\xEF\xE5" + "UV78" + "\xFD"
+ _fingerprint = "\xFE\xFE\xEF\xEE\xE1" + "UV78"
diff --git a/chirp/drivers/th_uvf8d.py b/chirp/drivers/th_uvf8d.py
index e302784..3b93232 100644
--- a/chirp/drivers/th_uvf8d.py
+++ b/chirp/drivers/th_uvf8d.py
@@ -87,7 +87,7 @@ def tyt_uvf8d_upload(radio):
radio.pipe.timeout = 1
if data != radio._mmap[:32]:
- raise errors.RadioError("Model mis-match: \n%s\n%s" %
+ raise errors.RadioError("Model mismatch: \n%s\n%s" %
(util.hexprint(data),
util.hexprint(radio._mmap[:32])))
@@ -288,7 +288,7 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio):
rf.valid_skips = ["", "S"]
rf.valid_power_levels = POWER_LEVELS
rf.valid_modes = ["FM", "NFM"]
- rf.valid_special_chans = SPECIALS.keys()
+ rf.valid_special_chans = list(SPECIALS.keys())
rf.valid_name_length = 7
return rf
@@ -301,7 +301,7 @@ class TYTUVF8DRadio(chirp_common.CloneModeRadio):
@classmethod
def match_model(cls, filedata, filename):
- return filedata.startswith("TYT-F10\x00")
+ return filedata.startswith(b"TYT-F10\x00")
def process_mmap(self):
self._memobj = bitwise.parse(UVF8D_MEM_FORMAT, self._mmap)
diff --git a/chirp/drivers/thd72.py b/chirp/drivers/thd72.py
index 59984e8..2920873 100644
--- a/chirp/drivers/thd72.py
+++ b/chirp/drivers/thd72.py
@@ -244,9 +244,9 @@ class THD72Radio(chirp_common.CloneModeRadio):
rf.has_bank = False
rf.has_settings = True
rf.valid_tuning_steps = []
- rf.valid_modes = MODES_REV.keys()
- rf.valid_tmodes = TMODES_REV.keys()
- rf.valid_duplexes = DUPLEX_REV.keys()
+ rf.valid_modes = list(MODES_REV.keys())
+ rf.valid_tmodes = list(TMODES_REV.keys())
+ rf.valid_duplexes = list(DUPLEX_REV.keys())
rf.valid_skips = ["", "S"]
rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC
rf.valid_name_length = 8
@@ -581,7 +581,7 @@ class THD72Radio(chirp_common.CloneModeRadio):
except AttributeError as e:
LOG.error("Setting %s is not in the memory map: %s" %
(element.get_name(), e))
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
@@ -738,9 +738,9 @@ if __name__ == "__main__":
return r
def usage():
- print "Usage: %s <-i input.img>|<-o output.img> -p port " \
- "[[-f first-addr] [-l last-addr] | [-b list,of,blocks]]" % \
- sys.argv[0]
+ print("Usage: %s <-i input.img>|<-o output.img> -p port "
+ "[[-f first-addr] [-l last-addr] | [-b list,of,blocks]]" %
+ sys.argv[0])
sys.exit(1)
opts, args = getopt.getopt(sys.argv[1:], "i:o:p:f:l:b:")
@@ -793,4 +793,4 @@ if __name__ == "__main__":
else:
r._mmap = file(fname, "rb").read(r._memsize)
r.upload(blocks)
- print "\nDone"
+ print("\nDone")
diff --git a/chirp/drivers/thuv1f.py b/chirp/drivers/thuv1f.py
index c39f17a..884e9cc 100644
--- a/chirp/drivers/thuv1f.py
+++ b/chirp/drivers/thuv1f.py
@@ -176,6 +176,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5),
PTTID_LIST = ["Off", "BOT", "EOT", "Both"]
BCL_LIST = ["Off", "CSQ", "QT/DQT"]
CODES_LIST = [x for x in range(1, 9)]
+STEPS = [5.0, 6.25, 7.5, 10.0, 12.5, 25.0, 37.5, 50.0, 100.0]
@directory.register
@@ -202,6 +203,7 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio):
rf.valid_skips = ["", "S"]
rf.valid_power_levels = POWER_LEVELS
rf.valid_modes = ["FM", "NFM"]
+ rf.valid_tuning_steps = STEPS
rf.valid_name_length = 7
rf.valid_cross_modes = ["Tone->Tone", "DTCS->DTCS",
"Tone->DTCS", "DTCS->Tone",
@@ -214,7 +216,7 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio):
self._mmap = uvf1_download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
self.process_mmap()
@@ -223,18 +225,18 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio):
uvf1_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
@classmethod
def match_model(cls, filedata, filename):
# TYT TH-UVF1 original
- if filedata.startswith("\x13\x60\x17\x40\x40\x00\x48\x00" +
- "\x35\x00\x39\x00\x47\x00\x52\x00"):
+ if filedata.startswith(b"\x13\x60\x17\x40\x40\x00\x48\x00" +
+ b"\x35\x00\x39\x00\x47\x00\x52\x00"):
return True
# TYT TH-UVF1 V2
- elif filedata.startswith("\x14\x40\x14\x80\x43\x00\x45\x00" +
- "\x13\x60\x17\x40\x40\x00\x47\x00"):
+ elif filedata.startswith(b"\x14\x40\x14\x80\x43\x00\x45\x00" +
+ b"\x13\x60\x17\x40\x40\x00\x47\x00"):
return True
else:
return False
diff --git a/chirp/drivers/tk270.py b/chirp/drivers/tk270.py
index b7927d2..0d16958 100644
--- a/chirp/drivers/tk270.py
+++ b/chirp/drivers/tk270.py
@@ -56,11 +56,11 @@ u8 active[4]; // 4 bytes / bit LSBF for the active cha
#seekto 0x0340;
struct {
- u8 kMoni; // monitor key funcion
- u8 kScan; // scan key funcion
- u8 kDial; // dial key funcion
- u8 kTa; // ta key funcion
- u8 kLo; // low key funcion
+ u8 kMoni; // monitor key function
+ u8 kScan; // scan key function
+ u8 kDial; // dial key function
+ u8 kTa; // ta key function
+ u8 kLo; // low key function
u8 unknown40[7];
// 0x034c
u8 tot; // TOT val * 30 steps (x00-0xa)
@@ -96,7 +96,7 @@ struct {
MEM_SIZE = 0x400
BLOCK_SIZE = 8
-MEM_BLOCKS = range(0, (MEM_SIZE / BLOCK_SIZE))
+MEM_BLOCKS = list(range(0, (MEM_SIZE // BLOCK_SIZE)))
ACK_CMD = "\x06"
TIMEOUT = 0.05 # from 0.03 up it' s safe, we set in 0.05 for a margin
@@ -405,11 +405,11 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
raise errors.RadioError("Error uploading data to radio")
def set_variant(self):
- """Select and set the correct variables for the class acording
+ """Select and set the correct variables for the class according
to the correct variant of the radio"""
rid = get_radio_id(self._mmap)
- # indentify the radio variant and set the enviroment to it's values
+ # identify the radio variant and set the environment to it's values
try:
self._upper, low, high, self._kind = self.VARIANTS[rid]
@@ -744,7 +744,7 @@ class Kenwood_P60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# off
sett.tot_reset = 0
if int(sett.sql) == 0xff:
- # a confortable level ~6
+ # a comfortable level ~6
sett.sql = 6
tot = RadioSetting("settings.tot", "Time Out Timer (TOT)",
diff --git a/chirp/drivers/tk760.py b/chirp/drivers/tk760.py
index c9a2ff1..e99371f 100644
--- a/chirp/drivers/tk760.py
+++ b/chirp/drivers/tk760.py
@@ -13,12 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import time
-import struct
-import logging
-
-LOG = logging.getLogger(__name__)
-
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -27,6 +21,12 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettings
from textwrap import dedent
+import time
+import struct
+import logging
+
+LOG = logging.getLogger(__name__)
+
MEM_FORMAT = """
#seekto 0x0000;
struct {
@@ -87,17 +87,18 @@ KEYS = {
0x01: "Monitor",
0x02: "Talk Around",
0x03: "Horn Alert",
- 0x04: "Public Adress",
+ 0x04: "Public Address",
0x05: "Auxiliary",
0x06: "Scan",
0x07: "Scan Del/Add",
0x08: "Home Channel",
- 0x09: "Operator Selectable Tone"
+ 0x09: "Operator Selectable Tone",
+ 0x0C: "Unknown"
}
MEM_SIZE = 0x400
BLOCK_SIZE = 8
-MEM_BLOCKS = range(0, (MEM_SIZE / BLOCK_SIZE))
+MEM_BLOCKS = list(range(0, (MEM_SIZE // BLOCK_SIZE)))
ACK_CMD = "\x06"
# from 0.03 up it' s safe
# I have to turn it up, some users reported problems with this, was 0.05
@@ -108,7 +109,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1),
MODES = ["NFM", "FM"]
SKIP_VALUES = ["", "S"]
TONES = chirp_common.TONES
-#TONES.remove(254.1)
+# TONES.remove(254.1)
DTCS_CODES = chirp_common.DTCS_CODES
TOT = ["off"] + ["%s" % x for x in range(30, 330, 30)]
@@ -120,7 +121,7 @@ def rawrecv(radio, amount):
data = ""
try:
data = radio.pipe.read(amount)
- #print("<= %02i: %s" % (len(data), util.hexprint(data)))
+ # print("<= %02i: %s" % (len(data), util.hexprint(data)))
except:
raise errors.RadioError("Error reading data from radio")
@@ -131,7 +132,7 @@ def rawsend(radio, data):
"""Raw send to the radio device"""
try:
radio.pipe.write(data)
- #print("=> %02i: %s" % (len(data), util.hexprint(data)))
+ # print("=> %02i: %s" % (len(data), util.hexprint(data)))
except:
raise errors.RadioError("Error sending data from radio")
@@ -162,7 +163,7 @@ def handshake(radio, msg="", full=False):
ack = rawrecv(radio, 1)
# check ACK
if ack != ACK_CMD:
- #close_radio(radio)
+ # close_radio(radio)
mesg = "Handshake failed: " + msg
raise errors.RadioError(mesg)
@@ -229,14 +230,14 @@ def open_radio(radio):
ident = rawrecv(radio, 8)
# validate the input
- if len(ident) != 8:
+ if len(ident) != 8:
LOG.debug("Wrong ID, get only %s bytes, we expect 8" % len(ident))
LOG.debug(hexprint(ident))
msg = "Bad ID received, just %s bytes, we want 8" % len(ident)
raise errors.RadioError(msg)
handshake(radio, "Comm error after ident", True)
- LOG.debug("Correct get ident and hanshake")
+ LOG.debug("Correct get ident and handshake")
if not (radio.TYPE in ident):
LOG.debug("Incorrect model ID:")
@@ -253,7 +254,7 @@ def do_download(radio):
"""This is your download function"""
open_radio(radio)
- # UI progress
+ # UI progress
status = chirp_common.Status()
status.cur = 0
status.max = MEM_SIZE / BLOCK_SIZE
@@ -280,7 +281,7 @@ def do_upload(radio):
"""Upload info to radio"""
open_radio(radio)
- # UI progress
+ # UI progress
status = chirp_common.Status()
status.cur = 0
status.max = MEM_SIZE / BLOCK_SIZE
@@ -311,12 +312,9 @@ def get_rid(data):
"""Extract the radio identification from the firmware"""
rid = data[0x0378:0x0380]
# we have to invert rid
- nrid = ""
- for i in range(1, len(rid) + 1):
- nrid += rid[-i]
- rid = nrid
+ nrid = rid[::-1]
- return rid
+ return nrid
def model_match(cls, data):
@@ -324,7 +322,7 @@ def model_match(cls, data):
rid = get_rid(data)
# DEBUG
- #print("Full ident string is %s" % util.hexprint(rid))
+ # print("Full ident string is %s" % util.hexprint(rid))
if (rid in cls.VARIANTS):
# correct model
@@ -333,7 +331,8 @@ def model_match(cls, data):
return False
-class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
+class Kenwood_M60_Radio(chirp_common.CloneModeRadio,
+ chirp_common.ExperimentalRadio):
"""Kenwood Mobile Family 60 Radios"""
VENDOR = "Kenwood"
_range = [136000000, 500000000] # don't mind, it will be overwritten
@@ -346,7 +345,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
rp = chirp_common.RadioPrompts()
rp.experimental = \
('This driver is experimental; not all features have been '
- 'implemented, but it has those features most used by hams.\n'
+ 'implemented, but it has those features most used by hams.\n'
'\n'
'This radios are able to work slightly outside the OEM '
'frequency limits. After testing, the limit in Chirp has '
@@ -401,6 +400,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
rf.valid_dtcs_codes = DTCS_CODES
rf.valid_bands = [self._range]
rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = [5., 6.25, 10., 12.5]
return rf
def sync_in(self):
@@ -423,11 +423,11 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
raise errors.RadioError("Error uploading data to radio")
def set_variant(self):
- """Select and set the correct variables for the class acording
+ """Select and set the correct variables for the class according
to the correct variant of the radio"""
rid = get_rid(self._mmap)
- # indentify the radio variant and set the enviroment to it's values
+ # identify the radio variant and set the environment to it's values
try:
self._upper, low, high, self._kind = self.VARIANTS[rid]
@@ -450,7 +450,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
"Wrong Kenwood radio, ID or unknown variant, see LOG output.")
def _prep_data(self):
- """Prepare the areas in the memmap to do a consistend write
+ """Prepare the areas in the memmap to do a consistent write
it has to make an update on the x200 flag data"""
achs = 0
@@ -712,12 +712,12 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
basic.append(mod)
tot = RadioSetting("settings.tot", "Time Out Timer (TOT)",
- RadioSettingValueList(TOT, TOT[int(sett.tot)]))
+ RadioSettingValueList(TOT, sett.tot))
basic.append(tot)
minvol = RadioSetting("settings.min_vol", "Minimum volume",
RadioSettingValueList(VOL,
- VOL[int(sett.min_vol)]))
+ sett.min_vol))
basic.append(minvol)
ptone = RadioSetting("settings.poweron_tone", "Power On tone",
@@ -736,28 +736,24 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
basic.append(clone)
# front keys
- mon = RadioSetting("settings.kMON", "MON",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(sett.kMON))]))
+ rs = RadioSettingValueList(KEYS.values(),
+ KEYS[int(sett.kMON)])
+ mon = RadioSetting("settings.kMON", "MON", rs)
fkeys.append(mon)
- a = RadioSetting("settings.kA", "A",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(sett.kA))]))
+ rs = RadioSettingValueList(KEYS.values(),
+ KEYS[int(sett.kA)])
+ a = RadioSetting("settings.kA", "A", rs)
fkeys.append(a)
- scn = RadioSetting("settings.kSCN", "SCN",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(sett.kSCN))]))
+ rs = RadioSettingValueList(KEYS.values(),
+ KEYS[int(sett.kSCN)])
+ scn = RadioSetting("settings.kSCN", "SCN", rs)
fkeys.append(scn)
- da = RadioSetting("settings.kDA", "D/A",
- RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(sett.kDA))]))
+ rs = RadioSettingValueList(KEYS.values(),
+ KEYS[int(sett.kDA)])
+ da = RadioSetting("settings.kDA", "D/A", rs)
fkeys.append(da)
return top
@@ -787,7 +783,8 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# case keys, with special config
if setting[0] == "k":
- value = KEYS.keys()[KEYS.values().index(str(value))]
+ value = list(KEYS.keys())[
+ list(KEYS.values()).index(str(value))]
# integers case + special case
if setting in ["tot", "min_vol"]:
@@ -803,7 +800,7 @@ class Kenwood_M60_Radio(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# Apply al configs done
# DEBUG
- #print("%s: %s" % (setting, value))
+ # print("%s: %s" % (setting, value))
setattr(obj, setting, value)
diff --git a/chirp/drivers/tk760g.py b/chirp/drivers/tk760g.py
index 0f90d5e..e12b79b 100644
--- a/chirp/drivers/tk760g.py
+++ b/chirp/drivers/tk760g.py
@@ -44,7 +44,7 @@ struct {
u8 tot_rekey; // x12 TOT Re-key value range(0, 60); off= 0
u8 unknown1; // x13 unknown
u8 tot_reset; // x14 TOT Re-key value range(0, 60); off= 0
- u8 unknown2; // x15 unknows
+ u8 unknown2; // x15 unknowns
u8 tot_alert; // x16 TOT pre alert: range(0,10); 0 = off
u8 unknown3[7]; // x17-x1d unknown
u8 sql_level; // x1e SQ reference level
@@ -81,9 +81,9 @@ struct {
control_tone:1, // 1 bit control tone (key tone), enabled: 1-on
poweron_tone:1; // 1 bit power on tone, enabled: 1-on
u8 unknown19[5]; // x85-x89
- u8 min_vol; // minimum volume posible: range(0,32); 0 = off
- u8 tone_vol; // minimum tone volume posible:
- // xff = continous, range(0, 31)
+ u8 min_vol; // minimum volume possible: range(0,32); 0 = off
+ u8 tone_vol; // minimum tone volume possible:
+ // xff = continuous, range(0, 31)
u8 unknown20[4]; // x8c-x8f
// --
u8 unknown21[4]; // x90-x93
@@ -108,11 +108,11 @@ struct {
#seekto 0x0110;
struct {
u8 kA; // Portable > Closed circle
- u8 kDA; // Protable > Triangle to Left
- u8 kGROUP_DOWN; // Protable > Triangle to Right
- u8 kGROUP_UP; // Protable > Side 1
+ u8 kDA; // Portable > Triangle to Left
+ u8 kGROUP_DOWN; // Portable > Triangle to Right
+ u8 kGROUP_UP; // Portable > Side 1
u8 kSCN; // Portable > Open Circle
- u8 kMON; // Protable > Side 2
+ u8 kMON; // Portable > Side 2
u8 kFOOT;
u8 kCH_UP;
u8 kCH_DOWN;
@@ -263,13 +263,13 @@ struct {
MEM_SIZE = 0x8000 # 32,768 bytes
BLOCK_SIZE = 256
-BLOCKS = MEM_SIZE / BLOCK_SIZE
-MEM_BLOCKS = range(0, BLOCKS)
+BLOCKS = MEM_SIZE // BLOCK_SIZE
+MEM_BLOCKS = list(range(0, BLOCKS))
# define and empty block of data, as it will be used a lot in this code
EMPTY_BLOCK = "\xFF" * 256
-RO_BLOCKS = range(0x10, 0x1F) + range(0x59, 0x5f)
+RO_BLOCKS = list(range(0x10, 0x1F)) + list(range(0x59, 0x5f))
ACK_CMD = "\x06"
POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1),
@@ -289,7 +289,7 @@ TOT_REKEY = ["off"] + ["%s" % x for x in range(1, 61)]
TOT_RESET = ["off"] + ["%s" % x for x in range(1, 16)]
VOL = ["off"] + ["%s" % x for x in range(1, 32)]
TVOL = ["%s" % x for x in range(0, 33)]
-TVOL[32] = "Continous"
+TVOL[32] = "Continuous"
SQL = ["off"] + ["%s" % x for x in range(1, 10)]
## BOT = 0, EOT = 1, Both = 2, NONE = 3
@@ -300,7 +300,7 @@ debug = False
KEYS = {
0x33: "Display character",
- 0x35: "Home Channel", # Posible portable only, chek it
+ 0x35: "Home Channel", # Possible portable only, check it
0x37: "CH down",
0x38: "CH up",
0x39: "Key lock",
@@ -313,7 +313,7 @@ KEYS = {
0x40: "Monitor A: open mommentary",
0x41: "Monitor B: Open Toggle",
0x42: "Monitor C: Carrier mommentary",
- 0x43: "Monitor D: Carrier toogle",
+ 0x43: "Monitor D: Carrier toggle",
0x44: "Operator selectable tone",
0x45: "Redial",
0x46: "RF Power Low", # portable only ?
@@ -485,7 +485,7 @@ def _open_radio(radio, status):
if exito is False:
_close_radio(radio)
- LOG.debug("Radio did not accepted PROGRAM command in %s atempts" % tries)
+ LOG.debug("Radio did not accepted PROGRAM command in %s attempts" % tries)
raise errors.RadioError("The radio doesn't accept program mode")
# DEBUG
@@ -552,7 +552,7 @@ def do_download(radio):
# now we get the data
d = _recv(radio)
# if empty block, it return false
- # aka we asume a empty 256 xFF block
+ # aka we assume a empty 256 xFF block
if d is False:
d = EMPTY_BLOCK
@@ -697,7 +697,7 @@ class memBank(chirp_common.Bank):
class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRadio):
- """Kenwood Serie 60G Radios base class"""
+ """Kenwood Series 60G Radios base class"""
VENDOR = "Kenwood"
BAUD_RATE = 9600
_memsize = MEM_SIZE
@@ -774,6 +774,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
rf.valid_bands = [self._range]
rf.valid_name_length = 8
rf.memory_bounds = (1, self._upper)
+ rf.valid_tuning_steps = [1., 2.5, 5., 6.25, 12.5]
return rf
def _fill(self, offset, data):
@@ -782,7 +783,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
self._mmap[offset + addr] = data[addr]
def _prep_data(self):
- """Prepare the areas in the memmap to do a consistend write
+ """Prepare the areas in the memmap to do a consistent write
it has to make an update on the x300 area with banks and channel
info; other in the x1000 with banks and channel counts
and a last one in x7000 with flag data"""
@@ -812,8 +813,8 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# building the data for the memmap
fdata = ""
- for k, v in data.iteritems():
- # posible bad data
+ for k, v in data.items():
+ # possible bad data
if k == 0:
k = 1
raise errors.InvalidValueError(
@@ -843,7 +844,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
bdata += (256 - (len(bdata)) % 256) * "\xFF"
# fill to match the whole area
- bdata += (16 - len(bdata) / 256) * EMPTY_BLOCK
+ bdata += (16 - len(bdata) // 256) * EMPTY_BLOCK
# updating the data in the memmap [x1000]
self._fill(0x1000, bdata)
@@ -858,11 +859,11 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
self._fill(0x7000, fldata)
def _set_variant(self):
- """Select and set the correct variables for the class acording
+ """Select and set the correct variables for the class according
to the correct variant of the radio"""
rid = self._mmap[0xA7:0xAE]
- # indentify the radio variant and set the enviroment to it's values
+ # identify the radio variant and set the environment to it's values
try:
self._upper, low, high, self._kind = self.VARIANTS[rid]
@@ -907,12 +908,12 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
do_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate with radio: %s" % e)
def process_mmap(self):
"""Process the memory object"""
- # how many channels are programed
+ # how many channels are programmed
self._chs_progs = ord(self._mmap[15])
# load the memobj
@@ -1080,7 +1081,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# get the eprom representation of this channel
_mem = self._memobj.memory[mem.number - 1]
- # if empty memmory
+ # if empty memory
if mem.empty:
_mem.set_raw("\xFF" * 48)
return
@@ -1088,7 +1089,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# frequency
_mem.rxfreq = mem.freq / 10
- # this are a mistery yet, but so falr there is no impact
+ # this are a mystery yet, but so falr there is no impact
# whit this default values for new channels
if int(_mem.rx_unkw) == 0xff:
_mem.rx_unkw = 0x35
@@ -1179,7 +1180,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# buttons
fkeys = RadioSettingGroup("keys", "Front keys config")
- # TODO / PLANED
+ # TODO / PLANNED
# adjust feqs
#freqs = RadioSettingGroup("freqs", "Adjust Frequencies")
@@ -1187,30 +1188,29 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# Basic
tot = RadioSetting("settings.tot", "Time Out Timer (TOT)",
- RadioSettingValueList(TOT, TOT[
- TOT.index(str(int(sett.tot)))]))
+ RadioSettingValueList(TOT, '%i' % sett.tot))
basic.append(tot)
totalert = RadioSetting("settings.tot_alert", "TOT pre alert",
- RadioSettingValueList(TOT_PRE,
- TOT_PRE[int(sett.tot_alert)]))
+ RadioSettingValueList(
+ TOT_PRE, current_index=sett.tot_alert))
basic.append(totalert)
totrekey = RadioSetting("settings.tot_rekey", "TOT re-key time",
- RadioSettingValueList(TOT_REKEY,
- TOT_REKEY[int(sett.tot_rekey)]))
+ RadioSettingValueList(
+ TOT_REKEY, current_index=sett.tot_rekey))
basic.append(totrekey)
totreset = RadioSetting("settings.tot_reset", "TOT reset time",
- RadioSettingValueList(TOT_RESET,
- TOT_RESET[int(sett.tot_reset)]))
+ RadioSettingValueList(
+ TOT_RESET, current_index=sett.tot_reset))
basic.append(totreset)
# this feature is for mobile only
if self.TYPE[0] == "M":
minvol = RadioSetting("settings.min_vol", "Minimum volume",
- RadioSettingValueList(VOL,
- VOL[int(sett.min_vol)]))
+ RadioSettingValueList(
+ VOL, current_index=sett.min_vol))
basic.append(minvol)
tv = int(sett.tone_vol)
@@ -1222,7 +1222,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
sql = RadioSetting("settings.sql_level", "SQL Ref Level",
RadioSettingValueList(
- SQL, SQL[int(sett.sql_level)]))
+ SQL, current_index=sett.sql_level))
basic.append(sql)
#c2t = RadioSetting("settings.c2t", "Clear to Transpond",
@@ -1301,36 +1301,31 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
dealer.append(fmw)
# front keys
- # The Mobile only parameters are wraped here
+ # The Mobile only parameters are wrapped here
if self.TYPE[0] == "M":
vu = RadioSetting("keys.kVOL_UP", "VOL UP",
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kVOL_UP))]))
+ KEYS[int(keys.kVOL_UP)]))
fkeys.append(vu)
vd = RadioSetting("keys.kVOL_DOWN", "VOL DOWN",
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kVOL_DOWN))]))
+ KEYS[int(keys.kVOL_DOWN)]))
fkeys.append(vd)
chu = RadioSetting("keys.kCH_UP", "CH UP",
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kCH_UP))]))
+ KEYS[int(keys.kCH_UP)]))
fkeys.append(chu)
chd = RadioSetting("keys.kCH_DOWN", "CH DOWN",
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kCH_DOWN))]))
+ KEYS[int(keys.kCH_DOWN)]))
fkeys.append(chd)
foot = RadioSetting("keys.kFOOT", "Foot switch",
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kCH_DOWN))]))
+ KEYS[int(keys.kFOOT)]))
fkeys.append(foot)
# this is the common buttons for all
@@ -1343,8 +1338,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
scn = RadioSetting("keys.kSCN", scn_name,
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kSCN))]))
+ KEYS[int(keys.kSCN)]))
fkeys.append(scn)
a_name = "A"
@@ -1353,8 +1347,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
a = RadioSetting("keys.kA", a_name,
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kA))]))
+ KEYS[int(keys.kA)]))
fkeys.append(a)
da_name = "D/A"
@@ -1363,8 +1356,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
da = RadioSetting("keys.kDA", da_name,
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kDA))]))
+ KEYS[int(keys.kDA)]))
fkeys.append(da)
gu_name = "Triangle up"
@@ -1373,8 +1365,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
gu = RadioSetting("keys.kGROUP_UP", gu_name,
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kGROUP_UP))]))
+ KEYS[int(keys.kGROUP_UP)]))
fkeys.append(gu)
# Side keys on portables
@@ -1384,8 +1375,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
gd = RadioSetting("keys.kGROUP_DOWN", gd_name,
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kGROUP_DOWN))]))
+ KEYS[int(keys.kGROUP_DOWN)]))
fkeys.append(gd)
mon_name = "MON"
@@ -1394,8 +1384,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
mon = RadioSetting("keys.kMON", mon_name,
RadioSettingValueList(KEYS.values(),
- KEYS.values()[KEYS.keys().index(
- int(keys.kMON))]))
+ KEYS[int(keys.kMON)]))
fkeys.append(mon)
return top
@@ -1479,7 +1468,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
# case keys, with special config
if inter == "keys":
- value = KEYS.keys()[KEYS.values().index(str(value))]
+ value = list(KEYS.keys())[list(KEYS.values()).index(str(value))]
# Apply al configs done
setattr(obj, setting, value)
@@ -1516,7 +1505,7 @@ class Kenwood_Serie_60G(chirp_common.CloneModeRadio, chirp_common.ExperimentalRa
raise errors.InvalidDataError(msg)
-# This kenwwood family is known as "60-G Serie"
+# This kenwwood family is known as "60-G Series"
# all this radios ending in G are compatible:
#
# Portables VHF TK-260G/270G/272G/278G
diff --git a/chirp/drivers/tk8180.py b/chirp/drivers/tk8180.py
index 6efa9b2..3cbb8e3 100644
--- a/chirp/drivers/tk8180.py
+++ b/chirp/drivers/tk8180.py
@@ -36,8 +36,8 @@ try:
has_future = True
except ImportError:
has_future = False
- LOG.warning('python-future package is not '
- 'available; %s requires it' % __name__)
+ LOG.debug('python-future package is not '
+ 'available; %s requires it' % __name__)
HEADER_FORMAT = """
@@ -353,7 +353,7 @@ def do_upload(radio):
send(radio, make_frame('Z', block, b'\xFF'))
else:
checksum = checksum_data(chunk)
- send(radio, make_frame('W', block, chunk + chr(checksum)))
+ send(radio, make_frame('W', block, chunk + bytes([checksum])))
ack = radio.pipe.read(1)
if ack != b'\x06':
@@ -541,6 +541,13 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
dest_zone.zoneinfo.name = (
'Zone %i' % (zone_number + 1)).ljust(12)
+ # Copy the settings we care about from the first zone
+ z0info = self._memobj.zone0.zoneinfo
+ dest_zone.zoneinfo.timeout = z0info.timeout
+ dest_zone.zoneinfo.tot_alert = z0info.tot_alert
+ dest_zone.zoneinfo.tot_rekey = z0info.tot_rekey
+ dest_zone.zoneinfo.tot_reset = z0info.tot_reset
+
def shuffle_zone(self):
"""Sort the memories in the zone according to logical channel number"""
# FIXME: Move this to the zone
@@ -650,7 +657,7 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
return int(val * 10)
elif mode == 'DTCS':
code = int('%i' % val, 8)
- code |= 0x2000
+ code |= 0x2800
if pol == 'R':
code |= 0x8000
return code
@@ -1010,10 +1017,11 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
RadioSettingValueString(0, 12, _name))
zone.append(name)
- def apply_timer(setting, key):
+ def apply_timer(setting, key, zone_number):
val = int(setting.value)
if val == 0:
val = 0xFFFF
+ _zone = getattr(self._memobj, 'zone%i' % zone_number).zoneinfo
setattr(_zone, key, val)
def collapse(val):
@@ -1025,25 +1033,25 @@ class KenwoodTKx180Radio(chirp_common.CloneModeRadio):
timer = RadioSetting(
'timeout', 'Time-out Timer',
RadioSettingValueInteger(15, 1200, collapse(_zone.timeout)))
- timer.set_apply_callback(apply_timer, 'timeout')
+ timer.set_apply_callback(apply_timer, 'timeout', i)
zone.append(timer)
timer = RadioSetting(
'tot_alert', 'TOT Pre-Alert',
RadioSettingValueInteger(0, 10, collapse(_zone.tot_alert)))
- timer.set_apply_callback(apply_timer, 'tot_alert')
+ timer.set_apply_callback(apply_timer, 'tot_alert', i)
zone.append(timer)
timer = RadioSetting(
'tot_rekey', 'TOT Re-Key Time',
RadioSettingValueInteger(0, 60, collapse(_zone.tot_rekey)))
- timer.set_apply_callback(apply_timer, 'tot_rekey')
+ timer.set_apply_callback(apply_timer, 'tot_rekey', i)
zone.append(timer)
timer = RadioSetting(
'tot_reset', 'TOT Reset Time',
RadioSettingValueInteger(0, 15, collapse(_zone.tot_reset)))
- timer.set_apply_callback(apply_timer, 'tot_reset')
+ timer.set_apply_callback(apply_timer, 'tot_reset', i)
zone.append(timer)
zone.append(self._inverted_flag_setting(
@@ -1213,3 +1221,15 @@ if has_future:
MODEL = 'TK-3180K2'
VALID_BANDS = [(400000000, 520000000)]
_model = b'P3180\x07'
+
+ @directory.register
+ class KenwoodTK8180E(KenwoodTKx180Radio):
+ MODEL = 'TK-8180E'
+ VALID_BANDS = [(400000000, 520000000)]
+ _model = b'M8189\''
+
+ @directory.register
+ class KenwoodTK7180ERadio(KenwoodTKx180Radio):
+ MODEL = 'TK-7180E'
+ VALID_BANDS = [(136000000, 174000000)]
+ _model = b'M7189$'
diff --git a/chirp/drivers/tmd710.py b/chirp/drivers/tmd710.py
new file mode 100644
index 0000000..62e224e
--- /dev/null
+++ b/chirp/drivers/tmd710.py
@@ -0,0 +1,2099 @@
+# Copyright 2011 Dan Smith <dsmith@danplanet.com>
+# -- 2019 Rick DeWitt <aa0rd@yahoo.com>
+# -- Implementing Kenwood TM-D710G as MCP Clone Mode for Python 2.7
+# -- Thanks to Herm Halbach, W7HRM, for the 710 model testing.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import time
+import struct
+import logging
+import re
+import math
+from chirp import chirp_common, directory, memmap
+from chirp import bitwise, errors, util
+from chirp.settings import RadioSettingGroup, RadioSetting, \
+ RadioSettingValueBoolean, RadioSettingValueList, \
+ RadioSettingValueString, RadioSettingValueInteger, \
+ RadioSettingValueFloat, RadioSettings, InvalidValueError
+from textwrap import dedent
+from chirp.drivers import kenwood_live
+
+LOG = logging.getLogger(__name__)
+
+HAS_FUTURE = True
+try: # PY3 compliance
+ from builtins import bytes
+except ImportError:
+ HAS_FUTURE = False
+ LOG.debug('python-future package is not '
+ 'available; %s requires it' % __name__)
+
+BAUD = 0
+STIMEOUT = 0.2
+TERM = b'\x0d' # Cmd write terminator (CR)
+ACK = b'\x06' # Data write acknowledge char
+W8S = 0.001 # short wait, secs
+W8L = 0.1 # long wait
+TMD710_DUPLEX = ["", "+", "-", "n/a", "split"]
+TMD710_SKIP = ["", "S"]
+TMD710_MODES = ["FM", "NFM", "AM"]
+TMD710_BANDS = [(118000000, 135995000),
+ (136000000, 199995000),
+ (200000000, 299995000),
+ (300000000, 399995000),
+ (400000000, 523995000),
+ (800000000, 1299995000)]
+TMD710_STEPS = [5.0, 6.25, 8.33, 10.0, 12.5, 15.0, 20.0, 25.0,
+ 30.0, 50.0, 100.0]
+# Need string list of those steps for mem.extra value list
+STEPS_STR = []
+for val in TMD710_STEPS:
+ STEPS_STR.append("%3.2f" % val)
+TMD710_TONE_MODES = ["", "Tone", "TSQL", "DTCS", "Cross"]
+TMD710_CROSS = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone"]
+TMD710_DTSC = list(chirp_common.DTCS_CODES)
+TMD710_TONES = list(chirp_common.TONES)
+TMD710_TONES.remove(159.8)
+TMD710_TONES.remove(165.5)
+TMD710_TONES.remove(171.3)
+TMD710_TONES.remove(177.3)
+TMD710_TONES.remove(183.5)
+TMD710_TONES.remove(189.9)
+TMD710_TONES.remove(196.6)
+TMD710_TONES.remove(199.5)
+TMD710_CHARS = chirp_common.CHARSET_ASCII
+TMD710_CHARS += chr(34) # "
+
+
+def _command(ser, cmd, rsplen, w8t=0.01):
+ """Send cmd to radio via ser port
+ cmd is output string with possible terminator
+ rsplen is expected response char count, NOT incl prefix and term
+ If rsplen = 0 then do not0 read after write """
+ ser.write(cmd)
+ LOG.debug(" Out %4i ->: %s" % (len(cmd), util.hexprint(cmd[0: 32])))
+ time.sleep(w8t)
+ result = b""
+ if rsplen > 0: # read response
+ result = ser.read(rsplen)
+ LOG.debug(" In %4i <-: %s" % (len(result),
+ util.hexprint(result[0: 32])))
+ return result
+
+
+def _connect_radio(radio):
+ """Determine baud rate and verify radio on-line"""
+ global BAUD
+ xid = "D710" + radio.SHORT
+ resp = kenwood_live.get_id(radio.pipe)
+ BAUD = radio.pipe.baudrate # As detected by kenwood_live
+ LOG.debug("Got [%s] at %i Baud." % (resp, BAUD))
+ resp = resp[3:] # Strip "ID " prefix
+ if len(resp) > 2: # Got something from "ID"
+ if resp == xid: # Good comms
+ return
+ else:
+ stx = "Radio responded as %s, not %s." % (resp, xid)
+ raise errors.RadioError(stx)
+ raise errors.RadioError("No response from radio")
+
+
+def _update_status(self, status, step=1):
+ """ Increment status bar """
+ status.cur += step
+ self.status_fn(status)
+ return
+
+
+def _val_list(setting, opts, obj, atrb, fix=0, ndx=-1):
+ """Callback:from ValueList. Set the integer index.
+ This function is here to be available to get_mem and get_set
+ fix is optional additive offset to the list index
+ ndx is optional obj[ndx] array index """
+ value = opts.index(str(setting.value))
+ value += fix
+ if ndx >= 0: # indexed obj
+ setattr(obj[ndx], atrb, value)
+ else:
+ setattr(obj, atrb, value)
+ return
+
+
+class KenwoodTMx710Radio(chirp_common.CloneModeRadio):
+ """ Base class for TMD-710 """
+ VENDOR = "Kenwood"
+ MODEL = "TM-x710"
+ SHORT = "X" # Short model ID code
+ NEEDS_COMPAT_SERIAL = False
+
+ _upper = 999 # Number of normal chans
+
+ # Put Special memory channels after normal ones
+ SPECIAL_MEMORIES = {"Scan-0Lo": 1000, "Scan-0Hi": 1001,
+ "Scan-1Lo": 1002, "Scan-1Hi": 1003,
+ "Scan-2Lo": 1004, "Scan-2Hi": 1005,
+ "Scan-3Lo": 1006, "Scan-3Hi": 1007,
+ "Scan-4Lo": 1008, "Scan-4Hi": 1009,
+ "Scan-5Lo": 1010, "Scan-5Hi": 1011,
+ "Scan-6Lo": 1012, "Scan-6Hi": 1013,
+ "Scan-7Lo": 1014, "Scan-7Hi": 1015,
+ "Scan-8Lo": 1016, "Scan-8Hi": 1017,
+ "Scan-9Lo": 1018, "Scan-9Hi": 1019,
+ "WX-1": 1020, "WX-2": 1021,
+ "WX-3": 1022, "WX-4": 1023,
+ "WX-5": 1024, "WX-6": 1025,
+ "WX-7": 1026, "WX-8": 1027,
+ "WX-9": 1028, "WX-10": 1029,
+ "Call C0": 1030, "Call C1": 1031
+ }
+ # _REV dict is used to retrieve name given number
+ SPECIAL_MEMORIES_REV = dict(zip(SPECIAL_MEMORIES.values(),
+ SPECIAL_MEMORIES.keys()))
+
+ def get_features(self):
+ rf = chirp_common.RadioFeatures()
+ rf.can_odd_split = True
+ rf.has_dtcs = True
+ rf.has_dtcs_polarity = False
+ if self.SHORT == "G": # NOT for D710
+ rf.has_rx_dtcs = True # Enable DTCS Rx Code column
+ rf.has_cross = True
+ rf.valid_cross_modes = TMD710_CROSS
+ rf.has_bank = False
+ rf.has_settings = True
+ rf.has_ctone = True
+ rf.has_mode = True
+ rf.has_comment = False
+ rf.valid_tmodes = TMD710_TONE_MODES
+ rf.valid_modes = TMD710_MODES
+ rf.valid_duplexes = TMD710_DUPLEX
+ rf.valid_tuning_steps = TMD710_STEPS
+ rf.valid_dtcs_codes = TMD710_DTSC
+ # Supports upper and lower case text
+ rf.valid_characters = TMD710_CHARS
+ rf.valid_name_length = 8
+ rf.valid_skips = TMD710_SKIP
+ rf.valid_bands = TMD710_BANDS
+ rf.memory_bounds = (0, 1029) # including special chans 1000-1029
+ rf.valid_special_chans = sorted(self.SPECIAL_MEMORIES.keys())
+ return rf
+
+ @classmethod
+ def get_prompts(cls):
+ rp = chirp_common.RadioPrompts()
+ rp.pre_download = _(dedent("""\
+ Connect your interface cable to the PC Port on the
+ back of the 'TX/RX' unit. NOT the Com Port on the head.
+ """))
+ rp.pre_upload = _(dedent("""\
+ Connect your interface cable to the PC Port on the
+ back of the 'TX/RX' unit. NOT the Com Port on the head.
+ """))
+ return rp
+
+ def sync_in(self):
+ """Download from radio"""
+ try:
+ _connect_radio(self)
+ data = bytes(self._read_mem())
+ except errors.RadioError:
+ # Pass through any real errors we raise
+ raise
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during download')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+ self._mmap = memmap.MemoryMapBytes(data)
+ self.process_mmap()
+
+ def sync_out(self):
+ """Upload to radio"""
+ try:
+ _connect_radio(self)
+ self._write_mem()
+ except Exception:
+ # If anything unexpected happens, make sure we raise
+ # a RadioError and log the problem
+ LOG.exception('Unexpected error during upload')
+ raise errors.RadioError('Unexpected error communicating '
+ 'with the radio')
+
+ def process_mmap(self):
+ """Process the mem map into the mem object"""
+ self._memobj = bitwise.parse(self.MEM_FORMAT, self._mmap)
+
+ def get_memory(self, number):
+ """Convert raw channel data (_mem) into UI columns (mem)"""
+ mem = chirp_common.Memory()
+ if self.SHORT == "G":
+ mem.extra = RadioSettingGroup("extra", "Extra")
+ # If called from 'Properties', spcl chans number is integer
+ propflg = False
+ if isinstance(number, int):
+ if number > 999:
+ propflg = True
+ if isinstance(number, str) or propflg:
+ if propflg:
+ mem.number = number
+ mem.name = self.SPECIAL_MEMORIES_REV[number]
+ mem.extd_number = mem.name
+ else:
+ mem.name = number # Spcl chns 1st var
+ mem.number = self.SPECIAL_MEMORIES[number]
+ mem.extd_number = number # Uses name as LOC
+ mem.immutable = ["name"]
+ if mem.number < 1030: # Scan edges, WX
+ _mem = self._memobj.ch_mem[mem.number]
+ _map = self._memobj.chmap[mem.number]
+ else: # Call chans
+ _mem = self._memobj.call[mem.number - 1030]
+ else: # Normal mem chans
+ _mem = self._memobj.ch_mem[number]
+ _nam = self._memobj.ch_nam[number]
+ _map = self._memobj.chmap[number]
+ mem.number = number
+ mnx = ""
+ for char in _nam.name:
+ if int(char) < 127:
+ mnx += chr(int(char))
+ mem.name = mnx
+ if _mem.rxfreq == 0x0ffffffff or _mem.rxfreq == 0:
+ mem.empty = True
+ return mem
+ mem.empty = False
+ if mem.number < 1030 and _map.skip != 0x0ff: # empty
+ mem.skip = TMD710_SKIP[_map.skip]
+ mem.freq = int(_mem.rxfreq)
+ mem.duplex = TMD710_DUPLEX[_mem.duplex]
+ mem.offset = int(_mem.offset)
+ # Duplex = 4 (split); offset contains the TX freq
+ mem.mode = TMD710_MODES[_mem.mode]
+ # _mem.tmode is 4-bit pattern, not number
+ mx = 0 # No tone
+ mem.cross_mode = TMD710_CROSS[0]
+ mem.rx_dtcs = TMD710_DTSC[_mem.dtcs]
+ mem.dtcs = TMD710_DTSC[_mem.dtcs]
+ if self.SHORT == "G":
+ if _mem.tmode & 8: # Tone
+ mx = 1
+ if _mem.tmode & 4: # Tsql
+ mx = 2
+ if _mem.tmode & 2: # Dtcs
+ mx = 3
+ if _mem.tmode & 1: # Cross
+ mx = 4
+ if _mem.cross == 1: # Tone->DTCS
+ mem.cross_mode = TMD710_CROSS[1]
+ if _mem.cross == 2: # DTCS->Tone
+ mem.cross_mode = TMD710_CROSS[2]
+ else: # D710; may have bit 8 set
+ if _mem.tmode & 4: # Tone
+ mx = 1
+ if _mem.tmode & 2: # Tsql
+ mx = 2
+ if _mem.tmode & 1: # Dtcs
+ mx = 3
+ mem.dtcs = TMD710_DTSC[_mem.dtcs]
+ mem.tmode = TMD710_TONE_MODES[mx]
+ mem.ctone = TMD710_TONES[_mem.ctone]
+ mem.rtone = TMD710_TONES[_mem.rtone]
+ mem.tuning_step = TMD710_STEPS[_mem.tstep]
+
+ if self.SHORT == "G": # Only the 710G
+ rx = RadioSettingValueList(STEPS_STR, STEPS_STR[_mem.splitstep])
+ sx = "Split TX step (KHz)"
+ rset = RadioSetting("splitstep", sx, rx)
+ mem.extra.append(rset)
+
+ return mem
+
+ def set_memory(self, mem):
+ """Convert UI column data (mem) into MEM_FORMAT memory (_mem)"""
+ if mem.number > 999: # Special chans
+ if mem.number < 1030: # Scan, Wx
+ _mem = self._memobj.ch_mem[mem.number]
+ _map = self._memobj.chmap[mem.number]
+ else: # Call chans
+ _mem = self._memobj.call[mem.number - 1030]
+ else:
+ _mem = self._memobj.ch_mem[mem.number]
+ _nam = self._memobj.ch_nam[mem.number]
+ _map = self._memobj.chmap[mem.number]
+ nx = len(mem.name)
+ for ix in range(8):
+ if ix < nx:
+ _nam.name[ix] = mem.name[ix]
+ else:
+ _nam.name[ix] = chr(0x0ff) # needs 8 chrs
+ if mem.empty:
+ _mem.rxfreq = 0x0ffffffff
+ _mem.offset = 0x0ffffff
+ _mem.duplex = 0x0f
+ _mem.tstep = 0x0ff
+ _mem.tmode = 0x0f
+ _mem.mode = 0x0ff
+ _mem.rtone = 0x0ff
+ _mem.ctone = 0x0ff
+ _mem.dtcs = 0x0ff
+ _map.skip = 0x0ff
+ _map.band = 0x0ff
+ for ix in range(8):
+ _nam.name[ix] = chr(0x0ff)
+ return
+ if _mem.rxfreq == 0x0ffffffff: # New Channel needs defaults
+ _mem.rxfreq = 144000000
+ _map.band = 5
+ _map.skip = 0
+ _mem.mode = 0
+ _mem.duplex = 0
+ _mem.offset = 0
+ _mem.rtone = 8
+ _mem.ctone = 8
+ _mem.dtcs = 0
+ _mem.tstep = 0
+ _mem.splitstep = 0
+ # Now use the UI values entered so far
+ _mem.rxfreq = mem.freq
+ _mem.mode = TMD710_MODES.index(mem.mode)
+ try:
+ _tone = mem.rtone
+ _mem.rtone = TMD710_TONES.index(mem.rtone)
+ _tone = mem.ctone
+ _mem.ctone = TMD710_TONES.index(mem.ctone)
+ except ValueError:
+ raise errors.UnsupportedToneError("This radio does not support " +
+ "tone %.1fHz" % _tone)
+ _mem.dtcs = TMD710_DTSC.index(mem.dtcs)
+ _mem.tmode = 0 # None
+ _mem.cross = 0
+ if self.SHORT == "G":
+ if mem.tmode == "Tone":
+ _mem.tmode = 8
+ if mem.tmode == "TSQL":
+ _mem.tmode = 4
+ if mem.tmode == "DTCS":
+ _mem.tmode = 2
+ if mem.tmode == "Cross":
+ _mem.tmode = 1
+ mx = TMD710_CROSS.index(mem.cross_mode)
+ _mem.cross = 3 # t -t
+ if mx == 1:
+ _mem.cross = 1 # t-d
+ _mem.dtcs = TMD710_DTSC.index(mem.rx_dtcs)
+ if mx == 2:
+ _mem.cross = 2 # d-t
+ _mem.dtcs = TMD710_DTSC.index(mem.dtcs)
+ else:
+ _mem.tmode = 0x80 # None
+ if mem.tmode == "Tone":
+ _mem.tmode = 0x0c
+ if mem.tmode == "TSQL":
+ _mem.tmode = 0x0a
+ if mem.tmode == "DTCS":
+ _mem.tmode = 0x09
+ if mem.duplex == "n/a": # Not valid
+ mem.duplex = ""
+ _mem.duplex = TMD710_DUPLEX.index(mem.duplex)
+ _mem.offset = mem.offset
+ _mem.tstep = TMD710_STEPS.index(mem.tuning_step)
+ # Set _map.band for this bank. Not Calls!
+ if mem.number < 1030:
+ _map.band = 5
+ val = mem.freq
+ for mx in range(6): # Band codes are 0, 5, 6, 7, 8, 9
+ if val >= TMD710_BANDS[mx][0] and \
+ val <= TMD710_BANDS[mx][1]:
+ _map.band = mx
+ if mx > 0:
+ _map.band = mx + 4
+ _map.skip = TMD710_SKIP.index(mem.skip)
+ # Only 1 mem.extra entry now
+ for ext in mem.extra:
+ if ext.get_name() == "splitstep":
+ val = STEPS_STR.index(str(ext.value))
+ setattr(_mem, "splitstep", val)
+ else:
+ setattr(_mem, ext.get_name(), ext.value)
+ return
+
+ def get_settings(self):
+ """Translate the MEM_FORMAT structs into settings in the UI"""
+ # Define mem struct write-back shortcuts
+ if self.SHORT == "G":
+ _bmp = self._memobj.bitmap
+ _blk1 = self._memobj.block1
+ _blk1a = self._memobj.block1a
+ _pmg = self._memobj.pmg # array[6] of settings
+ _dtmc = self._memobj.dtmc
+ _dtmn = self._memobj.dtmn
+ _com = self._memobj.mcpcom
+ _skyc = self._memobj.skycmd
+ basic = RadioSettingGroup("basic", "Basic")
+ disp = RadioSettingGroup("disp", "PM0: Display") # PM[0] settings
+ aud = RadioSettingGroup("aud", "PM0: Audio")
+ aux = RadioSettingGroup("aux", "PM0: Aux")
+ txrx = RadioSettingGroup("txrc", "PM0: Transmit/Receive")
+ memz = RadioSettingGroup("memz", "PM0: Memory")
+ pfk = RadioSettingGroup("pfk", "PM0: PF Keys")
+ pvfo = RadioSettingGroup("pvfo", "PM0: Programmable VFO")
+ bmsk = RadioSettingGroup("bmsk", "PM0: Band Masks") # end PM[0]
+ rptr = RadioSettingGroup("rptr", "Repeater")
+ dtmf = RadioSettingGroup("dtmf", "DTMF")
+ skyk = RadioSettingGroup("skyk", "Sky Command")
+ pmm = RadioSettingGroup("pmm", "PM Groups 1-5(Partial)")
+ group = RadioSettings(basic, disp, aud, aux, txrx, memz, pvfo, pfk,
+ bmsk, rptr, dtmf, skyk, pmm)
+
+ mhz1 = 1000000. # Raw freq is stored with 0.1 Htz resolution
+
+ def _adjraw(setting, obj, atrb, fix=0, ndx=-1):
+ """Callback for Integer add or subtract fix from value."""
+ vx = int(str(setting.value))
+ value = vx + int(fix)
+ if value < 0:
+ value = 0
+ if ndx < 0:
+ setattr(obj, atrb, value)
+ else:
+ setattr(obj[ndx], atrb, value)
+ return
+
+ def _mhz_val(setting, obj, atrb, ndx=-1, ndy=-1):
+ """ Callback to set freq back to Htz """
+ vx = float(str(setting.value))
+ vx = int(vx * mhz1)
+ if ndx < 0:
+ setattr(obj, atrb, vx)
+ else:
+ if atrb[0:7] == "progvfo": # 2-deep
+ stx = atrb.split(".")
+ setattr(obj[ndx].progvfo[ndy], stx[1], vx)
+ else:
+ setattr(obj[ndx], atrb, vx)
+ return
+
+ def _char_to_str(chrx):
+ """ Remove ff pads from char array """
+ # chrx is char array
+ str1 = ""
+ for sx in chrx:
+ if int(sx) > 31 and int(sx) < 127:
+ str1 += chr(int(sx))
+ return str1
+
+ def _pswd_vfy(setting, obj, atrb):
+ """ Verify password is 1-6 chars, numbers 1-5 """
+ str1 = str(setting.value).strip() # initial
+ str2 = ''.join(filter(lambda c: c in '12345', str1)) # valid chars
+ if str1 != str2:
+ # Two lines due to python 73 char limit
+ sx = "Bad characters in Password"
+ raise errors.RadioError(sx)
+ str2 = str1.ljust(6, chr(255)) # pad to 6 with ff's
+ setattr(obj, atrb, str2)
+ return
+
+ def _pad_str(setting, lenstr, padchr, obj, atrb, ndx=-1):
+ """ pad string to lenstr with padchr """
+ str1 = str(setting.value).strip() # initial string
+ str2 = str1.ljust(lenstr, padchr)
+ if ndx < 0:
+ setattr(obj, atrb, str2)
+ else:
+ setattr(obj[ndx], atrb, str2)
+ return
+
+ # ===== BASIC GROUP =====
+ sx = _char_to_str(_com.comnt)
+ rx = RadioSettingValueString(0, 32, sx)
+ sx = "Comment"
+ rset = RadioSetting("mcpcom.comnt", sx, rx)
+ basic.append(rset)
+
+ rx = RadioSettingValueInteger(0, 5, _blk1.pmrecall)
+ sx = "Current PM Select"
+ rset = RadioSetting("block1.pmrecall", sx, rx)
+ basic.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_blk1.pwdon))
+ sx = "Password"
+ rset = RadioSetting("block1.pwdon", sx, rx)
+ basic.append(rset)
+
+ sx = _char_to_str(_blk1.pswd).strip()
+ rx = RadioSettingValueString(0, 6, sx)
+ # rx.set_charset("12345") # Keeps finding `'
+ sx = "- Password (numerals 1-5)"
+ rset = RadioSetting("block1.pswd", sx, rx)
+ rset.set_apply_callback(_pswd_vfy, _blk1, "pswd")
+ basic.append(rset)
+
+ # ===== PM0 (off) DISPLAY GROUP =====
+ rx = RadioSettingValueString(0, 8, _char_to_str(_pmg[0].pwron))
+ sx = "Power-On message"
+ rset = RadioSetting("pmg/0.pwron", sx, rx)
+ disp.append(rset)
+
+ if self.SHORT == "G": # TMD-710G
+ rx = RadioSettingValueBoolean(bool(_bmp.bmpon))
+ sx = "PM0: Custom display bitmap"
+ rset = RadioSetting("bitmap.bmpon", sx, rx)
+ disp.append(rset)
+
+ rx = RadioSettingValueString(0, 64, _char_to_str(_bmp.bmpfyl))
+ rx.set_mutable(False)
+ sx = "- Custom bitmap filename"
+ rset = RadioSetting("bitmap.bmpfyl", sx, rx)
+ rset.set_doc("Read-only: To modify, use MCP-6 s/w")
+ disp.append(rset)
+
+ opts = ["VFO", "Mem Recall"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].a_mr])
+ sx = "A: Left Side VFO/MR"
+ rset = RadioSetting("pmg/0.a_mr", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "a_mr")
+ disp.append(rset)
+
+ rx = RadioSettingValueInteger(0, 999, _pmg[0].a_chn)
+ sx = "A: Left Side MR Channel"
+ rset = RadioSetting("pmg/0.a_chn", sx, rx)
+ disp.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[0].b_mr])
+ sx = "B: Right Side VFO/MR"
+ rset = RadioSetting("pmg/0.b_mr", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "b_mr")
+ disp.append(rset)
+
+ rx = RadioSettingValueInteger(0, 999, _pmg[0].b_chn)
+ sx = "B: Right Side MR Channel"
+ rset = RadioSetting("pmg/0.b_chn", sx, rx)
+ disp.append(rset)
+
+ rx = RadioSettingValueInteger(0, 8, _pmg[0].bright)
+ sx = "Brightness level"
+ rset = RadioSetting("pmg/0.bright", sx, rx)
+ disp.append(rset)
+
+ opts = ["Amber", "Green"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].bkltclr])
+ sx = "Backlight color"
+ rset = RadioSetting("pmg/0.bkltclr", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "bkltclr")
+ disp.append(rset)
+
+ val = _pmg[0].bkltcont + 1
+ rx = RadioSettingValueInteger(1, 16, val)
+ sx = "Contrast level"
+ rset = RadioSetting("pmg/0.bkltcont", sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[0], "bkltcont", -1)
+ disp.append(rset)
+
+ opts = ["Positive", "Negative"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].dsprev])
+ sx = "Color mode"
+ rset = RadioSetting("pmg/0.dsprev", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "dsprev")
+ disp.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].autobri))
+ sx = "Auto brightness"
+ rset = RadioSetting("pmg/0.autobri", sx, rx)
+ disp.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].dispbar))
+ sx = "Display partition bar"
+ rset = RadioSetting("pmg/0.dispbar", sx, rx)
+ disp.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].single))
+ sx = "Single band display"
+ rset = RadioSetting("pmg/0.single", sx, rx)
+ disp.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].autopm))
+ sx = "Auto PM Store"
+ rset = RadioSetting("pmg/0.autopm", sx, rx)
+ disp.append(rset)
+
+ # ===== AUDIO GROUP =====
+ rx = RadioSettingValueBoolean(bool(_pmg[0].beepon))
+ sx = "Beep On"
+ rset = RadioSetting("pmg/0.beepon", sx, rx)
+ aud.append(rset)
+
+ val = _pmg[0].beepvol + 1 # 1-7 downloads as 0-6
+ rx = RadioSettingValueInteger(1, 7, val)
+ sx = "Beep volume (1 - 7)"
+ rset = RadioSetting("pmg/0.beepvol", sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[0], "beepvol", -1)
+ aud.append(rset)
+
+ opts = ["Mode1", "Mode2"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].extspkr])
+ sx = "External Speaker"
+ rset = RadioSetting("pmg/0.extspkr", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "extspkr")
+ aud.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].pbkrpt))
+ sx = "VGS Plugin: Playback repeat"
+ rset = RadioSetting("pmg/0.pbkrpt", sx, rx)
+ aud.append(rset)
+
+ rx = RadioSettingValueInteger(0, 60, _pmg[0].pbkint)
+ sx = " Playback repeat interval (0 - 60 secs)"
+ rset = RadioSetting("pmg/0.pbkint", sx, rx)
+ aud.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].cntrec))
+ sx = " Continuous recording"
+ rset = RadioSetting("pmg/0.cntrec", sx, rx)
+ aud.append(rset)
+
+ opts = ["Off", "Auto", "Manual"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].ance])
+ sx = " Announce mode"
+ rset = RadioSetting("pmg/0.ance", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "ance")
+ aud.append(rset)
+
+ opts = ["English", "Japanese"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].lang])
+ sx = " Announce language"
+ rset = RadioSetting("pmg/0.lang", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "lang")
+ aud.append(rset)
+
+ rx = RadioSettingValueInteger(1, 7, _pmg[0].vcvol + 1)
+ sx = " Voice volume (1 - 7)"
+ rset = RadioSetting("pmg/0.vcvol", sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[0], "vcvol", -1)
+ aud.append(rset)
+
+ rx = RadioSettingValueInteger(0, 4, _pmg[0].vcspd)
+ sx = " Voice speed (0 - 4)"
+ rset = RadioSetting("pmg/0.vcspd", sx, rx)
+ aud.append(rset)
+
+ # ===== AUX GROUP =====
+ opts = ["9600", "19200", "38400", "57600"]
+ rx = RadioSettingValueList(opts, opts[_blk1.pcbaud])
+ sx = "PC port baud rate"
+ rset = RadioSetting("block1.pcbaud", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _blk1, "pcbaud")
+ aux.append(rset)
+
+ opts = ["A-Band", "B-Band", "TX-A / RX-B", "RX-A / TX-B"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].intband])
+ sx = "Internal TNC band"
+ rset = RadioSetting("pmg/0.intband", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "intband")
+ aux.append(rset)
+
+ opts = ["A-Band", "B-Band", "TX-A / RX-B", "RX-A / TX-B"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].extband])
+ sx = "External TNC band"
+ rset = RadioSetting("pmg/0.extband", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "extband")
+ aux.append(rset)
+
+ opts = ["1200", "9600"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].extbaud])
+ sx = "External TNC baud"
+ rset = RadioSetting("pmg/0.extbaud", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "extbaud")
+ aux.append(rset)
+
+ opts = ["Off", "BUSY", "SQL", "TX", "BUSY/TX", "SQL/TX"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].sqcsrc])
+ sx = "SQC output source"
+ rset = RadioSetting("pmg/0.sqcsrc", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "sqcsrc")
+ aux.append(rset)
+
+ opts = ["Low", "High"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].sqclogic])
+ sx = "SQC logic"
+ rset = RadioSetting("pmg/0.sqclogic", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "sqclogic")
+ aux.append(rset)
+
+ opts = ["Off", "30", "60", "90", "120", "180"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].apo])
+ sx = "APO: Auto Power Off (Mins)"
+ rset = RadioSetting("pmg/0.apo", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "apo")
+ aux.append(rset)
+
+ opts = ["Time Operate (TO)", "Carrier Operate (CO)", "Seek"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].scnrsm])
+ sx = "Scan resume mode"
+ rset = RadioSetting("pmg/0.scnrsm", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "scnrsm")
+ aux.append(rset)
+
+ rx = RadioSettingValueInteger(1, 10, _pmg[0].scntot + 1)
+ sx = " Scan TO delay (Secs)"
+ rset = RadioSetting("pmg/0.scntot", sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[0], "scntot", -1)
+ aux.append(rset)
+
+ rx = RadioSettingValueInteger(1, 10, _pmg[0].scncot + 1)
+ sx = " Scan CO delay (Secs)"
+ rset = RadioSetting("pmg/0.scncot", sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[0], "scncot", -1)
+ aux.append(rset)
+
+ opts = ["Mode 1: 1ch", "Mode 2: 61ch", "Mode 3: 91ch",
+ "Mode 4: 181ch"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].vsmode])
+ sx = "Visual scan"
+ rset = RadioSetting("pmg/0.vsmode", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "vsmode")
+ aux.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_blk1.m10mz))
+ sx = "10 Mhz mode"
+ rset = RadioSetting("block1.m10mz", sx, rx)
+ aux.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_blk1.ansbck))
+ sx = "Remote control answerback"
+ rset = RadioSetting("block1.ansbck", sx, rx)
+ aux.append(rset)
+
+ # ===== TX / RX Group =========
+ opts = ["A: Left", "B: Right"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].txband])
+ sx = "TX Side (PTT)"
+ rset = RadioSetting("pmg/0.txband", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "txband")
+ txrx.append(rset)
+
+ opts = ["High (50W)", "Medium (10W)", "Low (5W)"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].a_pwr])
+ sx = "A-Band transmit power"
+ rset = RadioSetting("pmg/0.a_pwr", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "a_pwr")
+ txrx.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[0].b_pwr])
+ sx = "B-Band transmit power"
+ rset = RadioSetting("pmg/0.b_pwr", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "b_pwr")
+ txrx.append(rset)
+
+ opts = ["Off", "125", "250", "500", "750", "1000"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].mutehu])
+ sx = "Rx Mute hangup time (ms)"
+ rset = RadioSetting("pmg/0.mutehu", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "mutehu")
+ txrx.append(rset)
+
+ opts = ["Off", "125", "250", "500"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].ssqlhu])
+ sx = "S-meter SQL hangup time (ms)"
+ rset = RadioSetting("pmg/0.ssqlhu", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "ssqlhu")
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].beatshft))
+ sx = "Beat shift"
+ rset = RadioSetting("pmg/0.beatshft", sx, rx)
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].asmsql))
+ sx = "A-Band S-meter SQL"
+ rset = RadioSetting("pmg/0.asmsql", sx, rx)
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].bsmsql))
+ sx = "B-Band S-meter SQL"
+ rset = RadioSetting("pmg/0.bsmsql", sx, rx)
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].vhfaip))
+ sx = "VHF band AIP"
+ rset = RadioSetting("pmg/0.vhfaip", sx, rx)
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].uhfaip))
+ sx = "UHF band AIP"
+ rset = RadioSetting("pmg/0.uhfaip", sx, rx)
+ txrx.append(rset)
+
+ opts = ["High", "Medium", "Low"]
+ rx = RadioSettingValueList(opts, opts[_blk1.micsens])
+ sx = "Microphone sensitivity (gain)"
+ rset = RadioSetting("block1.micsens", sx, rx)
+ txrx.append(rset)
+
+ opts = ["3", "5", "10"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].tot])
+ sx = "Time-Out timer (Mins)"
+ rset = RadioSetting("pmg/0.tot", sx, rx)
+ # rset.set_apply_callback(_val_list, opts, _pmg[0], "tot")
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].wxalerta))
+ sx = "WX Alert A-band"
+ rset = RadioSetting("pmg/0.wxalerta", sx, rx)
+ txrx.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].wxalertb))
+ sx = "WX Alert B-band"
+ rset = RadioSetting("pmg/0.wxalertb", sx, rx)
+ txrx.append(rset)
+
+ opts = ["Off", "15", "30", "60"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].wxscntm])
+ sx = "WX alert scan memory time (Mins)"
+ rset = RadioSetting("pmg/0.wxscntm", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "wxscntm")
+ txrx.append(rset)
+
+ # ===== DTMF GROUP =====
+ rx = RadioSettingValueBoolean(bool(_pmg[0].dtmfhld))
+ sx = "DTMF hold"
+ rset = RadioSetting("pmg/0.dtmfhld", sx, rx)
+ dtmf.append(rset)
+
+ opts = ["100", "250", "500", "750", "1000", "1500", "2000"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].dtmfpau])
+ sx = "DTMF pause duration (mS)"
+ rset = RadioSetting("pmg/0.dtmfpau", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "dtmfpau")
+ dtmf.append(rset)
+
+ opts = ["Fast", "Slow"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].dtmfspd])
+ sx = "DTMF speed"
+ rset = RadioSetting("pmg/0.dtmfspd", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "dtmfspd")
+ dtmf.append(rset)
+
+ for mx in range(0, 10):
+ csx = _char_to_str(_dtmn[mx].id).strip()
+ rx = RadioSettingValueString(0, 8, csx)
+ sx = "DTMF %i Name (8 chars)" % mx
+ rset = RadioSetting("dtmn.id/%d" % mx, sx, rx)
+ rset.set_apply_callback(_pad_str, 8, chr(255), _dtmn, "id", mx)
+ dtmf.append(rset)
+
+ csx = _char_to_str(_dtmc[mx].code).strip()
+ rx = RadioSettingValueString(0, 16, csx)
+ sx = " Code %i (16 chars)" % mx
+ rset = RadioSetting("dtmc.code/%d" % mx, sx, rx)
+ rset.set_apply_callback(_pad_str, 16, chr(255), _dtmc, "code", mx)
+ dtmf.append(rset)
+
+ # ===== MEMORY GROUP =====
+ opts = ["All Bands", "Current Band"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].recall])
+ sx = "Memory recall method"
+ rset = RadioSetting("pmg/0.recall", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "recall")
+ memz.append(rset)
+
+ rx = RadioSettingValueString(0, 10, _char_to_str(_pmg[0].memgrplk))
+ sx = "Group link"
+ rset = RadioSetting("pmg/0.memgrplk", sx, rx)
+ memz.append(rset)
+
+ opts = ["Fast", "Slow"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].eclnkspd])
+ sx = "Echolink speed"
+ rset = RadioSetting("pmg/0.eclnkspd", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "eclnkspd")
+ memz.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_blk1.dspmemch))
+ sx = "Display memory channel number"
+ rset = RadioSetting("block1.dspmemch", sx, rx)
+ memz.append(rset)
+
+ # ===== REPEATER GROUP =====
+ rx = RadioSettingValueBoolean(bool(_pmg[0].rptr1750))
+ sx = "1750 Hz transmit hold"
+ rset = RadioSetting("pmg/0.rptr1750", sx, rx)
+ rptr.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].rptrofst))
+ sx = "Auto repeater offset"
+ rset = RadioSetting("pmg/0.rptrofst", sx, rx)
+ rptr.append(rset)
+
+ opts = ["Cross Band", "TX:A-Band / RX:B-Band", "RX:A-Band / TX:B-Band"]
+ rx = RadioSettingValueList(opts, opts[_blk1.rptrmode])
+ sx = "Repeater Mode"
+ rset = RadioSetting("block1.rptrmode", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _blk1, "rptrmode")
+ rptr.append(rset)
+
+ opts = ["Off", "Morse", "Voice"]
+ rx = RadioSettingValueList(opts, opts[_blk1.rptridx])
+ sx = "Repeater ID transmit"
+ rset = RadioSetting("block1.rptridx", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _blk1, "rptridx")
+ rptr.append(rset)
+
+ rx = RadioSettingValueString(0, 12, _char_to_str(_blk1a.rptrid))
+ sx = "Repeater ID"
+ rset = RadioSetting("block1a.rptrid", sx, rx)
+ rptr.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_blk1.rptrhold))
+ sx = "Repeater transmit hold"
+ rset = RadioSetting("block1.rptrhold", sx, rx)
+ rptr.append(rset)
+
+ # ===== Prog VFO Group =============
+ for mx in range(0, 10):
+ # Raw freq is 0.1 Mhz resolution
+ vfx = int(_pmg[0].progvfo[mx].blow) / mhz1
+ if vfx == 0:
+ vfx = 118
+ rx = RadioSettingValueFloat(118.0, 1299.9, vfx, 0.005, 3)
+ sx = "VFO-%i Low Limit (MHz)" % mx
+ rset = RadioSetting("pmg/0.progvfo/%d.blow" % mx, sx, rx)
+ rset.set_apply_callback(_mhz_val, _pmg, "progvfo.blow", 0, mx)
+ pvfo.append(rset)
+
+ vfx = int(_pmg[0].progvfo[mx].bhigh) / mhz1
+ if vfx == 0:
+ vfx = 118
+ rx = RadioSettingValueFloat(118.0, 1300.0, vfx, 0.005, 3)
+ sx = " VFO-%i High Limit (MHz)" % mx
+ rset = RadioSetting("pmg/0.progvfo/%d.bhigh" % mx, sx, rx)
+ rset.set_apply_callback(_mhz_val, _pmg, "progvfo.bhigh", 0, mx)
+ pvfo.append(rset)
+
+ # ===== PFK GROUP =====
+ opts = ["WX CH", "FRQ.BAND", "CTRL", "MONITOR", "VGS", "VOICE",
+ "GROUP UP", "MENU", "MUTE", "SHIFT", "DUAL", "M>V",
+ "1750 Tone"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].pf1key])
+ sx = "Front panel PF1 key"
+ rset = RadioSetting("pmg/0.pf1key", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "pf1key")
+ pfk.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[0].pf2key])
+ sx = "Front panel PF2 key"
+ rset = RadioSetting("pmg/0.pf2key", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "pf2key")
+ pfk.append(rset)
+
+ opts = ["WX CH", "FRQ.BAND", "CTRL", "MONITOR", "VGS", "VOICE",
+ "GROUP UP", "MENU", "MUTE", "SHIFT", "DUAL", "M>V",
+ "VFO", "MR", "CALL", "MHz", "TONE", "REV", "LOW",
+ "LOCK", "A/B", "ENTER", "1750 Tone", "M.LIST",
+ "S.LIST", "MSG.NEW", "REPLY", "POS", "P.MONI",
+ "BEACON", "DX", "WX"]
+ rx = RadioSettingValueList(opts, opts[_pmg[0].micpf1])
+ sx = "Microphone PF1 key"
+ rset = RadioSetting("pmg/0.micpf1", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "micpf1")
+ pfk.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[0].micpf2])
+ sx = "Microphone PF2 key"
+ rset = RadioSetting("pmg/0.micpf2", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "micpf2")
+ pfk.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[0].micpf3])
+ sx = "Microphone PF3 key"
+ rset = RadioSetting("pmg/0.micpf3", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "micpf3")
+ pfk.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[0].micpf4])
+ sx = "Microphone PF4 key"
+ rset = RadioSetting("pmg/0.micpf4", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[0], "micpf4")
+ pfk.append(rset)
+
+ # ===== BMSK GROUP =====
+ rx = RadioSettingValueBoolean(bool(_pmg[0].abnd118))
+ sx = "A/Left: 118Mhz Band"
+ rset = RadioSetting("pmg/0.abnd118", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].abnd144))
+ sx = "A/Left: 144Mhz Band"
+ rset = RadioSetting("pmg/0.abnd144", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].abnd220))
+ sx = "A/Left: 220Mhz Band"
+ rset = RadioSetting("pmg/0.abnd220", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].abnd300))
+ sx = "A/Left: 300Mhz Band"
+ rset = RadioSetting("pmg/0.abnd300", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].abnd430))
+ sx = "A/Left: 430Mhz Band"
+ rset = RadioSetting("pmg/0.abnd430", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].bbnd144))
+ sx = "B/Right: 144Mhz Band"
+ rset = RadioSetting("pmg/0.bbnd144", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].bbnd220))
+ sx = "B/Right: 220Mhz Band"
+ rset = RadioSetting("pmg/0.bbnd220", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].bbnd300))
+ sx = "B/Right: 300Mhz Band"
+ rset = RadioSetting("pmg/0.bbnd300", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].bbnd430))
+ sx = "B/Right: 430Mhz Band"
+ rset = RadioSetting("pmg/0.bbnd430", sx, rx)
+ bmsk.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[0].bbnd800))
+ sx = "B/Right: 800Mhz Band"
+ rset = RadioSetting("pmg/0.bbnd800", sx, rx)
+ bmsk.append(rset)
+
+ # ===== Sky command Group =============
+ rx = RadioSettingValueString(0, 10, _char_to_str(_skyc.cmdr))
+ sx = "Commandr call sign"
+ rset = RadioSetting("skycmd.cmdr", sx, rx)
+ rset.set_apply_callback(_pad_str, 10, chr(0), _skyc, "cmdr")
+ skyk.append(rset)
+
+ rx = RadioSettingValueString(0, 10, _char_to_str(_skyc.tptr))
+ sx = "Transporter call sign"
+ rset = RadioSetting("skycmd.tptr", sx, rx)
+ rset.set_apply_callback(_pad_str, 10, chr(0), _skyc, "tptr")
+ skyk.append(rset)
+
+ opts = []
+ for val in TMD710_TONES:
+ opts.append(str(val))
+ rx = RadioSettingValueList(opts, opts[_skyc.skytone])
+ sx = "Tone frequency"
+ rset = RadioSetting("skycmd.skytone", sx, rx)
+ rset.set_apply_callback(_val_list, opts, _skyc, "skytone")
+ skyk.append(rset)
+
+ # ===== PM MEMORY GROUP =====
+ """ These 5 blocks of 512 bytes are repeats of the major settings """
+ # Only showing limited settings for now...
+ _pmn = self._memobj.pm_name
+ for ix in range(1, 6):
+ nx = ix - 1 # Names are [0-4]
+ rx = RadioSettingValueString(0, 16, _char_to_str(_pmn[nx].pmname))
+ sx = "PM Group %i Name" % ix
+ rset = RadioSetting("pm_name/%i.pmname" % nx, sx, rx)
+ rset.set_apply_callback(_pad_str, 16, chr(0xff), _pmn,
+ "pmname", nx)
+ pmm.append(rset)
+
+ rx = RadioSettingValueString(0, 8, _char_to_str(_pmg[ix].pwron))
+ sx = "- Power-On Message"
+ rset = RadioSetting("pmg/%i.pwron" % ix, sx, rx)
+ rset.set_apply_callback(_pad_str, 8, chr(0xff), _pmg, "pwron", ix)
+ pmm.append(rset)
+
+ opts = ["VFO", "Mem Recall"]
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].a_mr])
+ sx = "- A: Left Side VFO/MR"
+ rset = RadioSetting("pmg/%i.a_mr" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "a_mr")
+ pmm.append(rset)
+
+ rx = RadioSettingValueInteger(0, 999, _pmg[ix].a_chn)
+ sx = "- A: Left Side MR Channel"
+ rset = RadioSetting("pmg/%i.a_chn" % ix, sx, rx)
+ pmm.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].b_mr])
+ sx = "- B: Right Side VFO/MR"
+ rset = RadioSetting("pmg/%i.b_mr" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "b_mr")
+ pmm.append(rset)
+
+ rx = RadioSettingValueInteger(0, 999, _pmg[ix].b_chn)
+ sx = "- B: Right Side MR Channel"
+ rset = RadioSetting("pmg/%i.b_chn" % ix, sx, rx)
+ pmm.append(rset)
+
+ rx = RadioSettingValueInteger(0, 8, _pmg[ix].bright)
+ sx = "- Brightness level"
+ rset = RadioSetting("pmg/%i.bright" % ix, sx, rx)
+ pmm.append(rset)
+
+ opts = ["Amber", "Green"]
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].bkltclr])
+ sx = "- Backlight color"
+ rset = RadioSetting("pmg/%i.bkltclr" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "bkltclr")
+ pmm.append(rset)
+
+ val = _pmg[ix].bkltcont + 1
+ rx = RadioSettingValueInteger(1, 16, val)
+ sx = "- Contrast level"
+ rset = RadioSetting("pmg/%i.bkltcont" % ix, sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[ix], "bkltcont", -1)
+ pmm.append(rset)
+
+ opts = ["Positive", "Negative"]
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].dsprev])
+ sx = "- Color mode"
+ rset = RadioSetting("pmg/%i.dsprev" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "dsprev")
+ pmm.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[ix].beepon))
+ sx = "- Beep On"
+ rset = RadioSetting("pmg/%i.beepon" % ix, sx, rx)
+ pmm.append(rset)
+
+ val = _pmg[ix].beepvol + 1 # 1-7 downloads as 0-6
+ rx = RadioSettingValueInteger(1, 7, val)
+ sx = "- Beep volume (1 - 7)"
+ rset = RadioSetting("pmg/%i.beepvol" % ix, sx, rx)
+ rset.set_apply_callback(_adjraw, _pmg[ix], "beepvol", -1)
+ pmm.append(rset)
+
+ rx = RadioSettingValueBoolean(bool(_pmg[ix].autopm))
+ sx = "- Auto PM Store"
+ rset = RadioSetting("pmg/%i.autopm" % ix, sx, rx)
+ pmm.append(rset)
+
+ opts = ["A: Left", "B: Right"]
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].txband])
+ sx = "- X Side (PTT)"
+ rset = RadioSetting("pmg/%i.txband" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "txband")
+ pmm.append(rset)
+
+ opts = ["High (50W)", "Medium (10W)", "Low (5W)"]
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].a_pwr])
+ sx = "- A-Band transmit power"
+ rset = RadioSetting("pmg/%i.a_pwr" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "a_pwr")
+ pmm.append(rset)
+
+ rx = RadioSettingValueList(opts, opts[_pmg[ix].b_pwr])
+ sx = "- B-Band transmit power"
+ rset = RadioSetting("pmg/%i.b_pwr" % ix, sx, rx)
+ rset.set_apply_callback(_val_list, opts, _pmg[ix], "b_pwr")
+ pmm.append(rset)
+
+ return group # END get_settings()
+
+ def set_settings(self, settings):
+ """ Convert UI modified changes into mem_format values """
+ blks = (self._memobj.block1, self._memobj.block1a,
+ self._memobj.pmg, self._memobj.pm_name)
+ for _settings in blks:
+ for element in settings:
+ if not isinstance(element, RadioSetting):
+ self.set_settings(element)
+ continue
+ else:
+ try:
+ name = element.get_name()
+ if "." in name:
+ bits = name.split(".")
+ obj = self._memobj
+ for bit in bits[:-1]:
+ if "/" in bit:
+ bit, index = bit.split("/", 1)
+ index = int(index)
+ obj = getattr(obj, bit)[index]
+ else:
+ obj = getattr(obj, bit)
+ setting = bits[-1]
+ else:
+ obj = _settings
+ setting = element.get_name()
+
+ if element.has_apply_callback():
+ LOG.debug("Using apply callback")
+ element.run_apply_callback()
+ elif element.value.get_mutable():
+ LOG.debug("Setting %s = %s"
+ % (setting, element.value))
+ setattr(obj, setting, element.value)
+ except Exception as e:
+ LOG.debug(element.get_name())
+ raise
+ return
+
+ @classmethod
+ def match_model(cls, fdata, fyle):
+ """ Included to prevent 'File > New' error """
+ return False
+
+
+if HAS_FUTURE: # Only register drivers if environment is PY3 compliant
+ @directory.register
+ class KenwoodTMD710Radio(KenwoodTMx710Radio):
+ """ Kenwood TM-D710 VHF/UHF/APRS Radio model. """
+ VENDOR = "Kenwood"
+ MODEL = "TM-D710_CloneMode"
+ SHORT = "" # Quick model code
+
+ _num_blocks = 3
+ _num_packets = [0x9c, 1, 1]
+
+ MEM_FORMAT = """
+ struct chns { // 16 bytes channel structure
+ ul32 rxfreq;
+ u8 tstep;
+ u8 mode;
+ u8 tmode:4,
+ duplex:4; // 4 = split
+ u8 rtone;
+ u8 ctone;
+ u8 dtcs;
+ ul32 offset; // or Split mode TX freq
+ u8 splitstep;
+ u8 cross; // not used
+ };
+
+ struct pm_grp { // 512 bytes per group
+ u8 unk0200;
+ u8 a_mr;
+ u8 unk0202;
+ u8 unk0203;
+ u8 unk0204;
+ u8 unk0205;
+ u8 unk0206;
+ u8 a_pwr;
+ u8 wxalerta;
+ u8 asmsql;
+ u8 a_chn;
+ u8 unk020b;
+ u8 unk020c;
+ u8 b_mr;
+ u8 unk020e;
+ u8 unk020f;
+ u8 unk0210;
+ u8 unk0211;
+ u8 unk0212;
+ u8 b_pwr;
+ u8 wxalertb;
+ u8 bsmsql;
+ u8 b_chn;
+ u8 unk0217;
+ u8 unk0218;
+ u8 unk0219;
+ u8 unk021a;
+ u8 unk021b;
+ u8 unk021c;
+ u8 unk021d;
+ u8 unk021e;
+ u8 unk021f;
+ u8 unk0220;
+ u8 unk0221;
+ u8 unk0222;
+ u8 unk0223;
+ u8 unk0224;
+ u8 unk0225;
+ u8 unk0226;
+ u8 unk0227;
+ u8 unk0228;
+ u8 unk0229;
+ u8 unk022a;
+ u8 unk022b;
+ u8 unk022c;
+ u8 unk022d;
+ u8 unk022e;
+ u8 unk022f;
+ u8 unk0230;
+ u8 unk0231;
+ u8 sqclogic;
+ u8 txband;
+ u8 single;
+ u8 unk0235;
+ u8 mute;
+ u8 unk0237;
+ u8 unk0238;
+ u8 unk0239;
+ u8 unk0237a;
+ u8 unk023b;
+ u8 unk023c;
+ u8 unk023d;
+ u8 unk023e;
+ u8 unk023f;
+ struct chns vfo[10]; // 0x0240 - 0x02df
+ char pwron[8];
+ u8 unk02e8;
+ u8 unk02e9;
+ u8 unk02ea;
+ u8 unk02eb;
+ u8 unk02ec;
+ u8 unk02ed;
+ u8 unk02ee;
+ u8 unk02ef;
+ char memgrplk[10];
+ u8 unk02fa;
+ u8 unk02fb;
+ u8 unk02fc;
+ u8 unk02fd;
+ u8 unk02fe;
+ u8 unk02ff;
+ struct {
+ ul32 blow;
+ ul32 bhigh;
+ } progvfo[10];
+ u8 beepon;
+ u8 beepvol;
+ u8 extspkr;
+ u8 ance;
+ u8 lang;
+ u8 vcvol;
+ u8 vcspd;
+ u8 pbkrpt;
+ u8 pbkint;
+ u8 cntrec;
+ u8 vhfaip;
+ u8 uhfaip;
+ u8 ssqlhu;
+ u8 mutehu;
+ u8 beatshft;
+ u8 tot;
+ u8 recall;
+ u8 eclnkspd;
+ u8 dtmfhld;
+ u8 dtmfspd;
+ u8 dtmfpau;
+ u8 dtmflck;
+ u8 rptrofst;
+ u8 rptr1750;
+ u8 bright;
+ u8 autobri;
+ u8 bkltclr;
+ u8 pf1key;
+ u8 pf2key;
+ u8 micpf1;
+ u8 micpf2;
+ u8 micpf3;
+ u8 micpf4;
+ u8 miclck;
+ u8 unk0372;
+ u8 scnrsm;
+ u8 apo;
+ u8 extband;
+ u8 extbaud;
+ u8 sqcsrc;
+ u8 autopm;
+ u8 dispbar;
+ u8 unk037a;
+ u8 bkltcont;
+ u8 dsprev;
+ u8 vsmode;
+ u8 intband;
+ u8 wxscntm;
+ u8 scntot;
+ u8 scncot;
+ u8 unk0382;
+ u8 unk0383;
+ u8 unk0384;
+ u8 unk0385;
+ u8 unk0386;
+ u8 unk0387;
+ u8 unk0388;
+ u8 unk0389;
+ u8 unk038a;
+ u8 unk038b;
+ u8 unk038c;
+ u8 unk038d;
+ u8 unk038e;
+ u8 unk038f;
+ u8 abnd118;
+ u8 abnd144;
+ u8 abnd220;
+ u8 abnd300;
+ u8 abnd430;
+ u8 bbnd144;
+ u8 bbnd220;
+ u8 bbnd300;
+ u8 bbnd430;
+ u8 bbnd800;
+ u8 unk039a;
+ u8 unk039b;
+ u8 unk039c;
+ u8 unk039d;
+ u8 unk039e;
+ u8 unk039f;
+ u8 unk03a0[96]; // to 0x03ff
+ }; // end of struct pm
+
+ #seekto 0x0000; // block1: x000 - x023f
+ struct {
+ u8 unk000[16];
+ u8 unk010;
+ u8 unk011;
+ char unk012[3];
+ u8 ansbck;
+ u8 pmrecall; // 0x0016
+ u8 pnlklk;
+ u8 dspmemch;
+ u8 m10mz;
+ u8 micsens;
+ u8 opband;
+ u8 unk01c;
+ u8 rptrmode;
+ u8 rptrhold;
+ u8 rptridx;
+ u8 unk020;
+ u8 pcbaud;
+ u8 unk022;
+ u8 pwdon; // 0x0023
+ u8 unk024;
+ u8 unk025;
+ u8 unk026;
+ u8 unk027;
+ u8 unk028;
+ u8 unk029;
+ char pswd[6]; // 0x023a - 23f
+ } block1;
+
+ #seekto 0x0030;
+ struct {
+ char code[16]; // @ 0x0030
+ } dtmc[10];
+
+ struct {
+ char id[8]; // 0x00d0 - 0x011f
+ } dtmn[10];
+
+ struct { // block1a: 0x0120 - 0x023f
+ u8 unk0120;
+ u8 unk0121;
+ u8 unk0122[78];
+ char rptrid[12]; // 0x0170 - 017b
+ u8 unk017c;
+ u8 unk017d;
+ u8 unk017e;
+ u8 unk017f;
+ u8 unk0180[128]; // 0x0180 - 0x01ff
+ } block1a;
+
+ struct pm_grp pmg[6]; // 0x0200 - 0x0dff
+
+ #seekto 0x0e00;
+ struct {
+ u8 band;
+ u8 skip;
+ } chmap[1030]; // to 0x0160b
+
+ #seekto 0x01700; // 0x01700 - 0x0575f
+ struct chns ch_mem[1030]; // 0-999 MR and 1000 -1029 Specials
+
+ #seekto 0x05760;
+ struct chns call[2];
+
+ #seekto 0x05800;
+ struct {
+ char name[8];
+ } ch_nam[1020]; // ends @ 0x07e0
+
+ #seekto 0x077e0; // 0x077e0 - 0x07830
+ struct {
+ char name[8];
+ } wxnam[10];
+
+ #seekto 0x07da0;
+ struct {
+ char pmname[16];
+ } pm_name[5];
+
+ #seekto 0x07df0;
+ struct {
+ char comnt[32];
+ } mcpcom;
+
+ #seekto 0x08660;
+ struct {
+ char cmdr[10];
+ char tptr[10];
+ u8 skytone; // 0x08674
+ } skycmd;
+ // data stops at 0x09b98
+ """
+
+ def _read_mem(radio):
+ """ Load the memory map """
+ global BAUD
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Reading %i packets" % val
+ radio.status_fn(status)
+
+ data = ""
+
+ radio.pipe.baudrate = BAUD
+ cmc = b"0M PROGRAM" + TERM
+ resp0 = _command(radio.pipe, cmc, 3, W8S)
+ junk = radio.pipe.read(16) # flushit
+ for bkx in range(0, 0x09c):
+ if bkx != 0x07f: # Skip block 7f !!??
+ cmc = struct.pack('>cHB', b'R', bkx << 8, 0)
+ resp0 = _command(radio.pipe, cmc, 260, W8S)
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ if len(resp0) < 260:
+ junk = _command(radio.pipe, "E", 2, W8S)
+ sx = "Block 0x%x read error: " % bkx
+ sx += "Got %i bytes, expected 260." % len(resp0)
+ LOG.error(sx)
+ sx = "Block read error! Check debug.log"
+ raise errors.RadioError(sx)
+ if bkx == 0: # 1st packet of 1st block
+ mht = resp0[4:7] # [57 00 00 00] 03 4b 01 ff ff ...
+ data = resp0[5:6] # 2nd byte (4b) replaces 1st
+ data += resp0[5:] # then bytes 2 on (4b 4b 01 ff ...)
+ else:
+ data += resp0[4:] # skip cmd echo
+ _update_status(radio, status) # UI Update
+ cmc = struct.pack('>cHB', b'R', 0xFEF0, 0x10)
+ resp0 = _command(radio.pipe, cmc, 0x014, W8S)
+ data += resp0[4:]
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ _update_status(radio, status)
+ cmc = struct.pack('>cHB', b'R', 0xFF00, 0x90)
+ resp0 = _command(radio.pipe, cmc, 0x094, W8S)
+ data += resp0[4:]
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ _update_status(radio, status)
+ # Exit Prog mode, no TERM
+ resp = _command(radio.pipe, "E", 2, W8S) # Rtns 06 0d
+ radio.pipe.baudrate = BAUD
+ return data
+
+ def _write_mem(radio):
+ """ PROG MCP Blocks Send """
+ global BAUD
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Writing %i packets" % val
+ radio.status_fn(status)
+
+ imgadr = 0
+ radio.pipe.baudrate = BAUD
+ resp0 = _command(radio.pipe, "0M PROGRAM" + TERM, 3, W8S)
+ # Read block 0 magic header thingy, save it
+ cmc = "R" + chr(0) + chr(0) + chr(4)
+ resp0 = _command(radio.pipe, cmc, 8, W8S)
+ mht0 = resp0[4:] # Expecting [57 00 00 04] 03 4b 01 ff
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ cmc = "W" + chr(0) + chr(0) + chr(1) + chr(0x0ff)
+ junk = _command(radio.pipe, cmc, 1, W8S) # responds ACK
+ cmc = "R" + chr(0x080) + chr(0) + chr(3)
+ resp = _command(radio.pipe, cmc, 7, W8S) # [57 80 00 03] 00 33 00
+ mht1 = resp[4:]
+ junk = _command(radio.pipe, ACK, 1, W8S)
+ cmc = "W" + chr(0x080) + chr(0) + chr(1) + chr(0x0ff)
+ junk = _command(radio.pipe, cmc, 1, W8S)
+ imgadr = 4 # After 03 4b 01 ff
+ for bkx in range(0, radio._num_packets[0]):
+ cmc = "W" + chr(bkx) + chr(0) + chr(0)
+ imgstep = 256
+ if bkx == 0:
+ imgstep = 0x0fc
+ cmc = "W" + chr(0) + chr(4) + chr(imgstep)
+ cmc += radio.get_mmap()[imgadr:imgadr + imgstep]
+ else: # after first packet
+ cmc += radio.get_mmap()[imgadr:imgadr + imgstep]
+ if bkx != 0x07f: # don't send 7f !
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Packet 0x%x Write error, no ACK." % bkx)
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ imgadr += imgstep
+ _update_status(radio, status) # UI Update
+ # write fe and ff blocks
+ cmc = "W" + chr(0x0fe) + chr(0x0f0) + chr(16)
+ cmc += radio.get_mmap()[imgadr:imgadr + 16]
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Packet 0xfe Write error, no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ imgadr += 16
+ cmc = "W" + chr(0x0ff) + chr(0) + chr(0x090)
+ cmc += radio.get_mmap()[imgadr:imgadr + 0x090]
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Packet 0xff Write error, no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ # Write mht1
+ cmc = "W" + chr(0x080) + chr(0) + chr(3) + mht1
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Mht1 Write error at 0x080 00 03 , no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ # and mht0
+ cmc = "W" + chr(0) + chr(0) + chr(4) + mht0
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ if resp0 != ACK:
+ LOG.error("Mht0 Write error at 00 00 04 , no ACK.")
+ sx = "Radio failed to acknowledge upload packet!"
+ raise errors.RadioError(sx)
+ # Write E to Exit PROG mode
+ resp = _command(radio.pipe, "E", 2, W8S)
+ return
+
+ @directory.register
+ class KenwoodTMD710GRadio(KenwoodTMx710Radio):
+ """ Kenwood TM-D710G VHF/UHF/GPS/APRS Radio model. """
+ VENDOR = "Kenwood"
+ MODEL = "TM-D710G_CloneMode"
+ SHORT = "G" # Quick model code 1 for G
+
+ _num_blocks = 2 # Only reading first 2, not GPS logs
+ _packet_size = [261, 261, 261]
+ _block_addr = [0, 0x100, 0x200] # starting addr, each block
+ _num_packets = [0x7f, 0x0fe, 0x200] # num packets per block, 0-based
+
+ MEM_FORMAT = """
+ struct chns { // 16 bytes channel structure
+ ul32 rxfreq;
+ u8 tstep;
+ u8 mode;
+ u8 tmode:4,
+ duplex:4; // 4 = split
+ u8 rtone;
+ u8 ctone;
+ u8 dtcs;
+ u8 cross;
+ ul32 offset; // or Split mode TX freq
+ u8 splitstep;
+ };
+
+ struct pm_grp { // 512 bytes per group
+ u8 unk0200;
+ u8 a_mr;
+ u8 unk0202;
+ u8 unk0203;
+ u8 unk0204;
+ u8 unk0205;
+ u8 unk0206;
+ u8 a_pwr;
+ u8 wxalerta;
+ u8 asmsql;
+ u8 a_chn;
+ u8 unk020b;
+ u8 unk020c;
+ u8 b_mr;
+ u8 unk020e;
+ u8 unk020f;
+ u8 unk0210;
+ u8 unk0211;
+ u8 unk0212;
+ u8 b_pwr;
+ u8 wxalertb;
+ u8 bsmsql;
+ u8 b_chn;
+ u8 unk0217;
+ u8 unk0218;
+ u8 unk0219;
+ u8 unk021a;
+ u8 unk021b;
+ u8 unk021c;
+ u8 unk021d;
+ u8 unk021e;
+ u8 unk021f;
+ u8 unk0220;
+ u8 unk0221;
+ u8 unk0222;
+ u8 unk0223;
+ u8 unk0224;
+ u8 unk0225;
+ u8 unk0226;
+ u8 unk0227;
+ u8 unk0228;
+ u8 unk0229;
+ u8 unk022a;
+ u8 unk022b;
+ u8 unk022c;
+ u8 unk022d;
+ u8 unk022e;
+ u8 unk022f;
+ u8 unk0230;
+ u8 unk0231;
+ u8 sqclogic;
+ u8 txband;
+ u8 single;
+ u8 unk0235;
+ u8 mute;
+ u8 unk0237;
+ u8 unk0238;
+ u8 unk0239;
+ u8 unk0237a;
+ u8 unk023b;
+ u8 unk023c;
+ u8 unk023d;
+ u8 unk023e;
+ u8 unk023f;
+ struct chns vfo[10]; // 0x0240 - 0x02df
+ char pwron[8];
+ u8 unk02e8;
+ u8 unk02e9;
+ u8 unk02ea;
+ u8 unk02eb;
+ u8 unk02ec;
+ u8 unk02ed;
+ u8 unk02ee;
+ u8 unk02ef;
+ char memgrplk[10];
+ u8 unk02fa;
+ u8 unk02fb;
+ u8 unk02fc;
+ u8 unk02fd;
+ u8 unk02fe;
+ u8 unk02ff;
+ struct {
+ ul32 blow;
+ ul32 bhigh;
+ } progvfo[10];
+ u8 beepon;
+ u8 beepvol;
+ u8 extspkr;
+ u8 ance;
+ u8 lang;
+ u8 vcvol;
+ u8 vcspd;
+ u8 pbkrpt;
+ u8 pbkint;
+ u8 cntrec;
+ u8 vhfaip;
+ u8 uhfaip;
+ u8 ssqlhu;
+ u8 mutehu;
+ u8 beatshft;
+ u8 tot;
+ u8 recall;
+ u8 eclnkspd;
+ u8 dtmfhld;
+ u8 dtmfspd;
+ u8 dtmfpau;
+ u8 dtmflck;
+ u8 rptrofst;
+ u8 rptr1750;
+ u8 bright;
+ u8 autobri;
+ u8 bkltclr;
+ u8 pf1key;
+ u8 pf2key;
+ u8 micpf1;
+ u8 micpf2;
+ u8 micpf3;
+ u8 micpf4;
+ u8 miclck;
+ u8 unk0372;
+ u8 scnrsm;
+ u8 apo;
+ u8 extband;
+ u8 extbaud;
+ u8 sqcsrc;
+ u8 autopm;
+ u8 dispbar;
+ u8 unk037a;
+ u8 bkltcont;
+ u8 dsprev;
+ u8 vsmode;
+ u8 intband;
+ u8 wxscntm;
+ u8 scntot;
+ u8 scncot;
+ u8 unk0382;
+ u8 unk0383;
+ u8 unk0384;
+ u8 unk0385;
+ u8 unk0386;
+ u8 unk0387;
+ u8 unk0388;
+ u8 unk0389;
+ u8 unk038a;
+ u8 unk038b;
+ u8 unk038c;
+ u8 unk038d;
+ u8 unk038e;
+ u8 unk038f;
+ u8 abnd118;
+ u8 abnd144;
+ u8 abnd220;
+ u8 abnd300;
+ u8 abnd430;
+ u8 bbnd144;
+ u8 bbnd220;
+ u8 bbnd300;
+ u8 bbnd430;
+ u8 bbnd800;
+ u8 unk039a;
+ u8 unk039b;
+ u8 unk039c;
+ u8 unk039d;
+ u8 unk039e;
+ u8 unk039f;
+ u8 unk03a0[96]; // to 0x03ff
+ }; // end of struct pm
+
+ #seekto 0x0000; // block1: x000 - x023f
+ struct {
+ u8 unk000[16];
+ u8 unk010;
+ u8 unk011;
+ char unk012[3];
+ u8 ansbck;
+ u8 pmrecall; // 0x0016
+ u8 pnlklk;
+ u8 dspmemch;
+ u8 m10mz;
+ u8 micsens;
+ u8 opband;
+ u8 unk01c;
+ u8 rptrmode;
+ u8 rptrhold;
+ u8 rptridx;
+ u8 unk020;
+ u8 pcbaud;
+ u8 unk022;
+ u8 pwdon; // 0x0023
+ u8 unk024;
+ u8 unk025;
+ u8 unk026;
+ u8 unk027;
+ u8 unk028;
+ u8 unk029;
+ char pswd[6]; // 0x023a - 23f
+ } block1;
+
+ #seekto 0x0030;
+ struct {
+ char code[16]; // @ 0x0030
+ } dtmc[10];
+
+ struct {
+ char id[8]; // 0x00d0 - 0x011f
+ } dtmn[10];
+
+ struct { // block1a: 0x0120 - 0x023f
+ u8 unk0120;
+ u8 unk0121;
+ u8 unk0122[78];
+ char rptrid[12]; // 0x0170 - 017b
+ u8 unk017c;
+ u8 unk017d;
+ u8 unk017e;
+ u8 unk017f;
+ u8 unk0180[128]; // 0x0180 - 0x01ff
+ } block1a;
+
+ struct pm_grp pmg[6]; // 0x0200 - 0x0dff
+
+ #seekto 0x0e00;
+ struct {
+ u8 band;
+ u8 skip;
+ } chmap[1030]; // to 0x0160b
+
+ #seekto 0x01700; // 0x01700 - 0x0575f
+ struct chns ch_mem[1030]; // 0-999 MR and 1000 -1029 Specials
+
+ #seekto 0x058a0;
+ struct chns call[2];
+
+ #seekto 0x05900;
+ struct {
+ char name[8];
+ } ch_nam[1020]; // ends @ 0x07840
+
+ #seekto 0x078e0; // 0x078e0 - 0x0792f
+ struct {
+ char name[8];
+ } wxnam[10];
+
+ #seekto 0x07da0;
+ struct {
+ char pmname[16];
+ } pm_name[5];
+
+ #seekto 0x07df0;
+ struct {
+ char comnt[32];
+ } mcpcom;
+ // Block 1 ends @ 0x07eff
+ // Block 2 starts @ 0x07f00
+ #seekto 0x08660;
+ struct {
+ char cmdr[10];
+ char tptr[10];
+ u8 skytone; // 0x08674
+ } skycmd;
+
+ #seekto 0x10ef0;
+ struct {
+ u8 bmp[1896];
+ u8 unk11658[8]; // 0x11658
+ char bmpfyl[64]; // 0x11660
+ u8 unk116a0[95];
+ u8 bmpon; // 0x116ff
+ } bitmap;
+
+ // 2nd block ends @ 0x017cff
+ """
+
+ def _make_command(self, cmd, addr, length, data=b''):
+ cmc = struct.pack('>IB', addr, length)
+ return cmd.encode() + cmc[1:] + data
+
+ def _read_mem(radio):
+ """ Load the memory map """
+ global BAUD
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Reading %i packets" % val
+ radio.status_fn(status)
+
+ data = b""
+
+ radio.pipe.baudrate = BAUD
+ resp0 = radio.pipe.read(16) # flush
+ cmc = b"0M PROGRAM" + TERM
+ resp0 = _command(radio.pipe, cmc, 3, W8S)
+ if resp0[:1] == "?": # try once more
+ resp0 = _command(radio.pipe, cmc, 3, W8S)
+ radio.pipe.baudrate = 57600 # PROG mode is always 57.6
+ LOG.debug("Switching to 57600 baud download.")
+ junk = radio.pipe.read(1) # trailing byte
+ for blkn in range(0, radio._num_blocks):
+ for bkx in range(0, radio._num_packets[blkn]):
+ addr = (radio._block_addr[blkn] << 8) | (bkx << 8)
+ resp0 = _command(radio.pipe,
+ radio._make_command('R', addr, 0),
+ radio._packet_size[blkn], W8S)
+ if len(resp0) < radio._packet_size[blkn]:
+ junk = _command(radio.pipe, b"E", 0, W8S)
+ lb = len(resp0)
+ xb = radio._packet_size[blkn]
+ sx = "Block 0x%x, 0x%x read error: " % (blkn, bkx)
+ sx += "Got %i bytes, expected %i." % (lb, xb)
+ LOG.error(sx)
+ sx = "Block read error! Check debug.log"
+ raise errors.RadioError(sx)
+ if blkn == 0 and bkx == 0: # 1st packet of 1st block
+ mht = resp0[5:9] # Magic Header Thingy after cmd echo
+ data += mht[0:1]
+ data += b'\xff\xff\xff'
+ data += resp0[9:]
+ else:
+ data += resp0[5:] # skip cmd echo
+ _update_status(radio, status) # UI Update
+ # Exit Prog mode, no TERM
+ resp = _command(radio.pipe, b"E", 0, W8S)
+ radio.pipe.baudrate = BAUD
+ return data
+
+ def _write_mem(radio):
+ """ PROG MCP Blocks Send """
+ global BAUD
+ # UI progress
+ status = chirp_common.Status()
+ status.cur = 0
+ val = 0
+ for mx in range(0, radio._num_blocks):
+ val += radio._num_packets[mx]
+ status.max = val
+ status.msg = "Writing %i packets" % val
+ radio.status_fn(status)
+
+ imgadr = 0
+ radio.pipe.baudrate = BAUD
+ resp0 = _command(radio.pipe, b"0M PROGRAM" + TERM, 3, W8S)
+ radio.pipe.baudrate = 57600
+ LOG.debug("Switching to 57600 baud upload.")
+ junk = radio.pipe.read(1)
+ # Read block 0 magic header thingy, save it
+ addr = radio._block_addr[0] << 8
+ resp0 = _command(radio.pipe,
+ radio._make_command('R', addr, 4),
+ 16, W8S)
+ mht0 = resp0[5:]
+ # Now get block 1 mht
+ addr = radio._block_addr[1] << 8
+ resp0 = _command(radio.pipe,
+ radio._make_command('R', addr, 5),
+ 16, W8S)
+ mht1 = resp0[5:]
+ for blkn in range(0, radio._num_blocks):
+ for bkx in range(0, radio._num_packets[blkn]):
+ addr = (radio._block_addr[blkn] << 8) | (bkx << 8)
+
+ if bkx == 0: # First packet of the block includes mht
+ if blkn == 0:
+ data = (b'\xff\x4b\x01\x32' +
+ radio.get_mmap()[4:imgadr + 256])
+ elif blkn == 1:
+ data = mht1 + radio.get_mmap()[imgadr + 5:imgadr +
+ 256]
+ else: # after first packet
+ data = radio.get_mmap()[imgadr:imgadr + 256]
+ cmc = radio._make_command('W', addr, 0, data)
+
+ resp0 = _command(radio.pipe, cmc, 6, W8S)
+ if bkx > 0 and resp0 != ACK:
+ LOG.error("Packet 0x%x Write error, no ACK!" % bkx)
+ sx = "Radio failed to acknowledge upload. "
+ sx += "See debug.log"
+ raise errors.RadioError(sx)
+ imgadr += 256
+ _update_status(radio, status) # UI Update
+ # Re-write magic headers
+ cmc = radio._make_command('W', (radio._block_addr[0] << 8) | 1, 3,
+ mht0[1:3] + b'\x32')
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ cmc = radio._make_command('W', radio._block_addr[1] << 8, 5, mht1)
+ resp0 = _command(radio.pipe, cmc, 1, W8S)
+ cmc = radio._make_command('Z', radio._block_addr[0], 1, mht0[0:1])
+ resp0 = _command(radio.pipe, cmc, 16, W8S)
+ # Write E to Exit PROG mode
+ resp = _command(radio.pipe, b"E", 0, W8S)
+ radio.pipe.baudrate = BAUD
+ return
diff --git a/chirp/drivers/ts2000.py b/chirp/drivers/ts2000.py
index f2160ad..50706ab 100644
--- a/chirp/drivers/ts2000.py
+++ b/chirp/drivers/ts2000.py
@@ -50,7 +50,7 @@ class TS2000Radio(KenwoodLiveRadio):
rf.valid_tuning_steps = list(TS2000_SSB_STEPS + TS2000_FM_STEPS)
rf.valid_bands = [(1000, 1300000000)]
rf.valid_skips = ["", "S"]
- rf.valid_duplexes = TS2000_DUPLEX.values()
+ rf.valid_duplexes = list(TS2000_DUPLEX.values())
# TS-2000 uses ";" as a message separator even though it seems to
# allow you to to use all printable ASCII characters at the manual
@@ -217,7 +217,7 @@ class TS2000Radio(KenwoodLiveRadio):
duplex = 0
offset = 0
else:
- print "Bug: unsupported duplex `%s'" % mem.duplex
+ print("Bug: unsupported duplex `%s'" % mem.duplex)
if mem.mode in ["AM", "FM"]:
step = TS2000_FM_STEPS.index(mem.tuning_step)
else:
@@ -259,7 +259,7 @@ class TS2000Radio(KenwoodLiveRadio):
elif mem.duplex == "split":
duplex = 0
else:
- print "Bug: unsupported duplex `%s'" % mem.duplex
+ print("Bug: unsupported duplex `%s'" % mem.duplex)
if mem.mode in ["AM", "FM"]:
step = TS2000_FM_STEPS.index(mem.tuning_step)
else:
diff --git a/chirp/drivers/ts480.py b/chirp/drivers/ts480.py
index 47b1757..141d199 100644
--- a/chirp/drivers/ts480.py
+++ b/chirp/drivers/ts480.py
@@ -1,5 +1,7 @@
# Copyright 2019 Rick DeWitt <aa0rd@yahoo.com>
-# Implementing mem as Clone Mode
+# Implementing Kenwood TS-480 as Clone Mode
+# March 2021: Implementing true Split mode support per issue #8297
+# March 6, 2021: PL tone download fix for issue #8877
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@@ -18,7 +20,6 @@ import struct
import logging
import re
import math
-import threading
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -38,7 +39,8 @@ struct { // 20 bytes per chan
u8 tmode;
u8 rtone;
u8 ctone;
- u8 skip;
+ u8 split:4,
+ skip:4;
u8 step;
char name[8];
} ch_mem[110]; // 100 normal + 10 P-type
@@ -90,15 +92,15 @@ struct { // Menu A/B settings
"""
+MEMSIZE = 0x0b1d # img file size
STIMEOUT = 0.6
-LOCK = threading.Lock()
BAUD = 0 # Initial baud rate
MEMSEL = 0 # Default Menu A
BEEPVOL = 5 # Default beep level
W8S = 0.01 # short wait, secs
W8L = 0.05 # long wait
-TS480_DUPLEX = ["", "-", "+"]
+TS480_DUPLEX = ["", "split"]
TS480_SKIP = ["", "S"]
# start at 0:LSB
@@ -133,7 +135,6 @@ def command(ser, cmd, rsplen, w8t=0.01, exts=""):
# If rsplen = 0 then do not read after write
start = time.time()
- # LOCK.acquire()
stx = cmd # preserve cmd for response check
stx = stx + exts + ";" # append arguments
ser.write(stx)
@@ -146,7 +147,6 @@ def command(ser, cmd, rsplen, w8t=0.01, exts=""):
result = ser.read(rsplen)
LOG.debug("RADIO->PC [%s]" % result)
result = result[:-1] # remove terminator
- # LOCK.release()
return result.strip()
@@ -166,10 +166,10 @@ def _connect_radio(radio):
BAUD = bd
radio.pipe.write(";")
radio.pipe.write(";")
- resp = radio.pipe.read(4)
+ resp = radio.pipe.read(16)
radio.pipe.write("ID;")
- resp = radio.pipe.read(6)
- if resp == radio.ID: # Good comms
+ resp = radio.pipe.read(16)
+ if resp.find(radio.ID) >= 0: # Good comms
resp = command(radio.pipe, "AI0", 0, W8L)
return
elif resp in RADIO_IDS.keys():
@@ -248,15 +248,6 @@ def _make_dat(sx, nb):
return dx
-def _sets_val(stx, nv, nb):
- """ Split string stx into nv nb-bit values in 1 byte """
- # Right now: hardcoded for nv:3 values of nb:2 bits each
- v1 = int(stx[0]) << 6
- v1 = v1 | (int(stx[1]) << 4)
- v1 = v1 | (int(stx[2]) << 2)
- return chr(v1)
-
-
def _sets_asf(stx):
""" Process AS0 auto-mode setting """
asm = _make_dat(stx[0:11], 4) # 11-bit freq
@@ -284,7 +275,7 @@ def _read_settings(radio):
""" Continue filling memory map"""
global MEMSEL
# setc: the list of CAT commands for downloaded settings
- # Block paramters first. In the exact order of MEM_FORMAT
+ # Block parameters first. In the exact order of MEM_FORMAT
setc = radio.SETC
setc.extend(radio.EX) # Menu A EX params
setc.extend(radio.EX) # Menu B
@@ -337,6 +328,8 @@ def _read_settings(radio):
setts += _make_dat(result0, 4) # 11-bit freq
elif (cmc == "MF0") or (cmc == "MF1"): # No stored response
skipme = True
+ elif (cmc == "TY"): # remove upper 2 digits
+ result0 = result0[2:]
# Generic single byte processing
if not skipme:
setts += chr(int(result0))
@@ -359,7 +352,7 @@ def _write_mem(radio):
# UI progress
status = chirp_common.Status()
status.cur = 0
- status.max = radio._upper + 10 # 10 P chans
+ status.max = radio._upper
status.msg = "Writing Channel Memory"
radio.status_fn(status)
@@ -367,15 +360,19 @@ def _write_mem(radio):
BEEPVOL = int(result0[6:12])
result0 = command(radio.pipe, "EX01200000", 0, W8L) # Silence beeps
- for chn in range(0, (radio._upper + 11)): # Loop stops at +20
+ for chn in range(0, (radio._upper + 1)):
_mem = radio._memobj.ch_mem[chn]
cmx = "MW0%03i" % chn
- stm = cmx + radio._make_base_spec(_mem, _mem.rxfreq)
- result0 = command(radio.pipe, stm, 0, W8L) # No response
- if _mem.txfreq > 0: # Don't write MW1 if empty/deleted
- cmx = "MW1%03i" % chn
- stm = cmx + radio._make_base_spec(_mem, _mem.txfreq)
+ if _mem.rxfreq == 0: # Empty, deleted
+ stm = cmx + "0" * 35
result0 = command(radio.pipe, stm, 0, W8L)
+ else:
+ stm = cmx + radio._make_base_spec(_mem, _mem.rxfreq)
+ result0 = command(radio.pipe, stm, 0, W8L) # No response
+ if _mem.split: # SPLIT mode
+ cmx = "MW1%03i" % chn
+ stm = cmx + radio._make_base_spec(_mem, _mem.txfreq)
+ result0 = command(radio.pipe, stm, 0, W8L)
status.cur = chn
radio.status_fn(status)
return
@@ -454,15 +451,15 @@ def _write_sets(radio):
@directory.register
-class TS480Radio(chirp_common.CloneModeRadio):
- """Kenwood TS-590"""
+class TS480_CRadio(chirp_common.CloneModeRadio):
+ """ Kenwood TS-480 simulated clone mode """
VENDOR = "Kenwood"
MODEL = "TS-480_CloneMode"
ID = "ID020;"
# Settings read/write cmd sequence list
SETC = ["AS0", "SS", "AG0", "AN", "FA", "FB",
"MF", "MG", "PC", "RG", "TY", "MF0"]
- # This is the TS-590SG MENU A/B read_settings paramter tuple list
+ # This is the TS-590SG MENU A/B read_settings parameter tuple list
# The order is mandatory; to match the Mem_Format sequence
EX = ["EX000", "EX003", "EX007", "EX008", "EX009", "EX010", "EX011",
"EX012", "EX013", "EX014", "EX021", "EX022", "EX048", "EX049",
@@ -491,7 +488,7 @@ class TS480Radio(chirp_common.CloneModeRadio):
def get_features(self):
rf = chirp_common.RadioFeatures()
- rf.can_odd_split = False
+ rf.can_odd_split = True
rf.has_bank = False
rf.has_ctone = True
rf.has_dtcs = False
@@ -582,13 +579,14 @@ class TS480Radio(chirp_common.CloneModeRadio):
def get_memory(self, number):
"""Convert raw channel data (_mem) into UI columns (mem)"""
mem = chirp_common.Memory()
- if number > 99 and number < 110:
- return # Don't show VFO edges as mem chans
_mem = self._memobj.ch_mem[number]
mem.number = number
+ # --- Correct old img file loads with +/- offsets ---
+ if (_mem.txfreq != 0) and (_mem.rxfreq != _mem.txfreq):
+ _mem.split = 1
mnx = ""
for char in _mem.name:
- mnx += chr(char)
+ mnx += chr(int(char))
mem.name = mnx.strip()
mem.name = mem.name.upper()
if _mem.rxfreq == 0:
@@ -598,13 +596,10 @@ class TS480Radio(chirp_common.CloneModeRadio):
mem.freq = int(_mem.rxfreq)
mem.duplex = TS480_DUPLEX[0] # None by default
mem.offset = 0
- if _mem.rxfreq < _mem.txfreq: # + shift
- mem.duplex = TS480_DUPLEX[2]
- mem.offset = _mem.txfreq - _mem.rxfreq
- if _mem.rxfreq > _mem.txfreq: # - shift
+ if _mem.split: # NO +/- Offsets, just split
mem.duplex = TS480_DUPLEX[1]
- mem.offset = _mem.rxfreq - _mem.txfreq
- if _mem.txfreq == 0:
+ mem.offset = _mem.txfreq
+ elif _mem.txfreq == 0:
# leave offset alone, or run_tests will bomb
mem.duplex = TS480_DUPLEX[0]
mx = _mem.xmode - 1 # CAT modes start at 1
@@ -635,6 +630,7 @@ class TS480Radio(chirp_common.CloneModeRadio):
if mem.empty:
_mem.rxfreq = 0
_mem.txfreq = 0
+ _mem.split = 0
_mem.xmode = 0
_mem.step = 0
_mem.tmode = 0
@@ -656,10 +652,12 @@ class TS480Radio(chirp_common.CloneModeRadio):
_mem.name[ix] = " " # assignment needs 8 chrs
_mem.rxfreq = mem.freq
_mem.txfreq = 0
- if mem.duplex == "+":
- _mem.txfreq = mem.freq + mem.offset
- if mem.duplex == "-":
- _mem.txfreq = mem.freq - mem.offset
+ _mem.split = 0
+ if mem.duplex == "":
+ _mem.txfreq = _mem.rxfreq
+ elif mem.duplex == "split":
+ _mem.split = 1
+ _mem.txfreq = mem.offset
ix = TS480_MODES.index(mem.mode)
_mem.xmode = ix + 1 # stored as CAT values, LSB= 1
if ix == 7: # FSK-R
@@ -681,30 +679,28 @@ class TS480Radio(chirp_common.CloneModeRadio):
return
def _parse_mem_spec(self, spec0, spec1):
- """ Extract ascii memory paramters; build data string """
- # spec0 is simplex result, spec1 is split
+ """ Extract ascii memory parameters; build data string """
+ # spec0 is Rx freq string, spec1 is Tx
# pad string so indexes match Kenwood docs
spec0 = "x" + spec0 # match CAT document 1-based description
ix = len(spec0)
# _pxx variables are STRINGS
- _p1 = spec0[3] # P1 Split Specification
+ _p1 = spec0[3] # P1 Tx/Rx Specification
_p3 = spec0[5:7] # P3 Memory Channel
- _p4 = spec0[7:18] # P4 Frequency
+ _p4 = spec0[7:18] # P4 Rx Frequency
_p5 = spec0[18] # P5 Mode
_p6 = spec0[19] # P6 Chan Lockout (Skip)
_p7 = spec0[20] # P7 Tone Mode
_p8 = spec0[21:23] # P8 Tone Frequency Index
- if _p8 == "00":
- _p8 = "08"
_p9 = spec0[23:25] # P9 CTCSS Frequency Index
- if _p9 == "00":
- _p9 = "08"
_p14 = spec0[39:41] # P14 Step Size
_p16 = spec0[41:50] # P16 Max 8-Char Name if assigned
spec1 = "x" + spec1
- _p4s = int(spec1[7:18]) # P4: Offset freq
-
+ _p4s = spec1[7:18] # P4s: Tx freq
+ _split = 0
+ if _p4 != _p4s:
+ _split = 16 # upper byte bit 0 set
datm = "" # Fill in MEM_FORMAT sequence
datm += _make_dat(_p4, 4) # rxreq: u32, 4 bytes/chars
datm += _make_dat(_p4s, 4) # tx freq
@@ -712,7 +708,7 @@ class TS480Radio(chirp_common.CloneModeRadio):
datm += chr(int(_p7)) # Tmode: 0-3
datm += chr(int(_p8)) # rtone: 00-41
datm += chr(int(_p9)) # ctone: 00-41
- datm += chr(int(_p6)) # skip: 0/1
+ datm += chr(int(_p6) + _split) # split 0/1 & skip: 0/1
datm += chr(int(_p14)) # step: 0-9
v1 = len(_p16)
for ix in range(8):
@@ -723,6 +719,7 @@ class TS480Radio(chirp_common.CloneModeRadio):
return datm
def _make_base_spec(self, mem, freq):
+ """ Generate memory channel parameter string """
spec = "%011i%1i%1i%1i%02i%02i00000000000000%02i0%s" \
% (freq, mem.xmode, mem.skip, mem.tmode, mem.rtone,
mem.ctone, mem.step, mem.name)
@@ -823,7 +820,8 @@ class TS480Radio(chirp_common.CloneModeRadio):
options = ["TS-480HX (200W)", "TS-480SAT (100W + AT)",
"Japanese 50W type", "Japanese 20W type"]
- rx = RadioSettingValueString(14, 22, options[_sets.ty])
+ nx = _sets.ty & 7 # Can have 'reserved' upper 2 digits
+ rx = RadioSettingValueString(14, 22, options[nx])
rset = RadioSetting("settings.ty", "FirmwareVersion", rx)
rset.set_apply_callback(_my_readonly, _sets, "ty")
basic.append(rset)
@@ -857,7 +855,7 @@ class TS480Radio(chirp_common.CloneModeRadio):
if vx < 5:
vx = 5
options = [200, 100, 50, 20] # subject to firmware
- rx = RadioSettingValueInteger(5, options[_sets.ty], vx, nx)
+ rx = RadioSettingValueInteger(5, options[_sets.ty & 7], vx, nx)
sx = "TX Output power (Watts)"
rset = RadioSetting("settings.pc", sx, rx)
basic.append(rset)
@@ -1138,7 +1136,16 @@ class TS480Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
return
+
+ @classmethod
+ def match_model(cls, fdata, fyle):
+ """ Included to prevent 'File > New' error """
+ # Test the file data size
+ if len(fdata) == MEMSIZE:
+ return True
+ else:
+ return False
diff --git a/chirp/drivers/ts590.py b/chirp/drivers/ts590.py
index 497aac3..4ca6bf4 100644
--- a/chirp/drivers/ts590.py
+++ b/chirp/drivers/ts590.py
@@ -330,7 +330,7 @@ def _read_settings(radio):
""" Continue filling memory map"""
global MEMSEL
# setc: the list of CAT commands for downloaded settings
- # Block paramters first. In the exact order of MEM_FORMAT
+ # Block parameters first. In the exact order of MEM_FORMAT
setc = radio.SETC
setc.extend(radio.EX) # Menu A EX params
setc.extend(radio.EX) # Menu B
@@ -574,7 +574,7 @@ class TS590Radio(chirp_common.CloneModeRadio):
# Settings read/write cmd sequence list
SETC = ["AS0", "SS", "EQ", "AG0", "AN", "FA", "FB",
"FV", "MF", "MG", "PC", "RG", "TP", "MF0"]
- # This is the TS-590SG MENU A/B read_settings paramter tuple list
+ # This is the TS-590SG MENU A/B read_settings parameter tuple list
# The order is mandatory; to match the Mem_Format sequence
EX = ["EX001", "EX002", "EX003", "EX005", "EX006", "EX007",
"EX008", "EX009", "EX010", "EX011", "EX012", "EX013", "EX016",
@@ -878,7 +878,7 @@ class TS590Radio(chirp_common.CloneModeRadio):
return
def _parse_mem_spec(self, spec0, spec1):
- """ Extract ascii memory paramters; build data string """
+ """ Extract ascii memory parameters; build data string """
# spec0 is simplex result, spec1 is split
# pad string so indexes match Kenwood docs
spec0 = "x" + spec0 # match CAT document 1-based description
@@ -958,7 +958,7 @@ class TS590Radio(chirp_common.CloneModeRadio):
mhz1 = 1000000.
nsg = not self.SG
if nsg: # Make reverse EX_X dictionary
- x_ex = dict(zip(self.EX_X.values(), self.EX_X.keys()))
+ x_ex = {v: k for k, v in self.EX_X.items()}
# Callback functions
def _my_readonly(setting, obj, atrb):
@@ -1644,7 +1644,7 @@ class TS590Radio(chirp_common.CloneModeRadio):
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/ts850.py b/chirp/drivers/ts850.py
index 4520aca..8fb453d 100644
--- a/chirp/drivers/ts850.py
+++ b/chirp/drivers/ts850.py
@@ -37,7 +37,7 @@ TS850_MODES = {
"CW-R": "7",
"FSK-R": "9",
}
-TS850_MODES_REV = {val: mode for mode, val in TS850_MODES.iteritems()}
+TS850_MODES_REV = {val: mode for mode, val in TS850_MODES.items()}
TS850_TONES = list(chirp_common.OLD_TONES)
TS850_TONES.remove(69.3)
@@ -81,7 +81,7 @@ class TS850Radio(KenwoodLiveRadio):
rf.valid_bands = TS850_BANDS
rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC
rf.valid_duplexes = TS850_DUPLEX
- rf.valid_modes = TS850_MODES.keys()
+ rf.valid_modes = list(TS850_MODES.keys())
rf.valid_skips = TS850_SKIP
rf.valid_tmodes = TS850_TMODES
diff --git a/chirp/drivers/uv5r.py b/chirp/drivers/uv5r.py
index ea40d02..a801c8e 100644
--- a/chirp/drivers/uv5r.py
+++ b/chirp/drivers/uv5r.py
@@ -154,9 +154,7 @@ struct {
#seekto 0x0F10;
struct {
u8 freq[8];
- u8 unknown1;
- u8 offset[4];
- u8 unknown2;
+ u8 offset[6];
ul16 rxtone;
ul16 txtone;
u8 unused1:7,
@@ -178,9 +176,7 @@ struct {
#seekto 0x0F30;
struct {
u8 freq[8];
- u8 unknown1;
- u8 offset[4];
- u8 unknown2;
+ u8 offset[6];
ul16 rxtone;
ul16 txtone;
u8 unused1:7,
@@ -280,7 +276,7 @@ struct {
# 0x1EC0 - 0x2000
-vhf_220_radio = bytes(b"\x02")
+vhf_220_radio = b"\x02"
BASETYPE_UV5R = [b"BFS", b"BFB", b"N5R-2", b"N5R2", b"N5RV", b"BTS", b"D5R2",
b"B5R2"]
@@ -289,7 +285,7 @@ BASETYPE_UV82 = [b"US2S2", b"B82S", b"BF82", b"N82-2", b"N822"]
BASETYPE_BJ55 = [b"BJ55"] # needed for for the Baojie UV-55 in bjuv55.py
BASETYPE_UV6 = [b"BF1", b"UV6"]
BASETYPE_KT980HP = [b"BFP3V3 B"]
-BASETYPE_F8HP = [b"BFP3V3 F", b"N5R-3", b"N5R3", b"F5R3", b"BFT"]
+BASETYPE_F8HP = [b"BFP3V3 F", b"N5R-3", b"N5R3", b"F5R3", b"BFT", b"N5RV"]
BASETYPE_UV82HP = [b"N82-3", b"N823", b"N5R2"]
BASETYPE_UV82X3 = [b"HN5RV01"]
BASETYPE_LIST = BASETYPE_UV5R + BASETYPE_F11 + BASETYPE_UV82 + \
@@ -320,7 +316,8 @@ STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 20.0, 25.0, 50.0]
STEP291_LIST = [str(x) for x in STEPS]
TDRAB_LIST = ["Off"] + AB_LIST
TDRCH_LIST = ["CH%s" % x for x in range(1, 129)]
-TIMEOUT_LIST = ["%s sec" % x for x in range(15, 615, 15)]
+TIMEOUT_LIST = ["%s sec" % x for x in range(15, 615, 15)] + \
+ ["Off (if supported by radio)"]
TXPOWER_LIST = ["High", "Low"]
TXPOWER3_LIST = ["High", "Mid", "Low"]
VOICE_LIST = ["Off", "English", "Chinese"]
@@ -361,6 +358,14 @@ SETTING_LISTS = {
"wtled": COLOR_LIST
}
+GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
+ 462.6875, 462.7125]
+GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
+ 467.6875, 467.7125]
+GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
+ 462.6750, 462.7000, 462.7250]
+GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
+
def _do_status(radio, block):
status = chirp_common.Status()
@@ -376,6 +381,7 @@ UV5R_MODEL_UV82 = bytes(b"\x50\xBB\xFF\x20\x13\x01\x05")
UV5R_MODEL_UV6 = bytes(b"\x50\xBB\xFF\x20\x12\x08\x23")
UV5R_MODEL_UV6_ORIG = bytes(b"\x50\xBB\xFF\x12\x03\x98\x4D")
UV5R_MODEL_A58 = bytes(b"\x50\xBB\xFF\x20\x14\x04\x13")
+UV5R_MODEL_UV5G = bytes(b"\x50\xBB\xFF\x20\x12\x06\x25")
def _upper_band_from_data(data):
@@ -418,12 +424,12 @@ def _do_ident(radio, magic, secondack=True):
serial.write(bytes(b"\x02"))
# Until recently, the "ident" returned by the radios supported by this
- # driver have always been 8 bytes long. The image sturcture is the 8 byte
+ # driver have always been 8 bytes long. The image structure is the 8 byte
# "ident" followed by the downloaded memory data. So all of the settings
# structures are offset by 8 bytes. The ident returned from a UV-6 radio
# can be 8 bytes (original model) or now 12 bytes.
#
- # To accomodate this, the "ident" is now read one byte at a time until the
+ # To accommodate this, the "ident" is now read one byte at a time until the
# last byte ("\xdd") is encountered. The bytes containing the value "\x01"
# are discarded to shrink the "ident" length down to 8 bytes to keep the
# image data aligned with the existing settings structures.
@@ -510,6 +516,7 @@ def _get_radio_firmware_version(radio):
IDENT_BLACKLIST = {
b"\x50\x0D\x0C\x20\x16\x03\x28": "Radio identifies as BTECH UV-5X3",
+ b"\x50\xBB\xFF\x20\x12\x06\x25": "Radio identifies as Radioddity UV-5G",
}
@@ -565,6 +572,13 @@ def _do_download(radio):
# then append that model type to the end of the image so it can
# be properly detected when loaded.
append_model = True
+ elif "\x20" * 14 in radio_version:
+ # A radio UV-5R style radio that reports no firmware version has
+ # been detected.
+ # We are going to count on the user to make the right choice and
+ # then append that model type to the end of the image so it can
+ # be properly detected when loaded.
+ append_model = True
elif not any(type in radio_version for type in radio._basetype):
# This radio can't be properly detected by parsing its firmware
# version.
@@ -581,13 +595,14 @@ def _do_download(radio):
_do_status(radio, i)
_do_status(radio, radio.get_memsize())
LOG.debug("done.")
- LOG.debug("downloading aux block...")
- # Auxiliary block starts at 0x1ECO (?)
- for i in range(0x1EC0, 0x2000, 0x40):
- data += _read_block(radio, i, 0x40, False)
+ if radio._aux_block:
+ LOG.debug("downloading aux block...")
+ # Auxiliary block starts at 0x1ECO (?)
+ for i in range(0x1EC0, 0x2000, 0x40):
+ data += _read_block(radio, i, 0x40, False)
if append_model:
- data += radio.MODEL.ljust(8)
+ data += radio.MODEL.ljust(8).encode()
LOG.debug("done.")
return memmap.MemoryMapBytes(data)
@@ -631,20 +646,13 @@ def _do_upload(radio):
_ranges_aux_extra = [
(0x1F60, 0x1F70),
(0x1F80, 0x1F90),
- (0x1FC0, 0x1FD0)
+ (0x1FC0, 0x1FE0)
]
if image_version == radio_version:
image_matched_radio = True
- if image_version.startswith(b"HN5RV"):
- ranges_main = _ranges_main_default
- ranges_aux = _ranges_aux_default + _ranges_aux_extra
- elif image_version == 0xFF * 7:
- ranges_main = _ranges_main_default
- ranges_aux = _ranges_aux_default + _ranges_aux_extra
- else:
- ranges_main = radio._ranges_main
- ranges_aux = radio._ranges_aux
+ ranges_main = _ranges_main_default
+ ranges_aux = _ranges_aux_default + _ranges_aux_extra
elif any(type in radio_version for type in radio._basetype):
image_matched_radio = False
ranges_main = _ranges_main_default
@@ -655,6 +663,9 @@ def _do_upload(radio):
"of the radio (%s).")
raise errors.RadioError(msg % (image_version, radio_version))
+ if not radio._aux_block:
+ image_matched_radio = True
+
# Main block
mmap = radio.get_mmap().get_byte_compatible()
for start_addr, end_addr in ranges_main:
@@ -707,8 +718,7 @@ def model_match(cls, data):
return False
-class BaofengUV5R(chirp_common.CloneModeRadio,
- chirp_common.ExperimentalRadio):
+class BaofengUV5R(chirp_common.CloneModeRadio):
"""Baofeng UV-5R"""
VENDOR = "Baofeng"
@@ -721,9 +731,12 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
_idents = [UV5R_MODEL_291,
UV5R_MODEL_ORIG
]
- _vhf_range = (136000000, 174000000)
+ _vhf_range = (130000000, 176000000)
_220_range = (220000000, 260000000)
_uhf_range = (400000000, 520000000)
+ _aux_block = True
+ _tri_power = False
+ _gmrs = False
_mem_params = (0x1828 # poweron_msg offset
)
# offset of fw version in image file
@@ -782,6 +795,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_modes = ["FM", "NFM"]
rf.valid_tuning_steps = STEPS
+ rf.valid_dtcs_codes = UV5R_DTCS
normal_bands = [self._vhf_range, self._uhf_range]
rax_bands = [self._vhf_range, self._220_range]
@@ -811,6 +825,31 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
def process_mmap(self):
self._memobj = bitwise.parse(MEM_FORMAT % self._mem_params, self._mmap)
+ def validate_memory(self, mem):
+ msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
+
+ _msg_duplex2 = 'Memory location only supports "(None)" or "off"'
+ _msg_duplex3 = 'Memory location only supports "(None)", "+" or "off"'
+
+ if self._gmrs:
+ if mem.number < 1 or mem.number > 30:
+ if float(mem.freq) / 1000000 in GMRS_FREQS1:
+ if mem.duplex not in ['', 'off']:
+ # warn user wrong Duplex
+ msgs.append(chirp_common.ValidationError(_msg_duplex2))
+
+ if float(mem.freq) / 1000000 in GMRS_FREQS2:
+ if mem.duplex not in ['', 'off']:
+ # warn user wrong Duplex
+ msgs.append(chirp_common.ValidationError(_msg_duplex2))
+
+ if float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.duplex not in ['', '+', 'off']:
+ # warn user wrong Duplex
+ msgs.append(chirp_common.ValidationError(_msg_duplex3))
+
+ return msgs
+
def sync_in(self):
try:
self._mmap = _do_download(self)
@@ -924,7 +963,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
if not _mem.scan:
mem.skip = "S"
- if self.MODEL in ("KT-980HP", "BF-F8HP", "UV-82HP"):
+ if self._tri_power:
levels = UV5R_POWER_LEVELS3
else:
levels = UV5R_POWER_LEVELS
@@ -986,6 +1025,33 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
_mem.set_raw("\x00" * 16)
+ if self._gmrs:
+ if mem.number >= 1 and mem.number <= 30:
+ GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
+ mem.freq = GMRS_FREQ
+ if mem.number <= 22:
+ mem.duplex = ''
+ mem.offset = 0
+ if mem.number >= 8 and mem.number <= 14:
+ mem.mode = "NFM"
+ mem.power = UV5R_POWER_LEVELS[1]
+ if mem.number > 22:
+ mem.duplex = '+'
+ mem.offset = 5000000
+ elif float(mem.freq) / 1000000 in GMRS_FREQS:
+ if float(mem.freq) / 1000000 in GMRS_FREQS2:
+ mem.offset = 0
+ mem.mode = "NFM"
+ mem.power = UV5R_POWER_LEVELS[1]
+ if float(mem.freq) / 1000000 in GMRS_FREQS3:
+ if mem.duplex == '+':
+ mem.offset = 5000000
+ else:
+ mem.offset = 0
+ else:
+ mem.duplex = 'off'
+ mem.offset = 0
+
_mem.rxfreq = mem.freq / 10
if mem.duplex == "off":
@@ -1045,7 +1111,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
_mem.wide = mem.mode == "FM"
if mem.power:
- if self.MODEL in ("KT-980HP", "BF-F8HP", "UV-82HP"):
+ if self._tri_power:
levels = [str(l) for l in UV5R_POWER_LEVELS3]
_mem.lowpower = levels.index(str(mem.power))
else:
@@ -1170,7 +1236,8 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout]))
basic.append(rs)
- if self._is_orig() and self._my_version() < 251:
+ if ((self._is_orig() and self._my_version() < 251) or
+ (self.MODEL in ["TI-F8+", "TS-T9+"])):
rs = RadioSetting("voice", "Voice",
RadioSettingValueBoolean(_settings.voice))
advanced.append(rs)
@@ -1304,30 +1371,30 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
# Old image, without aux block
return group
- other = RadioSettingGroup("other", "Other Settings")
- group.append(other)
-
- def _filter(name):
- filtered = ""
- for char in str(name):
- if char in chirp_common.CHARSET_ASCII:
- filtered += char
- else:
- filtered += " "
- return filtered
+ if self.MODEL != "UV-6":
+ other = RadioSettingGroup("other", "Other Settings")
+ group.append(other)
+
+ def _filter(name):
+ filtered = ""
+ for char in str(name):
+ if char in chirp_common.CHARSET_ASCII:
+ filtered += char
+ else:
+ filtered += " "
+ return filtered
- _msg = self._memobj.firmware_msg
- val = RadioSettingValueString(0, 7, _filter(_msg.line1))
- val.set_mutable(False)
- rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
- other.append(rs)
+ _msg = self._memobj.firmware_msg
+ val = RadioSettingValueString(0, 7, _filter(_msg.line1))
+ val.set_mutable(False)
+ rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val)
+ other.append(rs)
- val = RadioSettingValueString(0, 7, _filter(_msg.line2))
- val.set_mutable(False)
- rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
- other.append(rs)
+ val = RadioSettingValueString(0, 7, _filter(_msg.line2))
+ val.set_mutable(False)
+ rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val)
+ other.append(rs)
- if self.MODEL != "UV-6":
_msg = self._memobj.sixpoweron_msg
rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1",
RadioSettingValueString(
@@ -1463,39 +1530,47 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
real_offset = 0
for byte in bytes:
real_offset = (real_offset * 10) + byte
- return chirp_common.format_freq(real_offset * 10000)
+ return chirp_common.format_freq(real_offset * 1000)
def apply_offset(setting, obj):
- value = chirp_common.parse_freq(str(setting.value)) / 10000
- for i in range(3, -1, -1):
+ value = chirp_common.parse_freq(str(setting.value)) / 1000
+ for i in range(5, -1, -1):
obj.offset[i] = value % 10
value /= 10
val1a = RadioSettingValueString(
0, 10, convert_bytes_to_offset(_vfoa.offset))
rs = RadioSetting("vfoa.offset",
- "VFO A Offset (0.00-69.95)", val1a)
+ "VFO A Offset (0.0-999.999)", val1a)
rs.set_apply_callback(apply_offset, _vfoa)
workmode.append(rs)
val1b = RadioSettingValueString(
0, 10, convert_bytes_to_offset(_vfob.offset))
rs = RadioSetting("vfob.offset",
- "VFO B Offset (0.00-69.95)", val1b)
+ "VFO B Offset (0.0-999.999)", val1b)
rs.set_apply_callback(apply_offset, _vfob)
workmode.append(rs)
- if self.MODEL in ("KT-980HP", "BF-F8HP", "UV-82HP"):
+ if self._tri_power:
+ if _vfoa.txpower3 > 0x02:
+ val = 0x00
+ else:
+ val = _vfoa.txpower3
rs = RadioSetting("vfoa.txpower3", "VFO A Power",
RadioSettingValueList(
TXPOWER3_LIST,
- TXPOWER3_LIST[_vfoa.txpower3]))
+ TXPOWER3_LIST[val]))
workmode.append(rs)
+ if _vfob.txpower3 > 0x02:
+ val = 0x00
+ else:
+ val = _vfob.txpower3
rs = RadioSetting("vfob.txpower3", "VFO B Power",
RadioSettingValueList(
TXPOWER3_LIST,
- TXPOWER3_LIST[_vfob.txpower3]))
+ TXPOWER3_LIST[val]))
workmode.append(rs)
else:
rs = RadioSetting("vfoa.txpower", "VFO A Power",
@@ -1566,7 +1641,11 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
dtmf = RadioSettingGroup("dtmf", "DTMF Settings")
group.append(dtmf)
- dtmfchars = "0123456789 *#ABCD"
+
+ if str(self._memobj.firmware_msg.line1) == "HN5RV01":
+ dtmfchars = "0123456789ABCD*#"
+ else:
+ dtmfchars = "0123456789 *#ABCD"
for i in range(0, 15):
_codeobj = self._memobj.pttid[i].code
@@ -1587,10 +1666,12 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
rs.set_apply_callback(apply_code, self._memobj.pttid[i])
dtmf.append(rs)
+ dtmfcharsani = "0123456789"
+
_codeobj = self._memobj.ani.code
- _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F])
+ _code = "".join([dtmfcharsani[x] for x in _codeobj if int(x) < 0x1F])
val = RadioSettingValueString(0, 5, _code, False)
- val.set_charset(dtmfchars)
+ val.set_charset(dtmfcharsani)
rs = RadioSetting("ani.code", "ANI Code", val)
def apply_code(setting, obj):
@@ -1653,7 +1734,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
RadioSettingValueInteger(0, 50, _settings.pttlt))
dtmf.append(rs)
- if not self._is_orig():
+ if not self._is_orig() and self._aux_block:
service = RadioSettingGroup("service", "Service Settings")
group.append(service)
@@ -1740,12 +1821,12 @@ class UV5XAlias(chirp_common.Alias):
class RT5RAlias(chirp_common.Alias):
VENDOR = "Retevis"
- MODEL = "RT-5R"
+ MODEL = "RT5R"
class RT5RVAlias(chirp_common.Alias):
VENDOR = "Retevis"
- MODEL = "RT-5RV"
+ MODEL = "RT5RV"
class RT5Alias(chirp_common.Alias):
@@ -1773,15 +1854,10 @@ class A5RAlias(chirp_common.Alias):
MODEL = "A-5R"
-class TenwayUV5RPro(chirp_common.Alias):
- VENDOR = 'Tenway'
- MODEL = 'UV-5R Pro'
-
-
@directory.register
class BaofengUV5RGeneric(BaofengUV5R):
ALIASES = [UV5XAlias, RT5RAlias, RT5RVAlias, RT5Alias, RH5RAlias,
- ROUV5REXAlias, A5RAlias, TenwayUV5RPro]
+ ROUV5REXAlias, A5RAlias]
@directory.register
@@ -1834,6 +1910,7 @@ class BaofengUV6Radio(BaofengUV5R):
_idents = [UV5R_MODEL_UV6,
UV5R_MODEL_UV6_ORIG
]
+ _aux_block = False
def get_features(self):
rf = BaofengUV5R.get_features(self)
@@ -1865,6 +1942,7 @@ class IntekKT980Radio(BaofengUV5R):
_idents = [UV5R_MODEL_291]
_vhf_range = (130000000, 180000000)
_uhf_range = (400000000, 521000000)
+ _tri_power = True
def get_features(self):
rf = BaofengUV5R.get_features(self)
@@ -1881,17 +1959,44 @@ class ROGA5SAlias(chirp_common.Alias):
MODEL = "GA-5S"
+class UV5XPAlias(chirp_common.Alias):
+ VENDOR = "Baofeng"
+ MODEL = "UV-5XP"
+
+
+class TSTIF8Alias(chirp_common.Alias):
+ VENDOR = "TechSide"
+ MODEL = "TI-F8+"
+
+
+class TenwayUV5RPro(chirp_common.Alias):
+ VENDOR = 'Tenway'
+ MODEL = 'UV-5R Pro'
+
+
+class TSTST9Alias(chirp_common.Alias):
+ VENDOR = "TechSide"
+ MODEL = "TS-T9+"
+
+
+class TDUV5RRadio(chirp_common.Alias):
+ VENDOR = "TIDRADIO"
+ MODEL = "TD-UV5R TriPower"
+
+
@directory.register
class BaofengBFF8HPRadio(BaofengUV5R):
VENDOR = "Baofeng"
MODEL = "BF-F8HP"
- ALIASES = [RT5_TPAlias, ROGA5SAlias]
+ ALIASES = [RT5_TPAlias, ROGA5SAlias, UV5XPAlias, TSTIF8Alias,
+ TenwayUV5RPro, TSTST9Alias, TDUV5RRadio]
_basetype = BASETYPE_F8HP
_idents = [UV5R_MODEL_291,
UV5R_MODEL_A58
]
_vhf_range = (130000000, 180000000)
_uhf_range = (400000000, 521000000)
+ _tri_power = True
def get_features(self):
rf = BaofengUV5R.get_features(self)
@@ -1903,14 +2008,23 @@ class BaofengBFF8HPRadio(BaofengUV5R):
return False
+class TenwayUV82Pro(chirp_common.Alias):
+ VENDOR = 'Tenway'
+ MODEL = 'UV-82 Pro'
+
+
@directory.register
class BaofengUV82HPRadio(BaofengUV5R):
VENDOR = "Baofeng"
MODEL = "UV-82HP"
+ ALIASES = [TenwayUV82Pro]
_basetype = BASETYPE_UV82HP
_idents = [UV5R_MODEL_UV82]
_vhf_range = (136000000, 175000000)
_uhf_range = (400000000, 521000000)
+ _valid_chars = chirp_common.CHARSET_ALPHANUMERIC + \
+ "!@#$%^&*()+-=[]:\";'<>?,./"
+ _tri_power = True
def get_features(self):
rf = BaofengUV5R.get_features(self)
@@ -1937,3 +2051,42 @@ class RadioddityUV5RX3Radio(BaofengUV5R):
@classmethod
def match_model(cls, filename, filedata):
return False
+
+
+@directory.register
+class RadioddityGT5RRadio(BaofengUV5R):
+ VENDOR = 'Baofeng'
+ MODEL = 'GT-5R'
+
+ vhftx = [144000000, 148000000]
+ uhftx = [420000000, 450000000]
+
+ def set_memory(self, mem):
+ # If memory is outside the TX limits, the radio will refuse
+ # transmit. Radioddity asked for us to enforce this behavior
+ # in chirp for consistency.
+ if not (mem.freq >= self.vhftx[0] and mem.freq < self.vhftx[1]) and \
+ not (mem.freq >= self.uhftx[0] and mem.freq < self.uhftx[1]):
+ LOG.info('Memory frequency outside TX limits of radio; '
+ 'forcing duplex=off')
+ mem.duplex = 'off'
+ mem.offset = 0
+ BaofengUV5R.set_memory(self, mem)
+
+ @classmethod
+ def match_model(cls, filename, filedata):
+ return False
+
+
+@directory.register
+class RadioddityUV5GRadio(BaofengUV5R):
+ VENDOR = 'Radioddity'
+ MODEL = 'UV-5G'
+
+ _basetype = BASETYPE_UV5R
+ _idents = [UV5R_MODEL_UV5G]
+ _gmrs = True
+
+ @classmethod
+ def match_model(cls, filename, filedata):
+ return False
diff --git a/chirp/drivers/uv5x3.py b/chirp/drivers/uv5x3.py
index 612dea0..039edec 100644
--- a/chirp/drivers/uv5x3.py
+++ b/chirp/drivers/uv5x3.py
@@ -19,8 +19,6 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp.drivers import baofeng_common
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
@@ -31,7 +29,9 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
InvalidValueError
from textwrap import dedent
-##### MAGICS #########################################################
+LOG = logging.getLogger(__name__)
+
+# #### MAGICS #########################################################
# BTECH UV-5X3 magic string
MSTRING_UV5X3 = "\x50\x0D\x0C\x20\x16\x03\x28"
@@ -39,7 +39,7 @@ MSTRING_UV5X3 = "\x50\x0D\x0C\x20\x16\x03\x28"
# MTC UV-5R-3 magic string
MSTRING_UV5R3 = "\x50\x0D\x0C\x20\x17\x09\x19"
-##### ID strings #####################################################
+# #### ID strings #####################################################
# BTECH UV-5X3
UV5X3_fp1 = "UVVG302" # BFB300 original
@@ -77,8 +77,9 @@ LIST_TIMEOUT = ["%s sec" % x for x in range(15, 615, 15)]
LIST_TXPOWER = ["High", "Low"]
LIST_VOICE = ["Off", "English", "Chinese"]
LIST_WORKMODE = ["Frequency", "Channel"]
-LIST_DTMF_SPECIAL_DIGITS = [ "*", "#", "A", "B", "C", "D"]
-LIST_DTMF_SPECIAL_VALUES = [ 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
+LIST_DTMF_SPECIAL_DIGITS = ["*", "#", "A", "B", "C", "D"]
+LIST_DTMF_SPECIAL_VALUES = [0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
+
def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
@@ -115,6 +116,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
_ranges = [(0x0000, 0x0DF0),
(0x0E00, 0x1800),
+ (0x1E00, 0x1E70),
(0x1EE0, 0x1EF0),
(0x1F60, 0x1F70),
(0x1F80, 0x1F90),
@@ -136,7 +138,6 @@ class UV5X3(baofeng_common.BaofengCommonHT):
PTTID_LIST = LIST_PTTID
SCODE_LIST = LIST_SCODE
-
MEM_FORMAT = """
#seekto 0x0000;
struct {
@@ -165,31 +166,31 @@ class UV5X3(baofeng_common.BaofengCommonHT):
#seekto 0x0C80;
struct {
u8 inspection[8];
- u8 monitor[8];
- u8 alarmcode[8];
- u8 stun[8];
- u8 kill[8];
- u8 revive[8];
- u8 code[7];
+ u8 monitor[8];
+ u8 alarmcode[8];
+ u8 stun[8];
+ u8 kill[8];
+ u8 revive[8];
+ u8 code[7];
u8 unknown06;
- u8 dtmfon;
- u8 dtmfoff;
- u8 unused00:6,
+ u8 dtmfon;
+ u8 dtmfoff;
+ u8 unused00:6,
aniid:2;
u8 unknown07[5];
- u8 masterid[5];
+ u8 masterid[5];
u8 unknown08[3];
u8 viceid[5];
u8 unknown09[3];
u8 unused01:7,
mastervice:1;
- u8 unused02:3,
+ u8 unused02:3,
mrevive:1,
mkill:1,
mstun:1,
mmonitor:1,
minspection:1;
- u8 unused03:3,
+ u8 unused03:3,
vrevive:1,
vkill:1,
vstun:1,
@@ -208,26 +209,26 @@ class UV5X3(baofeng_common.BaofengCommonHT):
struct {
u8 unused00:4,
squelch:4;
- u8 unused01:5,
+ u8 unused01:5,
step:3;
- u8 unknown00;
+ u8 unknown00;
u8 unused02:5,
save:3;
u8 unused03:4,
vox:4;
- u8 unknown01;
- u8 unused04:4,
+ u8 unknown01;
+ u8 unused04:4,
abr:4;
- u8 unused05:7,
+ u8 unused05:7,
tdr:1;
- u8 unused06:7,
+ u8 unused06:7,
beep:1;
- u8 unused07:2,
+ u8 unused07:2,
timeout:6;
u8 unknown02[4];
u8 unused09:6,
voice:2;
- u8 unknown03;
+ u8 unknown03;
u8 unused10:6,
dtmfst:2;
u8 unknown04;
@@ -270,25 +271,25 @@ class UV5X3(baofeng_common.BaofengCommonHT):
dani:1;
u8 unused28:2,
dtmfg:6;
- u8 unknown08:6,
- reset:1,
+ u8 unknown08:7,
unknown09:1;
- u8 unknown10[3];
- u8 cht;
- u8 unknown11[13];
+ u8 unknown10[3];
+ u8 cht;
+ u8 unknown11[13];
u8 displayab:1,
unknown12:2,
fmradio:1,
alarm:1,
- unknown13:2,
+ unknown13:1,
+ reset:1,
menu:1;
- u8 unknown14;
+ u8 unknown14;
u8 unused29:7,
workmode:1;
u8 unused30:7,
keylock:1;
} settings;
-
+
#seekto 0x0E76;
struct {
u8 unused0:1,
@@ -296,7 +297,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
u8 unused1:1,
mrchb:7;
} wmchannel;
-
+
struct vfo {
u8 unknown0[8];
u8 freq[8];
@@ -317,13 +318,13 @@ class UV5X3(baofeng_common.BaofengCommonHT):
widenarr:1,
unknown8:6;
};
-
+
#seekto 0x0F00;
struct {
struct vfo a;
struct vfo b;
} vfo;
-
+
#seekto 0x0F4E;
u16 fm_presets;
@@ -332,19 +333,38 @@ class UV5X3(baofeng_common.BaofengCommonHT):
char name[7];
u8 unknown[9];
} names[128];
-
+
+ struct subvfo {
+ u8 freq[8];
+ u8 unknown0[8];
+ };
+
+ #seekto 0x1E00;
+ struct {
+ struct subvfo vhf;
+ struct subvfo vhf2;
+ struct subvfo uhf;
+ } subvfoa;
+
+ #seekto 0x1E40;
+ struct {
+ struct subvfo vhf;
+ struct subvfo vhf2;
+ struct subvfo uhf;
+ } subvfob;
+
#seekto 0x1ED0;
struct {
char line1[7];
char line2[7];
} sixpoweron_msg;
-
+
#seekto 0x1EF0;
struct {
char line1[7];
char line2[7];
} firmware_msg;
-
+
struct squelch {
u8 sql0;
u8 sql1;
@@ -357,7 +377,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
u8 sql8;
u8 sql9;
};
-
+
#seekto 0x1F60;
struct {
struct squelch vhf;
@@ -374,7 +394,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
char line1[7];
char line2[7];
} poweron_msg;
-
+
struct limit {
u8 enable;
bbcd lower[2];
@@ -475,7 +495,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
basic.append(rs)
rs = RadioSetting("settings.beep", "Beep",
- RadioSettingValueBoolean(_mem.settings.beep))
+ RadioSettingValueBoolean(_mem.settings.beep))
basic.append(rs)
if _mem.settings.timeout > 0x27:
@@ -580,7 +600,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
val = _mem.settings.rpste
rs = RadioSetting("settings.rpste",
"Squelch Tail Eliminate (repeater)",
- RadioSettingValueList(
+ RadioSettingValueList(
LIST_RPSTE, LIST_RPSTE[val]))
basic.append(rs)
@@ -678,14 +698,20 @@ class UV5X3(baofeng_common.BaofengCommonHT):
else:
lower = 130
upper = 179
+ if int(_mem.limits.vhf.lower) < lower:
+ val = lower
+ else:
+ val = int(_mem.limits.vhf.lower)
rs = RadioSetting("limits.vhf.lower", "VHF Lower Limit (MHz)",
- RadioSettingValueInteger(
- lower, upper, _mem.limits.vhf.lower))
+ RadioSettingValueInteger(lower, upper, val))
other.append(rs)
+ if int(_mem.limits.vhf.upper) > upper:
+ val = upper
+ else:
+ val = int(_mem.limits.vhf.upper)
rs = RadioSetting("limits.vhf.upper", "VHF Upper Limit (MHz)",
- RadioSettingValueInteger(
- lower, upper, _mem.limits.vhf.upper))
+ RadioSettingValueInteger(lower, upper, val))
other.append(rs)
if str(_mem.firmware_msg.line1) == "UVVG302":
@@ -697,14 +723,20 @@ class UV5X3(baofeng_common.BaofengCommonHT):
else:
lower = 220
upper = 225
+ if int(_mem.limits.vhf2.lower) < lower:
+ val = lower
+ else:
+ val = int(_mem.limits.vhf2.lower)
rs = RadioSetting("limits.vhf2.lower", "VHF2 Lower Limit (MHz)",
- RadioSettingValueInteger(
- lower, upper, _mem.limits.vhf2.lower))
+ RadioSettingValueInteger(lower, upper, val))
other.append(rs)
+ if int(_mem.limits.vhf2.upper) > upper:
+ val = upper
+ else:
+ val = int(_mem.limits.vhf2.upper)
rs = RadioSetting("limits.vhf2.upper", "VHF2 Upper Limit (MHz)",
- RadioSettingValueInteger(
- lower, upper, _mem.limits.vhf2.upper))
+ RadioSettingValueInteger(lower, upper, val))
other.append(rs)
if str(_mem.firmware_msg.line1) == "UVVG302":
@@ -713,14 +745,20 @@ class UV5X3(baofeng_common.BaofengCommonHT):
else:
lower = 400
upper = 520
+ if int(_mem.limits.uhf.lower) < lower:
+ val = lower
+ else:
+ val = int(_mem.limits.uhf.lower)
rs = RadioSetting("limits.uhf.lower", "UHF Lower Limit (MHz)",
- RadioSettingValueInteger(
- lower, upper, _mem.limits.uhf.lower))
+ RadioSettingValueInteger(lower, upper, val))
other.append(rs)
+ if int(_mem.limits.uhf.upper) > upper:
+ val = upper
+ else:
+ val = int(_mem.limits.uhf.upper)
rs = RadioSetting("limits.uhf.upper", "UHF Upper Limit (MHz)",
- RadioSettingValueInteger(
- lower, upper, _mem.limits.uhf.upper))
+ RadioSettingValueInteger(lower, upper, val))
other.append(rs)
# Work mode settings
@@ -741,17 +779,20 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrcha))
+ _mem.wmchannel.mrcha))
work.append(rs)
rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrchb))
+ _mem.wmchannel.mrchb))
work.append(rs)
def convert_bytes_to_freq(bytes):
real_freq = 0
for byte in bytes:
+ if byte > 9:
+ real_freq = 0
+ continue
real_freq = (real_freq * 10) + byte
return chirp_common.format_freq(real_freq * 10)
@@ -768,16 +809,46 @@ class UV5X3(baofeng_common.BaofengCommonHT):
raise InvalidValueError(msg % (_vhf_lower))
msg = ("Can't be between %i.9975-%i.0000")
if (_vhf_upper + 1) * 1000000 <= value and \
- value < _vhf2_lower * 1000000:
+ value < _vhf2_lower * 1000000:
raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower))
if (_vhf2_upper + 1) * 1000000 <= value and \
- value < _uhf_lower * 1000000:
+ value < _uhf_lower * 1000000:
raise InvalidValueError(msg % (_vhf2_upper, _uhf_lower))
msg = ("Can't be greater than %i.9975")
if value > 99000000 and value >= (_uhf_upper + 1) * 1000000:
raise InvalidValueError(msg % (_uhf_upper))
return chirp_common.format_freq(value)
+ def my_vhf_validate(value):
+ _vhf_lower = int(_mem.limits.vhf.lower)
+ _vhf_upper = int(_mem.limits.vhf.upper)
+ value = chirp_common.parse_freq(value)
+ msg = ("Must be between %i.0000-%i.9975")
+ if (_vhf_upper + 1) * 1000000 <= value or \
+ value < _vhf_lower * 1000000:
+ raise InvalidValueError(msg % (_vhf_lower, _vhf_upper))
+ return chirp_common.format_freq(value)
+
+ def my_vhf2_validate(value):
+ _vhf2_lower = int(_mem.limits.vhf2.lower)
+ _vhf2_upper = int(_mem.limits.vhf2.upper)
+ value = chirp_common.parse_freq(value)
+ msg = ("Must be between %i.0000-%i.9975")
+ if (_vhf2_upper + 1) * 1000000 <= value or \
+ value < _vhf2_lower * 1000000:
+ raise InvalidValueError(msg % (_vhf2_lower, _vhf2_upper))
+ return chirp_common.format_freq(value)
+
+ def my_uhf_validate(value):
+ _uhf_lower = int(_mem.limits.uhf.lower)
+ _uhf_upper = int(_mem.limits.uhf.upper)
+ value = chirp_common.parse_freq(value)
+ msg = ("Must be between %i.0000-%i.9975")
+ if (_uhf_upper + 1) * 1000000 <= value or \
+ value < _uhf_lower * 1000000:
+ raise InvalidValueError(msg % (_uhf_lower, _uhf_upper))
+ return chirp_common.format_freq(value)
+
def apply_freq(setting, obj):
value = chirp_common.parse_freq(str(setting.value)) / 10
for i in range(7, -1, -1):
@@ -798,6 +869,60 @@ class UV5X3(baofeng_common.BaofengCommonHT):
rs.set_apply_callback(apply_freq, _mem.vfo.b)
work.append(rs)
+ val = convert_bytes_to_freq(_mem.subvfoa.vhf.freq)
+ if int(float(val)) == 0:
+ val = str(int(_mem.limits.vhf.lower)) + ".000000"
+ val1a = RadioSettingValueString(0, 10, val)
+ val1a.set_validate_callback(my_vhf_validate)
+ rs = RadioSetting("subvfoa.vhf.freq", "VFO A VHF (Saved)", val1a)
+ rs.set_apply_callback(apply_freq, _mem.subvfoa.vhf)
+ work.append(rs)
+
+ val = convert_bytes_to_freq(_mem.subvfob.vhf.freq)
+ if int(float(val)) == 0:
+ val = str(int(_mem.limits.vhf.lower)) + ".000000"
+ val1b = RadioSettingValueString(0, 10, val)
+ val1b.set_validate_callback(my_vhf_validate)
+ rs = RadioSetting("subvfob.vhf.freq", "VFO B VHF (Saved)", val1b)
+ rs.set_apply_callback(apply_freq, _mem.subvfob.vhf)
+ work.append(rs)
+
+ val = convert_bytes_to_freq(_mem.subvfoa.vhf2.freq)
+ if int(float(val)) == 0:
+ val = str(int(_mem.limits.vhf2.lower)) + ".000000"
+ val1a = RadioSettingValueString(0, 10, val)
+ val1a.set_validate_callback(my_vhf2_validate)
+ rs = RadioSetting("subvfoa.vhf2.freq", "VFO A VHF2 (Saved)", val1a)
+ rs.set_apply_callback(apply_freq, _mem.subvfoa.vhf2)
+ work.append(rs)
+
+ val = convert_bytes_to_freq(_mem.subvfob.vhf2.freq)
+ if int(float(val)) == 0:
+ val = str(int(_mem.limits.vhf2.lower)) + ".000000"
+ val1b = RadioSettingValueString(0, 10, val)
+ val1b.set_validate_callback(my_vhf2_validate)
+ rs = RadioSetting("subvfob.vhf2.freq", "VFO B VHF2 (Saved)", val1b)
+ rs.set_apply_callback(apply_freq, _mem.subvfob.vhf2)
+ work.append(rs)
+
+ val = convert_bytes_to_freq(_mem.subvfoa.uhf.freq)
+ if int(float(val)) == 0:
+ val = str(int(_mem.limits.uhf.lower)) + ".000000"
+ val1a = RadioSettingValueString(0, 10, val)
+ val1a.set_validate_callback(my_uhf_validate)
+ rs = RadioSetting("subvfoa.uhf.freq", "VFO A UHF (Saved)", val1a)
+ rs.set_apply_callback(apply_freq, _mem.subvfoa.uhf)
+ work.append(rs)
+
+ val = convert_bytes_to_freq(_mem.subvfob.uhf.freq)
+ if int(float(val)) == 0:
+ val = str(int(_mem.limits.uhf.lower)) + ".000000"
+ val1b = RadioSettingValueString(0, 10, val)
+ val1b.set_validate_callback(my_uhf_validate)
+ rs = RadioSetting("subvfob.uhf.freq", "VFO B UHF (Saved)", val1b)
+ rs.set_apply_callback(apply_freq, _mem.subvfob.uhf)
+ work.append(rs)
+
rs = RadioSetting("vfo.a.sftd", "VFO A Shift",
RadioSettingValueList(
LIST_SHIFTD, LIST_SHIFTD[_mem.vfo.a.sftd]))
@@ -1133,7 +1258,7 @@ class UV5X3(baofeng_common.BaofengCommonHT):
dtmfd.append(rs)
def apply_dmtf_listvalue(setting, obj):
- LOG.debug("Setting value: "+ str(setting.value) + " from list")
+ LOG.debug("Setting value: " + str(setting.value) + " from list")
val = str(setting.value)
index = LIST_DTMF_SPECIAL_DIGITS.index(val)
val = LIST_DTMF_SPECIAL_VALUES[index]
@@ -1191,7 +1316,8 @@ class UV5X3(baofeng_common.BaofengCommonHT):
_obj = self._memobj.squelch.uhf
_name = "UHF"
val = RadioSettingValueInteger(0, 123,
- getattr(_obj, "sql%i" % (index)))
+ getattr(_obj, "sql%i" % (
+ index)))
if index == 0:
val.set_mutable(False)
name = "%s Squelch %i" % (_name, index)
diff --git a/chirp/drivers/uv6r.py b/chirp/drivers/uv6r.py
index 57f3456..0cbc7d8 100644
--- a/chirp/drivers/uv6r.py
+++ b/chirp/drivers/uv6r.py
@@ -19,8 +19,6 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp.drivers import baofeng_common
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
@@ -31,14 +29,16 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
InvalidValueError
from textwrap import dedent
-##### MAGICS #########################################################
-
+LOG = logging.getLogger(__name__)
+
+# #### MAGICS #########################################################
+
# Baofeng UV-6R magic string
-MSTRING_UV6R = "\x50\xBB\xFF\x20\x14\x11\x22"
-
-##### ID strings #####################################################
-
-# Baofeng UV-6R
+MSTRING_UV6R = "\x50\xBB\xFF\x20\x14\x11\x22"
+
+# #### ID strings #####################################################
+
+# Baofeng UV-6R
UV6R_fp1 = " BF230#1"
UV6R_fp2 = " BF230#2"
@@ -70,6 +70,7 @@ LIST_TXPOWER = ["High", "Low"]
LIST_VOICE = ["Off", "English", "Chinese"]
LIST_WORKMODE = ["Frequency", "Channel"]
+
def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
match_rid1 = False
@@ -125,7 +126,6 @@ class UV6R(baofeng_common.BaofengCommonHT):
PTTID_LIST = LIST_PTTID
SCODE_LIST = LIST_SCODE
-
MEM_FORMAT = """
#seekto 0x0000;
struct {
@@ -418,7 +418,7 @@ class UV6R(baofeng_common.BaofengCommonHT):
basic.append(rs)
rs = RadioSetting("settings.beep", "Beep",
- RadioSettingValueBoolean(_mem.settings.beep))
+ RadioSettingValueBoolean(_mem.settings.beep))
basic.append(rs)
if _mem.settings.timeout > 0x27:
@@ -523,7 +523,7 @@ class UV6R(baofeng_common.BaofengCommonHT):
val = _mem.settings.rpste
rs = RadioSetting("settings.rpste",
"Squelch Tail Eliminate (repeater)",
- RadioSettingValueList(
+ RadioSettingValueList(
LIST_RPSTE, LIST_RPSTE[val]))
basic.append(rs)
@@ -645,12 +645,12 @@ class UV6R(baofeng_common.BaofengCommonHT):
rs = RadioSetting("wmchannel.mrcha", "MR A Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrcha))
+ _mem.wmchannel.mrcha))
work.append(rs)
rs = RadioSetting("wmchannel.mrchb", "MR B Channel",
RadioSettingValueInteger(0, 127,
- _mem.wmchannel.mrchb))
+ _mem.wmchannel.mrchb))
work.append(rs)
def convert_bytes_to_freq(bytes):
@@ -845,7 +845,7 @@ class UV6R(baofeng_common.BaofengCommonHT):
key = "squelch.sql%i" % (index)
_obj = self._memobj.squelch
val = RadioSettingValueInteger(0, 123,
- getattr(_obj, "sql%i" % (index)))
+ getattr(_obj, "sql%i" % (index)))
if index == 0:
val.set_mutable(False)
name = "Squelch %i" % (index)
diff --git a/chirp/drivers/uvb5.py b/chirp/drivers/uvb5.py
index a748cc3..32e2a89 100644
--- a/chirp/drivers/uvb5.py
+++ b/chirp/drivers/uvb5.py
@@ -795,5 +795,5 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
@classmethod
def match_model(cls, filedata, filename):
- return (filedata.startswith("KT511 Radio Program data") and
+ return (filedata.startswith(b"KT511 Radio Program data") and
len(filedata) == (cls._memsize + 0x30))
diff --git a/chirp/drivers/vgc.py b/chirp/drivers/vgc.py
index f5da899..97aece3 100644
--- a/chirp/drivers/vgc.py
+++ b/chirp/drivers/vgc.py
@@ -20,8 +20,6 @@ import struct
import logging
import re
-LOG = logging.getLogger(__name__)
-
from chirp import chirp_common, directory, memmap
from chirp import bitwise, errors, util
from chirp.settings import RadioSettingGroup, RadioSetting, \
@@ -30,6 +28,8 @@ from chirp.settings import RadioSettingGroup, RadioSetting, \
RadioSettingValueFloat, RadioSettings
from textwrap import dedent
+LOG = logging.getLogger(__name__)
+
MEM_FORMAT = """
struct mem {
lbcd rxfreq[4];
@@ -93,12 +93,12 @@ struct {
workmoda:1; // work mode (left side)
u8 scansb:1, // scan stop beep
aftone:3, // af tone control
- scand:1, // scan directon
+ scand:1, // scan direction
scanr:3; // scan resume
u8 rxexp:1, // rx expansion
ptt:1, // ptt mode
display:1, // display select (frequency/clock)
- omode:1, // operaton mode
+ omode:1, // operation mode
beep:2, // beep volume
spkr:2; // speaker
u8 cpuclk:1, // operating mode(cpu clock)
@@ -261,8 +261,8 @@ LIST_SCAND = ["Down", "Up"]
LIST_SCANR = ["Busy", "Hold", "1 sec", "3 sec", "5 sec"]
LIST_APO = ["Off", ".5", "1", "1.5"] + ["%s" % x for x in range(2, 13)]
LIST_BEEP = ["Off", "Low", "High"]
-LIST_FKEY = ["MHz/AD-F", "AF Dual 1(line-in)", "AF Dual 2(AM)", "AF Dual 3(FM)",
- "PA", "SQL off", "T-call", "WX"]
+LIST_FKEY = ["MHz/AD-F", "AF Dual 1(line-in)", "AF Dual 2(AM)",
+ "AF Dual 3(FM)", "PA", "SQL off", "T-call", "WX"]
LIST_PFKEY = ["Off", "SQL off", "TX power", "Scan", "RPT shift", "Reverse",
"T-Call"]
LIST_AB = ["A", "B"]
@@ -345,7 +345,7 @@ POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=5),
chirp_common.PowerLevel("High", watts=50)]
# B-TECH UV-50X3 id string
-UV50X3_id = "VGC6600MD"
+UV50X3_id = "VGC6600MD"
def _clean_buffer(radio):
@@ -451,7 +451,7 @@ def _do_ident(radio):
if ident != radio.IDENT:
# bad ident
msg = "Incorrect model ID, got this:"
- msg += util.hexprint(ident)
+ msg += util.hexprint(ident)
LOG.debug(msg)
raise errors.RadioError("Radio identification failed.")
@@ -551,8 +551,7 @@ def model_match(cls, data):
"""Match the opened/downloaded image to the correct version"""
rid = data[0x6140:0x6148]
- #if rid in cls._fileid:
- if rid in cls.IDENT:
+ if rid in cls.IDENT.encode():
return True
return False
@@ -787,7 +786,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
mem.extra = RadioSettingGroup("extra", "Extra")
bcl = RadioSetting("bcl", "Busy channel lockout",
- RadioSettingValueBoolean(bool(_mem.bcl)))
+ RadioSettingValueBoolean(bool(_mem.bcl)))
mem.extra.append(bcl)
revert = RadioSetting("revert", "Revert",
@@ -870,7 +869,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
if dname and not dname.changed():
dname.value = False
- # reseting unknowns, this has to be set by hand
+ # resetting unknowns, this has to be set by hand
_mem.unknown0 = 0
_mem.unknown1 = 0
_mem.unknown2 = 0
@@ -924,7 +923,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
basic.append(aftone)
spkr = RadioSetting("settings.spkr", "Speaker",
- RadioSettingValueList(LIST_SPKR,LIST_SPKR[
+ RadioSettingValueList(LIST_SPKR, LIST_SPKR[
_mem.settings.spkr]))
basic.append(spkr)
@@ -946,7 +945,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
basic.append(mgain)
ptt = RadioSetting("settings.ptt", "PTT mode",
- RadioSettingValueList(LIST_PTT,LIST_PTT[
+ RadioSettingValueList(LIST_PTT, LIST_PTT[
_mem.settings.ptt]))
basic.append(ptt)
@@ -954,7 +953,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
# B04 (per channel)
rxexp = RadioSetting("settings.rxexp", "RX expansion",
- RadioSettingValueList(LIST_RXEXP,LIST_RXEXP[
+ RadioSettingValueList(LIST_RXEXP, LIST_RXEXP[
_mem.settings.rxexp]))
basic.append(rxexp)
@@ -973,8 +972,9 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
# Display: C01-C06
display = RadioSetting("settings.display", "Display select",
- RadioSettingValueList(LIST_DISPLAY,
- LIST_DISPLAY[_mem.settings.display]))
+ RadioSettingValueList(
+ LIST_DISPLAY, LIST_DISPLAY[
+ _mem.settings.display]))
basic.append(display)
lcdb = RadioSetting("settings.lcdb", "LCD brightness",
@@ -1022,12 +1022,12 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
basic.append(dwstop)
scand = RadioSetting("settings.scand", "Scan direction",
- RadioSettingValueList(LIST_SCAND,LIST_SCAND[
+ RadioSettingValueList(LIST_SCAND, LIST_SCAND[
_mem.settings.scand]))
basic.append(scand)
scanr = RadioSetting("settings.scanr", "Scan resume",
- RadioSettingValueList(LIST_SCANR,LIST_SCANR[
+ RadioSettingValueList(LIST_SCANR, LIST_SCANR[
_mem.settings.scanr]))
basic.append(scanr)
@@ -1047,12 +1047,12 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
basic.append(ars)
beep = RadioSetting("settings.beep", "Beep volume",
- RadioSettingValueList(LIST_BEEP,LIST_BEEP[
+ RadioSettingValueList(LIST_BEEP, LIST_BEEP[
_mem.settings.beep]))
basic.append(beep)
fkey = RadioSetting("settings.fkey", "F key",
- RadioSettingValueList(LIST_FKEY,LIST_FKEY[
+ RadioSettingValueList(LIST_FKEY, LIST_FKEY[
_mem.settings.fkey]))
basic.append(fkey)
@@ -1077,36 +1077,40 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
basic.append(pfkey4)
omode = RadioSetting("settings.omode", "Operation mode",
- RadioSettingValueList(LIST_AB,LIST_AB[
+ RadioSettingValueList(LIST_AB, LIST_AB[
_mem.settings.omode]))
basic.append(omode)
rxcoverm = RadioSetting("settings.rxcoverm", "RX coverage - memory",
- RadioSettingValueList(LIST_COVERAGE,
- LIST_COVERAGE[_mem.settings.rxcoverm]))
+ RadioSettingValueList(
+ LIST_COVERAGE, LIST_COVERAGE[
+ _mem.settings.rxcoverm]))
basic.append(rxcoverm)
rxcoverv = RadioSetting("settings.rxcoverv", "RX coverage - VFO",
- RadioSettingValueList(LIST_COVERAGE,
- LIST_COVERAGE[_mem.settings.rxcoverv]))
+ RadioSettingValueList(
+ LIST_COVERAGE, LIST_COVERAGE[
+ _mem.settings.rxcoverv]))
basic.append(rxcoverv)
tot = RadioSetting("settings.tot", "Time out timer [min]",
RadioSettingValueList(LIST_TOT, LIST_TOT[
- _mem.settings.tot]))
+ _mem.settings.tot]))
basic.append(tot)
# Timer/Clock: G01-G04
# G01
datefmt = RadioSetting("settings.datefmt", "Date format",
- RadioSettingValueList(LIST_DATEFMT,
- LIST_DATEFMT[_mem.settings.datefmt]))
+ RadioSettingValueList(
+ LIST_DATEFMT, LIST_DATEFMT[
+ _mem.settings.datefmt]))
basic.append(datefmt)
timefmt = RadioSetting("settings.timefmt", "Time format",
- RadioSettingValueList(LIST_TIMEFMT,
- LIST_TIMEFMT[_mem.settings.timefmt]))
+ RadioSettingValueList(
+ LIST_TIMEFMT, LIST_TIMEFMT[
+ _mem.settings.timefmt]))
basic.append(timefmt)
timesig = RadioSetting("settings.timesig", "Time signal",
@@ -1140,7 +1144,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
# H04 (per channel)
decbandsel = RadioSetting("settings.decbandsel", "DTMF band select",
- RadioSettingValueList(LIST_AB,LIST_AB[
+ RadioSettingValueList(LIST_AB, LIST_AB[
_mem.settings.decbandsel]))
basic.append(decbandsel)
@@ -1151,18 +1155,21 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
# Pkt: I01-I03
databnd = RadioSetting("settings.databnd", "Packet data band",
- RadioSettingValueList(LIST_DATABND,LIST_DATABND[
- _mem.settings.databnd]))
+ RadioSettingValueList(
+ LIST_DATABND, LIST_DATABND[
+ _mem.settings.databnd]))
basic.append(databnd)
dataspd = RadioSetting("settings.dataspd", "Packet data speed",
- RadioSettingValueList(LIST_DATASPD,LIST_DATASPD[
- _mem.settings.dataspd]))
+ RadioSettingValueList(
+ LIST_DATASPD, LIST_DATASPD[
+ _mem.settings.dataspd]))
basic.append(dataspd)
datasql = RadioSetting("settings.datasql", "Packet data squelch",
- RadioSettingValueList(LIST_DATASQL,LIST_DATASQL[
- _mem.settings.datasql]))
+ RadioSettingValueList(
+ LIST_DATASQL, LIST_DATASQL[
+ _mem.settings.datasql]))
basic.append(datasql)
# Other
@@ -1172,7 +1179,7 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
other.append(dw)
cpuclk = RadioSetting("settings.cpuclk", "CPU clock frequency",
- RadioSettingValueList(LIST_CPUCLK,LIST_CPUCLK[
+ RadioSettingValueList(LIST_CPUCLK, LIST_CPUCLK[
_mem.settings.cpuclk]))
other.append(cpuclk)
@@ -1198,12 +1205,12 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
# Work
workmoda = RadioSetting("settings.workmoda", "Work mode A",
- RadioSettingValueList(LIST_WORK,LIST_WORK[
+ RadioSettingValueList(LIST_WORK, LIST_WORK[
_mem.settings.workmoda]))
work.append(workmoda)
workmodb = RadioSetting("settings.workmodb", "Work mode B",
- RadioSettingValueList(LIST_WORK,LIST_WORK[
+ RadioSettingValueList(LIST_WORK, LIST_WORK[
_mem.settings.workmodb]))
work.append(workmodb)
@@ -1228,23 +1235,23 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
work.append(sqlb)
stepa = RadioSetting("settings.stepa", "Auto step A",
- RadioSettingValueList(LIST_STEP,LIST_STEP[
+ RadioSettingValueList(LIST_STEP, LIST_STEP[
_mem.settings.stepa]))
work.append(stepa)
stepb = RadioSetting("settings.stepb", "Auto step B",
- RadioSettingValueList(LIST_STEP,LIST_STEP[
+ RadioSettingValueList(LIST_STEP, LIST_STEP[
_mem.settings.stepb]))
work.append(stepb)
mrcha = RadioSetting("settings.mrcha", "Current channel A",
RadioSettingValueInteger(0, 499,
- _mem.settings.mrcha))
+ _mem.settings.mrcha))
work.append(mrcha)
mrchb = RadioSetting("settings.mrchb", "Current channel B",
RadioSettingValueInteger(0, 499,
- _mem.settings.mrchb))
+ _mem.settings.mrchb))
work.append(mrchb)
val = _mem.settings.offseta / 100.00
@@ -1259,16 +1266,16 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
wpricha = RadioSetting("settings.wpricha", "Priority channel A",
RadioSettingValueInteger(0, 499,
- _mem.settings.wpricha))
+ _mem.settings.wpricha))
work.append(wpricha)
wprichb = RadioSetting("settings.wprichb", "Priority channel B",
RadioSettingValueInteger(0, 499,
- _mem.settings.wprichb))
+ _mem.settings.wprichb))
work.append(wprichb)
smode = RadioSetting("settings.smode", "Smart function mode",
- RadioSettingValueList(LIST_SMODE,LIST_SMODE[
+ RadioSettingValueList(LIST_SMODE, LIST_SMODE[
_mem.settings.smode]))
work.append(smode)
@@ -1280,13 +1287,13 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
dtmf.append(ttdkey)
ttdgt = RadioSetting("dtmf.ttdgt", "Digit time",
- RadioSettingValueList(LIST_TT200, LIST_TT200[
- (_mem.dtmf.ttdgt) - 5]))
+ RadioSettingValueList(LIST_TT200, LIST_TT200[
+ (_mem.dtmf.ttdgt) - 5]))
dtmf.append(ttdgt)
ttint = RadioSetting("dtmf.ttint", "Interval time",
- RadioSettingValueList(LIST_TT200, LIST_TT200[
- (_mem.dtmf.ttint) - 5]))
+ RadioSettingValueList(LIST_TT200, LIST_TT200[
+ (_mem.dtmf.ttint) - 5]))
dtmf.append(ttint)
tt1stdgt = RadioSetting("dtmf.tt1stdgt", "1st digit time",
@@ -1310,8 +1317,9 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
dtmf.append(ttsig)
ttautorst = RadioSetting("dtmf2.ttautorst", "Auto reset time",
- RadioSettingValueList(LIST_TTAUTORST,
- LIST_TTAUTORST[_mem.dtmf2.ttautorst]))
+ RadioSettingValueList(
+ LIST_TTAUTORST, LIST_TTAUTORST[
+ _mem.dtmf2.ttautorst]))
dtmf.append(ttautorst)
if _mem.dtmf2.ttgrpcode > 0x06:
@@ -1320,12 +1328,13 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
val = _mem.dtmf2.ttgrpcode
ttgrpcode = RadioSetting("dtmf2.ttgrpcode", "Group code",
RadioSettingValueList(LIST_TTGRPCODE,
- LIST_TTGRPCODE[val]))
+ LIST_TTGRPCODE[val]))
dtmf.append(ttgrpcode)
ttintcode = RadioSetting("dtmf2.ttintcode", "Interval code",
- RadioSettingValueList(LIST_TTINTCODE,
- LIST_TTINTCODE[_mem.dtmf2.ttintcode]))
+ RadioSettingValueList(
+ LIST_TTINTCODE, LIST_TTINTCODE[
+ _mem.dtmf2.ttintcode]))
dtmf.append(ttintcode)
if _mem.dtmf2.ttalert > 0x04:
@@ -1334,16 +1343,17 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
val = _mem.dtmf2.ttalert
ttalert = RadioSetting("dtmf2.ttalert", "Alert tone/transpond",
RadioSettingValueList(LIST_TTALERT,
- LIST_TTALERT[val]))
+ LIST_TTALERT[val]))
dtmf.append(ttalert)
ttautod = RadioSetting("dtmf.ttautod", "Auto dial group",
- RadioSettingValueList(LIST_TTAUTOD,
- LIST_TTAUTOD[_mem.dtmf.ttautod]))
+ RadioSettingValueList(
+ LIST_TTAUTOD, LIST_TTAUTOD[
+ _mem.dtmf.ttautod]))
dtmf.append(ttautod)
# setup 9 dtmf autodial entries
- for i in map(str, range(1, 10)):
+ for i in map(str, list(range(1, 10))):
objname = "code" + i
strname = "Code " + str(i)
dtmfsetting = getattr(_mem.dtmfcode, objname)
@@ -1410,11 +1420,10 @@ class VGCStyleRadio(chirp_common.CloneModeRadio,
elif element.value.get_mutable():
LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
- except Exception, e:
+ except Exception as e:
LOG.debug(element.get_name())
raise
-
@classmethod
def match_model(cls, filedata, filename):
match_size = False
diff --git a/chirp/drivers/vx170.py b/chirp/drivers/vx170.py
index b5aaa26..dde182c 100644
--- a/chirp/drivers/vx170.py
+++ b/chirp/drivers/vx170.py
@@ -106,7 +106,7 @@ class VX170Radio(ft7800.FTx800Radio):
3. Press and hold in the [moni] key while turning the radio on.
4. Select CLONE in menu, then press F. Radio restarts in clone mode.
("CLONE" will appear on the display).
-5. <b>After clicking OK</b>, breifly hold [PTT] key to send image.
+5. <b>After clicking OK</b>, briefly hold [PTT] key to send image.
("-TX-" will appear on the LCD). """))
rp.pre_upload = _(dedent("""\
1. Turn radio off.
diff --git a/chirp/drivers/vx3.py b/chirp/drivers/vx3.py
index 0eba272..39ff85e 100644
--- a/chirp/drivers/vx3.py
+++ b/chirp/drivers/vx3.py
@@ -775,7 +775,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
rs = RadioSetting(
"my_key", "My key",
RadioSettingValueList(keys, keys[_settings.my_key - 16]))
- # TODO: fix keys list isnt exactly right order
+ # TODO: fix keys list isn't exactly right order
# leave disabled in settings for now
# basic.append(rs)
diff --git a/chirp/drivers/vx6.py b/chirp/drivers/vx6.py
index 15f34e2..4616fe2 100644
--- a/chirp/drivers/vx6.py
+++ b/chirp/drivers/vx6.py
@@ -823,7 +823,7 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
return self._get_settings()
except:
import traceback
- pring(traceback.format_exc())
+ print(traceback.format_exc())
return None
def set_settings(self, uisettings):
@@ -871,5 +871,5 @@ class VX6Radio(yaesu_clone.YaesuCloneModeRadio):
elif setting == "password":
newval = self._encode_chars(newval, 4)
setattr(_settings, setting, newval)
- except Exception, e:
+ except Exception as e:
raise
diff --git a/chirp/drivers/vx8.py b/chirp/drivers/vx8.py
index 550d1ca..43c3102 100644
--- a/chirp/drivers/vx8.py
+++ b/chirp/drivers/vx8.py
@@ -1482,6 +1482,8 @@ class VX8DRadio(VX8Radio):
146, # Length of beacon data stored.
50) # Number of beacons stored.
+ _TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms",
+ "400ms", "500ms", "750ms", "1000ms")
_BEACON_TYPE = ("Off", "Interval", "SmartBeaconing")
_SMARTBEACON_PROFILE = ("Off", "Type 1", "Type 2", "Type 3")
_POSITIONS = ("GPS", "Manual Latitude/Longitude",
diff --git a/chirp/drivers/vxa700.py b/chirp/drivers/vxa700.py
index 87aeaa0..421abe2 100644
--- a/chirp/drivers/vxa700.py
+++ b/chirp/drivers/vxa700.py
@@ -86,14 +86,14 @@ def _download(radio):
def _upload(radio):
for i in range(0, radio.get_memsize(), 128):
chunk = radio.get_mmap()[i:i+128]
- cs = 0x20 + 130 + (i / 128)
+ cs = 0x20 + 130 + (i // 128)
for byte in chunk:
cs += ord(byte)
_spoonfeed(radio,
struct.pack("BBB128sB",
0x20,
130,
- i / 128,
+ i // 128,
chunk,
cs % 256))
radio.pipe.write("")
@@ -104,7 +104,7 @@ def _upload(radio):
time.sleep(0.5)
if ack != "\x06":
LOG.debug(repr(ack))
- raise errors.RadioError("Radio did not ack block %i" % (i / 132))
+ raise errors.RadioError("Radio did not ack block %i" % (i // 132))
# radio.pipe.read(1)
if radio.status_fn:
status = chirp_common.Status()
@@ -161,7 +161,7 @@ POWER = [chirp_common.PowerLevel("Low1", watts=0.050),
def _wipe_memory(_mem):
- _mem.set_raw("\x00" * (_mem.size() / 8))
+ _mem.set_raw("\x00" * (_mem.size() // 8))
@directory.register
@@ -177,7 +177,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
self._mmap = _download(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate " +
"with the radio: %s" % e)
self.process_mmap()
@@ -192,7 +192,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
_upload(self)
except errors.RadioError:
raise
- except Exception, e:
+ except Exception as e:
raise errors.RadioError("Failed to communicate " +
"with the radio: %s" % e)
@@ -226,7 +226,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
def get_memory(self, number):
_mem = self._get_mem(number)
- byte = (number - 1) / 8
+ byte = (number - 1) // 8
bit = 1 << ((number - 1) % 8)
mem = chirp_common.Memory()
@@ -264,7 +264,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
def set_memory(self, mem):
_mem = self._get_mem(mem.number)
- byte = (mem.number - 1) / 8
+ byte = (mem.number - 1) // 8
bit = 1 << ((mem.number - 1) % 8)
if mem.empty and self._memobj.invisible_bits[byte] & bit:
@@ -296,7 +296,7 @@ class VXA700Radio(chirp_common.CloneModeRadio):
_mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
_mem.tmode = TMODES.index(mem.tmode)
_mem.duplex = DUPLEX.index(mem.duplex)
- _mem.offset = mem.offset / 5000 / 10
+ _mem.offset = mem.offset // 5000 // 10
_mem.isfm = mem.mode == "FM"
_mem.skip = mem.skip == "S"
try:
@@ -314,4 +314,4 @@ class VXA700Radio(chirp_common.CloneModeRadio):
@classmethod
def match_model(cls, filedata, filename):
return len(filedata) == cls._memsize and \
- ord(filedata[5]) == 0x0F
+ filedata[5] == 0x0F
diff --git a/chirp/drivers/wouxun.py b/chirp/drivers/wouxun.py
index 21a1767..d0f55b8 100644
--- a/chirp/drivers/wouxun.py
+++ b/chirp/drivers/wouxun.py
@@ -379,12 +379,12 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
50, 174, decode_freq(
self._memobj.freq_ranges.vhf_tx_stop)))
freq_ranges.append(rs)
- rs = RadioSetting("uhf_tx_start", "2st band TX Lower Limit (MHz)",
+ rs = RadioSetting("uhf_tx_start", "2nd band TX Lower Limit (MHz)",
RadioSettingValueInteger(
136, 520, decode_freq(
self._memobj.freq_ranges.uhf_tx_start)))
freq_ranges.append(rs)
- rs = RadioSetting("uhf_tx_stop", "2st band TX Upper Limit (MHz)",
+ rs = RadioSetting("uhf_tx_stop", "2nd band TX Upper Limit (MHz)",
RadioSettingValueInteger(
136, 520, decode_freq(
self._memobj.freq_ranges.uhf_tx_stop)))
diff --git a/chirp/drivers/wouxun_common.py b/chirp/drivers/wouxun_common.py
index ec65d38..b665c20 100644
--- a/chirp/drivers/wouxun_common.py
+++ b/chirp/drivers/wouxun_common.py
@@ -19,7 +19,7 @@
import struct
import os
import logging
-from chirp import util, chirp_common, memmap
+from chirp import util, chirp_common, memmap, bitwise
LOG = logging.getLogger(__name__)
@@ -33,9 +33,9 @@ def do_download(radio, start, end, blocksize):
"""Initiate a download of @radio between @start and @end"""
image = ""
for i in range(start, end, blocksize):
- cmd = struct.pack(">cHb", "R", i, blocksize)
+ cmd = struct.pack(">cHb", b"R", i, blocksize)
LOG.debug(util.hexprint(cmd))
- radio.pipe.write(cmd)
+ radio.pipe.write(bitwise.string_straight_decode(cmd))
length = len(cmd) + blocksize
resp = radio.pipe.read(length)
if len(resp) != (len(cmd) + blocksize):
@@ -61,10 +61,10 @@ def do_upload(radio, start, end, blocksize):
"""Initiate an upload of @radio between @start and @end"""
ptr = start
for i in range(start, end, blocksize):
- cmd = struct.pack(">cHb", "W", i, blocksize)
- chunk = radio.get_mmap()[ptr:ptr+blocksize]
+ cmd = struct.pack(">cHb", b"W", i, blocksize)
+ chunk = radio.get_mmap().get_byte_compatible()[ptr:ptr+blocksize]
ptr += blocksize
- radio.pipe.write(cmd + chunk)
+ radio.pipe.write(bitwise.string_straight_decode(cmd + chunk))
LOG.debug(util.hexprint(cmd + chunk))
ack = radio.pipe.read(1)
diff --git a/chirp/elib_intl.py b/chirp/elib_intl.py
index 76e3b9b..6603e0b 100644
--- a/chirp/elib_intl.py
+++ b/chirp/elib_intl.py
@@ -504,7 +504,7 @@ def install_module(domain, localedir):
:returns: an anonymous function object, based on domain and localedir.
Codeset is always UTF-8.
- You may find this function usefull when writing localized modules.
+ You may find this function useful when writing localized modules.
Use this code to make _() available to your module:
.. sourcecode:: python
diff --git a/chirp/import_logic.py b/chirp/import_logic.py
index c2ed867..cc6a366 100644
--- a/chirp/import_logic.py
+++ b/chirp/import_logic.py
@@ -203,6 +203,10 @@ def import_mem(dst_radio, src_features, src_mem, overrides={}):
ensure_has_calls(dst_radio, src_mem)
dst_mem = src_mem.dupe()
+ # The source's immutable list almost definitely does not match the
+ # latter, so eliminate that list here and rely on set_memory() on
+ # the destination to enforce anything that should not be set.
+ dst_mem.immutable = []
for k, v in overrides.items():
dst_mem.__dict__[k] = v
diff --git a/chirp/logger.py b/chirp/logger.py
index 619927a..d063f37 100644
--- a/chirp/logger.py
+++ b/chirp/logger.py
@@ -15,7 +15,7 @@
r"""
-The chirp.logger module provides the core logging facilties for CHIRP.
+The chirp.logger module provides the core logging facilities for CHIRP.
It sets up the console and (optionally) a log file. For early debugging,
it checks the CHIRP_DEBUG, CHIRP_LOG, and CHIRP_LOG_LEVEL environment
variables.
diff --git a/chirp/platform.py b/chirp/platform.py
index 1fd928b..3b282de 100644
--- a/chirp/platform.py
+++ b/chirp/platform.py
@@ -95,8 +95,10 @@ class Platform:
def log_dir(self):
"""Return the preferred log file directory"""
logdir = os.path.join(self.config_dir(), "logs")
- if not os.path.isdir(logdir):
+ try:
os.mkdir(logdir)
+ except FileExistsError:
+ pass
return logdir
@@ -280,8 +282,10 @@ class UnixPlatform(Platform):
basepath = os.path.abspath(os.path.join(self.default_dir(),
".chirp"))
- if not os.path.isdir(basepath):
+ try:
os.mkdir(basepath)
+ except FileExistsError:
+ pass
Platform.__init__(self, basepath)
@@ -352,7 +356,10 @@ class Win32Platform(Platform):
basepath = os.path.abspath(os.path.join(appdata, "CHIRP"))
if not os.path.isdir(basepath):
- os.mkdir(basepath)
+ try:
+ os.mkdir(basepath)
+ except FileExistsError:
+ pass
Platform.__init__(self, basepath)
diff --git a/chirp/pyPEG.py b/chirp/pyPEG.py
index ce04502..772ed95 100644
--- a/chirp/pyPEG.py
+++ b/chirp/pyPEG.py
@@ -169,7 +169,7 @@ class parser(object):
except:
pass
- if isinstance(pattern, collections.Callable):
+ if isinstance(pattern, collections.abc.Callable):
if __debug__:
if print_trace:
try:
@@ -184,7 +184,7 @@ class parser(object):
name = Name(pattern.__name__)
pattern = pattern()
- if isinstance(pattern, collections.Callable):
+ if isinstance(pattern, collections.abc.Callable):
pattern = (pattern,)
text = skip(self.skipper, textline, skipWS, skipComments)
@@ -353,7 +353,7 @@ def parse(language, lineSource, skipWS=True, skipComments=None,
packrat=False, lineCount=True):
lines, lineNo = [], 0
- while isinstance(language, collections.Callable):
+ while isinstance(language, collections.abc.Callable):
language = language()
orig, ld = "", 0
diff --git a/chirp/radioreference.py b/chirp/radioreference.py
index 262e592..7c4d427 100644
--- a/chirp/radioreference.py
+++ b/chirp/radioreference.py
@@ -56,24 +56,54 @@ class RadioReferenceRadio(chirp_common.NetworkSourceRadio):
self._client = Client(self.URL)
self._freqs = None
self._modes = None
- self._zip = None
+ self._zipcounty = None
+ self._country = None
- def set_params(self, zipcode, username, password):
+ def set_params(self, zipcounty, username, password, country):
"""Set the parameters to be used for a query"""
- self._zip = zipcode
+ self._country = country
+ self._zipcounty = zipcounty
self._auth["username"] = username
self._auth["password"] = password
- def do_fetch(self):
- """Fetches frequencies for all subcategories in a county."""
- self._freqs = []
-
+ def do_getcanadacounties(self):
try:
service = self._client.service
- zipcode = service.getZipcodeInfo(self._zip, self._auth)
- county = service.getCountyInfo(zipcode.ctid, self._auth)
+ provincelist = service.getCountryInfo(2, self._auth)
+ provinces = {}
+ clist = []
+ for province in provincelist:
+ provinces[province[2]] = province[0]
+ provinceinfo = service.getStateInfo(province[0], self._auth)
+ for county in provinceinfo.countyList:
+ if (county[1] != 'UNKNOWN' and county[1] != 'N/A' and
+ county[1] != 'Provincewide'):
+ # some counties are actually cities but whatever fml
+ clist.append([province[0], province[2],
+ county[0], county[1]])
except WebFault as err:
raise errors.RadioError(err)
+ return clist, provinces
+
+ def do_fetch(self):
+ """Fetches frequencies for all subcategories in a county
+ (or zip if USA)."""
+ self._freqs = []
+ # if this method was accessed for the USA, use the zip; otherwise
+ # use the county ID
+ if self._country == 'US':
+ try:
+ service = self._client.service
+ zipcode = service.getZipcodeInfo(self._zipcounty, self._auth)
+ county = service.getCountyInfo(zipcode.ctid, self._auth)
+ except WebFault as err:
+ raise errors.RadioError(err)
+ if self._country == 'CA':
+ try:
+ service = self._client.service
+ county = service.getCountyInfo(self._zipcounty, self._auth)
+ except WebFault as err:
+ raise errors.RadioError(err)
status = chirp_common.Status()
status.max = 0
@@ -177,13 +207,15 @@ def main():
"""
Usage:
cd ~/src/chirp.hg
- python ./chirp/radioreference.py [ZIPCODE] [USERNAME] [PASSWORD]
+ python ./chirp/radioreference.py [USERNAME] [PASSWORD] \
+ [COUNTRY - 2 LETTER] [US ZIP(USA) OR COUNTY ID(CANADA)]
"""
import sys
rrr = RadioReferenceRadio(None)
- rrr.set_params(zipcode=sys.argv[1],
- username=sys.argv[2],
- password=sys.argv[3])
+ rrr.set_params(username=sys.argv[1],
+ password=sys.argv[2],
+ country=sys.argv[3],
+ zipcounty=sys.argv[4])
rrr.do_fetch()
print(rrr.get_raw_memory(0))
print(rrr.get_memory(0))
diff --git a/chirp/settings.py b/chirp/settings.py
index 7438425..d49df4e 100644
--- a/chirp/settings.py
+++ b/chirp/settings.py
@@ -169,16 +169,20 @@ class RadioSettingValueList(RadioSettingValue):
"""A list-of-strings setting"""
- def __init__(self, options, current):
+ def __init__(self, options, current=None, current_index=0):
RadioSettingValue.__init__(self)
- self._options = options
- self.set_value(current)
+ self._options = list(options)
+ self.set_value(current or self._options[int(current_index)])
def set_value(self, value):
if value not in self._options:
raise InvalidValueError("%s is not valid for this setting" % value)
RadioSettingValue.set_value(self, value)
+ def set_index(self, index):
+ # Will raise IndexError as expected
+ self.set_value(self._options[int(index)])
+
def get_options(self):
"""Returns the list of valid option values"""
return self._options
@@ -288,8 +292,8 @@ def zero_indexed_seq_map(user_options):
returns a list of tuples of form (str, int).
"""
- mem_vals = range(0, len(user_options))
- return zip(user_options, mem_vals)
+ mem_vals = list(range(0, len(user_options)))
+ return list(zip(user_options, mem_vals))
class RadioSettings(list):
@@ -435,7 +439,7 @@ class RadioSetting(RadioSettingGroup):
return "%s:%s" % (self._name, self.value)
def __repr__(self):
- return "[RadioSetting %s:%s]" % (self._name, self._value)
+ return "[RadioSetting %s:%s]" % (self._name, self.value)
# Magic foo.value attribute
def __getattr__(self, name):
diff --git a/chirp/ui/bandplans.py b/chirp/ui/bandplans.py
index 483261c..f5d204c 100644
--- a/chirp/ui/bandplans.py
+++ b/chirp/ui/bandplans.py
@@ -22,91 +22,30 @@ from chirp.ui import inputdialog
LOG = logging.getLogger(__name__)
-class BandPlans(object):
- def __init__(self, config):
- self._config = config
- self.plans = {}
-
- # Migrate old "automatic repeater offset" setting to
- # "North American Amateur Band Plan"
- ro = self._config.get("autorpt", "memedit")
- if ro is not None:
- self._config.set_bool("north_america", ro, "bandplan")
- self._config.remove_option("autorpt", "memedit")
- # And default new users to North America.
- if not self._config.is_defined("north_america", "bandplan"):
- self._config.set_bool("north_america", True, "bandplan")
-
- for plan in (bandplan_na, bandplan_au, bandplan_iaru_r1,
- bandplan_iaru_r2, bandplan_iaru_r3):
- name = plan.DESC.get("name", plan.SHORTNAME)
- self.plans[plan.SHORTNAME] = (name, plan)
-
- rpt_inputs = []
- for band in plan.BANDS:
- # Check for duplicates.
- duplicates = [x for x in plan.BANDS if x == band]
- if len(duplicates) > 1:
- LOG.warn("Bandplan %s has duplicates %s" %
- (name, duplicates))
- # Add repeater inputs.
- rpt_input = band.inverse()
- if rpt_input not in plan.BANDS:
- rpt_inputs.append(band.inverse())
- plan.bands = list(plan.BANDS)
- plan.bands.extend(rpt_inputs)
-
- def get_defaults_for_frequency(self, freq):
- freq = int(freq)
- result = bandplan.Band((freq, freq), repr(freq))
-
- for shortname, details in self.plans.items():
- if self._config.get_bool(shortname, "bandplan"):
- matches = [x for x in details[1].bands if x.contains(result)]
- # Add matches to defaults, favoring more specific matches.
- matches = sorted(matches, key=lambda x: x.width(),
- reverse=True)
- for match in matches:
- result.mode = match.mode or result.mode
- result.step_khz = match.step_khz or result.step_khz
- result.offset = match.offset or result.offset
- result.duplex = match.duplex or result.duplex
- result.tones = match.tones or result.tones
- if match.name:
- result.name = '/'.join((result.name or '', match.name))
- # Limit ourselves to one band plan match for simplicity.
- # Note that if the user selects multiple band plans by editing
- # the config file it will work as expected (except where plans
- # conflict).
- if matches:
- break
-
- return result
-
- def select_bandplan(self, parent_window):
- plans = ["None"]
- for shortname, details in self.plans.iteritems():
- if self._config.get_bool(shortname, "bandplan"):
- plans.insert(0, details[0])
- else:
- plans.append(details[0])
-
- d = inputdialog.ChoiceDialog(plans, parent=parent_window,
- title="Choose Defaults")
- d.label.set_text(_("Band plans define default channel settings for "
- "frequencies in a region. Choose a band plan "
- "or None for completely manual channel "
- "settings."))
- d.label.set_line_wrap(True)
- r = d.run()
-
- if r == gtk.RESPONSE_OK:
- selection = d.choice.get_active_text()
- for shortname, details in self.plans.iteritems():
- self._config.set_bool(shortname, selection == details[0],
- "bandplan")
- if selection == details[0]:
- LOG.info("Selected band plan %s: %s" %
- (shortname, selection))
-
- d.destroy()
+def select_bandplan(bandplans, parent_window):
+ plans = ["None"]
+ for shortname, details in bandplans.plans.iteritems():
+ if bandplans._config.get_bool(shortname, "bandplan"):
+ plans.insert(0, details[0])
+ else:
+ plans.append(details[0])
+
+ d = inputdialog.ChoiceDialog(plans, parent=parent_window,
+ title="Choose Defaults")
+ d.label.set_text(_("Band plans define default channel settings for "
+ "frequencies in a region. Choose a band plan "
+ "or None for completely manual channel "
+ "settings."))
+ d.label.set_line_wrap(True)
+ r = d.run()
+
+ if r == gtk.RESPONSE_OK:
+ selection = d.choice.get_active_text()
+ for shortname, details in bandplans.plans.iteritems():
+ bandplans._config.set_bool(shortname, selection == details[0],
+ "bandplan")
+ if selection == details[0]:
+ LOG.info("Selected band plan %s: %s" %
+ (shortname, selection))
+
+ d.destroy()
diff --git a/chirp/ui/clone.py b/chirp/ui/clone.py
index e659a8a..aea00c2 100644
--- a/chirp/ui/clone.py
+++ b/chirp/ui/clone.py
@@ -45,7 +45,8 @@ class CloneSettings:
class CloneSettingsDialog(gtk.Dialog):
def __make_field(self, label, widget):
- l = gtk.Label(label)
+ l = gtk.Label(label + ":")
+ l.set_alignment(1.0, 0.5)
self.__table.attach(l, 0, 1, self.__row, self.__row+1)
self.__table.attach(widget, 1, 2, self.__row, self.__row+1)
self.__row += 1
@@ -103,7 +104,7 @@ class CloneSettingsDialog(gtk.Dialog):
model_store = modelbox.get_model()
model_store.clear()
- for rclass in sorted(models, key=lambda c: c.__name__):
+ for rclass in sorted(models, key=lambda c: c.MODEL):
if rclass.MODEL not in added_models:
model_store.append([rclass.MODEL])
added_models.append(rclass.MODEL)
@@ -151,14 +152,12 @@ class CloneSettingsDialog(gtk.Dialog):
gtk.STOCK_OK, gtk.RESPONSE_OK)
gtk.Dialog.__init__(self, title,
parent=parent,
+ buttons=buttons,
flags=gtk.DIALOG_MODAL)
+ self.set_default_response(gtk.RESPONSE_OK)
+ self.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
self.__make_ui(settings)
- self.__cancel_button = self.add_button(gtk.STOCK_CANCEL,
- gtk.RESPONSE_CANCEL)
- self.__okay_button = self.add_button(gtk.STOCK_OK,
- gtk.RESPONSE_OK)
- self.__okay_button.grab_default()
- self.__okay_button.grab_focus()
def run(self):
r = gtk.Dialog.run(self)
@@ -258,7 +257,7 @@ class CloneThread(threading.Thread):
emsg = None
except Exception as e:
common.log_exception()
- LOG.error(_("Clone failed: {error}").format(error=e))
+ LOG.error("Clone failed: {error}".format(error=e))
emsg = e
gobject.idle_add(self.__progw.hide)
diff --git a/chirp/ui/editorset.py b/chirp/ui/editorset.py
index 697f5ef..c030595 100644
--- a/chirp/ui/editorset.py
+++ b/chirp/ui/editorset.py
@@ -168,6 +168,7 @@ class EditorSet(gtk.VBox):
self.modified = (tempname is not None)
if tempname:
self.filename = tempname
+ self.tooltip_filename = None
self.update_tab()
def make_label(self):
@@ -199,6 +200,9 @@ class EditorSet(gtk.VBox):
text = fn
self.text_label.set_text(self.radio.get_name() + ": " + text)
+ if self.filename != self.tooltip_filename:
+ self.text_label.set_tooltip_text(self.filename)
+ self.tooltip_filename = self.filename
def save(self, fname=None):
if not fname:
@@ -380,19 +384,6 @@ class EditorSet(gtk.VBox):
"export: {error}").format(error=e),
self)
- def prime(self):
- # NOTE: this is only called to prime new CSV files, so assume
- # only one memory editor for now
- mem = chirp_common.Memory()
- mem.freq = 146010000
-
- def cb(*args):
- gobject.idle_add(self.editors["memedit0"].prefill)
-
- job = common.RadioJob(cb, "set_memory", mem)
- job.set_desc(_("Priming memory"))
- self.rthread.submit(job)
-
def tab_selected(self, notebook, foo, pagenum):
widget = notebook.get_nth_page(pagenum)
for k, v in list(self.editors.items()):
diff --git a/chirp/ui/importdialog.py b/chirp/ui/importdialog.py
index 7a52852..548b4e2 100644
--- a/chirp/ui/importdialog.py
+++ b/chirp/ui/importdialog.py
@@ -237,7 +237,7 @@ class ImportDialog(gtk.Dialog):
LOG.error("One or more of the radios doesn't support banks")
return
- if not len(dst_banks) != len(src_banks):
+ if len(dst_banks) != len(src_banks):
LOG.warn("Source and destination radios have "
"a different number of banks")
else:
@@ -576,12 +576,15 @@ class ImportDialog(gtk.Dialog):
ACTION = _("Import")
def __init__(self, src_radio, dst_radio, parent=None):
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
gtk.Dialog.__init__(self,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
+ buttons=buttons,
title=self.TITLE,
parent=parent)
-
+ self.set_default_response(gtk.RESPONSE_OK)
+ self.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
self.col_import = 0
self.col_nloc = 1
self.col_oloc = 2
diff --git a/chirp/ui/inputdialog.py b/chirp/ui/inputdialog.py
index 29a2971..74362dc 100644
--- a/chirp/ui/inputdialog.py
+++ b/chirp/ui/inputdialog.py
@@ -33,6 +33,8 @@ class TextInputDialog(gtk.Dialog):
self.label = gtk.Label()
self.label.set_size_request(300, 100)
+ self.label.set_alignment(0.0, 0.5)
+
# pylint: disable-msg=E1101
self.vbox.pack_start(self.label, 1, 1, 0)
@@ -53,8 +55,13 @@ class ChoiceDialog(gtk.Dialog):
gtk.STOCK_OK, gtk.RESPONSE_OK)
gtk.Dialog.__init__(self, buttons=buttons, **args)
+ self.set_default_response(gtk.RESPONSE_OK)
+ self.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
+
self.label = gtk.Label()
self.label.set_size_request(300, 100)
+ self.label.set_alignment(0.0, 0.5)
# pylint: disable-msg=E1101
self.vbox.pack_start(self.label, 1, 1, 0)
self.label.show()
@@ -69,8 +76,6 @@ class ChoiceDialog(gtk.Dialog):
self.vbox.pack_start(self.choice, 1, 1, 0)
self.choice.show()
- self.set_default_response(gtk.RESPONSE_OK)
-
class EditableChoiceDialog(ChoiceDialog):
editable = True
@@ -85,6 +90,7 @@ class ExceptionDialog(gtk.MessageDialog):
def __init__(self, exception, **args):
gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK,
type=gtk.MESSAGE_ERROR, **args)
+ self.set_default_response(gtk.RESPONSE_OK)
self.set_property("text", _("An error has occurred"))
self.format_secondary_text(str(exception))
@@ -97,15 +103,17 @@ class ExceptionDialog(gtk.MessageDialog):
class FieldDialog(gtk.Dialog):
- def __init__(self, **kwargs):
- if "buttons" not in kwargs.keys():
- kwargs["buttons"] = (gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+ def __init__(self, **args):
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
+
+ gtk.Dialog.__init__(self, buttons=buttons, **args)
- self.__fields = {}
self.set_default_response(gtk.RESPONSE_OK)
+ self.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
- gtk.Dialog.__init__(self, **kwargs)
+ self.__fields = {}
def response(self, _):
LOG.debug("Blocking response")
@@ -114,7 +122,8 @@ class FieldDialog(gtk.Dialog):
def add_field(self, label, widget, validator=None):
box = gtk.HBox(True, 2)
- lab = gtk.Label(label)
+ lab = gtk.Label(label + ":")
+ lab.set_alignment(1.0, 0.5)
lab.show()
widget.set_size_request(150, -1)
@@ -135,9 +144,12 @@ class FieldDialog(gtk.Dialog):
class OverwriteDialog(gtk.MessageDialog):
def __init__(self, filename):
- gtk.Dialog.__init__(self,
- buttons=(_("Overwrite"), gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
+ gtk.Dialog.__init__(self, buttons=buttons)
+ self.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
self.set_property("text", _("File Exists"))
@@ -146,12 +158,3 @@ class OverwriteDialog(gtk.MessageDialog):
"Do you want to overwrite it?").format(name=filename)
self.format_secondary_text(text)
-
-if __name__ == "__main__":
- # pylint: disable-msg=C0103
- d = FieldDialog(buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))
- d.add_field("Foo", gtk.Entry())
- d.add_field("Bar", make_choice(["A", "B"]))
- d.run()
- gtk.main()
- d.destroy()
diff --git a/chirp/ui/mainapp.py b/chirp/ui/mainapp.py
index 5ac2156..adbd9a9 100644
--- a/chirp/ui/mainapp.py
+++ b/chirp/ui/mainapp.py
@@ -33,6 +33,7 @@ from chirp.drivers import generic_csv, repeaterbook
from chirp.drivers import ic9x, kenwood_live, idrp, vx7, vx5, vx6
from chirp.drivers import icf, ic9x_icf
from chirp import CHIRP_VERSION, chirp_common, detect, errors
+from chirp import bandplan
from chirp.ui import editorset, clone, miscwidgets, config, reporting, fips
from chirp.ui import bandplans
@@ -160,10 +161,14 @@ class ChirpMain(gtk.Window):
for i in range(0, self.tabs.get_n_pages()):
esets.append(self.tabs.get_nth_page(i))
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
d = gtk.Dialog(title="Diff Radios",
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL),
+ buttons=buttons,
parent=self)
+ d.set_default_response(gtk.RESPONSE_OK)
+ d.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
label = gtk.Label("")
label.set_markup("<b>-1</b> for either Mem # does a full-file hex " +
@@ -267,7 +272,6 @@ class ChirpMain(gtk.Window):
def do_new(self):
eset = editorset.EditorSet(_("Untitled") + ".csv", self)
self._connect_editorset(eset)
- eset.prime()
eset.show()
tab = self.tabs.append_page(eset, eset.get_tab_label())
@@ -295,9 +299,13 @@ of file.
lab.show()
choice = miscwidgets.make_choice(sorted(radiolist.keys()), False,
sorted(radiolist.keys())[0])
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
d = gtk.Dialog(title="Detection Failed",
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=buttons)
+ d.set_default_response(gtk.RESPONSE_OK)
+ d.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
d.vbox.pack_start(lab, 0, 0, 0)
d.vbox.pack_start(choice, 0, 0, 0)
d.vbox.set_spacing(5)
@@ -318,7 +326,6 @@ of file.
if not fname:
types = [(_("All files") + " (*.*)", "*"),
(_("CHIRP Radio Images") + " (*.img)", "*.img"),
- (_("CHIRP Files") + " (*.chirp)", "*.chirp"),
(_("CSV Files") + " (*.csv)", "*.csv"),
(_("DAT Files") + " (*.dat)", "*.dat"),
(_("EVE Files (VX5)") + " (*.eve)", "*.eve"),
@@ -331,6 +338,10 @@ of file.
if not fname:
return
+ if not os.path.exists(fname):
+ LOG.error("Unable to find file %s" % fname)
+ return
+
self.record_recent_file(fname)
if icf.is_icf_file(fname):
@@ -523,41 +534,63 @@ of file.
return recent
def _set_recent_list(self, recent):
- for fn in recent:
- CONF.set("recent%i" % recent.index(fn), fn, "state")
+ for index in range(0, KEEP_RECENT):
+ key = "recent%i" % index
+ if (index < len(recent)):
+ fn = recent[index]
+ CONF.set(key, fn, "state")
+ else:
+ CONF.remove_option(key, "state")
+ self.recent_files = None
def update_recent_files(self):
- i = 0
- for fname in self._get_recent_list():
- action_name = "recent%i" % i
+ if self.recent_files is not None:
+ return
+
+ self.recent_files = self._get_recent_list()
+ for index in range(0, KEEP_RECENT):
+ action_name = "recent%i" % index
path = "/MenuBar/file/recent"
old_action = self.menu_ag.get_action(action_name)
if old_action:
+ old_action.set_visible(False)
self.menu_ag.remove_action(old_action)
- file_basename = os.path.basename(fname).replace("_", "__")
- action = gtk.Action(
- action_name, "_%i. %s" % (i + 1, file_basename),
- _("Open recent file {name}").format(name=fname), "")
- action.connect("activate", lambda a, f: self.do_open(f), fname)
- mid = self.menu_uim.new_merge_id()
- self.menu_uim.add_ui(mid, path,
- action_name, action_name,
- gtk.UI_MANAGER_MENUITEM, False)
- self.menu_ag.add_action(action)
- i += 1
+ if (index < len(self.recent_files)):
+ fname = self.recent_files[index]
+ widget_label = os.path.basename(fname).replace("_", "__")
+ widget_tip = _("Open recent file") + (" {name}").format(
+ name=fname)
+ widget_path = path + "/" + action_name
+
+ action = gtk.Action(action_name, widget_label, widget_tip, "")
+ action.connect("activate", lambda a, f: self.do_open(f), fname)
- def record_recent_file(self, filename):
+ mid = self.menu_uim.new_merge_id()
+ self.menu_uim.add_ui(mid, path,
+ action_name, action_name,
+ gtk.UI_MANAGER_MENUITEM, True)
+ self.menu_ag.add_action(action)
+ try:
+ widget = self.menu_uim.get_widget(widget_path)
+ widget.set_tooltip_text(tip)
+ except:
+ pass
+
+ def record_recent_file(self, fname):
recent_files = self._get_recent_list()
- if filename not in recent_files:
- if len(recent_files) == KEEP_RECENT:
- del recent_files[-1]
- recent_files.insert(0, filename)
- self._set_recent_list(recent_files)
+ if fname in recent_files:
+ recent_files.remove(fname)
+ if len(recent_files) == KEEP_RECENT:
+ recent_files.pop(0)
+ recent_files.append(fname)
- self.update_recent_files()
+ self._set_recent_list(recent_files)
+
+ def clear_recent_files(self):
+ self._set_recent_list([])
def import_stock_config(self, action, config):
eset = self.get_current_editorset()
@@ -601,9 +634,9 @@ of file.
"")
action.connect("activate", self.import_stock_config, config)
mid = self.menu_uim.new_merge_id()
- mid = self.menu_uim.add_ui(mid, path,
- action_name, action_name,
- gtk.UI_MANAGER_MENUITEM, False)
+ self.menu_uim.add_ui(mid, path,
+ action_name, action_name,
+ gtk.UI_MANAGER_MENUITEM, False)
self.menu_ag.add_action(action)
def _do_open_action(config):
@@ -617,9 +650,9 @@ of file.
"")
action.connect("activate", lambda a, c: self.do_open(c), config)
mid = self.menu_uim.new_merge_id()
- mid = self.menu_uim.add_ui(mid, path,
- action_name, action_name,
- gtk.UI_MANAGER_MENUITEM, False)
+ self.menu_uim.add_ui(mid, path,
+ action_name, action_name,
+ gtk.UI_MANAGER_MENUITEM, False)
self.menu_ag.add_action(action)
configs = glob(os.path.join(stock_dir, "*.csv"))
@@ -803,11 +836,16 @@ of file.
return False
if eset.is_modified():
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_NO, gtk.RESPONSE_NO,
+ gtk.STOCK_YES, gtk.RESPONSE_YES)
dlg = miscwidgets.YesNoDialog(
title=_("Save Changes?"), parent=self,
- buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
- gtk.STOCK_NO, gtk.RESPONSE_NO,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=buttons)
+ dlg.set_default_response(gtk.RESPONSE_YES)
+ dlg.set_alternative_button_order([gtk.RESPONSE_YES,
+ gtk.RESPONSE_NO,
+ gtk.RESPONSE_CANCEL])
dlg.set_text(_("File is modified, save changes before closing?"))
res = dlg.run()
dlg.destroy()
@@ -838,7 +876,6 @@ of file.
def do_import(self):
types = [(_("All files") + " (*.*)", "*"),
- (_("CHIRP Files") + " (*.chirp)", "*.chirp"),
(_("CHIRP Radio Images") + " (*.img)", "*.img"),
(_("CSV Files") + " (*.csv)", "*.csv"),
(_("DAT Files") + " (*.dat)", "*.dat"),
@@ -858,6 +895,9 @@ of file.
count = eset.do_import(filen)
reporting.report_model_usage(eset.rthread.radio, "import", count > 0)
+ def do_clear_recently_opened(self):
+ self.clear_recent_files()
+
def do_dmrmarc_prompt(self):
fields = {"1City": (gtk.Entry(), lambda x: x),
"2State": (gtk.Entry(), lambda x: x),
@@ -1137,7 +1177,7 @@ of file.
query = "http://chirp.danplanet.com/query/rb/1.0/app_direct" \
"?loc=%s&band=%s&dist=%s" % (loc, band, dist)
- print query
+ print(query)
# Do this in case the import process is going to take a while
# to make sure we process events leading up to this
@@ -1385,13 +1425,144 @@ of file.
if do_import:
eset = self.get_current_editorset()
- rrstr = "radioreference://%s/%s/%s" % (zipcode, username, passwd)
+ rrstr = "radioreference://%s/%s/%s/%s" % (zipcode, username,
+ passwd, 'US')
+ count = eset.do_import(rrstr)
+ else:
+ try:
+ from chirp import radioreference
+ radio = radioreference.RadioReferenceRadio(None)
+ radio.set_params(zipcode, username, passwd, 'US')
+ self.do_open_live(radio, read_only=True)
+ except errors.RadioError, e:
+ common.show_error(e)
+
+ self.window.set_cursor(None)
+
+ def do_radioreference_promptcanada(self):
+ fields = {"1Username": (gtk.Entry(), lambda x: x),
+ "2Password": (gtk.Entry(), lambda x: x)
+ }
+
+ d = inputdialog.FieldDialog(title=_("RadioReference.com Query"),
+ parent=self)
+ for k in sorted(fields.keys()):
+ d.add_field(k[1:], fields[k][0])
+ fields[k][0].set_text(CONF.get(k[1:], "radioreference") or "")
+ fields[k][0].set_visibility(k != "2Password")
+
+ while d.run() == gtk.RESPONSE_OK:
+ valid = True
+ for k in sorted(fields.keys()):
+ widget, validator = fields[k]
+ try:
+ if validator(widget.get_text()):
+ CONF.set(k[1:], widget.get_text(), "radioreference")
+ continue
+ except Exception:
+ pass
+ common.show_error("Invalid value for %s" % k[1:])
+ valid = False
+ break
+
+ if valid:
+ d.destroy()
+ return True
+
+ d.destroy()
+ return False
+
+ def do_radioreference_promptcounty(self, username, passwd):
+ """gotta get the fkn province list (they do change sometimes)
+ and the absurd arbitrary county list
+ """
+ from chirp import radioreference
+ provincecounty = radioreference.RadioReferenceRadio(None)
+ provincecounty.set_params(None, username, passwd, None)
+ cancounties = provincecounty.do_getcanadacounties()
+ clist = cancounties[0]
+ provinces = cancounties[1]
+ default_prov = ""
+ default_county = ""
+ try:
+ code = int(CONF.get("province", "radioreference"))
+ for k, v in provinces.items():
+ if code == v:
+ default_prov = k
+ break
+ code = int(CONF.get("county", "radioreference"))
+ for row in clist:
+ if code == row[2]:
+ default_county = row[3]
+ break
+ except:
+ pass
+ province = miscwidgets.make_choice(sorted(provinces.keys()),
+ False, default_prov)
+ counties = []
+ for x in clist:
+ if x[1] == default_prov:
+ counties.append(x[3])
+ county = miscwidgets.make_choice(counties, False, default_county)
+
+ def _changed(box, county):
+ selectedprov = provinces[box.get_active_text()]
+ county.get_model().clear()
+ for list_county in clist:
+ if list_county[0] == selectedprov:
+ county.append_text(list_county[3])
+ county.set_active(0)
+ province.connect("changed", _changed, county)
+
+ d = inputdialog.FieldDialog(
+ title=_("RadioReference.com Province Query"), parent=self)
+ d.add_field("Province", province)
+ d.add_field("Region/City", county)
+ r = d.run()
+ d.destroy()
+ if r != gtk.RESPONSE_OK:
+ return False
+
+ code = provinces[province.get_active_text()]
+ for row in clist: # this is absolutely not the right way to do this!
+ if row[3] == county.get_active_text() and \
+ row[1] == province.get_active_text():
+ county_id = row[2]
+ CONF.set("province", str(code), "radioreference")
+ CONF.set("county", str(county_id), "radioreference")
+
+ return True
+
+ def do_radioreferencecanada(self, do_import):
+ self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ if not self.do_radioreference_promptcanada():
+ self.window.set_cursor(None)
+ return
+ username = CONF.get("Username", "radioreference")
+ passwd = CONF.get("Password", "radioreference")
+
+ self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ if not self.do_radioreference_promptcounty(username, passwd):
+ self.window.set_cursor(None)
+ return
+ county = CONF.get("County", "radioreference")
+
+ # Do this in case the import process is going to take a while
+ # to make sure we process events leading up to this
+ gtk.gdk.window_process_all_updates()
+ while gtk.events_pending():
+ gtk.main_iteration(False)
+
+ if do_import:
+ eset = self.get_current_editorset()
+ rrstr = "radioreference://%s/%s/%s/%s" % (county, username,
+ passwd, 'CA')
count = eset.do_import(rrstr)
else:
try:
from chirp import radioreference
radio = radioreference.RadioReferenceRadio(None)
- radio.set_params(zipcode, username, passwd)
+ radio.set_params(county, username, passwd, 'CA')
self.do_open_live(radio, read_only=True)
except errors.RadioError as e:
common.show_error(e)
@@ -1458,7 +1629,9 @@ of file.
os.linesep +
"Russian: Dmitry Slukin" +
os.linesep +
- "Portuguese (BR): Crezivando PP7CJ")
+ "Portuguese (BR): Crezivando PP7CJ" +
+ os.linesep +
+ "Chinese (Simplified): DuckSoft BH2UEP")
d.set_comments(verinfo)
d.run()
@@ -1473,10 +1646,14 @@ of file.
radio_name = "%s %s %s" % (eset.rthread.radio.VENDOR,
eset.rthread.radio.MODEL,
eset.rthread.radio.VARIANT)
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
d = gtk.Dialog(title=_("Select Columns"),
parent=self,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=buttons)
+ d.set_default_response(gtk.RESPONSE_OK)
+ d.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
vbox = gtk.VBox()
vbox.show()
@@ -1593,7 +1770,7 @@ of file.
def do_change_language(self):
langs = ["Auto", "English", "Polish", "Italian", "Dutch", "German",
"Hungarian", "Russian", "Portuguese (BR)", "French",
- "Spanish"]
+ "Spanish", 'Chinese (Simplified)', 'Ukrainian', 'Turkish']
d = inputdialog.ChoiceDialog(langs, parent=self,
title="Choose Language")
d.label.set_text(_("Choose a language or Auto to use the "
@@ -1656,12 +1833,16 @@ of file.
self.do_close()
elif action == "import":
self.do_import()
+ elif action == "clearrecent":
+ self.do_clear_recently_opened()
elif action in ["qdmrmarc", "idmrmarc"]:
self.do_dmrmarc(action[0] == "i")
elif action in ["qrfinder", "irfinder"]:
self.do_rfinder(action[0] == "i")
elif action in ["qradioreference", "iradioreference"]:
self.do_radioreference(action[0] == "i")
+ elif action in ["qradioreferencecanada", "iradioreferencecanada"]:
+ self.do_radioreferencecanada(action[0] == "i")
elif action == "export":
self.do_export()
elif action in ["qrbookpolitical", "irbookpolitical"]:
@@ -1684,8 +1865,8 @@ of file.
self.do_toggle_report(_action)
elif action == "channel_defaults":
# The memedit thread also has an instance of bandplans.
- bp = bandplans.BandPlans(CONF)
- bp.select_bandplan(self)
+ bp = bandplan.BandPlans(CONF)
+ bandplans.select_bandplan(bp)
elif action == "no_smart_tmode":
self.do_toggle_no_smart_tmode(_action)
elif action == "developer":
@@ -1717,7 +1898,10 @@ of file.
<menuitem action="new"/>
<menuitem action="open"/>
<menu action="openstock" name="openstock"/>
- <menu action="recent" name="recent"/>
+ <menu action="recent" name="recent">
+ <separator/>
+ <menuitem action="clearrecent"/>
+ </menu>
<menuitem action="save"/>
<menuitem action="saveas"/>
<menuitem action="loadmod"/>
@@ -1758,7 +1942,10 @@ of file.
<menuitem action="upload"/>
<menu action="importsrc" name="importsrc">
<menuitem action="idmrmarc"/>
- <menuitem action="iradioreference"/>
+ <menu action="iradioref" name="iradioref">
+ <menuitem action="iradioreferencecanada"/>
+ <menuitem action="iradioreference"/>
+ </menu>
<menu action="irbook" name="irbook">
<menuitem action="irbookpolitical"/>
<menuitem action="irbookproximity"/>
@@ -1768,7 +1955,10 @@ of file.
</menu>
<menu action="querysrc" name="querysrc">
<menuitem action="qdmrmarc"/>
- <menuitem action="qradioreference"/>
+ <menu action="qradioref" name="qradioref">
+ <menuitem action="qradioreferencecanada"/>
+ <menuitem action="qradioreference"/>
+ </menu>
<menu action="qrbook" name="qrbook">
<menuitem action="qrbookpolitical"/>
<menuitem action="qrbookproximity"/>
@@ -1804,8 +1994,10 @@ of file.
('file', None, _("_File"), None, None, self.mh),
('new', gtk.STOCK_NEW, None, None, None, self.mh),
('open', gtk.STOCK_OPEN, None, None, None, self.mh),
- ('openstock', None, _("Open stock config"), None, None, self.mh),
- ('recent', None, _("_Recent"), None, None, self.mh),
+ ('openstock', None, _("Open Stock Config"), None, None, self.mh),
+ ('recent', None, _("Open _Recent"), None, None, self.mh),
+ ('clearrecent', None, _("Clear Recently Opened"), None, None,
+ self.mh),
('save', gtk.STOCK_SAVE, None, None, None, self.mh),
('saveas', gtk.STOCK_SAVE_AS, None, None, None, self.mh),
('loadmod', None, _("Load Module"), None, None, self.mh),
@@ -1828,13 +2020,13 @@ of file.
('view', None, _("_View"), None, None, self.mh),
('columns', None, _("Columns"), None, None, self.mh),
('viewdeveloper', None, _("Developer"), None, None, self.mh),
- ('devshowraw', None, _('Show raw memory'),
+ ('devshowraw', None, _('Show Raw Memory'),
"%s<Shift>r" % CTRL_KEY, None, self.mh),
- ('devdiffraw', None, _("Diff raw memories"),
+ ('devdiffraw', None, _("Diff Raw Memories"),
"%s<Shift>d" % CTRL_KEY, None, self.mh),
- ('devdifftab', None, _("Diff tabs"),
+ ('devdifftab', None, _("Diff Tabs"),
"%s<Shift>t" % CTRL_KEY, None, self.mh),
- ('language', None, _("Change language"), None, None, self.mh),
+ ('language', None, _("Change Language"), None, None, self.mh),
('radio', None, _("_Radio"), None, None, self.mh),
('download', None, _("Download From Radio"),
"%sd" % ALT_KEY, None, self.mh),
@@ -1842,35 +2034,41 @@ of file.
"%su" % ALT_KEY, None, self.mh),
('import', None, _("Import"), "%si" % ALT_KEY, None, self.mh),
('export', None, _("Export"), "%se" % ALT_KEY, None, self.mh),
- ('importsrc', None, _("Import from data source"),
+ ('importsrc', None, _("Import From Data Source"),
None, None, self.mh),
('idmrmarc', None, _("DMR-MARC Repeaters"), None, None, self.mh),
- ('iradioreference', None, _("RadioReference.com"),
+ ('iradioref', None, _("RadioReference"), None, None, self.mh),
+ ('iradioreference', None, _("RadioReference.com US"),
+ None, None, self.mh),
+ ('iradioreferencecanada', None, _("RadioReference.com Canada"),
None, None, self.mh),
('irfinder', None, _("RFinder"), None, None, self.mh),
('irbook', None, _("RepeaterBook"), None, None, self.mh),
- ('irbookpolitical', None, _("RepeaterBook political query"), None,
+ ('irbookpolitical', None, _("RepeaterBook Political Query"), None,
None, self.mh),
- ('irbookproximity', None, _("RepeaterBook proximity query"), None,
+ ('irbookproximity', None, _("RepeaterBook Proximity Query"), None,
None, self.mh),
('ipr', None, _("przemienniki.net"), None, None, self.mh),
- ('querysrc', None, _("Query data source"), None, None, self.mh),
+ ('querysrc', None, _("Query Data Source"), None, None, self.mh),
('qdmrmarc', None, _("DMR-MARC Repeaters"), None, None, self.mh),
- ('qradioreference', None, _("RadioReference.com"),
+ ('qradioref', None, _("RadioReference"), None, None, self.mh),
+ ('qradioreference', None, _("RadioReference.com US"),
+ None, None, self.mh),
+ ('qradioreferencecanada', None, _("RadioReference.com Canada"),
None, None, self.mh),
('qrfinder', None, _("RFinder"), None, None, self.mh),
('qpr', None, _("przemienniki.net"), None, None, self.mh),
('qrbook', None, _("RepeaterBook"), None, None, self.mh),
- ('qrbookpolitical', None, _("RepeaterBook political query"), None,
+ ('qrbookpolitical', None, _("RepeaterBook Political Query"), None,
None, self.mh),
- ('qrbookproximity', None, _("RepeaterBook proximity query"), None,
+ ('qrbookproximity', None, _("RepeaterBook Proximity Query"), None,
None, self.mh),
('export_chirp', None, _("CHIRP Native File"),
None, None, self.mh),
('export_csv', None, _("CSV File"), None, None, self.mh),
- ('stock', None, _("Import from stock config"),
+ ('stock', None, _("Import From Stock Config"),
None, None, self.mh),
- ('channel_defaults', None, _("Channel defaults"),
+ ('channel_defaults', None, _("Channel Defaults"),
None, None, self.mh),
('cancelq', gtk.STOCK_STOP, None, "Escape", None, self.mh),
('help', None, _('Help'), None, None, self.mh),
@@ -1910,6 +2108,9 @@ of file.
self.add_accel_group(self.menu_uim.get_accel_group())
+ self.recentmenu = self.menu_uim.get_widget(
+ "/MenuBar/file/recent")
+
self.infomenu = self.menu_uim.get_widget(
"/MenuBar/help/clone_information")
@@ -1918,6 +2119,8 @@ of file.
# Initialize
self.do_toggle_developer(self.menu_ag.get_action("developer"))
+ self.recentmenu.connect("activate",
+ lambda a: self.update_recent_files())
return self.menu_uim.get_widget("/MenuBar")
@@ -2034,14 +2237,14 @@ of file.
try:
import gtk_osxapplication
macapp = gtk_osxapplication.OSXApplication()
- except ImportError:
+ except ImportError as e:
pass
# for gtk-mac-integration >= 2.0.7
try:
import gtkosx_application
macapp = gtkosx_application.Application()
- except ImportError:
+ except ImportError as e:
pass
# for gtk-mac-integration 2.1.3 in brew
@@ -2107,8 +2310,6 @@ of file.
vbox = gtk.VBox(False, 2)
- self._recent = []
-
self.menu_ag = None
mbar = self.make_menubar()
@@ -2161,6 +2362,7 @@ of file.
d.destroy()
CONF.set_bool("warned_about_reporting", True)
+ self.recent_files = None
self.update_recent_files()
try:
self.update_stock_configs()
diff --git a/chirp/ui/memdetail.py b/chirp/ui/memdetail.py
index 6f34b7b..abbe8c4 100644
--- a/chirp/ui/memdetail.py
+++ b/chirp/ui/memdetail.py
@@ -71,7 +71,7 @@ class ValueEditor:
extra_name = self._name.split("_", 1)[1]
LOG.debug('Setting extra %s=%r' % (extra_name, newval))
self._memory.extra[extra_name].value = newval
- except settings.InternalError, e:
+ except settings.InternalError as e:
self._errfn(self._name, str(e))
return str(e)
else:
@@ -201,7 +201,7 @@ class MemoryDetailEditor(gtk.Dialog):
def _add(self, tab, row, name, editor, text, colindex=0):
label = gtk.Label(text + ":")
- label.set_alignment(0.0, 0.5)
+ label.set_alignment(1.0, 0.5)
label.show()
tab.attach(label, colindex, colindex + 1, row, row + 1,
xoptions=gtk.FILL, yoptions=0, xpadding=6, ypadding=3)
@@ -319,12 +319,16 @@ class MemoryDetailEditor(gtk.Dialog):
def __init__(self, features, memory, parent=None):
self._memory = memory
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
gtk.Dialog.__init__(self,
title="Memory Properties",
flags=gtk.DIALOG_MODAL,
parent=parent,
- buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
- gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+ buttons=buttons)
+ self.set_default_response(gtk.RESPONSE_OK)
+ self.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
self.set_size_request(-1, 500)
self._tips = compat.CompatTooltips()
diff --git a/chirp/ui/memedit.py b/chirp/ui/memedit.py
index a1581f5..3cc2059 100644
--- a/chirp/ui/memedit.py
+++ b/chirp/ui/memedit.py
@@ -49,18 +49,10 @@ def handle_toggle(_, path, store, col):
store[path][col] = not store[path][col]
-def handle_ed(_, iter, new, store, col):
- old, = store.get(iter, col)
- if old != new:
- store.set(iter, col, new)
- return True
- else:
- return False
-
-
class ValueErrorDialog(gtk.MessageDialog):
def __init__(self, exception, **args):
gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK, **args)
+ self.set_default_response(gtk.RESPONSE_OK)
self.set_property("text", _("Invalid value for this field"))
self.format_secondary_text(str(exception))
@@ -340,9 +332,13 @@ class MemoryEditor(common.Editor):
return
iter = self.store.get_iter(path)
- if not self.store.get(iter, self.col("_filled"))[0] and \
- self.store.get(iter, self.col(_("Frequency")))[0] == 0:
- LOG.error(_("Editing new item, taking defaults"))
+ vals = self.store.get(iter, *range(0, len(self.cols)))
+ prev, = self.store.get(iter, self.col(cap))
+ filled, = self.store.get(iter, self.col("_filled"))
+ freq, = self.store.get(iter, self.col(_("Frequency")))
+
+ # Take default values, if not yet edited
+ if not filled and freq == 0:
self.insert_new(iter)
colnum = self.col(cap)
@@ -360,13 +356,16 @@ class MemoryEditor(common.Editor):
_("Cross Mode"): self.ed_tone_field,
}
+ # Call the specific editor for the given column
if cap in funcs:
new = funcs[cap](rend, path, new, colnum)
+ # Sanity check
if new is None:
- LOG.error(_("Bad value for {col}: {val}").format(col=cap, val=new))
+ LOG.error("Bad value for {col}: {val}".format(col=cap, val=new))
return
+ # Convert type based on column
if self.store.get_column_type(colnum) == TYPE_INT:
new = int(new)
elif self.store.get_column_type(colnum) == TYPE_FLOAT:
@@ -377,24 +376,30 @@ class MemoryEditor(common.Editor):
if new == "(None)":
new = ""
- if not handle_ed(rend, iter, new, self.store, self.col(cap)) and \
- cap != _("Frequency"):
- # No change was made
- # For frequency, we make an exception, since the handler might
- # have altered the duplex. That needs to be fixed.
+ # Verify a change was made
+ if new == prev:
+ # Restore all columns to their original values, a given editor
+ # may modify multiple columns so we need to restore each of them
+ # to their previous values in order to restore the original state.
+ self._restore(iter, vals)
return
- mem = self._get_memory(iter)
+ # Finally, set the new value
+ self.store.set(iter, self.col(cap), new)
+ # Have the radio validate the memory
+ mem = self._get_memory(iter)
msgs = self.rthread.radio.validate_memory(mem)
if msgs:
common.show_error(_("Error setting memory") + ": " +
"\r\n\r\n".join(msgs))
- self.prefill()
+ # Restore to original values and exit
+ self._restore(iter, vals)
return
mem.empty = False
+ # Kick off job to write memory
job = common.RadioJob(self._set_memory_cb, "set_memory", mem)
job.set_desc(_("Writing memory {number}").format(number=mem.number))
self.rthread.submit(job)
@@ -1088,36 +1093,37 @@ class MemoryEditor(common.Editor):
_('Internal Error: Renderer for column %s not found') % (
caption))
- def prefill(self):
- self.store.clear()
- self._rows_in_store = 0
-
- lo = int(self.lo_limit_adj.get_value())
- hi = int(self.hi_limit_adj.get_value())
-
+ def _prefill(self, num):
def handler(mem, number):
if not isinstance(mem, Exception):
if not mem.empty or self.show_empty:
gobject.idle_add(self.set_memory, mem)
else:
- mem = chirp_common.Memory()
- mem.number = number
- mem.name = "ERROR"
- mem.empty = True
+ mem = chirp_common.Memory(number, True, "Error")
gobject.idle_add(self.set_memory, mem)
+ job = common.RadioJob(handler, "get_memory", num)
+ job.set_desc(_("Getting memory {number}").format(number=num))
+ job.set_cb_args(num)
+ self.rthread.submit(job, 2)
+
+ def prefill(self):
+ self.store.clear()
+ self._rows_in_store = 0
+
+ lo = int(self.lo_limit_adj.get_value())
+ hi = int(self.hi_limit_adj.get_value())
+
for i in range(lo, hi+1):
- job = common.RadioJob(handler, "get_memory", i)
- job.set_desc(_("Getting memory {number}").format(number=i))
- job.set_cb_args(i)
- self.rthread.submit(job, 2)
+ self._prefill(i)
if self.show_special:
for i in self._features.valid_special_chans:
- job = common.RadioJob(handler, "get_memory", i)
- job.set_desc(_("Getting channel {chan}").format(chan=i))
- job.set_cb_args(i)
- self.rthread.submit(job, 2)
+ self._prefill(i)
+
+ def _restore(self, iter, vals):
+ for col, val in enumerate(vals):
+ self.store.set(iter, col, val)
def _set_memory(self, iter, memory):
self.store.set(iter,
@@ -1432,7 +1438,7 @@ class MemoryEditor(common.Editor):
# Run low priority jobs to get the rest of the memories
hi = int(self.hi_limit_adj.get_value())
- for i in range(hi, max+1):
+ for i in range(hi+1, max+1):
job = common.RadioJob(None, "get_memory", i)
job.set_desc(_("Getting memory {number}").format(number=i))
self.rthread.submit(job, 10)
@@ -1521,20 +1527,27 @@ class MemoryEditor(common.Editor):
loc, filled = store.get(iter,
self.col(_("Loc")), self.col("_filled"))
if filled and not always:
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_NO, gtk.RESPONSE_NO,
+ _("Yes to All"), gtk.RESPONSE_ACCEPT,
+ gtk.STOCK_YES, gtk.RESPONSE_YES)
d = miscwidgets.YesNoDialog(title=_("Overwrite?"),
- buttons=(gtk.STOCK_YES, 1,
- gtk.STOCK_NO, 2,
- gtk.STOCK_CANCEL, 3,
- "All", 4))
+ parent=None,
+ buttons=buttons)
+ d.set_default_response(gtk.RESPONSE_YES)
+ d.set_alternative_button_order([gtk.RESPONSE_YES,
+ gtk.RESPONSE_ACCEPT,
+ gtk.RESPONSE_NO,
+ gtk.RESPONSE_CANCEL])
d.set_text(
_("Overwrite location {number}?").format(number=loc))
r = d.run()
d.destroy()
- if r == 4:
+ if r == gtk.RESPONSE_ACCEPT:
always = True
- elif r == 3:
+ elif r == gtk.RESPONSE_CANCEL:
break
- elif r == 2:
+ elif r == gtk.RESPONSE_NO:
iter = store.iter_next(iter)
continue
@@ -1552,16 +1565,20 @@ class MemoryEditor(common.Editor):
errs = [x for x in msgs
if isinstance(x, chirp_common.ValidationError)]
if errs:
+ buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
d = miscwidgets.YesNoDialog(title=_("Incompatible Memory"),
- buttons=(gtk.STOCK_OK, 1,
- gtk.STOCK_CANCEL, 2))
+ buttons=buttons)
+ d.set_default_response(gtk.RESPONSE_OK)
+ d.set_alternative_button_order([gtk.RESPONSE_OK,
+ gtk.RESPONSE_CANCEL])
d.set_text(
_("Pasted memory {number} is not compatible with "
"this radio because:").format(number=src_number) +
os.linesep + os.linesep.join(msgs))
r = d.run()
d.destroy()
- if r == 2:
+ if r == gtk.RESPONSE_CANCEL:
break
else:
iter = store.iter_next(iter)
@@ -1738,7 +1755,3 @@ class DstarMemoryEditor(MemoryEditor):
self.col("RPT2CALL"), "",
self.col("Digital Code"), 0,
)
-
-
-class ID800MemoryEditor(DstarMemoryEditor):
- pass
diff --git a/chirp/ui/miscwidgets.py b/chirp/ui/miscwidgets.py
index e68ae2a..a7e8b78 100644
--- a/chirp/ui/miscwidgets.py
+++ b/chirp/ui/miscwidgets.py
@@ -611,9 +611,13 @@ class LatLonEntry(gtk.Entry):
class YesNoDialog(gtk.Dialog):
def __init__(self, title="", parent=None, buttons=None):
- gtk.Dialog.__init__(self, title=title, parent=parent, buttons=buttons)
+ gtk.Dialog.__init__(self,
+ title=title,
+ parent=parent,
+ buttons=buttons)
self._label = gtk.Label("")
+ self._label.set_alignment(0.0, 0.5)
self._label.show()
# pylint: disable-msg=E1101
diff --git a/chirp/ui/settingsedit.py b/chirp/ui/settingsedit.py
index 60272b3..98d1066 100644
--- a/chirp/ui/settingsedit.py
+++ b/chirp/ui/settingsedit.py
@@ -48,8 +48,9 @@ class SettingsEditor(common.Editor):
self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
self._view = gtk.TreeView(self._store)
self._view.get_selection().connect("changed", self._view_changed_cb)
- self._view.append_column(
- gtk.TreeViewColumn("", gtk.CellRendererText(), text=0))
+ column = gtk.TreeViewColumn("", gtk.CellRendererText(), text=0)
+ column.set_widget(gtk.Label())
+ self._view.append_column(column)
self._view.show()
scrolled_window = gtk.ScrolledWindow()
scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
@@ -135,7 +136,7 @@ class SettingsEditor(common.Editor):
# Label
label = gtk.Label(element.get_shortname() + ":")
- label.set_alignment(0.0, 0.5)
+ label.set_alignment(1.0, 0.5)
label.show()
table.attach(label, 0, 1, row, row + 1,
diff --git a/chirp/ui/shiftdialog.py b/chirp/ui/shiftdialog.py
index 98fdca1..dee1cb4 100644
--- a/chirp/ui/shiftdialog.py
+++ b/chirp/ui/shiftdialog.py
@@ -26,10 +26,11 @@ LOG = logging.getLogger(__name__)
class ShiftDialog(gtk.Dialog):
def __init__(self, rthread, parent=None):
+ buttons = (gtk.STOCK_CLOSE, gtk.RESPONSE_OK)
gtk.Dialog.__init__(self,
title=_("Shift"),
- buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_OK))
-
+ buttons=buttons)
+ self.set_default_response(gtk.RESPONSE_OK)
self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.rthread = rthread
diff --git a/chirp/wxui/clone.py b/chirp/wxui/clone.py
index e2a2a51..a3bb41d 100644
--- a/chirp/wxui/clone.py
+++ b/chirp/wxui/clone.py
@@ -1,9 +1,11 @@
import collections
import logging
+import textwrap
import threading
import serial
import wx
+import wx.lib.sized_controls
from chirp import chirp_common
from chirp import directory
@@ -30,12 +32,14 @@ class CloneThread(threading.Thread):
try:
self._fn()
except Exception as e:
- LOG.error('Failed to clone: %s' % e)
+ LOG.exception('Failed to clone: %s' % e)
self._dialog.fail(str(e))
else:
self._dialog.complete()
+# NOTE: This is the legacy settings thread that facilitates
+# LiveAdapter to get/fetch settings.
class SettingsThread(threading.Thread):
def __init__(self, radio, progdialog, settings=None):
super(SettingsThread, self).__init__()
@@ -69,12 +73,61 @@ class SettingsThread(threading.Thread):
wx.CallAfter(self._dialog.Update, 100, newmsg=_('Complete'))
+class ChirpRadioPromptDialog(wx.Dialog):
+ def __init__(self, *a, **k):
+ self.radio = k.pop('radio')
+ self.prompt = k.pop('prompt')
+ buttons = k.pop('buttons', wx.OK | wx.CANCEL)
+ super().__init__(*a, **k)
+
+ prompts = self.radio.get_prompts()
+ self.message = getattr(prompts, self.prompt)
+
+ bs = self.CreateButtonSizer(buttons)
+ vbox = wx.BoxSizer(wx.VERTICAL)
+ self.SetSizer(vbox)
+ vbox.Add(wx.StaticText(self,
+ label='\n'.join(textwrap.wrap(self.message))),
+ border=20, flag=wx.ALL)
+ self.cb = wx.CheckBox(self,
+ label="Do not prompt again for %s %s" % (
+ self.radio.VENDOR, self.radio.MODEL))
+ vbox.Add(self.cb, border=20, flag=wx.ALL)
+ vbox.Add(bs)
+ self.Fit()
+ self.Centre()
+
+ def persist_flag(self, radio, flag):
+ key = '%s_%s' % (flag, directory.radio_class_id(radio))
+ CONF.set_bool(key.lower(), not self.cb.IsChecked(), 'clone_prompts')
+
+ def check_flag(self, radio, flag):
+ key = '%s_%s' % (flag, directory.radio_class_id(radio))
+ return CONF.get_bool(key.lower(), 'clone_prompts', True)
+
+ def ShowModal(self):
+ if not self.message:
+ LOG.debug('No %s prompt for radio' % self.prompt)
+ return wx.ID_OK
+ if not self.check_flag(self.radio, self.prompt):
+ LOG.debug('Prompt %s disabled for radio' % self.prompt)
+ return wx.ID_OK
+ LOG.debug('Showing %s prompt' % self.prompt)
+ status = super().ShowModal()
+ if status == wx.ID_OK:
+ LOG.debug('Setting flag for prompt %s' % self.prompt)
+ self.persist_flag(self.radio, self.prompt)
+ else:
+ LOG.debug('No flag change for %s' % self.prompt)
+ return status
+
+
class ChirpCloneDialog(wx.Dialog):
def __init__(self, *a, **k):
super(ChirpCloneDialog, self).__init__(
*a, title='Communicate with radio', **k)
- panel = wx.Panel(self)
+ self.SetSize(-1, 260)
try:
grid = wx.FlexGridSizer(3, 2)
@@ -82,8 +135,8 @@ class ChirpCloneDialog(wx.Dialog):
grid = wx.FlexGridSizer(2, 5, 0)
def _add_grid(label, control):
- grid.Add(wx.StaticText(panel, label=label),
- border=20, flag=wx.ALIGN_CENTER|wx.RIGHT|wx.LEFT)
+ grid.Add(wx.StaticText(self, label=label),
+ border=20, flag=wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT)
grid.Add(control, 1, flag=wx.EXPAND)
ports = platform.get_platform().list_serial_ports()
@@ -92,38 +145,34 @@ class ChirpCloneDialog(wx.Dialog):
ports.insert(0, last_port)
elif not last_port:
last_port = ports[0]
- self._port = wx.ComboBox(panel, choices=ports)
+ self._port = wx.ComboBox(self, choices=ports, style=wx.CB_DROPDOWN)
self._port.SetValue(last_port)
self.Bind(wx.EVT_COMBOBOX, self._selected_port, self._port)
_add_grid('Port', self._port)
- self._vendor = wx.Choice(panel, choices=['Icom', 'Yaesu'])
+ self._vendor = wx.Choice(self, choices=['Icom', 'Yaesu'])
_add_grid('Vendor', self._vendor)
self.Bind(wx.EVT_CHOICE, self._selected_vendor, self._vendor)
- self._model = wx.Choice(panel, choices=[])
+ self._model = wx.Choice(self, choices=[])
_add_grid('Model', self._model)
self.Bind(wx.EVT_CHOICE, self._selected_model, self._model)
- self.gauge = wx.Gauge(panel)
+ self.gauge = wx.Gauge(self)
- hbox2 = wx.BoxSizer(wx.HORIZONTAL)
-
- action = self._make_action(panel)
-
- hbox2.Add(action)
- self._action_button = action
-
- cancel = wx.Button(panel, wx.ID_CANCEL)
- hbox2.Add(cancel, flag=wx.RIGHT)
+ bs = self.CreateButtonSizer(wx.OK | wx.CANCEL)
+ self.Bind(wx.EVT_BUTTON, self._action)
vbox = wx.BoxSizer(wx.VERTICAL)
- vbox.Add(grid, proportion=0, flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM,
+ vbox.Add(grid, proportion=0, flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP,
border=20)
- vbox.Add(self.gauge, flag=wx.EXPAND, border=10, proportion=1)
- vbox.Add(wx.StaticLine(panel), flag=wx.EXPAND|wx.TOP, border=10)
- vbox.Add(hbox2, proportion=0, flag=wx.ALIGN_RIGHT|wx.ALL, border=10)
- panel.SetSizer(vbox)
+ vbox.Add(self.gauge, flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=10,
+ proportion=0)
+ vbox.Add(wx.StaticLine(self), flag=wx.EXPAND | wx.TOP, border=10)
+ vbox.Add(bs)
+ self.SetSizer(vbox)
+ self.Layout()
+ self.Center()
self._vendors = collections.defaultdict(list)
for rclass in directory.DRV_TO_RADIO.values():
@@ -134,11 +183,14 @@ class ChirpCloneDialog(wx.Dialog):
for alias in rclass.ALIASES:
self._vendors[alias.VENDOR].append(alias)
+ for models in self._vendors.values():
+ models.sort(key=lambda x: '%s %s' % (x.MODEL, x.VARIANT))
+
self._vendor.Set(sorted(self._vendors.keys()))
try:
self.select_vendor_model(CONF.get('last_vendor', 'state'),
CONF.get('last_model', 'state'))
- except ValueError as e:
+ except ValueError:
LOG.warning('Last vendor/model not found')
def disable_model_select(self):
@@ -147,7 +199,7 @@ class ChirpCloneDialog(wx.Dialog):
def disable_running(self):
self._port.Disable()
- self._action_button.Disable()
+ self.FindWindowById(wx.ID_OK).Disable()
def _persist_choices(self):
CONF.set('last_vendor', self._vendor.GetStringSelection(), 'state')
@@ -158,7 +210,8 @@ class ChirpCloneDialog(wx.Dialog):
self._persist_choices()
def _select_vendor(self, vendor):
- models = [x.MODEL for x in self._vendors[vendor]]
+ models = [('%s %s' % (x.MODEL, x.VARIANT)).strip()
+ for x in self._vendors[vendor]]
self._model.Set(models)
self._model.SetSelection(0)
@@ -190,50 +243,82 @@ class ChirpCloneDialog(wx.Dialog):
wx.MessageBox(message,
'Error communicating with radio',
wx.ICON_ERROR)
- self.EndModal(wx.ID_CANCEL)
-
+ self.cancel_action()
wx.CallAfter(safe_fail)
+ def cancel_action(self):
+ if isinstance(self, ChirpDownloadDialog):
+ self._vendor.Enable()
+ self._model.Enable()
+ self._port.Enable()
+ self.FindWindowById(wx.ID_OK).Enable()
+
def get_selected_rclass(self):
vendor = self._vendor.GetStringSelection()
model = self._model.GetSelection()
+ LOG.debug('Selected %r' % self._vendors[vendor][model])
return self._vendors[vendor][model]
class ChirpDownloadDialog(ChirpCloneDialog):
- def _make_action(self, panel):
- start = wx.Button(panel, label='Download')
- start.Bind(wx.EVT_BUTTON, self._download)
- return start
-
def _selected_model(self, event):
super(ChirpDownloadDialog, self)._selected_model(event)
rclass = self.get_selected_rclass()
prompts = rclass.get_prompts()
- if prompts.pre_download:
- prompt = prompts.pre_download
- else:
- prompt = ''
-
- # FIXME: Handle download prompt here
+ if prompts.experimental:
+ d = ChirpRadioPromptDialog(self,
+ title='Experimental driver',
+ buttons=wx.OK,
+ radio=rclass,
+ prompt='experimental')
+ d.ShowModal()
+
+ def _action(self, event):
+ if event.GetEventObject().GetId() != wx.ID_OK:
+ self.EndModal(event.GetEventObject().GetId())
+ return
- def _download(self, event):
self.disable_model_select()
self.disable_running()
port = self._port.GetValue()
rclass = self.get_selected_rclass()
- pipe = serial.Serial(port=port, baudrate=rclass.BAUD_RATE,
- rtscts=rclass.HARDWARE_FLOW, timeout=0.25)
+ prompts = rclass.get_prompts()
+ if prompts.info:
+ d = ChirpRadioPromptDialog(self,
+ title='Radio information',
+ radio=rclass,
+ prompt='info')
+ if d.ShowModal() != wx.ID_OK:
+ self.cancel_action()
+ return
+ if prompts.pre_download:
+ d = ChirpRadioPromptDialog(self,
+ title='Download instructions',
+ radio=rclass,
+ prompt='pre_download')
+ if d.ShowModal() != wx.ID_OK:
+ self.cancel_action()
+ return
+
try:
+ pipe = serial.Serial(port=port, baudrate=rclass.BAUD_RATE,
+ rtscts=rclass.HARDWARE_FLOW, timeout=0.25)
self._radio = rclass(pipe)
except Exception as e:
self.fail(str(e))
return
if isinstance(self._radio, chirp_common.LiveRadio):
- self._radio = common.LiveAdapter(self._radio)
+ if CONF.get_bool('live_adapter', 'state', False):
+ # Use LiveAdapter to make LiveRadio behave like CloneMode
+ self._radio = common.LiveAdapter(self._radio)
+ else:
+ # Live radios are live
+ # FIXME: This needs to make sure we can talk to the radio first
+ self.EndModal(wx.ID_OK)
+ return
self._radio.status_fn = self._status
@@ -246,21 +331,39 @@ class ChirpUploadDialog(ChirpCloneDialog):
super(ChirpUploadDialog, self).__init__(*a, **k)
self._radio = radio
- self.select_vendor_model(self._radio.VENDOR,
- self._radio.MODEL)
+ self.select_vendor_model(
+ self._radio.VENDOR,
+ ('%s %s' % (self._radio.MODEL, self._radio.VARIANT)).strip())
+ self.disable_model_select()
if isinstance(self._radio, chirp_common.LiveRadio):
self._radio = common.LiveAdapter(self._radio)
- def _make_action(self, panel):
- start = wx.Button(panel, label='Upload')
- start.Bind(wx.EVT_BUTTON, self._upload)
- self.disable_model_select()
- return start
+ def _action(self, event):
+ if event.GetEventObject().GetId() != wx.ID_OK:
+ self.EndModal(event.GetEventObject().GetId())
+ return
- def _upload(self, event):
self.disable_running()
+ prompts = self._radio.get_prompts()
+ if prompts.info:
+ d = ChirpRadioPromptDialog(self,
+ title='Radio information',
+ radio=self._radio,
+ prompt='info')
+ if d.ShowModal() != wx.ID_OK:
+ self.cancel_action()
+ return
+ if prompts.pre_upload:
+ d = ChirpRadioPromptDialog(self,
+ title='Upload instructions',
+ radio=self._radio,
+ prompt='pre_upload')
+ if d.ShowModal() != wx.ID_OK:
+ self.cancel_action()
+ return
+
port = self._port.GetValue()
baud = self._radio.BAUD_RATE
diff --git a/chirp/wxui/common.py b/chirp/wxui/common.py
index 34dcf3e..9ae48f8 100644
--- a/chirp/wxui/common.py
+++ b/chirp/wxui/common.py
@@ -1,5 +1,6 @@
import functools
import logging
+import threading
import wx
@@ -7,11 +8,21 @@ from chirp import chirp_common
from chirp.drivers import generic_csv
from chirp import errors
from chirp import settings
+from chirp.wxui import radiothread
LOG = logging.getLogger(__name__)
CHIRP_DATA_MEMORY = wx.DataFormat('x-chirp/memory-channel')
EditorChanged, EVT_EDITOR_CHANGED = wx.lib.newevent.NewCommandEvent()
+StatusMessage, EVT_STATUS_MESSAGE = wx.lib.newevent.NewCommandEvent()
+
+# This is a lock that can be used to exclude edit-specific operations
+# from happening at the same time, like radiothread async
+# operations. This needs to be local to the thing with the wx.Grid as
+# its child, which is the chirp main window in our case. Making this
+# global is technically too broad, but in reality, it's equivalent for
+# us at the moment, and this is easier.
+EDIT_LOCK = threading.Lock()
class LiveAdapter(generic_csv.CSVRadio):
@@ -75,6 +86,37 @@ class LiveAdapter(generic_csv.CSVRadio):
class ChirpEditor(wx.Panel):
+ def __init__(self, *a, **k):
+ super().__init__(*a, **k)
+ self.setup_radio_interface()
+ self.wait_dialog = None
+
+ def start_wait_dialog(self, message):
+ if self.wait_dialog:
+ LOG.error('Wait dialog already in progress!')
+ return
+
+ self.wait_dialog = wx.ProgressDialog('Please wait', message, 100,
+ parent=self)
+ wx.CallAfter(self.wait_dialog.Show)
+
+ def bump_wait_dialog(self, value=None, message=None):
+ if value:
+ wx.CallAfter(self.wait_dialog.Update, value, newmsg=message)
+ else:
+ wx.CallAfter(self.wait_dialog.Pulse, message)
+
+ def stop_wait_dialog(self):
+ def cb():
+ if self.wait_dialog:
+ self.wait_dialog.Destroy()
+ self.wait_dialog = None
+
+ wx.CallAfter(cb)
+
+ def status_message(self, message):
+ wx.PostEvent(self, StatusMessage(self.GetId(), message=message))
+
def cb_copy(self, cut=False):
pass
@@ -91,6 +133,74 @@ class ChirpEditor(wx.Panel):
pass
+class ChirpSyncEditor:
+ """Radio interface that makes synchronous calls.
+
+ This executes RadioJob requests synchronously in the calling
+ thread and directly spawns the callback. To be used only with
+ radio drivers that manipulate in-memory state.
+ """
+ def do_radio(self, cb, fn, *a, **k):
+ """Synchronous passthrough for non-Live radios"""
+ job = radiothread.RadioJob(self, fn, a, k)
+ try:
+ job.result = getattr(self._radio, fn)(*a, **k)
+ except Exception as e:
+ LOG.exception('Failed to run %s(%s, %s)' % (
+ fn, ','.join(str(x) for x in a),
+ ','.join('%s=%r' % (k, v) for k, v in k.items())))
+ job.result = e
+ if cb:
+ cb(job)
+
+ def setup_radio_interface(self):
+ pass
+
+
+class ChirpAsyncEditor(ChirpSyncEditor):
+ """Radio interface that makes async calls in a helper thread.
+
+ This executes RadioJob requests asynchronously in a thread and
+ schedules the callback via a wx event.
+
+ """
+ def do_radio(self, cb, fn, *a, **k):
+ self._jobs[self._radio_thread.submit(self, fn, *a, **k)] = cb
+
+ def radio_thread_event(self, job, block=True):
+ if job.fn == 'get_memory':
+ msg = 'Refreshed memory %s' % job.args[0]
+ elif job.fn == 'set_memory':
+ msg = 'Uploaded memory %s' % job.args[0].number
+ elif job.fn == 'get_settings':
+ msg = 'Retrieved settings'
+ elif job.fn == 'set_settings':
+ msg = 'Saved settings'
+ else:
+ msg = 'Finished radio job %s' % job.fn
+
+ if not EDIT_LOCK.acquire(block):
+ return False
+ try:
+ self.status_message(msg)
+ cb = self._jobs.pop(job.id)
+ if cb:
+ wx.CallAfter(cb, job)
+
+ # Update our status, which may be reset to unmodified
+ wx.PostEvent(self, EditorChanged(self.GetId()))
+ finally:
+ EDIT_LOCK.release()
+
+ return True
+
+ def set_radio_thread(self, radio_thread):
+ self._radio_thread = radio_thread
+
+ def setup_radio_interface(self):
+ self._jobs = {}
+
+
class ChirpSettingGrid(wx.Panel):
def __init__(self, settinggroup, *a, **k):
super(ChirpSettingGrid, self).__init__(*a, **k)
@@ -131,6 +241,10 @@ class ChirpSettingGrid(wx.Panel):
if editor:
self.pg.Append(editor)
+ @property
+ def name(self):
+ return self._group.get_name()
+
def _pg_changed(self, event):
wx.PostEvent(self, EditorChanged(self.GetId()))
@@ -155,8 +269,8 @@ class ChirpSettingGrid(wx.Panel):
_('Value must be between %.4f and %.4f') % (
value.get_min(), value.get_max()))
return ChirpFloatProperty(setting.get_shortname(),
- setting.get_name(),
- value=int(value))
+ setting.get_name(),
+ value=int(value))
def _get_editor_choice(self, setting, value):
choices = value.get_options()
@@ -188,16 +302,22 @@ class ChirpSettingGrid(wx.Panel):
setting.get_name(),
value=str(value))
- def get_values(self):
+ def get_setting_values(self):
+ """Return a dict of {name: (RadioSetting, newvalue)}"""
values = {}
for prop in self.pg._Items():
if isinstance(prop, wx.propgrid.EnumProperty):
value = self._choices[prop.GetName()][prop.GetValue()]
else:
value = prop.GetValue()
- values[prop.GetName()] = value
+ setting = self._group[prop.GetName()]
+ values[prop.GetName()] = setting, value
return values
+ def get_values(self):
+ """Return a dict of {name: newvalue}"""
+ return {k: v[1] for k, v in self.get_setting_values().items()}
+
def saved(self):
for prop in self.pg._Items():
prop.SetModifiedStatus(False)
@@ -252,6 +372,8 @@ class error_proof(object):
self.show_error(e)
def __call__(self, fn):
+ self.fn = fn
+
@functools.wraps(fn)
def wrapper(*args, **kwargs):
return self.run_safe(fn, args, kwargs)
@@ -263,7 +385,7 @@ class error_proof(object):
def __exit__(self, exc_type, exc_val, traceback):
if exc_type:
if exc_type in self._expected:
- LOG.error('%s: %s: %s' % (fn, exc_type, exc_val))
+ LOG.error('%s: %s: %s' % (self.fn, exc_type, exc_val))
self.show_error(exc_val)
return True
else:
diff --git a/chirp/wxui/developer.py b/chirp/wxui/developer.py
index fd6cf62..fbe13d7 100644
--- a/chirp/wxui/developer.py
+++ b/chirp/wxui/developer.py
@@ -42,7 +42,7 @@ class MemoryDialog(wx.Dialog):
self.SetSizer(sizer)
self.text = wx.richtext.RichTextCtrl(
- self, style=wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER)
+ self, style=wx.VSCROLL | wx.HSCROLL | wx.NO_BORDER)
sizer.Add(self.text, 1, wx.EXPAND)
sizer.Add(wx.StaticLine(self), 0)
@@ -282,7 +282,7 @@ class ChirpBrowserPanel(wx.lib.scrolledpanel.ScrolledPanel):
self._sizer.Layout()
-class ChirpRadioBrowser(common.ChirpEditor):
+class ChirpRadioBrowser(common.ChirpEditor, common.ChirpSyncEditor):
def __init__(self, radio, *a, **k):
super(ChirpRadioBrowser, self).__init__(*a, **k)
self._loaded = False
@@ -297,7 +297,7 @@ class ChirpRadioBrowser(common.ChirpEditor):
# https://github.com/wxWidgets/Phoenix/issues/918
view = self._treebook.GetChildren()[0]
- view.SetMinSize((250,0))
+ view.SetMinSize((250, 0))
self._treebook.Bind(wx.EVT_TREEBOOK_PAGE_CHANGED,
self.page_selected)
@@ -310,12 +310,13 @@ class ChirpRadioBrowser(common.ChirpEditor):
if self._loaded:
return
- pd = wx.ProgressDialog('Loading', 'Building Radio Browser')
+ self.start_wait_dialog('Building Radio Browser')
+
self._loaded = True
self._load_from_radio('%s %s' % (self._radio.VENDOR,
self._radio.MODEL),
- self._radio._memobj, pd)
- pd.Destroy()
+ self._radio._memobj)
+ self.stop_wait_dialog()
if self._treebook.GetPageCount():
self._treebook.ExpandNode(0)
@@ -323,38 +324,37 @@ class ChirpRadioBrowser(common.ChirpEditor):
page = self._treebook.GetPage(event.GetSelection())
page.selected()
- def _load_from_radio(self, name, memobj, pd, parent=None):
+ def _load_from_radio(self, name, memobj, parent=None):
editor = None
- def sub_panel(name, memobj, pd, parent):
+ def sub_panel(name, memobj, parent):
page = ChirpBrowserPanel(self)
if parent:
pos = self._treebook.FindPage(parent)
self._treebook.InsertSubPage(pos, page, name)
- # Stop updating the progress dialog once we get past the
- # first generation in the tree because it slows us down
- # a lot.
- pd = None
else:
self._treebook.AddPage(page, name)
for subname, item in memobj.items():
- self._load_from_radio(subname, item, pd, parent=page)
+ self._load_from_radio(subname, item, parent=page)
+ # Stop updating the progress dialog once we get past the
+ # first generation in the tree because it slows us down
+ # a lot.
if isinstance(memobj, bitwise.structDataElement):
- if pd:
- pd.Pulse('Loading %s' % name)
- sub_panel(name, memobj, pd, parent)
+ if not parent:
+ self.bump_wait_dialog(message='Loading %s' % name)
+ sub_panel(name, memobj, parent)
elif isinstance(memobj, bitwise.arrayDataElement):
if isinstance(memobj[0], bitwise.charDataElement):
editor = ChirpStringEditor(parent, memobj)
elif isinstance(memobj[0], bitwise.bcdDataElement):
editor = ChirpBCDEditor(parent, memobj)
else:
- if pd:
- pd.Pulse('Loading %s' % name)
- sub_panel('%s[%i]' % (name, len(memobj)), memobj, pd, parent)
+ if not parent:
+ self.bump_wait_dialog(message='Loading %s' % name)
+ sub_panel('%s[%i]' % (name, len(memobj)), memobj, parent)
elif isinstance(memobj, bitwise.intDataElement):
editor = ChirpIntegerEditor(parent, memobj)
else:
diff --git a/chirp/wxui/main.py b/chirp/wxui/main.py
index b5dff0d..e08a21a 100644
--- a/chirp/wxui/main.py
+++ b/chirp/wxui/main.py
@@ -8,6 +8,8 @@ import wx
import wx.aui
import wx.lib.newevent
+from chirp import bandplan
+from chirp import chirp_common
from chirp import directory
from chirp import platform
from chirp.ui import config
@@ -15,6 +17,8 @@ from chirp.wxui import common
from chirp.wxui import clone
from chirp.wxui import developer
from chirp.wxui import memedit
+from chirp.wxui import query_sources
+from chirp.wxui import radiothread
from chirp.wxui import settingsedit
from chirp import CHIRP_VERSION
@@ -29,17 +33,35 @@ KEEP_RECENT = 8
OPEN_RECENT_MENU = None
OPEN_STOCK_CONFIG_MENU = None
+
class ChirpEditorSet(wx.Panel):
+ MEMEDIT_CLS = memedit.ChirpMemEdit
+ SETTINGS_CLS = settingsedit.ChirpCloneSettingsEdit
+
+ @property
+ def tab_name(self):
+ return '%s.%s' % (self.default_filename,
+ self._radio.FILE_EXTENSION)
+
+ def add_editor(self, editor, title):
+ self._editors.AddPage(editor, title)
+ self.Bind(common.EVT_STATUS_MESSAGE, self._editor_status, editor)
+
+ def _editor_status(self, event):
+ LOG.info('Editor status: %s' % event.message)
+ wx.PostEvent(self, common.StatusMessage(self.GetId(),
+ message=event.message))
+
def __init__(self, radio, filename, *a, **k):
super(ChirpEditorSet, self).__init__(*a, **k)
self._radio = radio
if filename is None:
- filename = '%s.%s' % (self.default_filename,
- radio.FILE_EXTENSION)
+ filename = self.tab_name
+
self._filename = filename
self._modified = not os.path.exists(filename)
- self._editors = wx.Notebook(self, style=wx.NB_LEFT)
+ self._editors = wx.Notebook(self, style=wx.NB_TOP)
self._editors.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING,
self._editor_selected)
@@ -50,6 +72,7 @@ class ChirpEditorSet(wx.Panel):
features = radio.get_features()
+ parent_radio = radio
if features.has_sub_devices:
radios = radio.get_sub_devices()
format = 'Memories (%(variant)s)'
@@ -58,23 +81,19 @@ class ChirpEditorSet(wx.Panel):
format = 'Memories'
for radio in radios:
- edit = memedit.ChirpMemEdit(radio, self._editors)
+ edit = self.MEMEDIT_CLS(radio, self._editors)
+ self.add_editor(edit, format % {'variant': radio.VARIANT})
edit.refresh()
self.Bind(common.EVT_EDITOR_CHANGED, self._editor_changed)
- self._editors.AddPage(edit, format % {'variant': radio.VARIANT})
if features.has_settings:
- if isinstance(radio, common.LiveAdapter):
- settings = settingsedit.ChirpLiveSettingsEdit(radio,
- self._editors)
- else:
- settings = settingsedit.ChirpCloneSettingsEdit(radio,
- self._editors)
- self._editors.AddPage(settings, 'Settings')
+ settings = self.SETTINGS_CLS(parent_radio, self._editors)
+ self.add_editor(settings, 'Settings')
- if CONF.get_bool('developer', 'state'):
- browser = developer.ChirpRadioBrowser(radio, self._editors)
- self._editors.AddPage(browser, 'Browser')
+ if (CONF.get_bool('developer', 'state') and
+ not isinstance(radio, chirp_common.LiveRadio)):
+ browser = developer.ChirpRadioBrowser(parent_radio, self._editors)
+ self.add_editor(browser, 'Browser')
def _editor_changed(self, event):
self._modified = True
@@ -138,6 +157,35 @@ class ChirpEditorSet(wx.Panel):
def select_all(self):
return self.current_editor.select_all()
+ def close(self):
+ pass
+
+
+class ChirpLiveEditorSet(ChirpEditorSet):
+ MEMEDIT_CLS = memedit.ChirpLiveMemEdit
+ SETTINGS_CLS = settingsedit.ChirpLiveSettingsEdit
+
+ @property
+ def tab_name(self):
+ return '%s %s@LIVE' % (self._radio.VENDOR,
+ self._radio.MODEL)
+
+ def __init__(self, radio, *a, **k):
+ self._radio_thread = radiothread.RadioThread(radio)
+ self._radio_thread.start()
+ super().__init__(radio, *a, **k)
+
+ def add_editor(self, editor, title):
+ super(ChirpLiveEditorSet, self).add_editor(editor, title)
+ editor.set_radio_thread(self._radio_thread)
+
+ def close(self):
+ self._radio_thread.end()
+
+ @property
+ def modified(self):
+ return self._radio_thread.pending != 0
+
class ChirpMain(wx.Frame):
def __init__(self, *args, **kwargs):
@@ -157,12 +205,15 @@ class ChirpMain(wx.Frame):
# self.make_toolbar()
self._editors = wx.aui.AuiNotebook(
- self, style=wx.aui.AUI_NB_CLOSE_ON_ALL_TABS|wx.aui.AUI_NB_TAB_MOVE)
+ self,
+ style=wx.aui.AUI_NB_CLOSE_ON_ALL_TABS | wx.aui.AUI_NB_TAB_MOVE)
self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self._editor_close)
self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED,
self._editor_page_changed)
self.Bind(wx.EVT_CLOSE, self._window_close)
+ self.statusbar = self.CreateStatusBar(1)
+
self._update_window_for_editor()
@property
@@ -186,6 +237,7 @@ class ChirpMain(wx.Frame):
os.path.basename(editorset.filename),
select=select)
self.Bind(EVT_EDITORSET_CHANGED, self._editor_changed, editorset)
+ self.Bind(common.EVT_STATUS_MESSAGE, self._editor_status, editorset)
self._update_editorset_title(editorset)
def make_menubar(self):
@@ -276,6 +328,27 @@ class ChirpMain(wx.Frame):
self.Bind(wx.EVT_MENU, self._menu_upload, upload_item)
radio_menu.Append(upload_item)
+ source_menu = wx.Menu()
+ radio_menu.AppendSubMenu(source_menu, 'Query Source')
+
+ query_rb_item = wx.MenuItem(source_menu, wx.NewId(), 'RepeaterBook')
+ self.Bind(wx.EVT_MENU, self._menu_query_rb, query_rb_item)
+ source_menu.Append(query_rb_item)
+
+ radio_menu.Append(wx.MenuItem(radio_menu, wx.ID_SEPARATOR))
+
+ auto_edits = wx.MenuItem(radio_menu, wx.NewId(),
+ 'Enable Automatic Edits',
+ kind=wx.ITEM_CHECK)
+ self.Bind(wx.EVT_MENU, self._menu_auto_edits, auto_edits)
+ radio_menu.Append(auto_edits)
+ auto_edits.Check(CONF.get_bool('auto_edits', 'state', True))
+
+ select_bandplan = wx.MenuItem(radio_menu, wx.NewId(),
+ 'Select Bandplan')
+ self.Bind(wx.EVT_MENU, self._menu_select_bandplan, select_bandplan)
+ radio_menu.Append(select_bandplan)
+
if CONF.get_bool('developer', 'state'):
radio_menu.Append(wx.MenuItem(file_menu, wx.ID_SEPARATOR))
@@ -306,7 +379,7 @@ class ChirpMain(wx.Frame):
self._interact_driver_item = wx.NewId()
interact_drv_item = wx.MenuItem(radio_menu,
self._interact_driver_item,
- 'Interact with driver')
+ 'Interact with driver')
self.Bind(wx.EVT_MENU, self._menu_interact_driver,
interact_drv_item)
radio_menu.Append(interact_drv_item)
@@ -317,6 +390,14 @@ class ChirpMain(wx.Frame):
self.Bind(wx.EVT_MENU, self._menu_about, about_item)
help_menu.Append(about_item)
+ developer_menu = wx.MenuItem(help_menu, wx.NewId(), 'Developer Mode',
+ kind=wx.ITEM_CHECK)
+ self.Bind(wx.EVT_MENU,
+ functools.partial(self._menu_developer, developer_menu),
+ developer_menu)
+ help_menu.Append(developer_menu)
+ developer_menu.Check(CONF.get_bool('developer', 'state'))
+
menu_bar = wx.MenuBar()
menu_bar.Append(file_menu, '&File')
menu_bar.Append(edit_menu, '&Edit')
@@ -334,27 +415,27 @@ class ChirpMain(wx.Frame):
tbopen = tb.AddTool(wx.NewId(), 'Open', bm(wx.ART_FILE_OPEN),
'Open a file')
- tbsave = tb.AddTool(wx.NewId(), 'Save', bm(wx.ART_FILE_SAVE),
- 'Save file')
- tbclose = tb.AddTool(wx.NewId(), 'Close', bm(wx.ART_CLOSE),
- 'Close file')
- tbdl = tb.AddTool(wx.NewId(), 'Download', bm(wx.ART_GO_DOWN),
+ tb.AddTool(wx.NewId(), 'Save', bm(wx.ART_FILE_SAVE),
+ 'Save file')
+ tb.AddTool(wx.NewId(), 'Close', bm(wx.ART_CLOSE),
+ 'Close file')
+ tb.AddTool(wx.NewId(), 'Download', bm(wx.ART_GO_DOWN),
'Download from radio')
- tbl = tb.AddTool(wx.NewId(), 'Upload', bm(wx.ART_GO_UP),
- 'Upload to radio')
+ tb.AddTool(wx.NewId(), 'Upload', bm(wx.ART_GO_UP),
+ 'Upload to radio')
self.Bind(wx.EVT_MENU, self._menu_open, tbopen)
tb.Realize()
def adj_menu_open_recent(self, filename):
- ### Don't add stock config files to the recent files list
+ # Don't add stock config files to the recent files list
stock_dir = platform.get_platform().config_file("stock_configs")
this_dir = os.path.dirname(filename)
if (stock_dir and os.path.exists(stock_dir) and
this_dir and os.path.samefile(stock_dir, this_dir)):
return
- ### Travel the Open Recent menu looking for filename
+ # Travel the Open Recent menu looking for filename
found_mi = None
empty_mi = None
for i in range(0, self.OPEN_RECENT_MENU.GetMenuItemCount()):
@@ -365,7 +446,7 @@ class ChirpMain(wx.Frame):
if fn == EMPTY_MENU_LABEL:
empty_mi = menu_item
- ### Move filename to top of menu or add it to top if it wasn't found
+ # Move filename to top of menu or add it to top if it wasn't found
if found_mi:
self.OPEN_RECENT_MENU.Remove(found_mi)
self.OPEN_RECENT_MENU.Prepend(found_mi)
@@ -373,18 +454,18 @@ class ChirpMain(wx.Frame):
submenu_item = self.OPEN_RECENT_MENU.Prepend(wx.ID_ANY, filename)
self.Bind(wx.EVT_MENU, self._menu_open_recent, submenu_item)
- ### Get rid of the place holder used in an empty menu
+ # Get rid of the place holder used in an empty menu
if empty_mi:
self.OPEN_RECENT_MENU.Delete(empty_mi)
- ### Trim the menu length
+ # Trim the menu length
if self.OPEN_RECENT_MENU.GetMenuItemCount() > KEEP_RECENT:
for i in range(self.OPEN_RECENT_MENU.GetMenuItemCount() - 1,
KEEP_RECENT - 1, -1):
extra_mi = self.OPEN_RECENT_MENU.FindItemByPosition(i)
self.OPEN_RECENT_MENU.Delete(extra_mi)
- ### Travel the Open Recent menu and save file names to config.
+ # Travel the Open Recent menu and save file names to config.
for i in range(0, self.OPEN_RECENT_MENU.GetMenuItemCount()):
if i >= KEEP_RECENT:
break
@@ -401,15 +482,21 @@ class ChirpMain(wx.Frame):
self._update_editorset_title(event.editorset)
self._update_window_for_editor()
+ def _editor_status(self, event):
+ # FIXME: Should probably only do this for the current editorset
+ self.statusbar.SetStatusText(event.message)
+
def _editor_close(self, event):
eset = self._editors.GetPage(event.GetSelection())
if eset.modified:
if wx.MessageBox(
'%s has not been saved. Close anyway?' % eset.filename,
'Close without saving?',
- wx.YES_NO|wx.NO_DEFAULT|wx.ICON_WARNING) != wx.YES:
+ wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING) != wx.YES:
event.Veto()
+ eset.close()
+
wx.CallAfter(self._update_window_for_editor)
def _update_window_for_editor(self):
@@ -420,11 +507,13 @@ class ChirpMain(wx.Frame):
can_upload = False
CSVRadio = directory.get_radio('Generic_CSV')
if eset is not None:
+ is_live = isinstance(eset.radio, chirp_common.LiveRadio)
can_close = True
- can_save = eset.modified
- can_saveas = True
- can_upload = not (isinstance(eset.radio, CSVRadio) and not
- isinstance(eset.radio, common.LiveAdapter))
+ can_save = eset.modified and not is_live
+ can_saveas = not is_live
+ can_upload = (not isinstance(eset.radio, CSVRadio) and
+ not isinstance(eset.radio, common.LiveAdapter) and
+ not is_live)
items = [
(wx.ID_CLOSE, can_close),
@@ -442,7 +531,7 @@ class ChirpMain(wx.Frame):
if wx.MessageBox(
'Some files have not been saved. Exit anyway?',
'Exit without saving?',
- wx.YES_NO|wx.NO_DEFAULT|wx.ICON_WARNING) != wx.YES:
+ wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING) != wx.YES:
if event.CanVeto():
event.Veto()
return
@@ -451,6 +540,13 @@ class ChirpMain(wx.Frame):
CONF.set_int('window_w', size.GetWidth(), 'state')
CONF.set_int('window_h', size.GetHeight(), 'state')
config._CONFIG.save()
+
+ # Make sure we call close on each editor, so it can end
+ # threads and do other cleanup
+ for i in range(self._editors.GetPageCount()):
+ e = self._editors.GetPage(i)
+ e.close()
+
self.Destroy()
def _update_editorset_title(self, editorset):
@@ -553,7 +649,10 @@ class ChirpMain(wx.Frame):
d.Centre()
if d.ShowModal() == wx.ID_OK:
radio = d._radio
- editorset = ChirpEditorSet(radio, None, self._editors)
+ if isinstance(radio, chirp_common.LiveRadio):
+ editorset = ChirpLiveEditorSet(radio, None, self._editors)
+ else:
+ editorset = ChirpEditorSet(radio, None, self._editors)
self.add_editorset(editorset)
def _menu_upload(self, event):
@@ -633,3 +732,40 @@ class ChirpMain(wx.Frame):
wx.MessageBox(aboutinfo, 'About CHIRP',
wx.OK | wx.ICON_INFORMATION)
+ def _menu_developer(self, menuitem, event):
+ CONF.set_bool('developer', menuitem.IsChecked(), 'state')
+ state = menuitem.IsChecked() and 'enabled' or 'disabled'
+ wx.MessageBox(('Developer state is now %s. '
+ 'CHIRP must be restarted to take effect') % state,
+ 'Restart Required', wx.OK)
+
+ def _menu_auto_edits(self, event):
+ CONF.set_bool('auto_edits', event.IsChecked(), 'state')
+ LOG.debug('Set auto_edits=%s' % event.IsChecked())
+
+ def _menu_select_bandplan(self, event):
+ bandplans = bandplan.BandPlans(CONF)
+ plans = sorted([(shortname, details[0])
+ for shortname, details in bandplans.plans.items()],
+ key=lambda x: x[1])
+ d = wx.SingleChoiceDialog(self, 'Select a bandplan',
+ 'Bandplan',
+ [x[1] for x in plans])
+ for index, (shortname, name) in enumerate(plans):
+ if CONF.get_bool(shortname, 'bandplan'):
+ d.SetSelection(index)
+ break
+ r = d.ShowModal()
+ if r == wx.ID_OK:
+ selected = plans[d.GetSelection()][0]
+ LOG.info('Selected bandplan: %s' % selected)
+ for shortname, name in plans:
+ CONF.set_bool(shortname, shortname == selected, 'bandplan')
+
+ def _menu_query_rb(self, event):
+ d = query_sources.RepeaterBookQueryDialog(self,
+ title='Query Repeaterbook')
+ r = d.ShowModal()
+ if r == wx.ID_OK:
+ LOG.debug('Result file: %s' % d.result_file)
+ self.open_file(d.result_file)
diff --git a/chirp/wxui/memedit.py b/chirp/wxui/memedit.py
index 2a41ec6..71db547 100644
--- a/chirp/wxui/memedit.py
+++ b/chirp/wxui/memedit.py
@@ -6,8 +6,10 @@ import wx
import wx.lib.newevent
import wx.grid
import wx.propgrid
+import wx.lib.mixins.gridlabelrenderer as glr
from chirp import chirp_common
+from chirp import bandplan
from chirp.ui import config
from chirp.wxui import common
from chirp.wxui import developer
@@ -16,6 +18,37 @@ LOG = logging.getLogger(__name__)
CONF = config.get()
+class ChirpMemoryGrid(wx.grid.Grid, glr.GridWithLabelRenderersMixin):
+ def __init__(self, *a, **k):
+ wx.grid.Grid.__init__(self, *a, **k)
+ glr.GridWithLabelRenderersMixin.__init__(self)
+
+
+class ChirpRowLabelRenderer(glr.GridDefaultRowLabelRenderer):
+ def __init__(self, *a, **k):
+ super().__init__(*a, **k)
+ self.bgcolor = None
+
+ def set_error(self):
+ self.bgcolor = '#FF0000'
+
+ def set_progress(self):
+ self.bgcolor = '#98FB98'
+
+ def clear_error(self):
+ self.bgcolor = None
+
+ def Draw(self, grid, dc, rect, row):
+ if self.bgcolor:
+ dc.SetBrush(wx.Brush(self.bgcolor))
+ dc.SetPen(wx.TRANSPARENT_PEN)
+ dc.DrawRectangle(rect)
+ hAlign, vAlign = grid.GetRowLabelAlignment()
+ text = grid.GetRowLabelValue(row)
+ self.DrawBorder(grid, dc, rect)
+ self.DrawText(grid, dc, rect, text, hAlign, vAlign)
+
+
class ChirpMemoryColumn(object):
NAME = None
DEFAULT = ''
@@ -84,7 +117,7 @@ class ChirpMemoryColumn(object):
validationInfo.SetFailureMessage(
'Invalid value: %r' % value)
return False
- except Exception as e:
+ except Exception:
LOG.exception('Failed to validate %r for property %s' % (
value, self._name))
validationInfo.SetFailureMessage(
@@ -98,6 +131,7 @@ class ChirpMemoryColumn(object):
class ChirpFrequencyColumn(ChirpMemoryColumn):
DEFAULT = 0
+
@property
def label(self):
if self._name == 'offset':
@@ -119,6 +153,28 @@ class ChirpFrequencyColumn(ChirpMemoryColumn):
return int(chirp_common.to_MHz(float(input_value)))
+class ChirpChoiceEditor(wx.grid.GridCellChoiceEditor):
+ """A locking GridCellChoiceEditor.
+
+ Events to our parent window will cause editing to stop and will
+ close our drop-down box, which is very annoying. This looks the
+ begin/end event to use the EDIT_LOCK to prevent other things from
+ submitting changes while we're in the middle of an edit.
+ """
+ def __init__(self, *a, **k):
+ super().__init__(*a, **k)
+ self._locked = False
+
+ def BeginEdit(self, *a, **k):
+ common.EDIT_LOCK.acquire()
+ self._locked = True
+ return super().BeginEdit(*a, **k)
+
+ def EndEdit(self, row, col, grid, val, **k):
+ common.EDIT_LOCK.release()
+ return self.Control.GetStringSelection()
+
+
class ChirpToneColumn(ChirpMemoryColumn):
def __init__(self, name, radio):
super(ChirpToneColumn, self).__init__(name, radio)
@@ -142,8 +198,7 @@ class ChirpToneColumn(ChirpMemoryColumn):
return float(input_value)
def get_editor(self):
- return wx.grid.GridCellChoiceEditor(['%.1f' % t
- for t in chirp_common.TONES])
+ return ChirpChoiceEditor(['%.1f' % t for t in chirp_common.TONES])
def get_propeditor(self, memory):
current = self.value(memory)
@@ -164,7 +219,7 @@ class ChirpChoiceColumn(ChirpMemoryColumn):
return self._choices[idx]
def get_editor(self):
- return wx.grid.GridCellChoiceEditor(self._str_choices)
+ return ChirpChoiceEditor(self._str_choices)
def get_propeditor(self, memory):
current = self._render_value(memory, self.value(memory))
@@ -228,24 +283,32 @@ class ChirpCrossModeColumn(ChirpChoiceColumn):
return memory.tmode != 'Cross'
-class ChirpMemEdit(common.ChirpEditor):
+class ChirpMemEdit(common.ChirpEditor, common.ChirpSyncEditor):
def __init__(self, radio, *a, **k):
super(ChirpMemEdit, self).__init__(*a, **k)
self._radio = radio
self._features = self._radio.get_features()
+ # This is set based on the radio behavior during refresh()
+ self._negative_specials = False
- #self._radio.subscribe(self._job_done)
- self._jobs = {}
self._memory_cache = {}
+ self._special_rows = {}
self._col_defs = self._setup_columns()
- self._grid = wx.grid.Grid(self)
+ self.bandplan = bandplan.BandPlans(CONF)
+
+ self._grid = ChirpMemoryGrid(self)
self._grid.CreateGrid(self._features.memory_bounds[1] +
len(self._features.valid_special_chans) + 1,
len(self._col_defs))
self._grid.SetSelectionMode(wx.grid.Grid.SelectRows)
+ self._grid.DisableDragRowSize()
+
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ sizer.Add(self._grid, 1, wx.EXPAND)
+ self.SetSizer(sizer)
self._fixed_font = wx.Font(pointSize=10,
family=wx.FONTFAMILY_TELETYPE,
@@ -263,10 +326,6 @@ class ChirpMemEdit(common.ChirpEditor):
self._grid.SetColAttr(col, attr)
self._grid.SetColMinimalWidth(col, 75)
- sizer = wx.BoxSizer(wx.VERTICAL)
- sizer.Add(self._grid, 1, wx.EXPAND)
- self.SetSizer(sizer)
-
wx.CallAfter(self._grid.AutoSizeColumns, setAsMin=False)
self._grid.Bind(wx.grid.EVT_GRID_CELL_CHANGING,
@@ -306,36 +365,83 @@ class ChirpMemEdit(common.ChirpEditor):
]
return defs
- def refresh_memory(self, memory):
- self._memory_cache[memory.number] = memory
+ def mem2row(self, number):
+ if isinstance(number, str):
+ return self._special_rows[number]
+ return number - self._features.memory_bounds[0]
- row = memory.number - self._features.memory_bounds[0]
+ def row2mem(self, row):
+ return row + self._features.memory_bounds[0]
- if memory.extd_number:
- self._grid.SetRowLabelValue(row, memory.extd_number)
- else:
- self._grid.SetRowLabelValue(row, str(memory.number))
+ def refresh_memory(self, number, memory):
+ row = self.mem2row(number)
- for col, col_def in enumerate(self._col_defs):
- self._grid.SetCellValue(row, col, col_def.render_value(memory))
+ if isinstance(memory, Exception):
+ LOG.error('Failed to load memory %s as error because: %s' % (
+ number, memory))
+ self._row_label_renderers[row].set_error()
+ self._grid.SetRowLabelValue(row, '!%s' % (
+ self._grid.GetRowLabelValue(row)))
+ return
+
+ self._memory_cache[row] = memory
+
+ with wx.grid.GridUpdateLocker(self._grid):
+ if memory.extd_number:
+ self._grid.SetRowLabelValue(row, memory.extd_number)
+ else:
+ self._grid.SetRowLabelValue(row, str(memory.number))
+
+ for col, col_def in enumerate(self._col_defs):
+ self._grid.SetCellValue(row, col, col_def.render_value(memory))
+
+ def refresh_memory_from_job(self, job):
+ self.refresh_memory(job.args[0], job.result)
def refresh(self):
- for i in range(*self._features.memory_bounds):
- try:
- m = self._radio.get_memory(i)
- except Exception as e:
- LOG.exception('Failure retreiving memory %i from %s' % (
- i, '%s %s %s' % (self._radio.VENDOR,
- self._radio.MODEL,
- self._radio.VARIANT)))
- continue
- self.refresh_memory(m)
- return
+ lower, upper = self._features.memory_bounds
+
+ # Build our row label renderers so we can set colors to
+ # indicate success or failure
+ self._row_label_renderers = []
+ for row, _ in enumerate(
+ range(lower,
+ upper + len(self._features.valid_special_chans) + 1)):
+ self._row_label_renderers.append(ChirpRowLabelRenderer())
+ self._grid.SetRowLabelRenderer(row, self._row_label_renderers[-1])
+
+ row = 0
+ for i in range(lower, upper + 1):
+ row += 1
+ self.do_radio(self.refresh_memory_from_job, 'get_memory', i)
for i in self._features.valid_special_chans:
- m = self._radio.get_memory(i)
- self.refresh_memory(m)
+ self._special_rows[i] = row
+ row += 1
+ self.do_radio(self.refresh_memory_from_job, 'get_memory', i)
+
+ def _set_memory_defaults(self, mem):
+ if not CONF.get_bool('auto_edits', 'state', True):
+ return
+
+ defaults = self.bandplan.get_defaults_for_frequency(mem.freq)
+
+ if not defaults.offset:
+ mem.duplex = ''
+ elif defaults.offset > 0:
+ mem.duplex = '+'
+ mem.offset = defaults.offset
+ elif defaults.offset < 0:
+ mem.duplex = '-'
+ mem.offset = abs(defaults.offset)
+
+ if defaults.step_khz:
+ mem.tuning_step = defaults.step_khz
+ if defaults.mode:
+ mem.mode = defaults.mode
+ if defaults.tones:
+ mem.rtone = defaults.tones[0]
def _memory_edited(self, event):
"""
@@ -349,18 +455,28 @@ class ChirpMemEdit(common.ChirpEditor):
col_def = self._col_defs[col]
try:
- mem = self._memory_cache[row + self._features.memory_bounds[0]]
+ mem = self._memory_cache[row]
except KeyError:
wx.MessageBox('Unable to edit memory before radio is loaded')
event.Veto()
return
+ def set_cb(job):
+ if isinstance(job.result, Exception):
+ self._row_label_renderers[row].set_error()
+ else:
+ self._row_label_renderers[row].clear_error()
+
try:
if col_def.label == 'Name':
val = self._radio.filter_name(val)
col_def.digest_value(mem, val)
+ if col_def.label == 'Frequency':
+ self._set_memory_defaults(mem)
mem.empty = False
- job = self._radio.set_memory(mem)
+ self._grid.SetRowLabelValue(row, '*%i' % mem.number)
+ self._row_label_renderers[row].set_progress()
+ self.do_radio(set_cb, 'set_memory', mem)
except Exception as e:
LOG.exception('Failed to edit memory')
wx.MessageBox('Invalid edit: %s' % e, 'Error')
@@ -385,16 +501,18 @@ class ChirpMemEdit(common.ChirpEditor):
Also provides the trigger to the editorset that we have changed.
"""
row = event.GetRow()
- mem = self._radio.get_memory(row + self._features.memory_bounds[0])
- self.refresh_memory(mem)
+ self.do_radio(self.refresh_memory_from_job, 'get_memory',
+ self.row2mem(row))
+
wx.PostEvent(self, common.EditorChanged(self.GetId()))
def delete_memory_at(self, row, event):
- number = row + self._features.memory_bounds[0]
- mem = self._radio.get_memory(number)
- mem.empty = True
- self._radio.set_memory(mem)
- self.refresh_memory(mem)
+ number = self.row2mem(row)
+
+ def del_cb(job):
+ self.do_radio(self.refresh_memory_from_job, 'get_memory', number)
+
+ self.do_radio(del_cb, 'erase_memory', number)
wx.PostEvent(self, common.EditorChanged(self.GetId()))
def _delete_memories_at(self, rows, event):
@@ -444,9 +562,6 @@ class ChirpMemEdit(common.ChirpEditor):
self.PopupMenu(menu)
menu.Destroy()
- def row2mem(self, row):
- return row + self._features.memory_bounds[0]
-
def _mem_properties(self, rows, event):
memories = [
self._radio.get_memory(self.row2mem(row))
@@ -455,7 +570,8 @@ class ChirpMemEdit(common.ChirpEditor):
if d.ShowModal() == wx.ID_OK:
for memory in d._memories:
self._radio.set_memory(memory)
- self.refresh_memory(memory)
+ self.refresh_memory(memory.number, memory)
+ wx.PostEvent(self, common.EditorChanged(self.GetId()))
def _mem_showraw(self, row, event):
mem = self._radio.get_raw_memory(self.row2mem(row))
@@ -484,7 +600,7 @@ class ChirpMemEdit(common.ChirpEditor):
if cut:
self._radio.erase_memory(mem.number)
mem = self._radio.get_memory(mem.number)
- self.refresh_memory(mem)
+ self.refresh_memory(mem.number, mem)
return data
def _cb_paste_memories(self, mems):
@@ -499,7 +615,7 @@ class ChirpMemEdit(common.ChirpEditor):
mem.number = row + self._features.memory_bounds[0]
row += 1
self._radio.set_memory(mem)
- self.refresh_memory(mem)
+ self.refresh_memory(mem.number, mem)
def cb_paste(self, data):
if data.GetFormat() == common.CHIRP_DATA_MEMORY:
@@ -513,6 +629,15 @@ class ChirpMemEdit(common.ChirpEditor):
def select_all(self):
self._grid.SelectAll()
+ def rows_visible(self):
+ first = self._grid.GetFirstFullyVisibleRow()
+ last = first + self._grid.GetScrollPageSize(wx.VERTICAL)
+ return first, last
+
+
+class ChirpLiveMemEdit(ChirpMemEdit, common.ChirpAsyncEditor):
+ pass
+
class ChirpMemPropDialog(wx.Dialog):
def __init__(self, memories, memedit, *a, **k):
@@ -555,7 +680,7 @@ class ChirpMemPropDialog(wx.Dialog):
hbox.Add(wx.Button(self, wx.ID_OK))
hbox.Add(wx.Button(self, wx.ID_CANCEL))
- vbox.Add(hbox, 0, wx.ALIGN_RIGHT|wx.ALL, border=10)
+ vbox.Add(hbox, 0, wx.ALIGN_RIGHT | wx.ALL, border=10)
self.Bind(wx.EVT_BUTTON, self._button)
diff --git a/chirp/wxui/query_sources.py b/chirp/wxui/query_sources.py
new file mode 100644
index 0000000..890db4e
--- /dev/null
+++ b/chirp/wxui/query_sources.py
@@ -0,0 +1,305 @@
+import logging
+import queue
+import requests
+import sys
+import tempfile
+import threading
+
+import wx
+
+from chirp import CHIRP_VERSION
+from chirp.ui import config
+from chirp.ui import fips
+
+CONF = config.get()
+LOG = logging.getLogger(__name__)
+QueryThreadEvent, EVT_QUERY_THREAD = wx.lib.newevent.NewCommandEvent()
+HEADERS = {
+ 'User-Agent': 'chirp/%s Python %i.%i.%i %s' % (
+ CHIRP_VERSION,
+ sys.version_info.major, sys.version_info.minor, sys.version_info.micro,
+ sys.platform),
+}
+
+
+class QueryThread(threading.Thread):
+ END_SENTINEL = object()
+
+ def __init__(self, *a, **k):
+ self.query_dialog = a[0]
+ super(QueryThread, self).__init__(*a[1:], **k)
+ self.status_queue = queue.Queue()
+
+ def run(self):
+ try:
+ self.do_query()
+ except Exception as e:
+ self.send_fail('Failed: %s' % str(e))
+
+ def send_status(self, status, percent):
+ self.query_dialog.status(status, percent)
+
+ def send_end(self):
+ self.query_dialog.end()
+
+ def send_fail(self, reason):
+ self.query_dialog.fail(reason)
+
+
+class QuerySourceDialog(wx.Dialog):
+ def __init__(self, *a, **k):
+ super(QuerySourceDialog, self).__init__(*a, **k)
+ vbox = self.build()
+ self.Center()
+
+ self.gauge = wx.Gauge(self)
+ self.gauge.SetRange(100)
+ vbox.Add(self.gauge, 0, wx.EXPAND)
+
+ self.statusmsg = wx.StaticText(
+ self, label='',
+ style=(wx.ALIGN_CENTRE_HORIZONTAL | wx.ST_NO_AUTORESIZE |
+ wx.ST_ELLIPSIZE_END))
+ vbox.Add(self.statusmsg, 0, wx.EXPAND)
+
+ bs = self.CreateButtonSizer(wx.OK | wx.CANCEL)
+ vbox.Add(bs)
+ self.Bind(wx.EVT_BUTTON, self._button)
+
+ self.Bind(EVT_QUERY_THREAD, self._got_status)
+
+ self.result_file = tempfile.NamedTemporaryFile(suffix='.csv').name
+
+ def _button(self, event):
+ id = event.GetEventObject().GetId()
+
+ if id == wx.ID_OK:
+ self.FindWindowById(wx.ID_OK).Disable()
+ self.do_query()
+ return
+
+ self.EndModal(id)
+
+ def build(self):
+ pass
+
+ def do_query(self):
+ pass
+
+ def status(self, status, percent):
+ wx.PostEvent(self, QueryThreadEvent(self.GetId(),
+ status=status, percent=percent))
+
+ def end(self):
+ self.status(None, 100)
+
+ def fail(self, reason):
+ self.status(reason, 100)
+
+ def _got_status(self, event):
+ self.gauge.SetValue(event.percent)
+ if event.status is None:
+ self.EndModal(wx.ID_OK)
+ else:
+ self.statusmsg.SetLabel(event.status)
+ if event.percent == 100:
+ self.FindWindowById(wx.ID_OK).Enable()
+
+
+class RepeaterBookQueryThread(QueryThread):
+ def do_query(self):
+ self.send_status('Querying', 10)
+
+ params = self.query_dialog.get_rb_params()
+ r = requests.get('http://chirp.danplanet.com/%s' % params.pop('_url'),
+ params=params,
+ headers=HEADERS,
+ stream=True)
+ if r.status_code != 200:
+ self.send_fail('Got error code %i from server' % r.status_code)
+ return
+
+ self.send_status('Downloading', 20)
+
+ size = 0
+ chunks = 0
+ LOG.debug('Writing to %s' % self.query_dialog.result_file)
+ with open(self.query_dialog.result_file, 'wb') as f:
+ for chunk in r.iter_content(chunk_size=8192):
+ size += len(chunk)
+ chunks += 1
+ self.send_status('Read %iKiB' % (size // 1024),
+ 20 + max(chunks * 10, 80))
+ f.write(chunk)
+
+ if size <= 105:
+ self.send_fail('No results!')
+ return
+
+ self.send_end()
+
+
+class RepeaterBookQueryDialog(QuerySourceDialog):
+ RB_BANDS = {
+ "--All--": 0,
+ "10 meters (29MHz)": 29,
+ "6 meters (54MHz)": 5,
+ "2 meters (144MHz)": 14,
+ "1.25 meters (220MHz)": 22,
+ "70 centimeters (440MHz)": 4,
+ "33 centimeters (900MHz)": 9,
+ "23 centimeters (1.2GHz)": 12,
+ }
+
+ def build(self):
+ self.tabs = wx.Notebook(self)
+ vbox = wx.BoxSizer(wx.VERTICAL)
+ self.SetSizer(vbox)
+ vbox.Add(self.tabs, 1, wx.EXPAND)
+
+ self.tabs.InsertPage(0, self._build_political(self.tabs), 'Political')
+ self.tabs.InsertPage(1, self._build_proximity(self.tabs), 'Proximity')
+ self.Layout()
+ return vbox
+
+ def _build_band_choice(self, parent):
+ return wx.Choice(parent, choices=list(self.RB_BANDS.keys()))
+
+ def _add_grid(self, grid, label, widget):
+ grid.Add(wx.StaticText(widget.GetParent(), label=label),
+ border=20, flag=wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT)
+ grid.Add(widget, 1, border=20, flag=wx.EXPAND | wx.RIGHT | wx.LEFT)
+
+ def _build_political(self, parent):
+ panel = wx.Panel(parent)
+ grid = wx.FlexGridSizer(2, 5, 0)
+ grid.AddGrowableCol(1)
+
+ self._state = wx.Choice(panel, choices=sorted(fips.FIPS_STATES.keys()))
+ self.Bind(wx.EVT_CHOICE, self._selected_state, self._state)
+ self._county = wx.Choice(panel, choices=['--All--'])
+ self.Bind(wx.EVT_CHOICE, self._selected_county, self._county)
+ self._pol_band = self._build_band_choice(panel)
+ self.Bind(wx.EVT_CHOICE, self._selected_band, self._pol_band)
+
+ self._fips_to_state = {str(v): k for k, v in fips.FIPS_STATES.items()}
+
+ current_state = CONF.get('state', 'repeaterbook')
+ current_county = CONF.get('county', 'repeaterbook')
+ if not current_state:
+ current_state = '1'
+ self._state.SetSelection(
+ self._state.FindString(self._fips_to_state[current_state]))
+ self._selected_state_name(self._fips_to_state[current_state])
+
+ try:
+ _fips_to_county = {
+ str(v): k
+ for k, v in fips.FIPS_COUNTIES[int(current_state)].items()}
+ self._county.SetSelection(
+ self._county.FindString(_fips_to_county[current_county]))
+ except Exception:
+ if current_county:
+ LOG.warning('Missing county code %r in state %r' % (
+ current_county,
+ current_state))
+
+ self._add_grid(grid, 'State', self._state)
+ self._add_grid(grid, 'County', self._county)
+ self._add_grid(grid, 'Band', self._pol_band)
+
+ vbox = wx.BoxSizer(wx.VERTICAL)
+ vbox.Add(grid, proportion=0, flag=wx.EXPAND,
+ border=20)
+ panel.SetSizer(vbox)
+ return panel
+
+ def _selected_state(self, event):
+ self._selected_state_name(event.GetString())
+
+ def _selected_state_name(self, state):
+ counties = sorted(fips.FIPS_COUNTIES[fips.FIPS_STATES[state]].keys())
+ self._county.Set(counties)
+ CONF.set('state', str(fips.FIPS_STATES[state]), 'repeaterbook')
+ self._selected_county_name(counties[0])
+
+ def _selected_county(self, event):
+ self._selected_county_name(event.GetString())
+
+ def _selected_county_name(self, county):
+ state = CONF.get('state', 'repeaterbook')
+ try:
+ state = int(state)
+ except ValueError:
+ pass
+ county_code = str(fips.FIPS_COUNTIES[state][county])
+ if county_code == '%':
+ CONF.remove_option('county', 'repeaterbook')
+ else:
+ CONF.set('county', county_code, 'repeaterbook')
+
+ def _build_proximity(self, parent):
+ panel = wx.Panel(parent)
+ grid = wx.FlexGridSizer(2, 5, 0)
+ grid.AddGrowableCol(1)
+
+ self._location = wx.TextCtrl(panel)
+ self._location.AppendText(CONF.get('location', 'repeaterbook') or '')
+ self.Bind(wx.EVT_TEXT, self._selected_location, self._location)
+ self._distance = wx.TextCtrl(panel)
+ self._distance.AppendText(CONF.get('distance', 'repeaterbook') or '')
+ self.Bind(wx.EVT_TEXT, self._selected_distance, self._distance)
+ self._prox_band = self._build_band_choice(panel)
+ self.Bind(wx.EVT_CHOICE, self._selected_band, self._prox_band)
+
+ self._add_grid(grid, 'Location', self._location)
+ self._add_grid(grid, 'Distance', self._distance)
+ self._add_grid(grid, 'Band', self._prox_band)
+
+ vbox = wx.BoxSizer(wx.VERTICAL)
+ vbox.Add(grid, flag=wx.EXPAND,
+ border=20)
+ panel.SetSizer(vbox)
+ return panel
+
+ def _selected_location(self, event):
+ CONF.set('location', event.GetString(), 'repeaterbook')
+
+ def _selected_distance(self, event):
+ CONF.set('distance', event.GetString(), 'repeaterbook')
+
+ def _selected_band(self, event):
+ CONF.set('band', str(self.RB_BANDS[event.GetString()]), 'repeaterbook')
+
+ def do_query(self):
+ RepeaterBookQueryThread(self).start()
+
+ def get_rb_params(self):
+ page = self.tabs.GetSelection()
+ if page == 0:
+ # Political
+ return {
+ '_url': 'query/rb/1.0/chirp',
+ 'state_id': CONF.get('state', 'repeaterbook'),
+ 'county_id': CONF.get('county', 'repeaterbook') or '%',
+ 'func': 'default',
+ 'band': CONF.get('band', 'repeaterbook') or '%',
+ 'freq': '%',
+ 'band6': '%',
+ 'loc': '%',
+ 'status_id': '%',
+ 'features': '%',
+ 'coverage': '%',
+ 'use': '%',
+ }
+ elif page == 1:
+ # Proximity
+ try:
+ return {
+ '_url': 'query/rb/1.0/app_direct',
+ 'loc': CONF.get('location', 'repeaterbook'),
+ 'dist': int(CONF.get('distance', 'repeaterbook')),
+ 'band': CONF.get('band', 'repeaterbook') or '%',
+ }
+ except (TypeError, ValueError):
+ raise Exception('Distance must be a number!')
diff --git a/chirp/wxui/radiothread.py b/chirp/wxui/radiothread.py
new file mode 100644
index 0000000..35357c4
--- /dev/null
+++ b/chirp/wxui/radiothread.py
@@ -0,0 +1,99 @@
+import logging
+import queue
+import threading
+import uuid
+
+LOG = logging.getLogger(__name__)
+_JOB_COUNTER = 0
+_JOB_COUNTER_LOCK = threading.Lock()
+
+
+def jobnumber():
+ global _JOB_COUNTER
+
+ # This shouldn't be called outside the main thread, so this should
+ # not be necessary. But, be careful anyway in case that changes in
+ # the future.
+ with _JOB_COUNTER_LOCK:
+ num = _JOB_COUNTER
+ _JOB_COUNTER += 1
+ return num
+
+
+class RadioJob:
+ def __init__(self, editor, fn, args, kwargs):
+ self.editor = editor
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+ self.result = None
+ self.id = str(uuid.uuid4())
+ self.jobnumber = jobnumber()
+
+ @property
+ def score(self):
+ if self.fn == 'get_memory':
+ return 20
+ elif self.fn.startswith('get'):
+ return 10
+ else:
+ return 0
+
+ def __lt__(self, job):
+ # Prioritize jobs with lower scores and jobs submitted before us
+ return self.score < job.score or self.jobnumber < job.jobnumber
+
+ def __repr__(self):
+ return '<RadioJob@%i>%s(%s,%s)=%r' % (
+ self.score,
+ self.fn,
+ ','.join(repr(a) for a in self.args),
+ ','.join('%s=%r' % (k, v) for k, v in self.kwargs.items()),
+ self.result)
+
+ def dispatch(self, radio):
+ try:
+ self.result = getattr(radio, self.fn)(*self.args, **self.kwargs)
+ except Exception as e:
+ LOG.exception('Failed to run %r' % self)
+ self.result = e
+
+ LOG.debug('Radio finished %r' % self)
+
+
+class RadioThread(threading.Thread):
+ SENTINEL = RadioJob(None, 'END', [], {})
+
+ def __init__(self, radio):
+ super().__init__()
+ self._radio = radio
+ self._queue = queue.PriorityQueue()
+ self._log = logging.getLogger('RadioThread')
+ self._waiting = []
+
+ def submit(self, editor, fn, *a, **k):
+ job = RadioJob(editor, fn, a, k)
+ self._queue.put(job)
+ return job.id
+
+ def end(self):
+ self._queue.put(self.SENTINEL)
+
+ def run(self):
+ while True:
+ job = self._queue.get()
+ if job is self.SENTINEL:
+ self._log.info('Exiting on request')
+ return
+ job.dispatch(self._radio)
+ self._waiting.append(job)
+
+ for job in list(self._waiting):
+ delivered = job.editor.radio_thread_event(
+ job, block=not self.pending)
+ if delivered:
+ self._waiting.remove(job)
+
+ @property
+ def pending(self):
+ return self._queue.qsize()
diff --git a/chirp/wxui/settingsedit.py b/chirp/wxui/settingsedit.py
index 8a61034..d68d0d4 100644
--- a/chirp/wxui/settingsedit.py
+++ b/chirp/wxui/settingsedit.py
@@ -4,7 +4,6 @@ import wx
import wx.dataview
from chirp import settings
-from chirp.wxui import clone
from chirp.wxui import common
LOG = logging.getLogger(__name__)
@@ -20,18 +19,26 @@ class ChirpSettingsEdit(common.ChirpEditor):
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
- self._pre_propgrid_hook(sizer)
-
self._group_control = wx.Listbook(self, style=wx.LB_LEFT)
sizer.Add(self._group_control, 1, wx.EXPAND)
self._initialized = False
self._group_control.Bind(wx.EVT_PAINT, self._activate)
+ def _initialize(self, job):
+ self.stop_wait_dialog()
+ with common.error_proof(Exception):
+ if isinstance(job.result, Exception):
+ raise job.result
+ self._settings = job.result
+ self._load_settings()
+
def _activate(self, event):
if not self._initialized:
self._initialized = True
- wx.CallAfter(self._initialize)
+ self.start_wait_dialog('Getting settings')
+ self.do_radio(lambda job: wx.CallAfter(self._initialize, job),
+ 'get_settings')
def _load_settings(self):
for group in self._settings:
@@ -56,12 +63,13 @@ class ChirpSettingsEdit(common.ChirpEditor):
def _apply_settings(self):
try:
- all_values = {}
for i in range(self._group_control.GetPageCount()):
page = self._group_control.GetPage(i)
- all_values.update(page.get_values())
- for group in self._settings:
- self._apply_setting_group(all_values, group)
+ for name, (setting, val) in page.get_setting_values().items():
+ LOG.debug('Setting %s:%s=%r' % (page.name,
+ setting.get_name(),
+ val))
+ setting.value = val
return True
except Exception as e:
LOG.exception('Failed to apply settings')
@@ -73,11 +81,15 @@ class ChirpSettingsEdit(common.ChirpEditor):
for element in group.values():
if isinstance(element, settings.RadioSetting):
if element.value.get_mutable():
- element.value = all_values[element.get_name()]
+ element.value = \
+ all_values[group.get_name()][element.get_name()]
else:
self._apply_setting_group(all_values, element)
def _changed(self, event):
+ if not self._apply_settings():
+ return
+ self.do_radio(None, 'set_settings', self._settings)
wx.PostEvent(self, common.EditorChanged(self.GetId()))
def saved(self):
@@ -86,76 +98,11 @@ class ChirpSettingsEdit(common.ChirpEditor):
page.saved()
-class ChirpCloneSettingsEdit(ChirpSettingsEdit):
-
- def __init__(self, *a, **k):
- super(ChirpCloneSettingsEdit, self).__init__(*a, **k)
-
- self._settings = self._radio.get_settings()
-
- def _initialize(self):
- self._load_settings()
-
- def _pre_propgrid_hook(self, sizer):
- pass
-
- def _changed(self, event):
- if not self._apply_settings():
- return
- self._radio.set_settings(self._settings)
- super(ChirpCloneSettingsEdit, self)._changed(event)
-
+class ChirpCloneSettingsEdit(ChirpSettingsEdit,
+ common.ChirpSyncEditor):
+ pass
-class ChirpLiveSettingsEdit(ChirpSettingsEdit):
- def _pre_propgrid_hook(self, sizer):
- buttons = wx.Panel(self)
- hbox = wx.BoxSizer(wx.HORIZONTAL)
- buttons.SetSizer(hbox)
- sizer.Add(buttons, 0, flag=wx.ALIGN_RIGHT)
- self._apply_btn = wx.Button(buttons, wx.ID_APPLY)
- hbox.Add(self._apply_btn, 0,
- flag=wx.ALIGN_RIGHT|wx.ALL, border=10)
- self._apply_btn.Disable()
- self._apply_btn.Bind(wx.EVT_BUTTON, self._apply_settings_button)
-
- def _apply_setting_edit(self):
- # Do not apply settings during edit for live radios
- pass
-
- def _changed(self, event):
- self._apply_btn.Enable()
- # Do not send the changed event for live radios
-
- def saved(self):
- # Do not allow saved event to change modified statuses
- pass
-
- def _initialize(self):
- LOG.debug('Loading settings for live radio')
- prog = wx.ProgressDialog('Loading Settings', 'Please wait...', 100,
- parent=self)
- thread = clone.SettingsThread(self._radio, prog)
- thread.start()
- prog.ShowModal()
- LOG.debug('Settings load complete')
- self._settings = thread.settings
- self._load_settings()
-
- def _apply_settings_button(self, event):
- if not self._apply_settings():
- return
-
- prog = wx.ProgressDialog('Applying Settings', 'Please wait...', 100,
- parent=self)
- thread = clone.SettingsThread(self._radio, prog, self._settings)
- thread.start()
- prog.ShowModal()
-
- if thread.error:
- wx.MessageBox('Error applying settings: %s' % thread.error,
- 'Error',
- wx.OK | wx.ICON_ERROR)
- else:
- self._apply_btn.Disable()
- super(ChirpLiveSettingsEdit, self).saved()
+class ChirpLiveSettingsEdit(ChirpSettingsEdit,
+ common.ChirpAsyncEditor):
+ pass
diff --git a/chirpc b/chirpc
index a32cb9f..c7aa2cf 100644
--- a/chirpc
+++ b/chirpc
@@ -66,7 +66,7 @@ class DTCSPolarityAction(argparse.Action):
value = values[0]
if value not in ["NN", "RN", "NR", "RR"]:
raise argparse.ArgumentError(
- self, "Invaid DTCS polarity: %s" % value)
+ self, "Invalid DTCS polarity: %s" % value)
setattr(namespace, self.dest, value)
diff --git a/chirpw b/chirpw
index 4e1c88b..481dd32 100755
--- a/chirpw
+++ b/chirpw
@@ -52,16 +52,19 @@ conf = config.get()
manual_language = conf.get("language", "state")
langs = []
if manual_language and manual_language != "Auto":
- lang_codes = {"English": "en_US",
- "Polish": "pl",
- "Italian": "it",
- "Dutch": "nl",
- "German": "de",
- "Hungarian": "hu",
- "Russian": "ru",
- "Portuguese (BR)": "pt_BR",
- "French": "fr",
- "Spanish": "es_ES",
+ lang_codes = {"English": "en_US",
+ "Polish": "pl",
+ "Italian": "it",
+ "Dutch": "nl",
+ "German": "de",
+ "Hungarian": "hu",
+ "Russian": "ru",
+ "Portuguese (BR)": "pt_BR",
+ "French": "fr",
+ "Spanish": "es_ES",
+ "Chinese (Simplified)": "zh_CN",
+ 'Ukrainian': "uk_UA",
+ 'Turkish': "tr_TR",
}
try:
LOG.info("Language: %s", lang_codes[manual_language])
diff --git a/chirpwx.py b/chirpwx.py
index 044aca9..96d3654 100755
--- a/chirpwx.py
+++ b/chirpwx.py
@@ -1,10 +1,7 @@
#!/usr/bin/env python3
import argparse
-import collections
-import functools
import gettext
-import logging
import os
import sys
@@ -13,15 +10,13 @@ import wx.aui
import wx.grid
import wx.lib.newevent
-from chirp import chirp_common
-from chirp.drivers import ic2820, generic_csv
from chirp import directory
from chirp import logger
+from chirp.ui import config
from chirp.wxui import main
-
if __name__ == '__main__':
gettext.install('CHIRP')
parser = argparse.ArgumentParser()
@@ -36,6 +31,9 @@ if __name__ == '__main__':
help="Include this driver while loading")
parser.add_argument("--inspect", action="store_true",
help="Show wxPython inspector")
+ if sys.platform == 'linux':
+ parser.add_argument('--no-linux-gdk-backend', action='store_true',
+ help='Do not force GDK_BACKEND=x11')
logger.add_arguments(parser)
args = parser.parse_args()
@@ -43,7 +41,16 @@ if __name__ == '__main__':
directory.safe_import_drivers(limit=args.onlydriver)
- #logging.basicConfig(level=logging.DEBUG)
+ CONF = config.get()
+ if CONF.get('developer', 'state'):
+ from chirp.drivers import fake
+ fake.register_fakes()
+
+ # wxGTK on Wayland seems to have problems. Override GDK_BACKEND to
+ # use X11, unless we were asked not to
+ if sys.platform == 'linux' and not args.no_linux_gdk_backend:
+ os.putenv('GDK_BACKEND', 'x11')
+
app = wx.App()
mainwindow = main.ChirpMain(None, title='CHIRP')
mainwindow.Show()
diff --git a/locale/Makefile b/locale/Makefile
index 5271862..3b880fa 100644
--- a/locale/Makefile
+++ b/locale/Makefile
@@ -1,4 +1,4 @@
-LOCALES = en_US pl it nl de hu ru pt_BR fr uk_UA es_ES
+LOCALES = en_US pl it nl de hu ru pt_BR fr uk_UA es_ES zh_CN tr_TR
MOFILES = $(patsubst %,%/LC_MESSAGES/CHIRP.mo,$(LOCALES))
COPY="Dan Smith <dsmith@danplanet.com>"
diff --git a/locale/es_ES.po b/locale/es_ES.po
index 20ca77d..4fa05d3 100644
--- a/locale/es_ES.po
+++ b/locale/es_ES.po
@@ -1,287 +1,542 @@
# Spanish translations for CHIRP package.
-# Copyright (C) 2011 Dan Smith <dsmith@danplanet.com>
+# Copyright (C) 2022 Dan Smith <dsmith@danplanet.com>
# This file is distributed under the same license as the CHIRP package.
-# Dan Smith <dan@theine>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: CHIRP\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-02-16 12:06-0800\n"
-"PO-Revision-Date: 2016-03-28 02:44+0100\n"
-"Last-Translator: Alfonso Moratalla <alfonso.moratalla@gmail.com>\n"
+"POT-Creation-Date: 2022-06-30 00:10-0400\n"
+"PO-Revision-Date: 2022-06-30 00:12-0400\n"
+"Last-Translator: MELERIX\n"
"Language-Team: \n"
-"Language: es_ES\n"
+"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Poedit 1.5.4\n"
+"X-Generator: Poedit 3.1\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+"X-Poedit-Basepath: ..\n"
+"X-Poedit-SearchPath-0: .\n"
-#: ../chirpui/common.py:204
-msgid "Completed"
-msgstr "Completado"
+#: chirp/drivers/bj9900.py:112
+msgid ""
+"This is experimental support for BJ-9900 which is still under development.\n"
+"Please ensure you have a good backup with OEM software.\n"
+"Also please send in bug and enhancement requests!\n"
+"You have been warned. Proceed at your own risk!"
+msgstr ""
+"Este es un soporte experimental para BJ-9900 que aún está en desarrollo.\n"
+"Por favor asegúrate de tener un buen respaldo con el software OEM.\n"
+"¡También por favor envía en solicitudes de errores y mejoras!\n"
+"Has sido advertido. ¡Procede bajo tu propio riesgo!"
+
+#: chirp/drivers/bj9900.py:137 chirp/drivers/ft450d.py:444
+#: chirp/drivers/ft817.py:339
+msgid "Cloning from radio"
+msgstr "Clonando desde radio"
+
+#: chirp/drivers/bj9900.py:164 chirp/drivers/ft450d.py:473
+#: chirp/drivers/ft817.py:377
+msgid "Cloning to radio"
+msgstr "Clonando a radio"
+
+#: chirp/drivers/ft450d.py:491 chirp/drivers/ft60.py:88
+#: chirp/drivers/ft817.py:403
+#, python-format
+msgid "Radio did not ack block %i"
+msgstr "La radio no reconoció el bloque %i"
+
+#: chirp/drivers/ft817.py:318
+msgid ""
+"Unable to read last block. This often happens when the selected model is US "
+"but the radio is a non-US one (or widebanded). Please choose the correct "
+"model and try again."
+msgstr ""
+"No se puede leer el último bloque. Esto suele suceder cuando el modelo "
+"seleccionado es de EE.UU pero la radio no es una de EE.UU (o de banda "
+"ancha). Por favor elije el modelo correcto e intenta de nuevo."
-#: ../chirpui/common.py:205
-msgid "idle"
-msgstr "inactivo"
+#: chirp/drivers/ft817.py:356
+msgid "Clone completed, checking for spurious bytes"
+msgstr "Clonado completado, comprobando por bytes espurios"
-#: ../chirpui/bankedit.py:52
-msgid "Retrieving bank information"
-msgstr "Recibiendo información del banco"
+#: chirp/drivers/ft817.py:361
+msgid ""
+"Radio sent data after the last awaited block, this happens when the selected "
+"model is a non-US but the radio is a US one. Please choose the correct model "
+"and try again."
+msgstr ""
+"La radio envió datos después del último bloque esperado, esto sucede cuando "
+"el modelo seleccionado no es de EE.UU. pero la radio es una de EE.UU. Por "
+"favor elije el modelo correcto e intenta de nuevo."
-#: ../chirpui/bankedit.py:75
-msgid "Setting name on bank"
-msgstr "Poniendo nombre al banco"
+#: chirp/drivers/vx5.py:117
+#, python-brace-format
+msgid "{bank} is full"
+msgstr "{bank} está lleno"
-#: ../chirpui/bankedit.py:85
-msgid "Bank"
-msgstr "Banco"
+#: chirp/drivers/vx5.py:134
+#, python-brace-format
+msgid "Memory {num} not in bank {bank}"
+msgstr "Memoria {num} no en banco {bank}"
-#: ../chirpui/bankedit.py:86 ../chirpui/bankedit.py:240
-#: ../chirpui/importdialog.py:536 ../chirpui/memedit.py:65
-#: ../chirpui/memedit.py:85 ../chirpui/memedit.py:247
-#: ../chirpui/memedit.py:872 ../chirpui/memedit.py:926
-#: ../chirpui/memedit.py:1063 ../chirpui/memedit.py:1065
+#: chirp/ui/bandplans.py:96
+msgid ""
+"Band plans define default channel settings for frequencies in a region. "
+"Choose a band plan or None for completely manual channel settings."
+msgstr ""
+"Los planes de banda definen los ajustes predeterminados de canal para las "
+"frecuencias en una región. Elije una plan de banda o Ninguno para ajustes de "
+"canal completamente manuales."
+
+#: chirp/ui/bankedit.py:58
+#, python-format
+msgid "Retrieving %s information"
+msgstr "Recuperando %s información"
+
+#: chirp/ui/bankedit.py:81
+#, python-format
+msgid "Setting name on %s"
+msgstr "Estableciendo nombre en %s"
+
+#: chirp/ui/bankedit.py:93 chirp/ui/bankedit.py:283
+#: chirp/ui/importdialog.py:601 chirp/ui/memdetail.py:334
+#: chirp/ui/memedit.py:67 chirp/ui/memedit.py:88 chirp/ui/memedit.py:343
+#: chirp/ui/memedit.py:1093 chirp/ui/memedit.py:1150 chirp/ui/memedit.py:1301
+#: chirp/ui/memedit.py:1303
msgid "Name"
msgstr "Nombre"
-#: ../chirpui/bankedit.py:185
-msgid "Updating bank index for memory {num}"
-msgstr "Actualizando índice del banco para memoria {num}"
+#: chirp/ui/bankedit.py:222
+#, python-brace-format
+msgid "Updating {type} index for memory {num}"
+msgstr "Actualizando {type} índice para memoria {num}"
-#: ../chirpui/bankedit.py:194
-msgid "Updating bank information for memory {num}"
-msgstr "Actualizando información del banco para memoria {num}"
+#: chirp/ui/bankedit.py:232
+#, python-brace-format
+msgid "Updating mapping information for memory {num}"
+msgstr "Actualizando información de mapeado para memoria {num}"
-#: ../chirpui/bankedit.py:200 ../chirpui/bankedit.py:229
+#: chirp/ui/bankedit.py:238 chirp/ui/bankedit.py:269
+#, python-brace-format
msgid "Getting memory {num}"
msgstr "Obteniendo memoria {num}"
-#: ../chirpui/bankedit.py:214
+#: chirp/ui/bankedit.py:253
+#, python-brace-format
msgid "Setting index for memory {num}"
-msgstr "Fijando índice para memoria {num}"
-
-#: ../chirpui/bankedit.py:223
-msgid "Getting bank for memory {num}"
-msgstr "Obteniendo banco para memoria {num}"
-
-#: ../chirpui/bankedit.py:238 ../chirpui/memedit.py:63
-#: ../chirpui/memedit.py:172 ../chirpui/memedit.py:246
-#: ../chirpui/memedit.py:315 ../chirpui/memedit.py:335
-#: ../chirpui/memedit.py:349 ../chirpui/memedit.py:423
-#: ../chirpui/memedit.py:435 ../chirpui/memedit.py:459
-#: ../chirpui/memedit.py:461 ../chirpui/memedit.py:534
-#: ../chirpui/memedit.py:548 ../chirpui/memedit.py:550
-#: ../chirpui/memedit.py:591 ../chirpui/memedit.py:593
-#: ../chirpui/memedit.py:621 ../chirpui/memedit.py:822
-#: ../chirpui/memedit.py:870 ../chirpui/memedit.py:895
-#: ../chirpui/memedit.py:907 ../chirpui/memedit.py:924
-#: ../chirpui/memedit.py:1230
+msgstr "Estableciendo índice para memoria {num}"
+
+#: chirp/ui/bankedit.py:262
+#, python-brace-format
+msgid "Getting {type} for memory {num}"
+msgstr "Obteniendo {type} para memoria {num}"
+
+#: chirp/ui/bankedit.py:281 chirp/ui/memedit.py:65 chirp/ui/memedit.py:195
+#: chirp/ui/memedit.py:342 chirp/ui/memedit.py:426 chirp/ui/memedit.py:445
+#: chirp/ui/memedit.py:459 chirp/ui/memedit.py:482 chirp/ui/memedit.py:504
+#: chirp/ui/memedit.py:530 chirp/ui/memedit.py:542 chirp/ui/memedit.py:566
+#: chirp/ui/memedit.py:568 chirp/ui/memedit.py:641 chirp/ui/memedit.py:655
+#: chirp/ui/memedit.py:657 chirp/ui/memedit.py:699 chirp/ui/memedit.py:701
+#: chirp/ui/memedit.py:775 chirp/ui/memedit.py:909 chirp/ui/memedit.py:983
+#: chirp/ui/memedit.py:1036 chirp/ui/memedit.py:1091 chirp/ui/memedit.py:1117
+#: chirp/ui/memedit.py:1130 chirp/ui/memedit.py:1148 chirp/ui/memedit.py:1477
msgid "Loc"
-msgstr "Loc"
+msgstr "Lugar"
-#: ../chirpui/bankedit.py:239 ../chirpui/importdialog.py:537
-#: ../chirpui/memedit.py:64 ../chirpui/memedit.py:86 ../chirpui/memedit.py:187
-#: ../chirpui/memedit.py:248 ../chirpui/memedit.py:271
-#: ../chirpui/memedit.py:296 ../chirpui/memedit.py:304
-#: ../chirpui/memedit.py:873 ../chirpui/memedit.py:923
+#: chirp/ui/bankedit.py:282 chirp/ui/importdialog.py:602
+#: chirp/ui/memdetail.py:332 chirp/ui/memedit.py:66 chirp/ui/memedit.py:89
+#: chirp/ui/memedit.py:210 chirp/ui/memedit.py:334 chirp/ui/memedit.py:344
+#: chirp/ui/memedit.py:407 chirp/ui/memedit.py:415 chirp/ui/memedit.py:1094
+#: chirp/ui/memedit.py:1147
msgid "Frequency"
msgstr "Frecuencia"
-#: ../chirpui/bankedit.py:241
+#: chirp/ui/bankedit.py:284
msgid "Index"
msgstr "Índice"
-#: ../chirpui/bankedit.py:302
-msgid "Getting bank information for memory {num}"
-msgstr "Obteniendo información del banco para memoria {num}"
+#: chirp/ui/bankedit.py:375
+#, python-brace-format
+msgid "Getting {type} information for memory {num}"
+msgstr "Obteniendo {type} información para memoria {num}"
-#: ../chirpui/bankedit.py:323
-msgid "Getting bank information"
-msgstr "Obteniendo información del banco"
+#: chirp/ui/bankedit.py:401
+#, python-format
+msgid "Getting %s information"
+msgstr "Obteniendo %s información"
-#: ../chirpui/inputdialog.py:81
-msgid "An error has occurred"
-msgstr "Ha ocurrido un error"
+#: chirp/ui/clone.py:40
+#, python-brace-format
+msgid "{vendor} {model} on {port}"
+msgstr "{vendor} {model} en {port}"
-#: ../chirpui/inputdialog.py:130
-msgid "Overwrite"
-msgstr "Sobreescribir"
+#: chirp/ui/clone.py:111 chirp/ui/clone.py:112 chirp/ui/clone.py:172
+msgid "Detect"
+msgstr "Detectar"
-#: ../chirpui/inputdialog.py:133
-msgid "File Exists"
-msgstr "El fichero existe"
+#: chirp/ui/clone.py:135
+msgid "Port"
+msgstr "Puerto"
-#: ../chirpui/inputdialog.py:136
-msgid "The file {name} already exists. Do you want to overwrite it?"
-msgstr "El fichero {name} ya existe. ¿Quiere sobreescribirlo?"
+#: chirp/ui/clone.py:136
+msgid "Vendor"
+msgstr "Vendedor"
+
+#: chirp/ui/clone.py:137
+msgid "Model"
+msgstr "Modelo"
+
+#: chirp/ui/clone.py:150
+msgid "Radio"
+msgstr "Radio"
+
+#: chirp/ui/clone.py:177
+#, python-brace-format
+msgid "Unable to detect radio on {port}"
+msgstr "No se puede detectar radio en {port}"
+
+#: chirp/ui/clone.py:209
+#, python-brace-format
+msgid "Internal error: Unable to upload to {model}"
+msgstr "Error interno: No se puede subir a {model}"
+
+#: chirp/ui/cloneprog.py:44
+msgid "Clone Progress"
+msgstr "Progreso de clonado"
+
+#: chirp/ui/cloneprog.py:47
+msgid "Cloning"
+msgstr "Clonando"
+
+#: chirp/ui/cloneprog.py:56
+msgid "Cancel"
+msgstr "Cancelar"
+
+#: chirp/ui/common.py:246
+msgid "Completed"
+msgstr "Completado"
+
+#: chirp/ui/common.py:247
+msgid "idle"
+msgstr "inactivo"
+
+#: chirp/ui/common.py:354
+msgid "Details"
+msgstr "Detalles"
+
+#: chirp/ui/common.py:357
+msgid "Proceed?"
+msgstr "¿Proceder?"
+
+#: chirp/ui/common.py:366
+msgid "Do not show this next time"
+msgstr "No mostrar esto la próxima vez"
+
+#: chirp/ui/dstaredit.py:44
+msgid "Callsign"
+msgstr "Señal de llamada"
+
+#: chirp/ui/dstaredit.py:129
+msgid "Your callsign"
+msgstr "Tu señal de llamada"
+
+#: chirp/ui/dstaredit.py:137
+msgid "Repeater callsign"
+msgstr "Señal de llamada del repetidor"
+
+#: chirp/ui/dstaredit.py:145
+msgid "My callsign"
+msgstr "Mi señal de llamada"
+
+#: chirp/ui/dstaredit.py:175 chirp/ui/memedit.py:1640
+msgid "Downloading URCALL list"
+msgstr "Descargando lista URCALL"
+
+#: chirp/ui/dstaredit.py:179 chirp/ui/memedit.py:1652
+msgid "Downloading RPTCALL list"
+msgstr "Descargando lista RPTCALL"
+
+#: chirp/ui/dstaredit.py:183
+msgid "Downloading MYCALL list"
+msgstr "Descargando lista MYCALL"
+
+#: chirp/ui/editorset.py:85
+#, python-format
+msgid "Memories (%(variant)s)"
+msgstr "Memorias (%(variant)s)"
+
+#: chirp/ui/editorset.py:89
+msgid "Memories"
+msgstr "Memorias"
+
+#: chirp/ui/editorset.py:100
+msgid "D-STAR"
+msgstr "D-STAR"
+
+#: chirp/ui/editorset.py:149
+msgid "Settings"
+msgstr "Ajustes"
+
+#: chirp/ui/editorset.py:158
+msgid "Browser"
+msgstr "Navegador"
-#: ../chirpui/importdialog.py:90
+#: chirp/ui/editorset.py:279
+#, python-brace-format
+msgid "The {vendor} {model} has multiple independent sub-devices"
+msgstr "El {vendor} {model} tiene múltiples sub dispositivos independientes"
+
+#: chirp/ui/editorset.py:281
+msgid "Choose one to import from:"
+msgstr "Elige uno para importar desde:"
+
+#: chirp/ui/editorset.py:286
+msgid "Cancelled"
+msgstr "Cancelado"
+
+#: chirp/ui/editorset.py:291
+msgid "Internal Error"
+msgstr "Error interno"
+
+#: chirp/ui/editorset.py:332
+#, python-brace-format
+msgid ""
+"There were errors while opening {file}. The affected memories will not be "
+"importable!"
+msgstr ""
+"Hubo errores mientras se abría {file}. ¡Las memorias afectadas no serán "
+"importables!"
+
+#: chirp/ui/editorset.py:344
+#, python-brace-format
+msgid "There was an error during import: {error}"
+msgstr "Hubo un error durante la importación: {error}"
+
+#: chirp/ui/editorset.py:352
+msgid "Unsupported file type"
+msgstr "Tipo de archivo no soportado"
+
+#: chirp/ui/editorset.py:368 chirp/ui/editorset.py:383
+#, python-brace-format
+msgid "There was an error during export: {error}"
+msgstr "Hubo un error durante la exportación: {error}"
+
+#: chirp/ui/importdialog.py:96
+#, python-brace-format
msgid ""
"Location {number} is already being imported. Choose another value for 'New "
"Location' before selection 'Import'"
msgstr ""
-"La localización {number} ya ha sido importada. Elija otro valor para 'Nueva "
-"Localización' antes de seleccionar 'Importar'"
+"Localización {number} ya está siendo importada. Elije algún otro valor para "
+"'Nueva Localización' antes de seleccionar 'Importar'"
-#: ../chirpui/importdialog.py:121
+#: chirp/ui/importdialog.py:128
msgid "Invalid value. Must be an integer."
-msgstr "Valor no válido. Debe ser un número entero."
+msgstr "Valor invalido. Debe ser un entero."
-#: ../chirpui/importdialog.py:130
+#: chirp/ui/importdialog.py:137
+#, python-brace-format
msgid "Location {number} is already being imported"
msgstr "Localización {number} ya está siendo importada"
-#: ../chirpui/importdialog.py:182
+#: chirp/ui/importdialog.py:194
msgid "Updating URCALL list"
-msgstr "Actualizando listado URCALL"
+msgstr "Actualizando lista URCALL"
-#: ../chirpui/importdialog.py:187
+#: chirp/ui/importdialog.py:199
msgid "Updating RPTCALL list"
-msgstr "Actualizando listado RPTCALL"
+msgstr "Actualizando lista RPTCALL"
-#: ../chirpui/importdialog.py:256
+#: chirp/ui/importdialog.py:272
+#, python-brace-format
msgid "Setting memory {number}"
-msgstr "Fijando memoria {number}"
+msgstr "Estableciendo memoria {number}"
-#: ../chirpui/importdialog.py:260
+#: chirp/ui/importdialog.py:277
msgid "Importing bank information"
-msgstr "Importando información del banco"
+msgstr "Importando información de banco"
-#: ../chirpui/importdialog.py:264
+#: chirp/ui/importdialog.py:281
msgid "Error importing memories:"
msgstr "Error importando memorias:"
-#: ../chirpui/importdialog.py:376
+#: chirp/ui/importdialog.py:393
msgid "All"
-msgstr "Todos"
+msgstr "Todo"
-#: ../chirpui/importdialog.py:382
+#: chirp/ui/importdialog.py:399
msgid "None"
msgstr "Ninguno"
-#: ../chirpui/importdialog.py:388
+#: chirp/ui/importdialog.py:405
msgid "Inverse"
msgstr "Inverso"
-#: ../chirpui/importdialog.py:394
+#: chirp/ui/importdialog.py:411
msgid "Select"
msgstr "Seleccionar"
-#: ../chirpui/importdialog.py:416
+#: chirp/ui/importdialog.py:457
msgid "Auto"
msgstr "Auto"
-#: ../chirpui/importdialog.py:422
+#: chirp/ui/importdialog.py:463
msgid "Reverse"
msgstr "Reverso"
-#: ../chirpui/importdialog.py:428
+#: chirp/ui/importdialog.py:469
msgid "Adjust New Location"
msgstr "Ajustar nueva localización"
-#: ../chirpui/importdialog.py:438
+#: chirp/ui/importdialog.py:479
msgid "Confirm overwrites"
msgstr "Confirmar sobreescritura"
-#: ../chirpui/importdialog.py:444
+#: chirp/ui/importdialog.py:485
msgid "Options"
msgstr "Opciones"
-#: ../chirpui/importdialog.py:495
+#: chirp/ui/importdialog.py:558
msgid "Cannot be imported because"
msgstr "No puede ser importado porque"
-#: ../chirpui/importdialog.py:513
+#: chirp/ui/importdialog.py:575
msgid "Import From File"
-msgstr "Importar desde fichero"
+msgstr "Importar desde archivo"
-#: ../chirpui/importdialog.py:514 ../chirpui/mainapp.py:1196
+#: chirp/ui/importdialog.py:576 chirp/ui/mainapp.py:2023
msgid "Import"
msgstr "Importar"
-#: ../chirpui/importdialog.py:534
+#: chirp/ui/importdialog.py:599
msgid "To"
msgstr "A"
-#: ../chirpui/importdialog.py:535
+#: chirp/ui/importdialog.py:600
msgid "From"
msgstr "Desde"
-#: ../chirpui/importdialog.py:538 ../chirpui/memedit.py:78
-#: ../chirpui/memedit.py:99 ../chirpui/memedit.py:886
-#: ../chirpui/memedit.py:940 ../chirpui/memedit.py:1068
+#: chirp/ui/importdialog.py:603 chirp/ui/memdetail.py:362
+#: chirp/ui/memedit.py:81 chirp/ui/memedit.py:103 chirp/ui/memedit.py:1108
+#: chirp/ui/memedit.py:1165 chirp/ui/memedit.py:1306
msgid "Comment"
msgstr "Comentario"
-#: ../chirpui/importdialog.py:542
+#: chirp/ui/importdialog.py:607
msgid "Location memory will be imported into"
-msgstr "La localización de memoria será importada en"
+msgstr "Localización de memoria será importada en"
-#: ../chirpui/importdialog.py:543
+#: chirp/ui/importdialog.py:608
msgid "Location of memory in the file being imported"
-msgstr "Localización de la memoria en el fichero que está siendo importado"
+msgstr "Localización de la memoria en el archivo siendo importado"
-#: ../chirpui/importdialog.py:566
+#: chirp/ui/importdialog.py:631
msgid "Preparing memory list..."
msgstr "Preparando lista de memoria..."
-#: ../chirpui/importdialog.py:575
+#: chirp/ui/importdialog.py:641
msgid "Export To File"
-msgstr "Exportar a fichero"
+msgstr "Exportar a archivo"
-#: ../chirpui/importdialog.py:576 ../chirpui/mainapp.py:1197
+#: chirp/ui/importdialog.py:642 chirp/ui/mainapp.py:2024
msgid "Export"
msgstr "Exportar"
-#: ../chirpui/mainapp.py:269 ../chirpui/mainapp.py:483
+#: chirp/ui/inputdialog.py:94
+msgid "An error has occurred"
+msgstr "Ha ocurrido un error"
+
+#: chirp/ui/inputdialog.py:154
+msgid "File Exists"
+msgstr "Archivo existe"
+
+#: chirp/ui/inputdialog.py:157
+#, python-brace-format
+msgid "The file {name} already exists. Do you want to overwrite it?"
+msgstr "El archivo {name} ya existe. ¿Quieres sobrescribirlo?"
+
+#: chirp/ui/mainapp.py:272 chirp/ui/mainapp.py:513
msgid "Untitled"
-msgstr "Sin nombre"
+msgstr "Sin título"
-#: ../chirpui/mainapp.py:316 ../chirpui/mainapp.py:715
+#: chirp/ui/mainapp.py:326 chirp/ui/mainapp.py:875
+msgid "All files"
+msgstr "Todos los archivos"
+
+#: chirp/ui/mainapp.py:327 chirp/ui/mainapp.py:876
msgid "CHIRP Radio Images"
msgstr "Imagenes de radio CHIRP"
-#: ../chirpui/mainapp.py:317 ../chirpui/mainapp.py:714
-#: ../chirpui/mainapp.py:880
-msgid "CHIRP Files"
-msgstr "Ficheros CHIRP"
-
-#: ../chirpui/mainapp.py:318 ../chirpui/mainapp.py:716
-#: ../chirpui/mainapp.py:879
+#: chirp/ui/mainapp.py:328 chirp/ui/mainapp.py:877 chirp/ui/mainapp.py:1557
msgid "CSV Files"
-msgstr "Ficheros CSV"
+msgstr "Archivos CSV"
+
+#: chirp/ui/mainapp.py:329 chirp/ui/mainapp.py:878
+msgid "DAT Files"
+msgstr "Archivos DAT"
-#: ../chirpui/mainapp.py:319 ../chirpui/mainapp.py:717
+#: chirp/ui/mainapp.py:330 chirp/ui/mainapp.py:879
+msgid "EVE Files (VX5)"
+msgstr "Archivos EVE (VX5)"
+
+#: chirp/ui/mainapp.py:331 chirp/ui/mainapp.py:880
msgid "ICF Files"
-msgstr "Ficheros ICF"
+msgstr "Archivos ICF"
+
+#: chirp/ui/mainapp.py:332 chirp/ui/mainapp.py:884
+msgid "VX5 Commander Files"
+msgstr "Archivos de VX5 Commander"
-#: ../chirpui/mainapp.py:320 ../chirpui/mainapp.py:718
+#: chirp/ui/mainapp.py:333 chirp/ui/mainapp.py:885
+msgid "VX6 Commander Files"
+msgstr "Archivos de VX6 Commander"
+
+#: chirp/ui/mainapp.py:334 chirp/ui/mainapp.py:886
msgid "VX7 Commander Files"
-msgstr "Ficheros del VX7 Commander"
+msgstr "Archivos de VX7 Commander"
-#: ../chirpui/mainapp.py:330
+#: chirp/ui/mainapp.py:348
msgid ""
"ICF files cannot be edited, only displayed or imported into another file. "
"Open in read-only mode?"
msgstr ""
-"Los ficheros ICF no se pueden editar, solo mostrarse o importarse en otro "
-"fichero. ¿Abrirlo en modo solo-lectura?"
+"Archivos ICF no se pueden editar, solo mostrarse o importarse en algún otro "
+"archivo. ¿Abrir en modo solo lectura?"
+
+#: chirp/ui/mainapp.py:371
+msgid ""
+"Unable to open this image. It was generated with a newer version of CHIRP "
+"and thus may be for a radio model that is not supported by this version. "
+"Please update to the latest version of CHIRP and try again."
+msgstr ""
+"No se puede abrir esta imagen. Esta fue generada con una versión más nueva "
+"de CHIRP y por lo tanto puede ser para un modelo de radio que no es "
+"soportada por esta versión. Por favor actualiza a la última versión de CHIRP "
+"e intenta de nuevo."
-#: ../chirpui/mainapp.py:373
+#: chirp/ui/mainapp.py:380
+msgid "Unable to open this image: unsupported model"
+msgstr "No se puede abrir esta imagen: modelo no soportado"
+
+#: chirp/ui/mainapp.py:400
+#, python-brace-format
msgid "There was an error opening {fname}: {error}"
msgstr "Hubo un error abriendo {fname}: {error}"
-#: ../chirpui/mainapp.py:388
+#: chirp/ui/mainapp.py:412
+#, python-brace-format
msgid "{num} errors during open:"
msgstr "{num} errores mientras se abría:"
-#: ../chirpui/mainapp.py:394
+#: chirp/ui/mainapp.py:420
msgid "Note:"
msgstr "Nota:"
-#: ../chirpui/mainapp.py:395
+#: chirp/ui/mainapp.py:421
+#, python-brace-format
msgid ""
"The {vendor} {model} operates in <b>live mode</b>. This means that any "
"changes you make are immediately sent to the radio. Because of this, you "
@@ -289,61 +544,154 @@ msgid ""
"edit the contents offline, please <u>Export</u> to a CSV file, using the "
"<b>File menu</b>."
msgstr ""
-"El {vendor} {model} opera en <b>modo live</b>. Esto significa que cualquier "
-"cambio que haga es enviado inmediatamente a la radio. Por esto, no puede "
-"usar las operaciones <u>Guardar</u> o <u>Subir</u>. Si quiere editar el "
-"contenido offline, por favor <u>Exporte</u> a un fichero CSV, usando el menu "
-"<b>Archivo</b>."
+"El {vendor} {model} opera en <b>modo en vivo</b>. Esto significa que "
+"cualquier cambio que hagas es enviado inmediatamente a la radio. Debido a "
+"esto , no puedes usar las operaciones <u>Guardar</u> o <u>Subir</u>. Si "
+"quieres editar el contenido sin conexón, por favor <u>Exporta</u> a un "
+"archivo CSV, usando el <b>menú Archivo</b>."
-#: ../chirpui/mainapp.py:404
+#: chirp/ui/mainapp.py:430
msgid "Don't show this again"
-msgstr "No mostrar esto otra vez"
+msgstr "No mostrar esto de neuvo"
-#: ../chirpui/mainapp.py:448
+#: chirp/ui/mainapp.py:464
+#, python-brace-format
msgid "{vendor} {model} image file"
-msgstr "fichero de imagen para {vendor} {model}"
+msgstr "archivo de imagen {vendor} {model}"
-#: ../chirpui/mainapp.py:456
+#: chirp/ui/mainapp.py:480
msgid "VX7 Commander"
msgstr "VX7 Commander"
-#: ../chirpui/mainapp.py:518
-msgid "Open recent file {name}"
-msgstr "Abrir fichero reciente {name}"
+#: chirp/ui/mainapp.py:482
+msgid "VX6 Commander"
+msgstr "VX6 Commander"
+
+#: chirp/ui/mainapp.py:484
+msgid "EVE"
+msgstr "EVE"
+
+#: chirp/ui/mainapp.py:485
+msgid "VX5 Commander"
+msgstr "VX5 Commander"
-#: ../chirpui/mainapp.py:579
+#: chirp/ui/mainapp.py:562
+msgid "Open recent file"
+msgstr "Abrir archivo reciente"
+
+#: chirp/ui/mainapp.py:631
+#, python-brace-format
msgid "Import stock configuration {name}"
-msgstr "Importar configuración por defecto {name}"
+msgstr "Importar configuración original {name}"
-#: ../chirpui/mainapp.py:595
+#: chirp/ui/mainapp.py:647
+#, python-brace-format
msgid "Open stock configuration {name}"
-msgstr "Abrir configuración por defecto {name}"
+msgstr "Abrir configuración original {name}"
+
+#: chirp/ui/mainapp.py:668
+msgid "Proceed with experimental driver?"
+msgstr "¿Proceder con controlador experimental?"
+
+#: chirp/ui/mainapp.py:670
+msgid "This radio's driver is experimental. Do you want to proceed?"
+msgstr "El controlador de esta radio es experimental. ¿Quieres proceder?"
+
+#: chirp/ui/mainapp.py:689
+#, python-brace-format
+msgid "{name} Information"
+msgstr "{name} Información"
+
+#: chirp/ui/mainapp.py:691
+#, python-brace-format
+msgid "{information}"
+msgstr "{information}"
+
+#: chirp/ui/mainapp.py:695
+msgid "Don't show information for any radio again"
+msgstr "No mostrar información para alguna radio de nuevo"
+
+#: chirp/ui/mainapp.py:719
+#, python-brace-format
+msgid "{name} Instructions"
+msgstr "{name} Instrucciones"
-#: ../chirpui/mainapp.py:681
-msgid "Discard Changes?"
-msgstr "¿Descartar cambios?"
+#: chirp/ui/mainapp.py:721
+#, python-brace-format
+msgid "{instructions}"
+msgstr "{instructions}"
-#: ../chirpui/mainapp.py:686
+#: chirp/ui/mainapp.py:725
+msgid "Don't show instructions for any radio again"
+msgstr "No mostrar instrucciones para alguna radio de nuevo"
+
+#: chirp/ui/mainapp.py:840
+msgid "Save Changes?"
+msgstr "¿Guardar cambios?"
+
+#: chirp/ui/mainapp.py:846
msgid "File is modified, save changes before closing?"
-msgstr "El fichero ha sido modificado, ¿guardar los cambios antes de cerrarlo?"
+msgstr "El archivo está modificado, ¿guardar los cambios antes de cerrar?"
+
+#: chirp/ui/mainapp.py:881
+msgid "Kenwood HMK Files"
+msgstr "Archivos Kenwood HMK"
+
+#: chirp/ui/mainapp.py:882
+msgid "Kenwood ITM Files"
+msgstr "Archivos Kenwood ITM"
+
+#: chirp/ui/mainapp.py:883
+msgid "Travel Plus Files"
+msgstr "Archivos Travel Plus"
+
+#: chirp/ui/mainapp.py:904
+msgid "DMR-MARC Repeater Database Dump"
+msgstr "Volcado de la base de datos de repetidor DMR-MARC"
+
+#: chirp/ui/mainapp.py:1014 chirp/ui/mainapp.py:1121
+msgid "RepeaterBook Query"
+msgstr "Consultar RepeaterBook"
+
+#: chirp/ui/mainapp.py:1075 chirp/ui/mainapp.py:1181
+msgid "RepeaterBook query failed"
+msgstr "Consulta RepeaterBook fallida"
+
+#: chirp/ui/mainapp.py:1248
+#, python-format
+msgid "Invalid value for %s"
+msgstr "Valor inválido para %s"
-#: ../chirpui/mainapp.py:923
-msgid "With significant contributions by:"
+#: chirp/ui/mainapp.py:1271
+msgid "Query failed"
+msgstr "Consulta fallida"
+
+#: chirp/ui/mainapp.py:1366 chirp/ui/mainapp.py:1431
+msgid "RadioReference.com Query"
+msgstr "Consultar RadioReference.com"
+
+#: chirp/ui/mainapp.py:1502
+msgid "RadioReference.com Province Query"
+msgstr "Consulta provincia RadioReference.com"
+
+#: chirp/ui/mainapp.py:1603
+msgid "With significant contributions from:"
msgstr "Con contribuciones significativas de:"
-#: ../chirpui/mainapp.py:940
+#: chirp/ui/mainapp.py:1639
msgid "Select Columns"
msgstr "Seleccionar columnas"
-#: ../chirpui/mainapp.py:955
+#: chirp/ui/mainapp.py:1656
+#, python-brace-format
msgid "Visible columns for {radio}"
msgstr "Columnas visibles para {radio}"
-#: ../chirpui/mainapp.py:1012
+#: chirp/ui/mainapp.py:1719
msgid "Reporting is disabled"
-msgstr "Informar está deshabilitado"
+msgstr "Reportar está deshabilitado"
-#: ../chirpui/mainapp.py:1013
+#: chirp/ui/mainapp.py:1721
msgid ""
"The reporting feature of CHIRP is designed to help <u>improve quality</u> by "
"allowing the authors to focus on the radio drivers used most often and "
@@ -354,593 +702,634 @@ msgid ""
"\n"
"<b>Are you sure you want to disable this feature?</b>"
msgstr ""
-"La característica de informar de CHIRP está diseñada para ayudar a "
-"<u>mejorar la calidad</u> permitiendo a los autores centrarse en los drivers "
-"de las radios usadas mas frecuentemente y los errores que se experimentan "
-"los usuarios. Los informes no contienen información que identifique al "
-"usuario y solo son usadas para fines estadísticos por los autores. Su "
-"privacidad es extremadamente importante, pero <u>por favor considere dejar "
-"esta característica habilitada para ayudar a hacer CHIRP mejor</u>\n"
+"La función de reportar de CHIRP está diseñada para ayudar a <u>mejorar la "
+"calidad</u> al permitir a los autores enfocarse en los controladores de las "
+"radios usadas mas frecuentemente y errores experimentados por los usuarios. "
+"Los reportes no contienen información de identificación y solo son usados "
+"para propósitos estadísticos por los autores. Tu privacidad es "
+"extremadamente importante, pero <u>¡por favor considera dejar esta función "
+"habilitada para ayudar a hacer a CHIRP mejor!</u>\n"
"\n"
-"<b>¿Seguro que quiere deshabilitar esta caracteristica?</b>"
+"<b>¿Seguro que quieres deshabilitar esta función?</b>"
-#: ../chirpui/mainapp.py:1045
+#: chirp/ui/mainapp.py:1764
msgid ""
"Choose a language or Auto to use the operating system default. You will need "
"to restart the application before the change will take effect"
msgstr ""
-"Elija un idioma o Auto para usar el de por defecto del sistema operativo. "
-"Tendrá que reiniciar la aplicación para que el cambio surta efecto."
+"Elige un lenguaje o Auto para usar el por defecto del sistema operativo. "
+"Tendrás que reiniciar la aplicación antes para que el cambio surta efecto"
+
+#: chirp/ui/mainapp.py:1777
+msgid "Python Modules"
+msgstr "Módulos Python"
+
+#: chirp/ui/mainapp.py:1778
+msgid "Modules"
+msgstr "Modulos"
-#: ../chirpui/mainapp.py:1169
+#: chirp/ui/mainapp.py:1982
msgid "_File"
-msgstr "_Fichero"
+msgstr "_Archivo"
-#: ../chirpui/mainapp.py:1172
-msgid "Open stock config"
-msgstr "Abrir configuración por defecto"
+#: chirp/ui/mainapp.py:1985
+msgid "Open Stock Config"
+msgstr "Abrir configuración original"
-#: ../chirpui/mainapp.py:1173
-msgid "_Recent"
-msgstr "_Reciente"
+#: chirp/ui/mainapp.py:1986
+msgid "Open _Recent"
+msgstr "Abrir _reciente"
-#: ../chirpui/mainapp.py:1178
+#: chirp/ui/mainapp.py:1987
+msgid "Clear Recently Opened"
+msgstr "Limpiar abierto recientemente"
+
+#: chirp/ui/mainapp.py:1991
+msgid "Load Module"
+msgstr "Cargar modulo"
+
+#: chirp/ui/mainapp.py:1994
msgid "_Edit"
msgstr "_Editar"
-#: ../chirpui/mainapp.py:1179
+#: chirp/ui/mainapp.py:1995
msgid "_Cut"
msgstr "_Cortar"
-#: ../chirpui/mainapp.py:1180
+#: chirp/ui/mainapp.py:1996
msgid "_Copy"
msgstr "_Copiar"
-#: ../chirpui/mainapp.py:1181
+#: chirp/ui/mainapp.py:1997
msgid "_Paste"
msgstr "_Pegar"
-#: ../chirpui/mainapp.py:1182
+#: chirp/ui/mainapp.py:1999
msgid "_Delete"
msgstr "_Borrar"
-#: ../chirpui/mainapp.py:1183
+#: chirp/ui/mainapp.py:2000
+msgid "Select _All"
+msgstr "Seleccionar _todo"
+
+#: chirp/ui/mainapp.py:2001
msgid "Move _Up"
-msgstr "Subir"
+msgstr "Mover _arriba"
-#: ../chirpui/mainapp.py:1184
+#: chirp/ui/mainapp.py:2003
msgid "Move Dow_n"
-msgstr "Mover Abaj_o"
+msgstr "Mover abaj_o"
-#: ../chirpui/mainapp.py:1185
+#: chirp/ui/mainapp.py:2005
msgid "E_xchange"
-msgstr "I_ntercambio"
+msgstr "I_ntercambiar"
-#: ../chirpui/mainapp.py:1186
+#: chirp/ui/mainapp.py:2007 chirp/ui/memedit.py:888
+msgid "P_roperties"
+msgstr "P_ropiedades"
+
+#: chirp/ui/mainapp.py:2008
msgid "_View"
msgstr "_Ver"
-#: ../chirpui/mainapp.py:1187
+#: chirp/ui/mainapp.py:2009
msgid "Columns"
msgstr "Columnas"
-#: ../chirpui/mainapp.py:1188
+#: chirp/ui/mainapp.py:2010
msgid "Developer"
msgstr "Desarrollador"
-#: ../chirpui/mainapp.py:1189
-msgid "Show raw memory"
-msgstr "Mostrar memoria raw"
+#: chirp/ui/mainapp.py:2011 chirp/ui/memedit.py:889
+msgid "Show Raw Memory"
+msgstr "Mostrar memoria en bruto"
-#: ../chirpui/mainapp.py:1190
-msgid "Diff raw memories"
-msgstr "Diferencias entre memorias raw"
+#: chirp/ui/mainapp.py:2013 chirp/ui/memedit.py:890
+msgid "Diff Raw Memories"
+msgstr "Diferenciar memorias en bruto"
-#: ../chirpui/mainapp.py:1191
-msgid "Diff tabs"
-msgstr "Pestañas de diferencias"
+#: chirp/ui/mainapp.py:2015
+msgid "Diff Tabs"
+msgstr "Diferenciar pestañas"
-#: ../chirpui/mainapp.py:1192
-msgid "Change language"
-msgstr "Cambiar idioma"
+#: chirp/ui/mainapp.py:2017
+msgid "Change Language"
+msgstr "Cambiar lenguaje"
-#: ../chirpui/mainapp.py:1193
+#: chirp/ui/mainapp.py:2018
msgid "_Radio"
msgstr "_Radio"
-#: ../chirpui/mainapp.py:1194
+#: chirp/ui/mainapp.py:2019
msgid "Download From Radio"
msgstr "Descargar desde radio"
-#: ../chirpui/mainapp.py:1195
+#: chirp/ui/mainapp.py:2021
msgid "Upload To Radio"
msgstr "Subir a radio"
-#: ../chirpui/mainapp.py:1198
-msgid "Import from RFinder"
-msgstr "Importar desde RFinder"
+#: chirp/ui/mainapp.py:2025
+msgid "Import From Data Source"
+msgstr "Importar desde fuente de datos"
-#: ../chirpui/mainapp.py:1199
-msgid "CHIRP Native File"
-msgstr "Fichero CHIRP nativo"
+#: chirp/ui/mainapp.py:2027 chirp/ui/mainapp.py:2041
+msgid "DMR-MARC Repeaters"
+msgstr "Repetidores DMR-MARC"
-#: ../chirpui/mainapp.py:1200
-msgid "CSV File"
-msgstr "Fichero CSV"
+#: chirp/ui/mainapp.py:2028 chirp/ui/mainapp.py:2042
+msgid "RadioReference"
+msgstr "RadioReference"
-#: ../chirpui/mainapp.py:1201
-msgid "Import from RepeaterBook"
-msgstr "Importar desde RepeaterBook"
+#: chirp/ui/mainapp.py:2029 chirp/ui/mainapp.py:2043
+msgid "RadioReference.com US"
+msgstr "RadioReference.com EE.UU"
-#: ../chirpui/mainapp.py:1202
-msgid "Import from stock config"
-msgstr "Importar desde configuración por defecto"
+#: chirp/ui/mainapp.py:2031 chirp/ui/mainapp.py:2045
+msgid "RadioReference.com Canada"
+msgstr "RadioReference.com Canadá"
-#: ../chirpui/mainapp.py:1204
-msgid "Help"
-msgstr "Ayuda"
+#: chirp/ui/mainapp.py:2033 chirp/ui/mainapp.py:2047
+msgid "RFinder"
+msgstr "RFinder"
-#: ../chirpui/mainapp.py:1215
-msgid "Report statistics"
-msgstr "Enviar estadísticas"
+#: chirp/ui/mainapp.py:2034 chirp/ui/mainapp.py:2049
+msgid "RepeaterBook"
+msgstr "RepeaterBook"
-#: ../chirpui/mainapp.py:1216
-msgid "Hide Unused Fields"
-msgstr "Ocultar campos no usados"
+#: chirp/ui/mainapp.py:2035 chirp/ui/mainapp.py:2050
+msgid "RepeaterBook Political Query"
+msgstr "Consulta política de RepeaterBook"
-#: ../chirpui/mainapp.py:1217
-msgid "Automatic Repeater Offset"
-msgstr "Desplazamiento del repetidor automático"
+#: chirp/ui/mainapp.py:2037 chirp/ui/mainapp.py:2052
+msgid "RepeaterBook Proximity Query"
+msgstr "Consulta de proximidad de RepeaterBook"
-#: ../chirpui/mainapp.py:1218
-msgid "Enable Developer Functions"
-msgstr "Habilitar funciones de desarrollador"
+#: chirp/ui/mainapp.py:2039 chirp/ui/mainapp.py:2048
+msgid "przemienniki.net"
+msgstr "przemienniki.net"
-#: ../chirpui/mainapp.py:1352
-msgid "Error reporting is enabled"
-msgstr "Informar de errores está habilitado"
-
-#: ../chirpui/mainapp.py:1355
-msgid ""
-"If you wish to disable this feature you may do so in the <u>Help</u> menu"
-msgstr ""
-"Si quieres deshabilitar esta característica tiene que hacerlo en el menú "
-"<u>Ayuda</u>"
-
-#: ../chirpui/cloneprog.py:43
-msgid "Clone Progress"
-msgstr "Progreso del clonado"
-
-#: ../chirpui/cloneprog.py:46
-msgid "Cloning"
-msgstr "Clonando"
-
-#: ../chirpui/cloneprog.py:55
-msgid "Cancel"
-msgstr "Cancelar"
-
-#: ../chirpui/shiftdialog.py:27
-msgid "Shift"
-msgstr "Desplazamiento"
-
-#: ../chirpui/shiftdialog.py:63
-msgid "Moving {src} to {dst}"
-msgstr "Moviendo {src} a {dst}"
-
-#: ../chirpui/shiftdialog.py:80
-msgid "Looking for a free spot ({number})"
-msgstr "Buscando un hueco libre({number})"
-
-#: ../chirpui/shiftdialog.py:135
-msgid "Moved {count} memories"
-msgstr "Movidas {count} memorias"
-
-#: ../chirpui/clone.py:35
-msgid "{vendor} {model} on {port}"
-msgstr "{vendor} {model} en {port}"
-
-#: ../chirpui/clone.py:100 ../chirpui/clone.py:162
-msgid "Detect"
-msgstr "Detectar"
-
-#: ../chirpui/clone.py:123
-msgid "Port"
-msgstr "Puerto"
-
-#: ../chirpui/clone.py:124
-msgid "Vendor"
-msgstr "Proveedor"
-
-#: ../chirpui/clone.py:125
-msgid "Model"
-msgstr "Modelo"
+#: chirp/ui/mainapp.py:2040
+msgid "Query Data Source"
+msgstr "Consultar fuente de datos"
-#: ../chirpui/clone.py:138
-msgid "Radio"
-msgstr "Radio"
-
-#: ../chirpui/clone.py:166
-msgid "Unable to detect radio on {port}"
-msgstr "No se puede detectar radio en {port}"
-
-#: ../chirpui/clone.py:178
-msgid "Internal error: Unable to upload to {model}"
-msgstr "Error interno: No se ha podido subir a {model}"
-
-#: ../chirpui/clone.py:226
-msgid "Clone failed: {error}"
-msgstr "Clonado fallido: {error}"
-
-#: ../chirpui/dstaredit.py:40
-msgid "Callsign"
-msgstr "Indicativo"
+#: chirp/ui/mainapp.py:2054
+msgid "CHIRP Native File"
+msgstr "Archivo nativo de CHIRP"
-#: ../chirpui/dstaredit.py:124
-msgid "Your callsign"
-msgstr "Tu indicativo"
+#: chirp/ui/mainapp.py:2056
+msgid "CSV File"
+msgstr "Archivo CSV"
-#: ../chirpui/dstaredit.py:132
-msgid "Repeater callsign"
-msgstr "Indicativo del repetidor"
+#: chirp/ui/mainapp.py:2057
+msgid "Import From Stock Config"
+msgstr "Importar desde configuración original"
-#: ../chirpui/dstaredit.py:140
-msgid "My callsign"
-msgstr "Mi indicativ"
+#: chirp/ui/mainapp.py:2059
+msgid "Channel Defaults"
+msgstr "Predeterminados del canal"
-#: ../chirpui/dstaredit.py:170 ../chirpui/memedit.py:1365
-msgid "Downloading URCALL list"
-msgstr "Descargando lista URCALL"
-
-#: ../chirpui/dstaredit.py:174 ../chirpui/memedit.py:1377
-msgid "Downloading RPTCALL list"
-msgstr "Descargando lista RPTCALL"
+#: chirp/ui/mainapp.py:2062
+msgid "Help"
+msgstr "Ayuda"
-#: ../chirpui/dstaredit.py:178
-msgid "Downloading MYCALL list"
-msgstr "Descargando lista MYCALL"
+#: chirp/ui/mainapp.py:2064
+msgid "Get Help Online..."
+msgstr "Obtener ayuda en línea..."
-#: ../chirpui/editorset.py:87
-msgid "Memories"
-msgstr "Memorias"
+#: chirp/ui/mainapp.py:2075
+msgid "Report Statistics"
+msgstr "Reportar estadísticas"
-#: ../chirpui/editorset.py:92
-msgid "D-STAR"
-msgstr "D-STAR"
+#: chirp/ui/mainapp.py:2077
+msgid "Hide Unused Fields"
+msgstr "Ocultar campos no usados"
-#: ../chirpui/editorset.py:98
-msgid "Bank Names"
-msgstr "Nombres de los bancos"
+#: chirp/ui/mainapp.py:2079
+msgid "Smart Tone Modes"
+msgstr "Modos de tono inteligente"
-#: ../chirpui/editorset.py:104
-msgid "Banks"
-msgstr "Bancos"
+#: chirp/ui/mainapp.py:2081
+msgid "Show Information"
+msgstr "Mostrar información"
-#: ../chirpui/editorset.py:222
-msgid "The {vendor} {model} has multiple independent sub-devices"
-msgstr "El {vendor} {model} tiene multiples sub-dispositivos independientes"
+#: chirp/ui/mainapp.py:2083
+msgid "Show Instructions"
+msgstr "Mostrar instrucciones"
-#: ../chirpui/editorset.py:225
-msgid "Choose one to import from:"
-msgstr "Elija uno desde el que importar:"
+#: chirp/ui/mainapp.py:2085
+msgid "Enable Developer Functions"
+msgstr "Habilitar funciones de desarrollador"
-#: ../chirpui/editorset.py:230
-msgid "Cancelled"
-msgstr "Cancelado"
+#: chirp/ui/mainapp.py:2206
+#, python-brace-format
+msgid "A new version of CHIRP is available: {ver}. "
+msgstr "Una nueva versión de CHIRP está disponible: {ver}. "
-#: ../chirpui/editorset.py:235
-msgid "Internal Error"
-msgstr "Error interno"
+#: chirp/ui/mainapp.py:2328
+msgid "Error reporting is enabled"
+msgstr "Reporte de errores está habilitado"
-#: ../chirpui/editorset.py:248
+#: chirp/ui/mainapp.py:2331
msgid ""
-"There were errors while opening {file}. The affected memories will not be "
-"importable!"
+"If you wish to disable this feature you may do so in the <u>Help</u> menu"
msgstr ""
-"Hubo errores mientras se abría {file}. ¡Las memorias afectadas no se podrán "
-"importar!"
-
-#: ../chirpui/editorset.py:260
-msgid "There was an error during import: {error}"
-msgstr "Hubo un error durante la importación: {error}"
+"Si deseas deshabilitar esta función puedes hacerlo en el menú <u>Ayuda</u>"
-#: ../chirpui/editorset.py:270
-msgid "Unsupported file type"
-msgstr "Tipo de fichero no soportado"
-
-#: ../chirpui/editorset.py:286 ../chirpui/editorset.py:301
-msgid "There was an error during export: {error}"
-msgstr "Hubo un error mientras se exportaba: {error}"
+#: chirp/ui/memdetail.py:237
+msgid "General"
+msgstr "General"
-#: ../chirpui/editorset.py:313
-msgid "Priming memory"
-msgstr "Priming memory"
+#: chirp/ui/memdetail.py:279
+msgid "Other"
+msgstr "Otro"
-#: ../chirpui/memedit.py:52
-msgid "Invalid value for this field"
-msgstr "Valor no válido para este campo"
-
-#: ../chirpui/memedit.py:66 ../chirpui/memedit.py:97 ../chirpui/memedit.py:111
-#: ../chirpui/memedit.py:204 ../chirpui/memedit.py:312
-#: ../chirpui/memedit.py:874 ../chirpui/memedit.py:931
-#: ../chirpui/memedit.py:1069 ../chirpui/memedit.py:1133
+#: chirp/ui/memdetail.py:336 chirp/ui/memedit.py:68 chirp/ui/memedit.py:101
+#: chirp/ui/memedit.py:116 chirp/ui/memedit.py:231 chirp/ui/memedit.py:237
+#: chirp/ui/memedit.py:271 chirp/ui/memedit.py:423 chirp/ui/memedit.py:1095
+#: chirp/ui/memedit.py:1156 chirp/ui/memedit.py:1307 chirp/ui/memedit.py:1367
msgid "Tone Mode"
-msgstr "Modo del tono"
-
-#: ../chirpui/memedit.py:67 ../chirpui/memedit.py:87 ../chirpui/memedit.py:103
-#: ../chirpui/memedit.py:214 ../chirpui/memedit.py:218
-#: ../chirpui/memedit.py:220 ../chirpui/memedit.py:310
-#: ../chirpui/memedit.py:875 ../chirpui/memedit.py:928
-#: ../chirpui/memedit.py:1070
+msgstr "Modo de tono"
+
+#: chirp/ui/memdetail.py:338 chirp/ui/memedit.py:69 chirp/ui/memedit.py:90
+#: chirp/ui/memedit.py:107 chirp/ui/memedit.py:166 chirp/ui/memedit.py:167
+#: chirp/ui/memedit.py:256 chirp/ui/memedit.py:286 chirp/ui/memedit.py:293
+#: chirp/ui/memedit.py:298 chirp/ui/memedit.py:306 chirp/ui/memedit.py:347
+#: chirp/ui/memedit.py:421 chirp/ui/memedit.py:1096 chirp/ui/memedit.py:1152
+#: chirp/ui/memedit.py:1308
msgid "Tone"
msgstr "Tono"
-#: ../chirpui/memedit.py:68 ../chirpui/memedit.py:88 ../chirpui/memedit.py:104
-#: ../chirpui/memedit.py:210 ../chirpui/memedit.py:218
-#: ../chirpui/memedit.py:221 ../chirpui/memedit.py:310
-#: ../chirpui/memedit.py:876 ../chirpui/memedit.py:929
-#: ../chirpui/memedit.py:1066
+#: chirp/ui/memdetail.py:340 chirp/ui/memedit.py:70 chirp/ui/memedit.py:91
+#: chirp/ui/memedit.py:108 chirp/ui/memedit.py:260 chirp/ui/memedit.py:279
+#: chirp/ui/memedit.py:294 chirp/ui/memedit.py:299 chirp/ui/memedit.py:310
+#: chirp/ui/memedit.py:348 chirp/ui/memedit.py:421 chirp/ui/memedit.py:1097
+#: chirp/ui/memedit.py:1153 chirp/ui/memedit.py:1304
msgid "ToneSql"
msgstr "ToneSql"
-#: ../chirpui/memedit.py:69 ../chirpui/memedit.py:89 ../chirpui/memedit.py:105
-#: ../chirpui/memedit.py:211 ../chirpui/memedit.py:215
-#: ../chirpui/memedit.py:222 ../chirpui/memedit.py:306
-#: ../chirpui/memedit.py:877 ../chirpui/memedit.py:930
-#: ../chirpui/memedit.py:1059
+#: chirp/ui/memdetail.py:342 chirp/ui/memedit.py:71 chirp/ui/memedit.py:92
+#: chirp/ui/memedit.py:109 chirp/ui/memedit.py:244 chirp/ui/memedit.py:280
+#: chirp/ui/memedit.py:288 chirp/ui/memedit.py:300 chirp/ui/memedit.py:308
+#: chirp/ui/memedit.py:349 chirp/ui/memedit.py:417 chirp/ui/memedit.py:1098
+#: chirp/ui/memedit.py:1154 chirp/ui/memedit.py:1296 chirp/ui/memedit.py:1373
msgid "DTCS Code"
msgstr "Código DTCS"
-#: ../chirpui/memedit.py:70 ../chirpui/memedit.py:90 ../chirpui/memedit.py:106
-#: ../chirpui/memedit.py:212 ../chirpui/memedit.py:216
-#: ../chirpui/memedit.py:223 ../chirpui/memedit.py:878
-#: ../chirpui/memedit.py:933 ../chirpui/memedit.py:1060
+#: chirp/ui/memdetail.py:344
+msgid "RX DTCS Code"
+msgstr "Código RX DTCS"
+
+#: chirp/ui/memdetail.py:346 chirp/ui/memedit.py:73 chirp/ui/memedit.py:94
+#: chirp/ui/memedit.py:111 chirp/ui/memedit.py:252 chirp/ui/memedit.py:282
+#: chirp/ui/memedit.py:290 chirp/ui/memedit.py:302 chirp/ui/memedit.py:314
+#: chirp/ui/memedit.py:351 chirp/ui/memedit.py:1100 chirp/ui/memedit.py:1158
+#: chirp/ui/memedit.py:1298 chirp/ui/memedit.py:1372
msgid "DTCS Pol"
-msgstr "DTCS Pol"
+msgstr "Polaridad DTCS"
-#: ../chirpui/memedit.py:71 ../chirpui/memedit.py:91 ../chirpui/memedit.py:112
-#: ../chirpui/memedit.py:879 ../chirpui/memedit.py:932
-#: ../chirpui/memedit.py:1067 ../chirpui/memedit.py:1134
-msgid "Cross Mode"
+#: chirp/ui/memdetail.py:348
+msgid "Cross mode"
msgstr "Modo cruzado"
-#: ../chirpui/memedit.py:72 ../chirpui/memedit.py:92 ../chirpui/memedit.py:109
-#: ../chirpui/memedit.py:137 ../chirpui/memedit.py:205
-#: ../chirpui/memedit.py:249 ../chirpui/memedit.py:312
-#: ../chirpui/memedit.py:880 ../chirpui/memedit.py:934
-#: ../chirpui/memedit.py:1071 ../chirpui/memedit.py:1144
+#: chirp/ui/memdetail.py:350 chirp/ui/memedit.py:75 chirp/ui/memedit.py:96
+#: chirp/ui/memedit.py:114 chirp/ui/memedit.py:140 chirp/ui/memedit.py:147
+#: chirp/ui/memedit.py:272 chirp/ui/memedit.py:345 chirp/ui/memedit.py:423
+#: chirp/ui/memedit.py:1102 chirp/ui/memedit.py:1159 chirp/ui/memedit.py:1309
+#: chirp/ui/memedit.py:1381
msgid "Duplex"
-msgstr "Duplex"
+msgstr "Dúplex"
-#: ../chirpui/memedit.py:73 ../chirpui/memedit.py:93 ../chirpui/memedit.py:135
-#: ../chirpui/memedit.py:198 ../chirpui/memedit.py:226
-#: ../chirpui/memedit.py:250 ../chirpui/memedit.py:308
-#: ../chirpui/memedit.py:881 ../chirpui/memedit.py:935
-#: ../chirpui/memedit.py:1062
+#: chirp/ui/memdetail.py:352 chirp/ui/memedit.py:76 chirp/ui/memedit.py:97
+#: chirp/ui/memedit.py:145 chirp/ui/memedit.py:218 chirp/ui/memedit.py:317
+#: chirp/ui/memedit.py:346 chirp/ui/memedit.py:419 chirp/ui/memedit.py:1103
+#: chirp/ui/memedit.py:1160 chirp/ui/memedit.py:1300
msgid "Offset"
msgstr "Desplazamiento"
-#: ../chirpui/memedit.py:74 ../chirpui/memedit.py:94 ../chirpui/memedit.py:107
-#: ../chirpui/memedit.py:882 ../chirpui/memedit.py:936
-#: ../chirpui/memedit.py:1061 ../chirpui/memedit.py:1132
-#: ../chirpui/memedit.py:1289 ../chirpui/memedit.py:1307
-#: ../chirpui/memedit.py:1317
+#: chirp/ui/memdetail.py:354 chirp/ui/memedit.py:77 chirp/ui/memedit.py:98
+#: chirp/ui/memedit.py:112 chirp/ui/memedit.py:159 chirp/ui/memedit.py:160
+#: chirp/ui/memedit.py:163 chirp/ui/memedit.py:407 chirp/ui/memedit.py:1104
+#: chirp/ui/memedit.py:1161 chirp/ui/memedit.py:1299 chirp/ui/memedit.py:1366
+#: chirp/ui/memedit.py:1383 chirp/ui/memedit.py:1384 chirp/ui/memedit.py:1564
+#: chirp/ui/memedit.py:1582 chirp/ui/memedit.py:1592
msgid "Mode"
msgstr "Modo"
-#: ../chirpui/memedit.py:75 ../chirpui/memedit.py:95 ../chirpui/memedit.py:108
-#: ../chirpui/memedit.py:296 ../chirpui/memedit.py:883
-#: ../chirpui/memedit.py:937 ../chirpui/memedit.py:1073
-#: ../chirpui/memedit.py:1136 ../chirpui/memedit.py:1140
-msgid "Power"
-msgstr "Potencia"
-
-#: ../chirpui/memedit.py:76 ../chirpui/memedit.py:96 ../chirpui/memedit.py:110
-#: ../chirpui/memedit.py:140 ../chirpui/memedit.py:143
-#: ../chirpui/memedit.py:884 ../chirpui/memedit.py:938
-#: ../chirpui/memedit.py:1064
+#: chirp/ui/memdetail.py:356 chirp/ui/memedit.py:79 chirp/ui/memedit.py:100
+#: chirp/ui/memedit.py:115 chirp/ui/memedit.py:150 chirp/ui/memedit.py:151
+#: chirp/ui/memedit.py:156 chirp/ui/memedit.py:1106 chirp/ui/memedit.py:1163
+#: chirp/ui/memedit.py:1302 chirp/ui/memedit.py:1379
msgid "Tune Step"
-msgstr "Escalón de sintonía"
+msgstr "Paso de sintonización"
-#: ../chirpui/memedit.py:77 ../chirpui/memedit.py:98 ../chirpui/memedit.py:885
-#: ../chirpui/memedit.py:939 ../chirpui/memedit.py:1072
-#: ../chirpui/memedit.py:1135
+#: chirp/ui/memdetail.py:358 chirp/ui/memedit.py:80 chirp/ui/memedit.py:102
+#: chirp/ui/memedit.py:1107 chirp/ui/memedit.py:1164 chirp/ui/memedit.py:1310
+#: chirp/ui/memedit.py:1369
msgid "Skip"
-msgstr "Saltar"
+msgstr "Omitir"
+
+#: chirp/ui/memdetail.py:360 chirp/ui/memedit.py:78 chirp/ui/memedit.py:99
+#: chirp/ui/memedit.py:113 chirp/ui/memedit.py:407 chirp/ui/memedit.py:1105
+#: chirp/ui/memedit.py:1162 chirp/ui/memedit.py:1311 chirp/ui/memedit.py:1370
+#: chirp/ui/memedit.py:1377
+msgid "Power"
+msgstr "Poder"
-#: ../chirpui/memedit.py:175
+#: chirp/ui/memdetail.py:408
+msgid "Memory validation failed:"
+msgstr "Validación de memoria fallida:"
+
+#: chirp/ui/memedit.py:52
+msgid "Invalid value for this field"
+msgstr "Valor invalido para este campo"
+
+#: chirp/ui/memedit.py:72 chirp/ui/memedit.py:93 chirp/ui/memedit.py:110
+#: chirp/ui/memedit.py:248 chirp/ui/memedit.py:281 chirp/ui/memedit.py:289
+#: chirp/ui/memedit.py:296 chirp/ui/memedit.py:301 chirp/ui/memedit.py:312
+#: chirp/ui/memedit.py:350 chirp/ui/memedit.py:417 chirp/ui/memedit.py:1099
+#: chirp/ui/memedit.py:1155 chirp/ui/memedit.py:1297 chirp/ui/memedit.py:1374
+msgid "DTCS Rx Code"
+msgstr "Código DTCS Rx"
+
+#: chirp/ui/memedit.py:74 chirp/ui/memedit.py:95 chirp/ui/memedit.py:117
+#: chirp/ui/memedit.py:232 chirp/ui/memedit.py:242 chirp/ui/memedit.py:264
+#: chirp/ui/memedit.py:273 chirp/ui/memedit.py:283 chirp/ui/memedit.py:291
+#: chirp/ui/memedit.py:295 chirp/ui/memedit.py:303 chirp/ui/memedit.py:352
+#: chirp/ui/memedit.py:1101 chirp/ui/memedit.py:1157 chirp/ui/memedit.py:1305
+#: chirp/ui/memedit.py:1368
+msgid "Cross Mode"
+msgstr "Modo cruzado"
+
+#: chirp/ui/memedit.py:198
+#, python-brace-format
msgid "Erasing memory {loc}"
msgstr "Borrando memoria {loc}"
-#: ../chirpui/memedit.py:236
+#: chirp/ui/memedit.py:327
msgid "Unable to make changes to this model"
msgstr "No se pueden hacer cambios a este modelo"
-#: ../chirpui/memedit.py:241
-msgid "Editing new item, taking defaults"
-msgstr "Editando elemento nuevo, tomando valores por defecto"
-
-#: ../chirpui/memedit.py:257
-msgid "Bad value for {col}: {val}"
-msgstr "Valor incorrecto para {col}: {val}"
-
-#: ../chirpui/memedit.py:281
+#: chirp/ui/memedit.py:390
msgid "Error setting memory"
-msgstr "Error fijando memoria"
+msgstr "Error estableciendo memoria"
-#: ../chirpui/memedit.py:289 ../chirpui/memedit.py:356
-#: ../chirpui/memedit.py:1272
+#: chirp/ui/memedit.py:400 chirp/ui/memedit.py:466 chirp/ui/memedit.py:742
+#: chirp/ui/memedit.py:765 chirp/ui/memedit.py:1541
+#, python-brace-format
msgid "Writing memory {number}"
msgstr "Escribiendo memoria {number}"
-#: ../chirpui/memedit.py:361
+#: chirp/ui/memedit.py:471
msgid ""
"This operation requires moving all subsequent channels by one spot until an "
"empty location is reached. This can take a LONG time. Are you sure you "
"want to do this?"
msgstr ""
-"Esta operación requiere mover los subsecuentes canales un hueco hasta "
-"encontrar una localización vacía. Esto puede tardar MUCHO tiempo. ¿Está "
-"seguro de hacerlo?"
+"Esta operación requiere mover los canales subsecuentes un lugar hasta "
+"encontrar una localización vacía. Esto puede tomar MUCHO tiempo. ¿Estás "
+"seguro de querer hacerlo?"
-#: ../chirpui/memedit.py:387
+#: chirp/ui/memedit.py:495
+#, python-brace-format
msgid "Adding memory {number}"
-msgstr "Añadiendo memoria {number}"
+msgstr "Agregando memoria {number}"
-#: ../chirpui/memedit.py:400 ../chirpui/memedit.py:913
+#: chirp/ui/memedit.py:508 chirp/ui/memedit.py:1137
+#, python-brace-format
msgid "Erasing memory {number}"
msgstr "Borrando memoria {number}"
-#: ../chirpui/memedit.py:409 ../chirpui/memedit.py:518
-#: ../chirpui/memedit.py:564 ../chirpui/memedit.py:569
-#: ../chirpui/memedit.py:856 ../chirpui/memedit.py:1166
+#: chirp/ui/memedit.py:517 chirp/ui/memedit.py:625 chirp/ui/memedit.py:672
+#: chirp/ui/memedit.py:677 chirp/ui/memedit.py:1066 chirp/ui/memedit.py:1399
+#, python-brace-format
msgid "Getting memory {number}"
msgstr "Obteniendo memoria {number}"
-#: ../chirpui/memedit.py:497 ../chirpui/memedit.py:508
-#: ../chirpui/memedit.py:556
+#: chirp/ui/memedit.py:604 chirp/ui/memedit.py:615 chirp/ui/memedit.py:664
+#, python-brace-format
msgid "Moving memory from {old} to {new}"
-msgstr "Moviendo memoria de {old} a {new}"
+msgstr "Moviendo memoria desde {old} a {new}"
-#: ../chirpui/memedit.py:578
+#: chirp/ui/memedit.py:686
+#, python-brace-format
msgid "Raw memory {number}"
-msgstr "Memoria raw {number}"
+msgstr "Memoria en bruto {number}"
-#: ../chirpui/memedit.py:582 ../chirpui/memedit.py:610
-#: ../chirpui/memedit.py:615
+#: chirp/ui/memedit.py:690 chirp/ui/memedit.py:718 chirp/ui/memedit.py:723
+#, python-brace-format
msgid "Getting raw memory {number}"
-msgstr "Obteniendo memoria raw {number}"
+msgstr "Obteniendo memoria en bruto {number}"
-#: ../chirpui/memedit.py:587
+#: chirp/ui/memedit.py:695
msgid "You can only diff two memories!"
-msgstr "¡Solo puede ver diferencias entre dos memorias!"
+msgstr "¡Solo puedes diferenciar dos memorias!"
-#: ../chirpui/memedit.py:598
+#: chirp/ui/memedit.py:706
+#, python-brace-format
msgid "Memory {number}"
msgstr "Memoria {number}"
-#: ../chirpui/memedit.py:604
+#: chirp/ui/memedit.py:712
+#, python-brace-format
msgid "Diff of {a} and {b}"
-msgstr "Diferencia entre {a} y {b}"
+msgstr "Diferencia de {a} y {b}"
+
+#: chirp/ui/memedit.py:746
+#, python-brace-format
+msgid "Getting original memory {number}"
+msgstr "Obteniendo memoria original {number}"
-#: ../chirpui/memedit.py:628
+#: chirp/ui/memedit.py:784
msgid "Memories must be contiguous"
-msgstr "Las memorias deben ser continuas"
+msgstr "Memorias deben ser contiguas"
-#: ../chirpui/memedit.py:700
+#: chirp/ui/memedit.py:875
+msgid "Cut"
+msgstr "Cortar"
+
+#: chirp/ui/memedit.py:876
+msgid "Copy"
+msgstr "Copiar"
+
+#: chirp/ui/memedit.py:877
+msgid "Paste"
+msgstr "Pegar"
+
+#: chirp/ui/memedit.py:878
+msgid "Select All"
+msgstr "Seleccionar todo"
+
+#: chirp/ui/memedit.py:879
msgid "Insert row above"
msgstr "Insertar fila encima"
-#: ../chirpui/memedit.py:701
+#: chirp/ui/memedit.py:880
msgid "Insert row below"
msgstr "Insertar fila debajo"
-#: ../chirpui/memedit.py:702
+#: chirp/ui/memedit.py:881
msgid "Delete"
msgstr "Borrar"
-#: ../chirpui/memedit.py:702
-msgid "Delete all"
-msgstr "Borrar todo"
+#: chirp/ui/memedit.py:882
+msgid "this memory"
+msgstr "esta memoria"
+
+#: chirp/ui/memedit.py:882
+msgid "these memories"
+msgstr "estas memorias"
-#: ../chirpui/memedit.py:703
-msgid "Delete (and shift up)"
-msgstr "Borrar (y desplazar hacia arriba)"
+#: chirp/ui/memedit.py:883
+msgid "...and shift block up"
+msgstr "...y desplazar bloque hacia arriba"
-#: ../chirpui/memedit.py:704
+#: chirp/ui/memedit.py:884
+msgid "...and shift all memories up"
+msgstr "...y desplazar todas las memorias hacia arriba"
+
+#: chirp/ui/memedit.py:885
msgid "Move up"
-msgstr "Subir"
+msgstr "Mover arriba"
-#: ../chirpui/memedit.py:705
+#: chirp/ui/memedit.py:886
msgid "Move down"
-msgstr "Bajar"
+msgstr "Mover abajo"
-#: ../chirpui/memedit.py:706
+#: chirp/ui/memedit.py:887
msgid "Exchange memories"
msgstr "Intercambiar memorias"
-#: ../chirpui/memedit.py:707
-msgid "Cut"
-msgstr "Cortar"
-
-#: ../chirpui/memedit.py:708
-msgid "Copy"
-msgstr "Copiar"
-
-#: ../chirpui/memedit.py:709
-msgid "Paste"
-msgstr "Pegar"
-
-#: ../chirpui/memedit.py:710
-msgid "Show Raw Memory"
-msgstr "Mostrar memoria raw"
-
-#: ../chirpui/memedit.py:711
-msgid "Diff Raw Memories"
-msgstr "Diferencias entre memorias raw"
-
-#: ../chirpui/memedit.py:835
+#: chirp/ui/memedit.py:1053
+#, python-brace-format
msgid "Internal Error: Column {name} not found"
-msgstr "Error interno: La columna {name} no se encuentra"
-
-#: ../chirpui/memedit.py:863
-msgid "Getting channel {chan}"
-msgstr "Obteniendo canal {chan}"
+msgstr "Error interno: Columna {name} no encontrada"
-#: ../chirpui/memedit.py:952
+#: chirp/ui/memedit.py:1177
+#, python-brace-format
msgid "Internal Error: Invalid limit {number}"
msgstr "Error interno: límite {number} invalido"
-#: ../chirpui/memedit.py:962
-msgid "Memory range:"
+#: chirp/ui/memedit.py:1188
+msgid "Memory Range:"
msgstr "Rango de memoria:"
-#: ../chirpui/memedit.py:989
-msgid "Go"
-msgstr "Ir"
+#: chirp/ui/memedit.py:1215
+msgid "Refresh"
+msgstr "Actualizar"
-#: ../chirpui/memedit.py:1012
+#: chirp/ui/memedit.py:1238
msgid "Special Channels"
msgstr "Canales especiales"
-#: ../chirpui/memedit.py:1019
+#: chirp/ui/memedit.py:1246
msgid "Show Empty"
-msgstr "Mostrar vacíos"
+msgstr "Mostrar vacío"
-#: ../chirpui/memedit.py:1198
+#: chirp/ui/memedit.py:1258
+msgid "Properties"
+msgstr "Propiedades"
+
+#: chirp/ui/memedit.py:1433
+#, python-brace-format
msgid "Cutting memory {number}"
msgstr "Cortando memoria {number}"
-#: ../chirpui/memedit.py:1232
+#: chirp/ui/memedit.py:1465
+#, python-brace-format
+msgid ""
+"Unable to paste {src} memories into {dst} rows. Increase the memory bounds "
+"or show empty memories."
+msgstr ""
+"No se pueden pegar {src} memorias en {dst} filas. Incrementa los límites de "
+"la memoria o muestra memorias vacías."
+
+#: chirp/ui/memedit.py:1481
+msgid "Yes to All"
+msgstr "Sí a todo"
+
+#: chirp/ui/memedit.py:1483
msgid "Overwrite?"
msgstr "¿Sobrescribir?"
-#: ../chirpui/memedit.py:1237
+#: chirp/ui/memedit.py:1492
+#, python-brace-format
msgid "Overwrite location {number}?"
msgstr "¿Sobrescribir localización {number}?"
-#: ../chirpui/memedit.py:1254
+#: chirp/ui/memedit.py:1519
msgid "Incompatible Memory"
msgstr "Memoria incompatible"
-#: ../chirpui/memedit.py:1257
+#: chirp/ui/memedit.py:1525
+#, python-brace-format
msgid "Pasted memory {number} is not compatible with this radio because:"
-msgstr "Memoria {number} pegada no es compatible con esta radio porque:"
+msgstr "Memoria pegada {number} no es compatible con esta radio porque:"
-#: ../chirpui/memedit.py:1309 ../chirpui/memedit.py:1324
+#: chirp/ui/memedit.py:1584 chirp/ui/memedit.py:1599
msgid "URCALL"
msgstr "URCALL"
-#: ../chirpui/memedit.py:1309 ../chirpui/memedit.py:1325
+#: chirp/ui/memedit.py:1584 chirp/ui/memedit.py:1600
msgid "RPT1CALL"
msgstr "RPT1CALL"
-#: ../chirpui/memedit.py:1309 ../chirpui/memedit.py:1326
+#: chirp/ui/memedit.py:1584 chirp/ui/memedit.py:1601
msgid "RPT2CALL"
msgstr "RPT2CALL"
-#: ../chirpui/memedit.py:1310 ../chirpui/memedit.py:1327
+#: chirp/ui/memedit.py:1585 chirp/ui/memedit.py:1602
msgid "Digital Code"
msgstr "Código digital"
-#~ msgid "%i errors during open, check the debug log for details"
-#~ msgstr "%i errors during open, check the debug log for details"
+#: chirp/ui/settingsedit.py:82
+#, python-format
+msgid "Error in setting value: %s"
+msgstr "Error en valor de ajuste: %s"
+
+#: chirp/ui/settingsedit.py:114
+#, python-format
+msgid "Invalid setting value: %s"
+msgstr "Valor de ajuste inválido: %s"
+
+#: chirp/ui/settingsedit.py:175
+msgid "Enabled"
+msgstr "Habilitado"
+
+#: chirp/ui/shiftdialog.py:31
+msgid "Shift"
+msgstr "Desplazamiento"
+
+#: chirp/ui/shiftdialog.py:65
+#, python-brace-format
+msgid "Moving {src} to {dst}"
+msgstr "Moviendo {src} a {dst}"
+
+#: chirp/ui/shiftdialog.py:85
+#, python-brace-format
+msgid "Looking for a free spot ({number})"
+msgstr "Buscando un lugar libre ({number})"
+
+#: chirp/ui/shiftdialog.py:98
+msgid "No space to insert a row"
+msgstr "No hay espacio para insertar una fila"
+
+#: chirp/ui/shiftdialog.py:146
+#, python-brace-format
+msgid "Moved {count} memories"
+msgstr "Movidas {count} memorias"
+
+#: share/chirp.desktop:5
+msgid "CHIRP"
+msgstr "CHIRP"
+
+#: share/chirp.desktop:6
+msgid "Radio Programming Tool"
+msgstr "Herramienta de programación de radio"
+
+#: share/chirp.desktop:7
+msgid "Program amateur radios"
+msgstr "Programa radioaficionados"
+
+#: share/chirp.desktop:13
+msgid "Hamradio;Programming;Handheld;Radio;Amateur;Programmer"
+msgstr "Radioafición;Programación;Portátil;Radio;Aficionado;Programador"
diff --git a/locale/tr_TR.po b/locale/tr_TR.po
new file mode 100644
index 0000000..b183300
--- /dev/null
+++ b/locale/tr_TR.po
@@ -0,0 +1,2220 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: CHIRP\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: 2022-09-25 01:05+0300\n"
+"Last-Translator: Abdullah YILMAZ (TA1AUB) <h.abdullahyilmaz@hotmail.com>\n"
+"Language-Team: TURKISH\n"
+"Language: tr\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: Poedit 3.1.1\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+
+msgid "...and shift all memories up"
+msgstr "... ve tüm kayıtları yukarı kaydır"
+
+msgid "...and shift block up"
+msgstr "...ve bloğu yukarı kaydır"
+
+msgid "A new version of CHIRP is available: "
+msgstr "CHIRP'in yeni bir sürümü mevcut: "
+
+msgid "A new version of CHIRP is available: {ver}. "
+msgstr "CHIRP'in yeni bir sürümü mevcut: {ver}. "
+
+msgid "About"
+msgstr "Hakkında"
+
+msgid "Adding memory {number}"
+msgstr "{number} kaydı ekleniyor"
+
+msgid "Adjust New Location"
+msgstr "Yeni Konumu Ayarla"
+
+msgid "All"
+msgstr "Tümü"
+
+msgid "All files"
+msgstr "Tüm dosyalar"
+
+msgid "An error has occurred"
+msgstr "Bir hata oluştu"
+
+msgid "Auto"
+msgstr "Otomatik"
+
+msgid "Automatic Repeater Offset"
+msgstr "Otomatik Tekrarlama Ofseti"
+
+msgid "Bad value for {col}: {val}"
+msgstr "{col} için kötü değer: {val}"
+
+msgid "Band plans define default channel settings for frequencies in a region. Choose a band plan or None for completely manual channel settings."
+msgstr "Bant planları, bir bölgedeki frekanslar için varsayılan kanal ayarlarını tanımlar. Tamamen manuel kanal ayarları için bir bant planını veya Hiçbirini seçin."
+
+msgid "Bank"
+msgstr "Banka"
+
+msgid "Bank Names"
+msgstr "Banka İsimleri"
+
+msgid "Banks"
+msgstr "Bankalar"
+
+msgid "Browser"
+msgstr "Tarayıcı"
+
+msgid "CHIRP"
+msgstr "CHIRP"
+
+msgid "CHIRP Documentation"
+msgstr "CHIRP Belgeleri"
+
+msgid "CHIRP Files"
+msgstr "CHIRP Dosyaları"
+
+msgid "CHIRP Native File"
+msgstr "CHIRP Yerel Dosyası"
+
+msgid "CHIRP Radio Images"
+msgstr "CHIRP Telsiz İmajları"
+
+msgid "CSV File"
+msgstr "CSV Dosyası"
+
+msgid "CSV Files"
+msgstr "CSV Dosyası"
+
+msgid "Callsign"
+msgstr "Çağrı işareti"
+
+msgid "Cancel"
+msgstr "İptal"
+
+msgid "Cancelled"
+msgstr "İptal edildi"
+
+msgid "Cannot be imported because"
+msgstr "İçe aktarılamıyor çünkü"
+
+msgid "Change Language"
+msgstr "Dili Değiştir (Change Language)"
+
+msgid "Change language"
+msgstr "Dili değiştir (Change language)"
+
+msgid "Channel Defaults"
+msgstr "Kanal Varsayılanları"
+
+msgid "Channel defaults"
+msgstr "Kanal varsayılanları"
+
+msgid "Check this to change the {name} value"
+msgstr "{name} değerini değiştirmek için bunu kontrol edin"
+
+msgid "Choose Language"
+msgstr "Dil Seçin"
+
+msgid "Choose a language or Auto to use the operating system default. You will need to restart the application before the change will take effect"
+msgstr "Bir dil seçin veya işletim sistemi varsayılanını kullanmak için otomatiği seçin. Değişikliğin uygulanması için uygulamayı yeniden başlatmanız gerekir"
+
+msgid "Choose one to import from:"
+msgstr "İçe aktarılacak bir şey seçin:"
+
+msgid "Clear Recently Opened"
+msgstr "Son Açılanları Temizle"
+
+msgid "Clone Progress"
+msgstr "Klon İlerlemesi"
+
+msgid "Clone completed, checking for spurious bytes"
+msgstr "Klon tamamlandı, sahte baytlar kontrol ediliyor"
+
+msgid "Clone failed: {error}"
+msgstr "Klon başarısız oldu: {error}"
+
+msgid "Cloning"
+msgstr "Klonlanıyor"
+
+msgid "Cloning from radio"
+msgstr "Telsizden klonlama"
+
+msgid "Cloning to radio"
+msgstr "Telsize klonlama"
+
+msgid "Close"
+msgstr "Kapat"
+
+msgid "Columns"
+msgstr "Sütunlar"
+
+msgid "Comment"
+msgstr "Yorum"
+
+msgid "Completed"
+msgstr "Tamamlandı"
+
+msgid "Confirm overwrites"
+msgstr "Üzerine yazmayı onayla"
+
+msgid "Copy"
+msgstr "Kopyala"
+
+msgid "Cross Mode"
+msgstr "Çapraz Mod"
+
+msgid "Cross mode"
+msgstr "Çapraz mod"
+
+msgid "Cut"
+msgstr "Kes"
+
+msgid "Cutting memory {number}"
+msgstr "{number} kaydı kesiliyor"
+
+msgid "D-STAR"
+msgstr "Takas"
+
+msgid "DAT Files"
+msgstr "DAT Dosyaları"
+
+msgid "DMR-MARC Repeater Database Dump"
+msgstr "DMR-MARC Tekrarlayıcı Veritabanı Dökümü"
+
+msgid "DMR-MARC Repeaters"
+msgstr "DMR-MARC Tekrarlayıcılar"
+
+msgid "DTCS Code"
+msgstr "DTCS Kodu"
+
+msgid "DTCS Pol"
+msgstr "DTCS Pol"
+
+msgid "DTCS Rx Code"
+msgstr "DTCS Rx Kodu"
+
+msgid "Delete"
+msgstr "Sil"
+
+msgid "Delete (and shift up)"
+msgstr "Sil (ve yukarı kaydır)"
+
+msgid "Delete all"
+msgstr "Hepsini sil"
+
+msgid "Details"
+msgstr "Detaylar"
+
+msgid "Detect"
+msgstr "Tespit etme"
+
+msgid "Developer"
+msgstr "Geliştirici"
+
+msgid "Diff Raw Memories"
+msgstr "Farklı Ham kayıtlar"
+
+msgid "Diff Tabs"
+msgstr "Fark Sekmeleri"
+
+msgid "Diff of {a} and {b}"
+msgstr "{a} ve {b} arasındaki fark"
+
+msgid "Diff raw memories"
+msgstr "Farklı ham kayıtlar"
+
+msgid "Diff tabs"
+msgstr "Fark sekmeleri"
+
+msgid "Digital Code"
+msgstr "Dijital Kod"
+
+msgid "Do not show this next time"
+msgstr "Bunu bir dahaki sefere gösterme"
+
+msgid "Documentation"
+msgstr "Belgeler"
+
+msgid ""
+"Documentation for CHIRP, including FAQs, and help for common problems is available on the CHIRP web site, please go to\n"
+"\n"
+"<a href=\"http://chirp.danplanet.com/projects/chirp/wiki/Documentation\">http://chirp.danplanet.com/projects/chirp/wiki/Documentation</a>\n"
+msgstr ""
+"CHIRP için SSS'leri de içeren dokümantasyon ve yaygın sorunlara yönelik yardım CHIRP web sitesinde mevcuttur, lütfen şu adrese gidin\n"
+"\n"
+"<a href=\"http://chirp.danplanet.com/projects/chirp/wiki/Documentation\">http://chirp.danplanet.com/projects/chirp/wiki/Documentation</a>\n"
+
+msgid "Don't show information for any radio again"
+msgstr "Bir daha hiçbir telsiz için bilgi gösterme"
+
+msgid "Don't show instructions for any radio again"
+msgstr "Bir daha hiçbir telsiz için talimatları gösterme"
+
+msgid "Don't show this again"
+msgstr "Bunu bir daha gösterme"
+
+msgid "Download From Radio"
+msgstr "Telsizden İndir"
+
+msgid "Downloading MYCALL list"
+msgstr "MYCALL (çağrı listem) indiriliyor"
+
+msgid "Downloading RPTCALL list"
+msgstr "RPTCAL (tekrarlanan çağrı) listesini indiriliyor"
+
+msgid "Downloading URCALL list"
+msgstr "URCALL (sizin çağrı) listesi indiriliyor"
+
+msgid "Duplex"
+msgstr "Duplex"
+
+msgid "EVE"
+msgstr "EVE"
+
+msgid "EVE Files (VX5)"
+msgstr "EVE Dosyaları (VX5)"
+
+msgid "E_xchange"
+msgstr "T_akas"
+
+msgid "Edit"
+msgstr "Düzenle"
+
+msgid "Edit Memory #{num}"
+msgstr "Kaydı Düzenle #{num}"
+
+msgid "Edit Memory#{num}"
+msgstr "Kaydı Düzenle#{num}"
+
+msgid "Edit Multiple Memories"
+msgstr "Birden Fazla Kaydı Düzenle"
+
+msgid "Editing new item, taking defaults"
+msgstr "Yeni öğe düzenleniyor, varsayılanlar alınıyor"
+
+msgid "Enable Developer Functions"
+msgstr "Geliştirici İşlevlerini Etkinleştir"
+
+msgid "Enabled"
+msgstr "Etkin"
+
+msgid "Erasing memory {loc}"
+msgstr "Kayıt siliniyor {loc}"
+
+msgid "Erasing memory {number}"
+msgstr "Kayıt siliniyor {number}"
+
+msgid "Error importing memories:"
+msgstr "Kayıt içe aktarılırken hata oluştu:"
+
+msgid "Error in setting value: %s"
+msgstr "Değer ayarında hata: %s"
+
+msgid "Error reporting is enabled"
+msgstr "Hata raporlama etkinleştirildi"
+
+msgid "Error setting memory"
+msgstr "Kayıt ayarında hata"
+
+msgid "Exchange memories"
+msgstr "Kayıtları değiştir"
+
+msgid "Export"
+msgstr "Dışa Aktar"
+
+msgid "Export To File"
+msgstr "Dosyaya Aktar"
+
+msgid "File Exists"
+msgstr "Dosya Mevcut"
+
+msgid "File is modified, save changes before closing?"
+msgstr "Dosya değiştirildi, kapatmadan önce değişiklikler kaydedilsin mi?"
+
+msgid "Frequency"
+msgstr "Frekans"
+
+msgid "From"
+msgstr "Dan"
+
+msgid "General"
+msgstr "Genel"
+
+msgid "Get Help Online..."
+msgstr "Çevrimiçi Yardım Alın..."
+
+msgid "Getting %s information"
+msgstr "%s bilgisi alınıyor"
+
+msgid "Getting bank for memory {num}"
+msgstr "{num} kaydı için banka alınıyor"
+
+msgid "Getting bank information"
+msgstr "Banka bilgileri alınıyor"
+
+msgid "Getting bank information for memory {num}"
+msgstr "{num} kaydı için banka bilgileri alınıyor"
+
+msgid "Getting channel {chan}"
+msgstr "{chan} kanalı alınıyor"
+
+msgid "Getting memory {number}"
+msgstr "{number} kaydı alınıyor"
+
+msgid "Getting memory {num}"
+msgstr "{num} kaydı alınıyor"
+
+msgid "Getting original memory {number}"
+msgstr "Orijinal {number} kaydı alınıyor"
+
+msgid "Getting raw memory {number}"
+msgstr "{number} ham kaydı alınıyor"
+
+msgid "Getting {type} for memory {num}"
+msgstr "{num} kaydı için {type} alınıyor"
+
+msgid "Getting {type} information for memory {num}"
+msgstr "{num} kaydı için {type} bilgisi alınıyor"
+
+msgid "Go"
+msgstr "Git"
+
+msgid "Hamradio;Programming;Handheld;Radio;Amateur;Programmer"
+msgstr "AmatörTelsiz;Programlama;ElTipi;Telsiz;Amatör;Programcı"
+
+msgid "Help"
+msgstr "Yardım"
+
+msgid "Hide Unused Fields"
+msgstr "Kullanılmayan Alanları Gizle"
+
+msgid "ICF Files"
+msgstr "ICF Dosyaları"
+
+msgid "ICF files cannot be edited, only displayed or imported into another file. Open in read-only mode?"
+msgstr "ICF dosyaları düzenlenemez, yalnızca görüntülenebilir veya başka bir dosyaya aktarılamaz. Salt okunur modda açılsın mı?"
+
+msgid "If you wish to disable this feature you may do so in the <u>Help</u> menu"
+msgstr "Bu özelliği devre dışı bırakmak isterseniz, bunu <u>Yardım</u> menüsünden yapabilirsiniz"
+
+msgid "Import"
+msgstr "İçe Aktar"
+
+msgid "Import From Data Source"
+msgstr "Veri Kaynağından İçe Aktar"
+
+msgid "Import From File"
+msgstr "Dosyadan İçe Aktar"
+
+msgid "Import From Stock Config"
+msgstr "Stok Yapılandırmasından İçe Aktar"
+
+msgid "Import from RFinder"
+msgstr "RFinder'dan içe aktar"
+
+msgid "Import from data source"
+msgstr "Veri kaynağından içe aktar"
+
+msgid "Import from stock config"
+msgstr "Stok yapılandırmasından içe aktar"
+
+msgid "Import stock configuration {name}"
+msgstr "{name} stok yapılandırmasını içe aktar"
+
+msgid "Importing bank information"
+msgstr "Banka bilgileri içe aktarılıyor"
+
+msgid "Incompatible Memory"
+msgstr "Uyumsuz Kayıt"
+
+msgid "Index"
+msgstr "Dizin"
+
+msgid "Insert row above"
+msgstr "Yukarıya satır ekle"
+
+msgid "Insert row below"
+msgstr "Aşağıya satır ekle"
+
+msgid "Internal Error"
+msgstr "İç Hata"
+
+msgid "Internal Error: Column {name} not found"
+msgstr "Dahili Hata: Sütun {name} bulunamadı"
+
+msgid "Internal Error: Invalid limit {number}"
+msgstr "Dahili Hata: Geçersiz limit {number}"
+
+msgid "Internal error: Unable to upload to {model}"
+msgstr "Dahili hata: {model}'e yüklenemiyor"
+
+msgid "Invalid setting value: %s"
+msgstr "Geçersiz ayar değeri: %s"
+
+msgid "Invalid value for %s"
+msgstr "%s için geçersiz değer"
+
+msgid "Invalid value for this field"
+msgstr "Bu alan için geçersiz değer"
+
+msgid "Invalid value. Must be an integer."
+msgstr "Geçersiz değer. Tam sayı olmak zorunda."
+
+msgid "Inverse"
+msgstr "Ters"
+
+msgid "Kenwood HMK Files"
+msgstr "Kenwood HMK Dosyaları"
+
+msgid "Kenwood ITM Files"
+msgstr "Kenwood ITM Dosyaları"
+
+msgid "Load Module"
+msgstr "Modülü Yükle"
+
+msgid "Loc"
+msgstr "Konum"
+
+msgid "Location memory will be imported into"
+msgstr "Konum kaydı şuraya aktarılacak"
+
+msgid "Location of memory in the file being imported"
+msgstr "İçe aktarılan dosyadaki kaydın konumu"
+
+msgid "Location {number} is already being imported"
+msgstr "{number} konumu zaten içe aktarılıyor"
+
+msgid "Location {number} is already being imported. Choose another valü for 'New Location' before selection 'Import'"
+msgstr "{number} konumu zaten içe aktarılıyor. 'İçe Aktar' seçiminden önce 'Yeni Konum' için başka bir değer seçin"
+
+msgid "Location {number} is already being imported. Choose another value for 'New Location' before selection 'Import'"
+msgstr "{number} konumu zaten içe aktarılıyor. 'İçe Aktar' seçiminden önce 'Yeni Konum' için başka bir değer seçin"
+
+msgid "Looking for a free spot ({number})"
+msgstr "Boş yer arıyorum ({number})"
+
+msgid "Memories"
+msgstr "Kayıtlar"
+
+msgid "Memories (%(variant)s)"
+msgstr "Kayıtlar (%(variant)s)"
+
+msgid "Memories must be contiguous"
+msgstr "Kayıtlar bitişik olmalı"
+
+msgid "Memory Range:"
+msgstr "Kayıt Aralığı:"
+
+msgid "Memory range:"
+msgstr "Kayıt aralığı:"
+
+msgid "Memory validation failed:"
+msgstr "Kayıt doğrulaması başarısız oldu:"
+
+msgid "Memory {number}"
+msgstr "Kayıt {number}"
+
+msgid "Memory {num} not in bank {bank}"
+msgstr "{num} kaydı {bank} bankasında değil"
+
+msgid "Mode"
+msgstr "Mod"
+
+msgid "Model"
+msgstr "Model"
+
+msgid "Modules"
+msgstr "Modüller"
+
+msgid "Move Dow_n"
+msgstr "Aşağı Taş_ı"
+
+msgid "Move _Up"
+msgstr "Yukarı _Taşı"
+
+msgid "Move down"
+msgstr "Aşağı taşı"
+
+msgid "Move up"
+msgstr "Yukarı taşı"
+
+msgid "Moved {count} memories"
+msgstr "{count} kaydı taşındı"
+
+msgid "Moving memory from {old} to {new}"
+msgstr "Kayıt {old} olandan {new} olana taşınıyor..."
+
+msgid "Moving {src} to {dst}"
+msgstr "{src}, {dst}'e taşınıyor"
+
+msgid "My callsign"
+msgstr "Benim çağrı işaretim"
+
+msgid "Name"
+msgstr "İsim"
+
+msgid "New"
+msgstr "Yeni"
+
+msgid "No space to insert a row"
+msgstr "Satır eklemek için boşluk yok"
+
+msgid "None"
+msgstr "Hiçbiri"
+
+msgid "Note:"
+msgstr "Not:"
+
+msgid "Offset"
+msgstr "Ofset"
+
+msgid "Open"
+msgstr "Aç"
+
+msgid "Open Recent"
+msgstr "Son Kullanılanları Aç"
+
+msgid "Open Stock Config"
+msgstr "Stok Yapılandırmasını Aç"
+
+msgid "Open _Recent"
+msgstr "Son _Kullanılanları Aç"
+
+msgid "Open recent file"
+msgstr "Son dosyayı aç"
+
+msgid "Open recent file {name}"
+msgstr "{name} geçmiş dosyasını aç"
+
+msgid "Open stock config"
+msgstr "Stok yapılandırmasını aç"
+
+msgid "Open stock configuration {name}"
+msgstr "{name} stok yapılandırmasını aç"
+
+msgid "Options"
+msgstr "Seçenekler"
+
+msgid "Other"
+msgstr "Diğer"
+
+msgid "Overwrite"
+msgstr "Üzerine yaz"
+
+msgid "Overwrite location {number}?"
+msgstr "{number} konumunun üzerine yazılsın mı?"
+
+msgid "Overwrite?"
+msgstr "Üzerine yazılsın mı?"
+
+msgid "P_roperties"
+msgstr "Ö_zellikler"
+
+msgid "Paste"
+msgstr "Yapıştır"
+
+msgid "Pasted memory {number} is not compatible with this radio because:"
+msgstr "Yapıştırılan {number} kaydı bu telsizle uyumlu değil çünkü:"
+
+msgid "Port"
+msgstr "Port"
+
+msgid "Power"
+msgstr "Güç"
+
+msgid "Preparing memory list..."
+msgstr "Kayıt listesi hazırlanıyor..."
+
+msgid "Priming memory"
+msgstr "Kayıt hazırlanıyor"
+
+msgid "Proceed with experimental driver?"
+msgstr "Deneysel sürücü ile devam edilsin mi?"
+
+msgid "Proceed?"
+msgstr "Devam et?"
+
+msgid "Program amateur radios"
+msgstr "Amatör telsizleri programla"
+
+msgid "Properties"
+msgstr "Özellikler"
+
+msgid "Python Modules"
+msgstr "Python Modülleri"
+
+msgid "Query Data Source"
+msgstr "Veri Kaynağını Sorgula"
+
+msgid "Query data source"
+msgstr "Veri kaynağını sorgula"
+
+msgid "Query failed"
+msgstr "Sorgu başarısız"
+
+msgid "Quit"
+msgstr "Çıkış"
+
+msgid "RFinder"
+msgstr "RFinder"
+
+msgid "RPT1CALL"
+msgstr "RFinder"
+
+msgid "RPT2CALL"
+msgstr "RPT2CALL"
+
+msgid "RX DTCS Code"
+msgstr "RX DTCS Kodu"
+
+msgid "Radio"
+msgstr "Telsiz"
+
+msgid "Radio Programming Tool"
+msgstr "Telsiz Programlama Aracı"
+
+msgid "Radio did not ack block %i"
+msgstr "Telsiz %i bloğunu onaylamadı"
+
+msgid "Radio sent data after the last awaited block, this happens when the selected model is a non-US but the radio is a US one. Please choose the correct model and try again."
+msgstr "Telsiz, beklenen son bloktan sonra veri gönderdi, bu, seçilen model ABD dışındaysa gerçekleşir ama telsiz bir ABD telsizi. Lütfen doğru modeli seçin ve tekrar deneyin."
+
+msgid "RadioReference"
+msgstr "RadioReference"
+
+msgid "RadioReference.com"
+msgstr "RadioReference.com"
+
+msgid "RadioReference.com Canada"
+msgstr "RadioReference.com Kanada"
+
+msgid "RadioReference.com Province Query"
+msgstr "RadioReference.com İl Sorgusu"
+
+msgid "RadioReference.com Query"
+msgstr "RadioReference.com Sorgusu"
+
+msgid "RadioReference.com US"
+msgstr "RadioReference.com ABD"
+
+msgid "Raw memory {number}"
+msgstr "Ham kayıt {number}"
+
+msgid "Refresh"
+msgstr "Yenile"
+
+msgid "Repeater callsign"
+msgstr "Tekrarlayıcı çağrı işareti"
+
+msgid "RepeaterBook"
+msgstr "RepeaterBook"
+
+msgid "RepeaterBook Political Query"
+msgstr "RepeaterBook Siyasi Sorgusu"
+
+msgid "RepeaterBook Proximity Query"
+msgstr "RepeaterBook Yakınlık Sorgusu"
+
+msgid "RepeaterBook Query"
+msgstr "RepeaterBook Sorgusu"
+
+msgid "RepeaterBook query failed"
+msgstr "RepeaterBook sorgusu başarısız oldu"
+
+msgid "Report Statistics"
+msgstr "İstatistikleri Rapor Et"
+
+msgid "Report statistics"
+msgstr "İstatistikleri rapor et"
+
+msgid "Reporting is disabled"
+msgstr "Raporlama devre dışı"
+
+msgid "Retrieving %s information"
+msgstr "%s bilgisi alınıyor"
+
+msgid "Retrieving bank information"
+msgstr "Banka bilgileri alınıyor"
+
+msgid "Reverse"
+msgstr "Tersi"
+
+msgid "Save"
+msgstr "Kaydet"
+
+msgid "Save As"
+msgstr "Farklı Kaydet"
+
+msgid "Save Changes?"
+msgstr "Değişiklikleri Kaydet?"
+
+msgid "Select"
+msgstr "Seç"
+
+msgid "Select All"
+msgstr "Tümünü seç"
+
+msgid "Select Columns"
+msgstr "Sütunları Seç"
+
+msgid "Select _All"
+msgstr "Tümünü _Seç"
+
+msgid "Setting index for memory {num}"
+msgstr "{num} kaydı için ayar dizini"
+
+msgid "Setting memory {number}"
+msgstr "Kaydın ayarlanması {sayı}"
+
+msgid "Setting name on %s"
+msgstr "%s üzerinde ad ayarlanıyor"
+
+msgid "Setting name on bank"
+msgstr "Bankada isim ayarlama"
+
+msgid "Settings"
+msgstr "Ayarlar"
+
+msgid "Shift"
+msgstr "Shift"
+
+msgid "Show Empty"
+msgstr "Boş Kayıtlar"
+
+msgid "Show Information"
+msgstr "Bilgi göster"
+
+msgid "Show Instructions"
+msgstr "Talimatları Göster"
+
+msgid "Show Raw Memory"
+msgstr "Ham Kaydı Göster"
+
+msgid "Show raw memory"
+msgstr "Ham kaydı göster"
+
+msgid "Skip"
+msgstr "Atla"
+
+msgid "Smart Tone Modes"
+msgstr "Akıllı Ton Modları"
+
+msgid "Special Channels"
+msgstr "Özel Kanallar"
+
+msgid "The file {name} already exists. Do you want to overwrite it?"
+msgstr "{name} dosyası zaten var. Üzerine yazmak istiyor musunuz?"
+
+msgid ""
+"The reporting feature of CHIRP is designed to help <u>improve quality</u> by allowing the authors to focus on the radio drivers used most often and errors experienced by the users. The reports contain no "
+"identifying information and are used only for statistical purposes by the authors. Your privacy is extremely important, but <u>please consider leaving this feature enabled to help make CHIRP better!</u>\n"
+"\n"
+"<b>Are you sure you want to disable this feature?</b>"
+msgstr ""
+"CHIRP'in raporlama özelliği, yazarların en sık kullanılan telsiz sürücülerine ve kullanıcıların yaşadığı hatalara odaklanmasını sağlayarak <u>kaliteyi iyileştirmeye</u> yardımcı olmak için tasarlanmıştır. Raporlar "
+"tanımlayıcı bilgi içermez ve yazarlar tarafından yalnızca istatistiksel amaçlarla kullanılır. Gizliliğiniz son derece önemlidir, ancak <u>CHIRP'i daha iyi hale getirmeye yardımcı olmak için lütfen bu özelliği "
+"etkinleştirmeyi düşünün!</u>\n"
+"\n"
+"<b>Bu özelliği devre dışı bırakmak istediğinizden emin misiniz?</b>"
+
+msgid "The {vendor} {model} has multiple independent sub-devices"
+msgstr "{vendor} {model} birden çok bağımsız alt cihaza sahip"
+
+msgid ""
+"The {vendor} {model} operates in <b>live mode</b>. This means that any changes you make are immediately sent to the radio. Because of this, you cannot perform the <u>Save</u> or <u>Upload</u> operations. If you "
+"wish to edit the contents offline, please <u>Export</u> to a CSV file, using the <b>File menu</b>."
+msgstr ""
+"{vendor} {model} <b>canlı modda</b> çalışır. Bu, yaptığınız tüm değişikliklerin anında telsize gönderileceği anlamına gelir. Bu nedenle, <u>Kaydet</u> veya <u>Yükle</u> işlemlerini gerçekleştiremezsiniz. İçeriği "
+"çevrimdışı düzenlemek istiyorsanız, lütfen <b>Dosya menüsünü</b> kullanarak bir CSV dosyasına <u>Dışa aktarın</u>."
+
+msgid "There was an error during export: {error}"
+msgstr "Dışa aktarma sırasında bir hata oluştu: {error}"
+
+msgid "There was an error during import: {error}"
+msgstr "İçe aktarma sırasında bir hata oluştu: {error}"
+
+msgid "There was an error opening {fname}: {error}"
+msgstr "{fname} açılırken bir hata oluştu: {error}"
+
+msgid "There were errors while opening {file}. The affected memories will not be importable!"
+msgstr "{file} açılırken hatalar oluştu. Etkilenen kayıtlar içe aktarılmayacak!"
+
+msgid ""
+"This is experimental support for BJ-9900 which is still under development.\n"
+"Please ensure you have a good backup with OEM software.\n"
+"Also please send in bug and enhancement requests!\n"
+"You have been warned. Proceed at your own risk!"
+msgstr ""
+"Bu, halen geliştirilmekte olan BJ-9900 için deneysel destektir.\n"
+"Lütfen OEM yazılımıyla iyi bir yedeklemeniz olduğundan emin olun.\n"
+"Ayrıca lütfen hata raporu ve geliştirme istekleri gönderin!\n"
+"Uyarıldınız. Kendi sorumluluğunuzda ilerleyin!"
+
+msgid "This operation requires moving all subsequent channels by one spot until an empty location is reached. This can take a LONG time. Are you sure you want to do this?"
+msgstr "Bu işlem, boş bir konuma ulaşılana kadar sonraki tüm kanalların bir noktada taşınmasını gerektirir. Bu UZUN zaman alabilir. Bunu yapmak istediğinden emin misin?"
+
+msgid "This radio's driver is experimental. Do you want to proceed?"
+msgstr "Bu telsizin sürücüsü deneyseldir. Devam etmek istiyor musunuz?"
+
+msgid "To"
+msgstr "İle"
+
+msgid "Tone"
+msgstr "Ton"
+
+msgid "Tone Mode"
+msgstr "Ton Modu"
+
+msgid "ToneSql"
+msgstr "ToneSql"
+
+msgid "Travel Plus Files"
+msgstr "Seyahat Artı Dosyaları"
+
+msgid "Tune Step"
+msgstr "Adımı Ayarla"
+
+msgid "URCALL"
+msgstr "URCALL"
+
+msgid "Unable to detect radio on {port}"
+msgstr "{port} üzerinde telsiz algılanamadı"
+
+msgid "Unable to make changes to this model"
+msgstr "Bu modelde değişiklik yapılamıyor"
+
+msgid "Unable to open this image. It was generated with a newer version of CHIRP and thus may be for a radio model that is not supported by this version. Please update to the latest version of CHIRP and try again."
+msgstr "Bu imaj açılamıyor. CHIRP'in daha yeni bir sürümüyle oluşturulmuş ve bu nedenle bu sürüm tarafından desteklenmeyen bir telsiz modeli için olabilir. Lütfen en son CHIRP sürümüne güncelleyin ve tekrar deneyin."
+
+msgid "Unable to open this image: unsupported model"
+msgstr "Bu imaj açılamıyor: desteklenmeyen model"
+
+msgid "Unable to paste {src} memories into {dst} rows. Increase the memory bounds or show empty memories."
+msgstr "{src} kayıtları {dst} satırlarına yapıştırılamıyor. Kayıt sınırlarını artırın veya boş kayıtları gösterin."
+
+msgid "Unable to read last block. This often happens when the selected model is US but the radio is a non-US one (or widebanded). Please choose the correct model and try again."
+msgstr "Son blok okunamıyor. Bu genellikle seçilen model ABD olduğunda olur ama telsiz ABD dışı bir telsizdir (veya geniş bantlıdır). Lütfen doğru modeli seçin ve tekrar deneyin."
+
+msgid "Unsupported file type"
+msgstr "Desteklenmeyen dosya türü"
+
+msgid "Untitled"
+msgstr "Başlıksız"
+
+msgid "Updating RPTCALL list"
+msgstr "RPTCALL listesi güncelleniyor"
+
+msgid "Updating URCALL list"
+msgstr "URCALL listesi güncelleniyor"
+
+msgid "Updating bank index for memory {num}"
+msgstr "{num} kaydı için banka dizini güncelleniyor"
+
+msgid "Updating bank information for memory {num}"
+msgstr "{num} kaydı için banka bilgileri güncelleniyor"
+
+msgid "Updating mapping information for memory {num}"
+msgstr "{num} kaydı için eşleme bilgileri güncelleniyor"
+
+msgid "Updating {type} index for memory {num}"
+msgstr "{num} kayıt için {type} dizini güncelleniyor"
+
+msgid "Upload To Radio"
+msgstr "Telsize Yükle"
+
+msgid "VX5 Commander"
+msgstr "VX5 Commander"
+
+msgid "VX5 Commander Files"
+msgstr "VX5 Commander Dosyaları"
+
+msgid "VX6 Commander"
+msgstr "VX6 Commander"
+
+msgid "VX6 Commander Files"
+msgstr "VX6 Commander Dosyaları"
+
+msgid "VX7 Commander"
+msgstr "VX7 Commander"
+
+msgid "VX7 Commander Files"
+msgstr "VX7 Commander Dosyaları"
+
+msgid "Vendor"
+msgstr "Tedarikçi"
+
+msgid "Visible columns for {radio}"
+msgstr "{radio} için görünür sütunlar"
+
+msgid "With significant contributions by:"
+msgstr "Önemli katkılarıyla:"
+
+msgid "With significant contributions from:"
+msgstr "Önemli katkılarla:"
+
+msgid "Writing memory {number}"
+msgstr "{number} kaydı yazılıyor"
+
+msgid "Yes to All"
+msgstr "Hepsine evet"
+
+msgid "You can only diff two memories!"
+msgstr "Sadece iki kaydı birbirinden ayırabilirsin!"
+
+msgid "Your callsign"
+msgstr "Çağrı işaretiniz"
+
+msgid "_Copy"
+msgstr "_Kopyala"
+
+msgid "_Cut"
+msgstr "_Kes"
+
+msgid "_Delete"
+msgstr "_Sil"
+
+msgid "_Edit"
+msgstr "_Düzen"
+
+msgid "_File"
+msgstr "_Dosya"
+
+msgid "_Paste"
+msgstr "_Yapıştır"
+
+msgid "_Radio"
+msgstr "_Telsiz"
+
+msgid "_Recent"
+msgstr "_Geçmiş"
+
+msgid "_View"
+msgstr "_Görünüm"
+
+msgid "idle"
+msgstr "boşta"
+
+msgid "przemienniki.net"
+msgstr "przemienniki.net"
+
+msgid "these memories"
+msgstr "bu kayıtları"
+
+msgid "this memory"
+msgstr "bu kaydı"
+
+msgid "{bank} is full"
+msgstr "{bank} dolu"
+
+msgid "{information}"
+msgstr "{information}"
+
+msgid "{instructions}"
+msgstr "{instructions}"
+
+msgid "{name} Information"
+msgstr "{name} Bilgi"
+
+msgid "{name} Instructions"
+msgstr "{name} Talimatlar"
+
+msgid "{num} errors during open:"
+msgstr "açma sırasında {num} hatalar:"
+
+msgid "{vendor} {model} image file"
+msgstr "{vendor} {model} imaj dosyası"
+
+msgid "{vendor} {model} on {port}"
+msgstr "{vendor} {model} üzerinde {port}"
+
+msgid "Memory Properties"
+msgstr "Kayıt özellikleri"
+
+msgid "Yes"
+msgstr "Evet"
+
+msgid "No"
+msgstr "Hayır"
+
+msgid "Ok"
+msgstr "Tamam"
+
+msgid "OK"
+msgstr "TAMAM"
+
+msgid "Off"
+msgstr "Kapalı"
+
+msgid "Both"
+msgstr "İkisi de"
+
+msgid "High"
+msgstr "Yüksek"
+
+msgid "Low"
+msgstr "Düşük"
+
+msgid "Basic Settings"
+msgstr "Temel Ayarlar"
+
+msgid "Advanced Settings"
+msgstr "Gelişmiş Ayarlar"
+
+msgid "Other Settings"
+msgstr "Diğer ayarlar"
+
+msgid "Work Mode Settings"
+msgstr "Çalışma Modu Ayarları"
+
+msgid "FM Radio Preset"
+msgstr "FM Radyo Ön Ayarı"
+
+msgid "DTMF Settings"
+msgstr "DTMF Ayarları"
+
+msgid "Service Settings"
+msgstr "Servis Ayarları"
+
+msgid ""
+"A new version of CHIRP is available: {ver}. It is recommended that you upgrade as soon as possible. Please go to: \r\n"
+"\r\n"
+"<a href=\"http://chirp.danplanet.com\">http://chirp.danplanet.com</a>"
+msgstr ""
+"CHIRP'in yeni bir sürümü mevcut: {ver}. En kısa sürede yükseltmeniz önerilir. Lütfen git:\n"
+"\n"
+"<a href=\"http://chirp.danplanet.com\">http://chirp.danplanet.com</a>"
+
+msgid "Escape"
+msgstr "Çıkış"
+
+msgid "Icon %s not found"
+msgstr "%s simgesi bulunamadı"
+
+msgid "Closing %i"
+msgstr "%i kapatılıyor"
+
+msgid "Manually selected %s"
+msgstr "Manuel olarak seçildi %s"
+
+msgid "Server reports version %s is available"
+msgstr "Sunucu raporları sürümü %s mevcut"
+
+#: ../chirpdrivers/alinco.py:624 ../chirpdrivers/alinco.py:634
+msgid ""
+"1. Ensure your firmware version is 4_10 or higher\n"
+"2. Turn radio off\n"
+"3. Connect your interface cable\n"
+"4. Turn radio on\n"
+"5. Press and release PTT 3 times while holding MONI key\n"
+"6. Supported baud rates: 57600 (default) and 19200\n"
+" (rotate dial while holding MONI to change)\n"
+"7. Click OK\n"
+msgstr ""
+"1. Donanım yazılımı sürümünüzün 4_10 veya üzeri olduğundan emin olun\n"
+"2. Telsizi kapatın\n"
+"3. Arayüz kablonuzu bağlayın\n"
+"4. Telsizi açın\n"
+"5. MONI tuşunu basılı tutarken PTT'ye 3 kez basın ve bırakın\n"
+"6. Desteklenen baud hızları: 57600 (varsayılan) ve 19200\n"
+" (değiştirmek için MONI'ye basılı tutarken kadranı çevirin)\n"
+"7. TAMAM'a tıklayın\n"
+
+#: ../chirpdrivers/baofeng_wp970i.py:324 ../chirpdrivers/gmrsuv1.py:394 ../chirpdrivers/gmrsv2.py:373 ../chirpdrivers/mursv1.py:345 ../chirpdrivers/tdxone_tdq8a.py:457 ../chirpdrivers/uv5x3.py:420
+#: ../chirpdrivers/uv6r.py:344 ../chirpdrivers/vgc.py:592
+msgid ""
+"Follow these instructions to download your info:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the download of your radio data\n"
+msgstr ""
+"Bilgilerinizi indirmek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin indirilmesini gerçekleştirin\n"
+
+#: ../chirpdrivers/baofeng_wp970i.py:332 ../chirpdrivers/gmrsuv1.py:403 ../chirpdrivers/gmrsv2.py:381 ../chirpdrivers/lt725uv.py:519 ../chirpdrivers/mursv1.py:353 ../chirpdrivers/tdxone_tdq8a.py:465
+#: ../chirpdrivers/uv5x3.py:428 ../chirpdrivers/uv6r.py:352
+msgid ""
+"Follow this instructions to upload your info:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the upload of your radio data\n"
+msgstr ""
+"Bilgilerinizi yüklemek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin yüklemesini gerçekleştirin\n"
+
+#: ../chirpdrivers/bf-t1.py:482 ../chirpdrivers/btech.py:679
+msgid ""
+"Follow these instructions to download your info:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the download of your radio data\n"
+"\n"
+msgstr ""
+"Bilgilerinizi indirmek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin indirilmesini gerçekleştirin\n"
+"\n"
+
+#: ../chirpdrivers/bf-t1.py:491 ../chirpdrivers/btech.py:688
+msgid ""
+"Follow these instructions to upload your info:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the upload of your radio data\n"
+"\n"
+msgstr ""
+"Bilgilerinizi yüklemek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin yüklenmesini gerçekleştirin\n"
+"\n"
+
+#: ../chirpdrivers/bj9900.py:105
+msgid ""
+"1. Turn radio off.\n"
+"2. Remove front head.\n"
+"3. Connect data cable to radio, use the same connector where\n"
+" head was connected to, <b>not the mic connector</b>.\n"
+"4. Click OK."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Ön başlığı çıkarın.\n"
+"3. Veri kablosunu telsize bağlayın, \n"
+" <b>mikrofon konektörüne değil</b> kafanın bağlı olduğu konektörü kullanın.\n"
+"4. TAMAM'a tıklayın."
+
+#: ../chirpdrivers/fd268.py:309../chirpdrivers/fd268.py:318
+msgid ""
+"This radio has a tricky way of enter into program mode,\n"
+"even the original software has a few tries to get inside.\n"
+"\n"
+"I will try 8 times (most of the time ~3 will doit) and this\n"
+"can take a few seconds, if don't work, try again a few times.\n"
+"\n"
+"If you can get into it, please check the radio and cable."
+msgstr ""
+"Bu telsizin program moduna girmenin zor bir yolu var,\n"
+"orijinal yazılım ile bile girmek için birkaç deneme yapmak gerekir.\n"
+"\n"
+"8 kez deneyeceğim (çoğu zaman ~3 de işe yarar) ve bu\n"
+"birkaç saniye sürebilir, işe yaramazsa birkaç kez tekrar deneyin.\n"
+"\n"
+"İşe yaramazsa, lütfen telsizi ve kabloyu kontrol edin."
+
+#: ../chirpdrivers/ft1d.py:649
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Press and hold in the [F] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [BAND] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Telsizi açarken [F] tuşunu basılı tutun\n"
+" (\"CLONE\" ekranda görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [BAND] tuşuna basın."
+
+#: ../chirpdrivers/ft1d.py:656
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Press and hold in the [F] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. Press the [Dx] key (\"-WAIT-\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Telsizi açarken [F] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. [Dx] tuşuna basın (ekranda \"-WAIT-\" görünecektir)."
+
+#: ../chirpdrivers/ft2d.py:85
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Press and hold [DISP] key while turning on radio\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK here in chirp</b>,\n"
+" press the [Send] screen button."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Telsizi açarken [DISP] tuşunu basılı tutun\n"
+" (\"CLONE\" ekranda görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>,\n"
+" [Gönder] ekran tuşuna basın."
+
+#: ../chirpdrivers/ft2d.py:92
+msgid ""
+" 1. Turn radio off.\n"
+" 2. Connect cable to DATA terminal.\n"
+" 3. Press and hold in [DISP] key while turning on radio\n"
+" (\"CLONE\" will appear on radio LCD).\n"
+" 4. Press [RECEIVE] screen button\n"
+" (\"-WAIT-\" will appear on radio LCD).\n"
+"5. Finally, press OK button below."
+msgstr ""
+" 1. Telsizi kapatın.\n"
+" 2. Kabloyu DATA terminaline bağlayın.\n"
+" 3. Telsizi açarken [DISP] tuşunu basılı tutun\n"
+" (telsiz LCD'sinde \"CLONE\" görünecektir).\n"
+" 4. [RECEIVE] ekran tuşuna basın\n"
+" (telsiz LCD'sinde \"-WAIT-\" görünecektir).\n"
+"5. Son olarak aşağıdaki OK tuşuna basın."
+
+#: ../chirpdrivers/ft4.py:675
+msgid ""
+"1. Connect programming cable to MIC jack.\n"
+"2. Press OK."
+msgstr ""
+"1. Programlama kablosunu MIC jakına bağlayın.\n"
+"2. TAMAM'a basın."
+
+#: ../chirpdrivers/ft50.py:195
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold [PTT] &amp; Knob while turning the\n"
+" radio on.\n"
+"4. <b>After clicking OK</b>, press the [PTT] switch to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [PTT] &amp; tuşuna basın.\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imaj göndermek\n"
+" için [PTT] tuşuna basın."
+
+#: ../chirpdrivers/ft50.py:201
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold [PTT] &amp; Knob while turning the\n"
+" radio on.\n"
+"4. Press the [MONI] switch (\"WAIT\" will appear on the LCD).\n"
+"5. Press OK."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [PTT] &amp; tuşuna basın.\n"
+"4. [MONI] tuşuna basın (ekranda \"WAIT\" görünecektir).\n"
+"5. TAMAM'a basın."
+
+#: ../chirpdrivers/ft60.py:355
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [MONI] switch while turning the\n"
+" radio on.\n"
+"4. Rotate the DIAL job to select \"F8 CLONE\".\n"
+"5. Press the [F/W] key momentarily.\n"
+"6. <b>After clicking OK</b>, hold the [PTT] switch\n"
+" for one second to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [PTT] &amp; tuşuna basın.\n"
+"3. Telsizi açarken [MONI] tuşunu basılı tutun.\n"
+"4. \"F8 CLONE\" öğesini seçmek için KADRANI çevirin.\n"
+"5. Bir an için [F/W] tuşuna basın.\n"
+"6. <b>TAMAM'ı tıkladıktan sonra</b>, imaj göndermek için [PTT] tuşunu bir saniye basılı tutun."
+
+#: ../chirpdrivers/ft60.py:365
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [MONI] switch while turning the\n"
+" radio on.\n"
+"4. Rotate the DIAL job to select \"F8 CLONE\".\n"
+"5. Press the [F/W] key momentarily.\n"
+"6. Press the [MONI] switch (\"--RX--\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [MONI] tuşunu basılı tutun.\n"
+"4. \"F8 CLONE\" öğesini seçmek için KADRANI çevirin.\n"
+"5. Bir an için [F/W] tuşuna basın.\n"
+"6. [MONI] tuşuna basın (ekranda \"--RX--\" görünecektir)."
+
+#: ../chirpdrivers/ft70.py:
+msgid ""
+"1. Turn radio on.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Unclip battery.\n"
+"4. Press and hold in the [AMS] key and power key while clipping the battery back in\n"
+"(\"ADMS\" will appear on the display).\n"
+"5. <b>After clicking OK</b>, press the [BAND] key."
+msgstr ""
+"1. Telsizi açın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Pilin klipsini açın.\n"
+"4. Pili tekrar yerine takarken [AMS] tuşunu ve güç tuşunu basılı tutun.\n"
+"(ekranda \"ADMS\" görünecektir).\n"
+"5. <b>TAMAM'ı tıkladıktan sonra</b> [BAND] tuşuna basın."
+
+#: ../chirpdrivers/ft70.py:545
+msgid ""
+"1. Turn radio on.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Unclip battery.\n"
+"4. Press and hold in the [AMS] key and power key while clipping the battery back in\n"
+"(\"ADMS\" will appear on the display).\n"
+"5. Press the [MODE] key (\"-WAIT-\" will appear on the LCD). <b>Then click OK</b>"
+msgstr ""
+"1. Telsizi açın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Pilin klipsini açın.\n"
+"4. Pili tekrar yerine takarken [AMS] tuşunu ve güç tuşunu basılı tutun.\n"
+"(ekranda \"ADMS\" görünecektir).\n"
+"5. [MODE] tuşuna basın (ekranda \"-WAIT-\" görünecektir). <b>Ardından TAMAM'ı tıklayın</b>"
+
+#: ../chirpdrivers/ft90.py:196
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect mic and hold [ACC] on mic while powering on.\n"
+" (\"CLONE\" will appear on the display)\n"
+"3. Replace mic with PC programming cable.\n"
+"4. <b>After clicking OK</b>, press the [SET] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Mikrofonu bağlayın ve açarken mikrofondaki [ACC] tuşunu basılı tutun.\n"
+" (\"CLONE\" ekranda görünecektir)\n"
+"3. Mikrofonu PC programlama kablosuyla değiştirin.\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [SET] tuşuna basın."
+
+#: ../chirpdrivers/ft90.py:202
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect mic and hold [ACC] on mic while powering on.\n"
+" (\"CLONE\" will appear on the display)\n"
+"3. Replace mic with PC programming cable.\n"
+"4. Press the [DISP/SS] key\n"
+" (\"R\" will appear on the lower left of LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Mikrofonu bağlayın ve açarken mikrofondaki [ACC] tuşunu basılı tutun.\n"
+" (\"CLONE\" ekranda görünecektir)\n"
+"3. Mikrofonu PC programlama kablosuyla değiştirin.\n"
+"4. [DISP/SS] tuşuna basın\n"
+" (LCD'nin sol alt köşesinde \"R\" görünecektir)."
+
+#: ../chirpdrivers/ft450d.py:387
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to ACC jack.\n"
+"3. Press and hold in the [MODE &lt;] and [MODE &gt;] keys while\n"
+" turning the radio on (\"CLONE MODE\" will appear on the\n"
+" display).\n"
+"4. <b>After clicking OK</b> here, press the [C.S.] key to\n"
+" send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu ACC jakına bağlayın.\n"
+"3. Telsizi açarken [MODE &lt;] ve [MODE &gt;] tuşlarını basılı tutun \n"
+" (ekranda \"KLON MODU\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için\n"
+" [C.S.] tuşuna basın."
+
+#: ../chirpdrivers/ft450d.py:395
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to ACC jack.\n"
+"3. Press and hold in the [MODE &lt;] and [MODE &gt;] keys while\n"
+" turning the radio on (\"CLONE MODE\" will appear on the\n"
+" display).\n"
+"4. Click OK here.\n"
+" (\"Receiving\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu ACC jakına bağlayın.\n"
+"3. Telsizi açarken [MODE &lt;] ve [MODE &gt;] tuşlarını basılı tutun (\"ekranda KLON MODU\" görünecektir).\n"
+"4. Burada TAMAM'ı tıklayın.\n"
+" (ekranda \"Alınıyor\" görünecektir)."
+
+#: ../chirpdrivers/ft817.py:280
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to ACC jack.\n"
+"3. Press and hold in the [MODE &lt;] and [MODE &gt;] keys while\n"
+" turning the radio on (\"CLONE MODE\" will appear on the\n"
+" display).\n"
+"4. <b>After clicking OK</b>, press the [A] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu ACC jakına bağlayın.\n"
+"3. Telsizi açarken [MODE &lt;] ve [MODE &gt;] tuşlarını\n"
+" basılı tutun (\"ekranda KLON MODU\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için\n"
+" [A] tuşuna basın."
+
+#: ../chirpdrivers/ft817.py:287
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to ACC jack.\n"
+"3. Press and hold in the [MODE &lt;] and [MODE &gt;] keys while\n"
+" turning the radio on (\"CLONE MODE\" will appear on the\n"
+" display).\n"
+"4. Press the [C] key (\"RX\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu ACC jakına bağlayın.\n"
+"3. Telsizi açarken [MODE &lt;] ve [MODE &gt;] tuşlarını basılı tutun (\"ekranda KLON MODU\" görünecektir).\n"
+"4. [C] tuşuna basın (ekranda \"RX\" görünecektir)."
+
+#: ../chirpdrivers/ft857.py:441
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to CAT/LINEAR jack.\n"
+"3. Press and hold in the [MODE &lt;] and [MODE &gt;] keys while\n"
+" turning the radio on (\"CLONE MODE\" will appear on the\n"
+" display).\n"
+"4. <b>After clicking OK</b>,\n"
+" press the [C](SEND) key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu CAT/LINEAR jakına bağlayın.\n"
+"3. Telsizi açarken [MODE &lt;] ve [MODE &gt;] tuşlarını basılı tutun (ekranda \"KLON MODU\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [C](GÖNDER) tuşuna basın."
+
+#: ../chirpdrivers/ft857.py:449
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to ACC jack.\n"
+"3. Press and hold in the [MODE &lt;] and [MODE &gt;] keys while\n"
+" turning the radio on (\"CLONE MODE\" will appear on the\n"
+" display).\n"
+"4. Press the [A](RCV) key (\"receiving\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu ACC jakına bağlayın.\n"
+"3. Telsizi açarken [MODE &lt;] ve [MODE &gt;] tuşlarını basılı tutun (ekranda \"KLON MODU\" görünecektir).\n"
+"4. [A](RCV) tuşuna basın (ekranda \"alıyor\" görünecektir)."
+
+#: ../chirpdrivers/ft1500m.py:96
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic jack.\n"
+"3. Press and hold in the [MHz], [LOW], and [D/MR] keys\n"
+" while turning the radio on.\n"
+"4. <b>After clicking OK</b>, press the [MHz(SET)] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mikrofon jakına bağlayın.\n"
+"3. Telsizi açarken [MHz], [LOW] ve [D/MR] tuşlarına basılı tutun\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [MHz(SET)] tuşuna basın."
+
+#: ../chirpdrivers/ft1500m.py:102
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic jack.\n"
+"3. Press and hold in the [MHz], [LOW], and [D/MR] keys\n"
+" while turning the radio on.\n"
+"4. Press the [D/MR(MW)] key (\"--WAIT--\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mikrofon jakına bağlayın.\n"
+"3. Telsizi açarken [MHz], [LOW] ve [D/MR] tuşlarını basılı tutun.\n"
+"4. [D/MR(MW)] tuşuna basın (ekranda \"--WAIT--\" görünecektir)."
+
+#: ../chirpdrivers/ft1802.py:96
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic jack.\n"
+"3. Press and hold in the [LOW(A/N)] key while turning the radio on.\n"
+"4. <b>After clicking OK</b>, press the [MHz(SET)] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mikrofon jakına bağlayın.\n"
+"3. Telsizi açarken [LOW(A/N)] tuşunu basılı tutun.\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [MHz(SET)] tuşuna basın."
+
+#: ../chirpdrivers/ft1802.py:101
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic jack.\n"
+"3. Press and hold in the [LOW(A/N)] key while turning the radio on.\n"
+"4. Press the [D/MR(MW)] key (\"--WAIT--\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mikrofon jakına bağlayın.\n"
+"3. Telsizi açarken [LOW(A/N)] tuşunu basılı tutun.\n"
+"4. [D/MR(MW)] tuşuna basın (ekranda \"--WAIT--\" görünecektir)."
+
+#: ../chirpdrivers/ft2900.py:1227
+msgid ""
+"1. Turn Radio off.\n"
+"2. Connect data cable.\n"
+"3. While holding \"A/N LOW\" button, turn radio on.\n"
+"4. <b>After clicking OK</b>, press \"SET MHz\" to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Veri kablosunu bağlayın.\n"
+"3. \"A/N LOW\" tuşunu basılı tutarken telsizi açın.\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için \"SET MHz\"e basın."
+
+#: ../chirpdrivers/ft2900.py:1232
+msgid ""
+"1. Turn Radio off.\n"
+"2. Connect data cable.\n"
+"3. While holding \"A/N LOW\" button, turn radio on.\n"
+"4. Press \"MW D/MR\" to receive image.\n"
+"5. Make sure display says \"-WAIT-\" (see note below if not)\n"
+"6. Click OK to dismiss this dialog and start transfer.\n"
+"\n"
+"Note: if you don't see \"-WAIT-\" at step 5, try cycling\n"
+" power and pressing and holding red \"*L\" button to unlock\n"
+" radio, then start back at step 1."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Veri kablosunu bağlayın.\n"
+"3. \"A/N LOW\" tuşunu basılı tutarken telsizi açın.\n"
+"4. İmajı almak için \"MW D/MR\" tuşuna basın.\n"
+"5. Ekranda \"-WAIT-\" yazdığından emin olun (değilse aşağıdaki nota bakın)\n"
+"6. Bu iletişim kutusunu kapatmak ve aktarımı başlatmak için TAMAM'a tıklayın.\n"
+"\n"
+"Not: 5. adımda \"-WAIT-\" öğesini görmüyorsanız, gücü kapatıp açmayı\n"
+" ve telsizin kilidini açmak için kırmızı \"*L\" tuşunu basılı tutmayı deneyin,\n"
+" ardından 1. adımdan başlayın."
+
+#: ../chirpdrivers/ft7100.py:1122
+msgid ""
+"1. Turn Radio off.\n"
+"2. Connect data cable.\n"
+"3. While holding \"TONE\" and \"REV\" buttons, turn radio on.\n"
+"4. <b>After clicking OK</b>, press \"TONE\" to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Veri kablosunu bağlayın.\n"
+"3. \"TONE\" ve \"REV\" tuşlarını basılı tutarken telsizi açın.\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için \"TONE\" tuşuna basın."
+
+#: ../chirpdrivers/ft7100.py:1126
+msgid ""
+"1. Turn Radio off.\n"
+"2. Connect data cable.\n"
+"3. While holding \"TON\" and \"REV\" buttons, turn radio on.\n"
+"4. Press \"REV\" to receive image.\n"
+"5. Make sure display says \"CLONE RX\" and green led is blinking\n"
+"6. Click OK to start transfer."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Veri kablosunu bağlayın.\n"
+"3. \"TON\" ve \"REV\" tuşlarını basılı tutarken telsizi açın.\n"
+"4. İmajı almak için \"REV\" tuşuna basın.\n"
+"5. Ekranda \"CLONE RX\" yazdığından ve yeşil ledin yanıp söndüğünden emin olun.\n"
+"6. Aktarımı başlatmak için TAMAM'a tıklayın."
+
+#: ../chirpdrivers/ft7800.py:275
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA jack.\n"
+"3. Press and hold in the [MHz(PRI)] key while turning the\n"
+" radio on.\n"
+"4. Rotate the DIAL job to select \"F-7 CLONE\".\n"
+"5. Press and hold in the [BAND(SET)] key. The display\n"
+" will disappear for a moment, then the \"CLONE\" notation\n"
+" will appear.\n"
+"6. <b>After clicking OK</b>, press the [V/M(MW)] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA jakına bağlayın.\n"
+"3. Telsizi açarken [MHz(PRI)] tuşunu basılı tutun.\n"
+"4. \"F-7 CLONE\" öğesini seçmek için KADRANI çevirin.\n"
+"5. [BAND(SET)] tuşunu basılı tutun. Ekran bir an için kaybolacak, ardından \"CLONE\" yazısı belirecektir.\n"
+"6. <b>TAMAM'ı tıkladıktan sonra</b>, imaj göndermek için [V/M(MW)] tuşuna basın."
+
+#: ../chirpdrivers/ft7800.py:285
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA jack.\n"
+"3. Press and hold in the [MHz(PRI)] key while turning the\n"
+" radio on.\n"
+"4. Rotate the DIAL job to select \"F-7 CLONE\".\n"
+"5. Press and hold in the [BAND(SET)] key. The display\n"
+" will disappear for a moment, then the \"CLONE\" notation\n"
+" will appear.\n"
+"6. Press the [LOW(ACC)] key (\"--RX--\" will appear on the display)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA jakına bağlayın.\n"
+"3. Telsizi açarken [MHz(PRI)] tuşunu basılı tutun.\n"
+"4. \"F-7 CLONE\" öğesini seçmek için KADRANI çevirin.\n"
+"5. [BAND(SET)] tuşunu basılı tutun. Ekran bir an için kaybolacak, ardından \"CLONE\" yazısı belirecektir.\n"
+"6. [LOW(ACC)] tuşuna basın (ekranda \"--RX--\" görünecektir)."
+
+#: ../chirpdrivers/ftlx011.py:306
+msgid ""
+"Please follow this steps carefully:\n"
+"\n"
+"1 - Turn on your radio\n"
+"2 - Connect the interface cable to your radio.\n"
+"3 - Click the button on this window to start download\n"
+" (Radio will beep and led will flash)\n"
+"4 - Then press the \"A\" button in your radio to start cloning.\n"
+" (At the end radio will beep)\n"
+msgstr ""
+"Lütfen bu adımları dikkatlice izleyin:\n"
+"\n"
+"1 - Telsizinizi açın\n"
+"2 - Arayüz kablosunu telsizinize bağlayın.\n"
+"3 - İndirmeyi başlatmak için bu penceredeki tuşa tıklayın\n"
+" (Telsiz bip sesi çıkaracak ve led yanıp sönecektir)\n"
+"4 - Ardından klonlamaya başlamak için telsizinizdeki \"A\" tuşuna basın.\n"
+" (Sonunda telsiz bip sesi çıkaracaktır)\n"
+
+#: ../chirpdrivers/ftlx011.py:316
+msgid ""
+"Please follow this steps carefully:\n"
+"\n"
+"1 - Turn on your radio\n"
+"2 - Connect the interface cable to your radio\n"
+"3 - Click the button on this window to start download\n"
+" (you may see another dialog, click ok)\n"
+"4 - Radio will beep and led will flash\n"
+"5 - You will get a 10 seconds timeout to press \"MON\" before\n"
+" data upload start\n"
+"6 - If all goes right radio will beep at end.\n"
+"\n"
+"After cloning remove the cable and power cycle your radio to\n"
+"get into normal mode.\n"
+msgstr ""
+"Lütfen bu adımları dikkatlice izleyin:\n"
+"\n"
+"1 - Telsizinizi açın\n"
+"2 - Arayüz kablosunu telsizinize bağlayın\n"
+"3 - İndirmeyi başlatmak için bu penceredeki tuşa tıklayın (başka bir iletişim kutusu görebilirsiniz, tamam'a tıklayın)\n"
+"4 - Telsiz bip sesi çıkaracak ve led yanıp sönecektir\n"
+"5 - Veri yükleme başlamadan önce \"MON\" tuşuna basmanız için 10 saniyelik bir zaman aşımı süresi alacaksınız.\n"
+"6 - Her şey yolunda giderse sonunda telsiz bip sesi çıkaracaktır.\n"
+"\n"
+"Klonladıktan sonra kabloyu çıkarın ve normal moda geçmek için telsizinizi kapatıp açın.\n"
+
+#: ../chirpdrivers/ftm3200d.py:83
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Press and hold in the [MHz(SETUP)] key while turning the radio\n"
+" on (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [REV(DW)] key\n"
+" to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Telsizi açarken [MHz(SETUP)] tuşunu basılı tutun (\"ekranda CLONE\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [GERİ(DW)] tuşuna basın."
+
+#: ../chirpdrivers/ftm3200d.py:90
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA terminal.\n"
+"3. Press and hold in the [MHz(SETUP)] key while turning the radio\n"
+" on (\"CLONE\" will appear on the display).\n"
+"4. Press the [MHz(SETUP)] key\n"
+" (\"-WAIT-\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA terminaline bağlayın.\n"
+"3. Telsizi açarken [MHz(SETUP)] tuşunu basılı tutun (\"ekranda CLONE\" görünecektir).\n"
+"4. [MHz(SETUP)] tuşuna basın\n"
+" (ekranda \"-WAIT-\" görünecektir)."
+
+#: ../chirpdrivers/ftm7250d.py:84
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC Jack.\n"
+"3. Press and hold in the [MHz(SETUP)] key while turning the radio\n"
+" on (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [GM(AMS)] key\n"
+" to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC Jakına bağlayın.\n"
+"3. Telsizi açarken [MHz(SETUP)] tuşunu basılı tutun (\"ekranda CLONE\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imaj göndermek için [GM(AMS)] tuşuna basın."
+
+#: ../chirpdrivers/ftm7250d.py:91
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC Jack.\n"
+"3. Press and hold in the [MHz(SETUP)] key while turning the radio\n"
+" on (\"CLONE\" will appear on the display).\n"
+"4. Press the [MHz(SETUP)] key\n"
+" (\"-WAIT-\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC Jakına bağlayın.\n"
+"3. Telsizi açarken [MHz(SETUP)] tuşunu basılı tutun (\"ekranda CLONE\" görünecektir).\n"
+"4. [MHz(SETUP)] tuşuna basın\n"
+" (ekranda \"-WAIT-\" görünecektir)."
+
+#: ../chirpdrivers/ic2730.py:305
+msgid ""
+"Follow these instructions to download your config:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable to the Speaker-2 jack\n"
+"3 - Turn on your radio\n"
+"4 - Radio > Download from radio\n"
+"5 - Disconnect the interface cable! Otherwise there will be\n"
+" no right-side audio!\n"
+msgstr ""
+"Yapılandırmanızı indirmek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu Speaker-2 jakına bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz > Telsizden İndir\n"
+"5 - Arayüz kablosunu çıkarın! Aksi takdirde, sağ taraf sesi olmayacaktır!\n"
+
+#: ../chirpdrivers/ic2730.py:315
+msgid ""
+"Follow these instructions to upload your config:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable to the Speaker-2 jack\n"
+"3 - Turn on your radio\n"
+"4 - Radio > Upload to radio\n"
+"5 - Disconnect the interface cable, otherwise there will be\n"
+" no right-side audio!\n"
+"6 - Cycle power on the radio to exit clone mode\n"
+msgstr ""
+"Yapılandırmanızı yüklemek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu Speaker-2 jakına bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz > Telsize yükle\n"
+"5 - Arayüz kablosunu çıkarın, aksi takdirde sağ tarafta ses olmayacaktır!\n"
+"6 - Klon modundan çıkmak için telsizi kapatıp açın\n"
+
+#: ../chirpdrivers/lt725uv.py:511 ../chirpdrivers/vgc.py:584
+msgid ""
+"Follow this instructions to download your info:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the download of your radio data\n"
+msgstr ""
+"Bilgilerinizi indirmek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin indirilmesini gerçekleştirin\n"
+
+#: ../chirpdrivers/tg_uv2p.py:221 ../chirpdrivers/uvb5.py:284 ../chirpdrivers/wouxun.py:214
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic/spkr connector.\n"
+"3. Make sure connector is firmly connected.\n"
+"4. Turn radio on.\n"
+"5. Ensure that the radio is tuned to channel with no activity.\n"
+"6. Click OK to download image from device."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mik/hprlr konektörüne bağlayın.\n"
+"3. Konektörün sıkıca bağlandığından emin olun.\n"
+"4. Telsizi açın.\n"
+"5. Telsizin etkin olmayan kanala ayarlandığından emin olun.\n"
+"6. İmajı cihazdan indirmek için TAMAM'a tıklayın."
+
+#: ../chirpdrivers/tg_uv2p.py:228 ../chirpdrivers/uvb5.py:291 ../chirpdrivers/wouxun.py:221
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic/spkr connector.\n"
+"3. Make sure connector is firmly connected.\n"
+"4. Turn radio on.\n"
+"5. Ensure that the radio is tuned to channel with no activity.\n"
+"6. Click OK to upload image to device."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mic/spkr konektörüne bağlayın.\n"
+"3. Konektörün sıkıca bağlandığından emin olun.\n"
+"4. Telsizi açın.\n"
+"5. Telsizin etkin olmayan kanala ayarlandığından emin olun.\n"
+"6. İmajı cihaza yüklemek için TAMAM'a tıklayın."
+
+#: ../chirpdrivers/th_uv88.py:478
+msgid "This is an early stage beta driver\n"
+msgstr "Bu erken aşama beta sürücüsüdür\n"
+
+#: ../chirpdrivers/th_uv88.py:481
+msgid "This is an early stage beta driver - upload at your own risk\n"
+msgstr "Bu, erken aşamadaki bir beta sürücüsüdür - yükleme riski size aittir\n"
+
+#: ../chirpdrivers/th_uv8000.py:534
+msgid ""
+"Follow these instructions to download the radio memory:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio, volume @ 50%\n"
+"4 - Radio > Download from radio\n"
+msgstr ""
+"Telsiz hafızasını indirmek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın, ses seviyesi @ %50\n"
+"4 - Telsiz > Telsizden İndir\n"
+
+#: ../chirpdrivers/th_uv8000.py:542
+msgid ""
+"Follow these instructions to upload the radio memory:\n"
+"\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio, volume @ 50%\n"
+"4 - Radio > Upload to radio\n"
+msgstr ""
+"Telsiz hafızasını yüklemek için şu talimatları izleyin:\n"
+"\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın, ses seviyesi @ %50\n"
+"4 - Telsiz > Telsize yükle\n"
+
+#: ../chirpdrivers/tk270.py:340 ../chirpdrivers/tk760.py:361
+msgid ""
+"Follow this instructions to read your radio:\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the download of your radio data\n"
+msgstr ""
+"Telsizinizi okumak için bu talimatları izleyin:\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin indirmesini gerçekleştirin\n"
+
+#: ../chirpdrivers/tk270.py:347 ../chirpdrivers/tk760.py:368
+msgid ""
+"Follow this instructions to write your radio:\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio\n"
+"4 - Do the upload of your radio data\n"
+msgstr ""
+"Telsizinizi yazmak için bu talimatları izleyin:\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın\n"
+"4 - Telsiz verilerinizin yüklemesini gerçekleştirin\n"
+
+#: ../chirpdrivers/tk760g.py:729
+msgid ""
+"Follow this instructions to download your info:\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio (unblock it if password protected)\n"
+"4 - Do the download of your radio data\n"
+msgstr ""
+"Bilgilerinizi indirmek için bu talimatları izleyin:\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın (şifre korumalıysa engelini kaldırın)\n"
+"4 - Telsiz verilerinizin indirmesini gerçekleştirin\n"
+
+#: ../chirpdrivers/tk760g.py:736
+msgid ""
+"Follow this instructions to upload your info:\n"
+"1 - Turn off your radio\n"
+"2 - Connect your interface cable\n"
+"3 - Turn on your radio (unblock it if password protected)\n"
+"4 - Do the upload of your radio data\n"
+msgstr ""
+"Bilgilerinizi yüklemek için bu talimatları izleyin:\n"
+"1 - Telsizinizi kapatın\n"
+"2 - Arayüz kablonuzu bağlayın\n"
+"3 - Telsizinizi açın (şifre korumalıysa engelini kaldırın)\n"
+"4 - Telsiz verilerinizin yüklemesini gerçekleştirin\n"
+
+#: ../chirpdrivers/tmd710.py:203 ../chirpdrivers/tmd710.py:207
+msgid ""
+"Connect your interface cable to the PC Port on the\n"
+"back of the 'TX/RX' unit. NOT the Com Port on the head.\n"
+msgstr ""
+"Arayüz kablonuzu 'TX/RX' ünitesinin arkasındaki\n"
+"PC Bağlantı Noktasına bağlayın. Kafadaki Com Portu DEĞİL.\n"
+
+#: ../chirpdrivers/ts480.py:524
+msgid ""
+"Follow these instructions to download the radio memory:\n"
+"1 - Connect your interface cable\n"
+"2 - Radio > Download from radio: Don't adjust any settings\n"
+"on the radio head!\n"
+"3 - Disconnect your interface cable\n"
+msgstr ""
+"Telsiz hafızasını indirmek için şu talimatları izleyin:\n"
+"1 - Arayüz kablonuzu bağlayın\n"
+"2 - Telsiz > Telsizden İndir: Telsiz kafasında herhangi bir ayar yapmayın!\n"
+"3 - Arayüz kablonuzu çıkarın\n"
+
+#: ../chirpdrivers/ts480.py:531
+msgid ""
+"Follow these instructions to upload the radio memory:\n"
+"1 - Connect your interface cable\n"
+"2 - Radio > Upload to radio: Don't adjust any settings\n"
+"on the radio head!\n"
+"3 - Disconnect your interface cable\n"
+msgstr ""
+"Telsiz hafızasını yüklemek için şu talimatları izleyin:\n"
+"1 - Arayüz kablonuzu bağlayın\n"
+"2 - Telsiz > Telsize yükle: Telsiz kafasında herhangi bir ayar yapmayın!\n"
+"3 - Arayüz kablonuzu çıkarın\n"
+
+#: ../chirpdrivers/ts590.py:685
+msgid ""
+"Follow these instructions to download the radio memory:\n"
+"1 - Connect your interface cable\n"
+"2 - Radio > Download from radio: DO NOT mess with the radio\n"
+"during download!\n"
+"3 - Disconnect your interface cable\n"
+msgstr ""
+"Telsiz hafızasını indirmek için şu talimatları izleyin:\n"
+"1 - Arayüz kablonuzu bağlayın\n"
+"2 - Telsiz > Telsizden İndir: İndirme sırasında telsiz ile uğraşmayın!\n"
+"3 - Arayüz kablonuzu çıkarın\n"
+
+#: ../chirpdrivers/ts590.py:692
+msgid ""
+"Follow these instructions to upload the radio memory:\n"
+"1 - Connect your interface cable\n"
+"2 - Radio > Upload to radio: DO NOT mess with the radio\n"
+"during upload!\n"
+"3 - Disconnect your interface cable\n"
+msgstr ""
+"Telsiz hafızasını yüklemek için şu talimatları izleyin:\n"
+"1 - Arayüz kablonuzu bağlayın\n"
+"2 - Telsiz > Telsize Yükle: Yükleme sırasında telsiz ile uğraşmayın!\n"
+"3 - Arayüz kablonuzu çıkarın\n"
+
+#: ../chirpdrivers/uv5r.py:764
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic/spkr connector.\n"
+"3. Make sure connector is firmly connected.\n"
+"4. Turn radio on (volume may need to be set at 100%).\n"
+"5. Ensure that the radio is tuned to channel with no activity.\n"
+"6. Click OK to download image from device."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mik/hprlr konektörüne bağlayın.\n"
+"3. Konektörün sıkıca bağlandığından emin olun.\n"
+"4. Telsizi açın (ses düzeyinin %100 olarak ayarlanması gerekebilir).\n"
+"5. Telsizin etkin olmayan kanala ayarlandığından emin olun.\n"
+"6. İmajı cihazdan indirmek için TAMAM'a tıklayın."
+
+#: ../chirpdrivers/uv5r.py:771
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to mic/spkr connector.\n"
+"3. Make sure connector is firmly connected.\n"
+"4. Turn radio on (volume may need to be set at 100%).\n"
+"5. Ensure that the radio is tuned to channel with no activity.\n"
+"6. Click OK to upload image to device."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu mic/spkr konektörüne bağlayın.\n"
+"3. Konektörün sıkıca bağlandığından emin olun.\n"
+"4. Telsizi açın (ses düzeyinin %100 olarak ayarlanması gerekebilir).\n"
+"5. Telsizin etkin olmayan kanala ayarlandığından emin olun.\n"
+"6. İmajı cihaza yüklemek için TAMAM'a tıklayın."
+
+#: ../chirpdrivers/vx3.py:375 ../chirpdrivers/vx6.py:363
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [F/W] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [BAND] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [F/W] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [BAND] tuşuna basın."
+
+#: ../chirpdrivers/vx3.py:381 ../chirpdrivers/vx6.py:369
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [F/W] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. Press the [V/M] key (\"-WAIT-\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [F/W] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. [V/M] tuşuna basın (ekranda \"-WAIT-\" görünecektir)."
+
+#: ../chirpdrivers/vx3.py:317
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/EAR jack.\n"
+"3. Press and hold in the [F/W] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [VFO(DW)SC] key to receive\n"
+" the image from the radio."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/EAR jakına bağlayın.\n"
+"3. Telsizi açarken [F/W] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı telsizden almak için [VFO(DW)SC] tuşuna basın."
+
+#: ../chirpdrivers/vx3.py:324
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/EAR jack.\n"
+"3. Press and hold in the [F/W] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. Press the [MR(SKP)SC] key (\"CLONE WAIT\" will appear\n"
+" on the LCD).\n"
+"5. Click OK to send image to radio."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/EAR jakına bağlayın.\n"
+"3. Telsizi açarken [F/W] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. [MR(SKP)SC] tuşuna basın (ekranda \"CLONE WAIT\" görünecektir).\n"
+"5. İmajı telsize göndermek için TAMAM'a tıklayın."
+
+#: ../chirpdrivers/vx7.py:193
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [MON-F] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [BAND] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [MON-F] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [BAND] tuşuna basın."
+
+#: ../chirpdrivers/vx7.py:199
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [MON-F] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. Press the [V/M] key (\"CLONE WAIT\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [MON-F] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. [V/M] tuşuna basın (ekranda \"CLONE WAIT\" görünecektir)."
+
+#: ../chirpdrivers/vx8.py:590
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA jack.\n"
+"3. Press and hold in the [FW] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. <b>After clicking OK</b>, press the [BAND] key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA jakına bağlayın.\n"
+"3. Telsizi açarken [FW] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [BAND] tuşuna basın."
+
+#: ../chirpdrivers/vx8.py:596
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to DATA jack.\n"
+"3. Press and hold in the [FW] key while turning the radio on\n"
+" (\"CLONE\" will appear on the display).\n"
+"4. Press the [MODE] key (\"-WAIT-\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu DATA jakına bağlayın.\n"
+"3. Telsizi açarken [FW] tuşunu basılı tutun\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"4. [MODE] tuşuna basın (ekranda \"CLONE WAIT\" görünecektir)."
+
+#: ../chirpdrivers/vx170.py:103
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect cable to MIC/SP jack.\n"
+"3. Press and hold in the [moni] key while turning the radio on.\n"
+"4. Select CLONE in menu, then press F. Radio restarts in clone mode.\n"
+" (\"CLONE\" will appear on the display).\n"
+"5. <b>After clicking OK</b>, briefly hold [PTT] key to send image.\n"
+" (\"-TX-\" will appear on the LCD). "
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Kabloyu MIC/SP jakına bağlayın.\n"
+"3. Telsizi açarken [moni] tuşunu basılı tutun.\n"
+"4. Menüden KLON'u seçin, ardından F'ye basın. Telsiz klon modunda yeniden başlar.\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"5. <b>TAMAM'ı tıkladıktan sonra</b>, imajı göndermek için [PTT] tuşunu kısa bir süre basılı tutun.\n"
+" (ekranda \"-TX-\" görünecektir). "
+
+#: ../chirpdrivers/vx170.py:111
+msgid ""
+"1. Turn radio off.\n"
+"3. Press and hold in the [moni] key while turning the radio on.\n"
+"4. Select CLONE in menu, then press F. Radio restarts in clone mode.\n"
+" (\"CLONE\" will appear on the display).\n"
+"5. Press the [moni] key (\"-RX-\" will appear on the LCD)."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"3. Telsizi açarken [moni] tuşunu basılı tutun.\n"
+"4. Menüden KLON'u seçin, ardından F'ye basın. Telsiz klon modunda yeniden başlar.\n"
+" (ekranda \"CLONE\" görünecektir).\n"
+"5. [moni] tuşuna basın (ekranda \"-RX-\" görünecektir)."
+
+#: ../chirpdrivers/yaesu_clone.py:215
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect data cable.\n"
+"3. Prepare radio for clone.\n"
+"4. <b>After clicking OK</b>, press the key to send image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Veri kablosunu bağlayın.\n"
+"3. Telsizi klon için hazırlayın.\n"
+"4. <b>TAMAM'ı tıkladıktan sonra</b>, imaj göndermek için tuşuna basın."
+
+#: ../chirpdrivers/yaesu_clone.py:220
+msgid ""
+"1. Turn radio off.\n"
+"2. Connect data cable.\n"
+"3. Prepare radio for clone.\n"
+"4. Press the key to receive the image."
+msgstr ""
+"1. Telsizi kapatın.\n"
+"2. Veri kablosunu bağlayın.\n"
+"3. Telsizi klon için hazırlayın.\n"
+"4. İmajı almak için tuşuna basın."
diff --git a/locale/zh_CN.po b/locale/zh_CN.po
new file mode 100644
index 0000000..5fa0ff1
--- /dev/null
+++ b/locale/zh_CN.po
@@ -0,0 +1,1275 @@
+# Copyright (C) 2022 Dan Smith <dsmith@danplanet.com>
+# This file is distributed under the same license as the CHIRP package.
+#
+# DuckSoft, BH2UEP <realducksoft@gmail.com>, 2022.
+msgid ""
+msgstr ""
+"Project-Id-Version: CHIRP\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2022-06-04 01:53+0800\n"
+"PO-Revision-Date: 2022-06-04 02:01+0800\n"
+"Last-Translator: DuckSoft, BH2UEP <realducksoft@gmail.com>\n"
+"Language: zh_CN\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Lokalize 22.04.1\n"
+
+#: ../chirp/ui/cloneprog.py:44
+msgid "Clone Progress"
+msgstr "复制进度"
+
+#: ../chirp/ui/cloneprog.py:47
+msgid "Cloning"
+msgstr "正在复制"
+
+#: ../chirp/ui/cloneprog.py:56
+msgid "Cancel"
+msgstr "取消"
+
+#: ../chirp/ui/editorset.py:85
+#, python-format
+msgid "Memories (%(variant)s)"
+msgstr "存储(%(variant)s)"
+
+#: ../chirp/ui/editorset.py:89
+msgid "Memories"
+msgstr "存储"
+
+#: ../chirp/ui/editorset.py:100
+msgid "D-STAR"
+msgstr "D-STAR"
+
+#: ../chirp/ui/editorset.py:149
+msgid "Settings"
+msgstr "设置"
+
+#: ../chirp/ui/editorset.py:158
+msgid "Browser"
+msgstr "浏览器"
+
+#: ../chirp/ui/editorset.py:279
+#, python-brace-format
+msgid "The {vendor} {model} has multiple independent sub-devices"
+msgstr "电台 {vendor} {model} 有多个独立的子设备"
+
+#: ../chirp/ui/editorset.py:281
+msgid "Choose one to import from:"
+msgstr "选择一个来导入:"
+
+#: ../chirp/ui/editorset.py:286
+msgid "Cancelled"
+msgstr "已取消"
+
+#: ../chirp/ui/editorset.py:291
+msgid "Internal Error"
+msgstr "内部错误"
+
+#: ../chirp/ui/editorset.py:332
+#, python-brace-format
+msgid ""
+"There were errors while opening {file}. The affected memories will not be "
+"importable!"
+msgstr "打开 {file} 时出错。受影响的存储将不可导入!"
+
+#: ../chirp/ui/editorset.py:344
+#, python-brace-format
+msgid "There was an error during import: {error}"
+msgstr "导入时出错:{error}"
+
+#: ../chirp/ui/editorset.py:352
+msgid "Unsupported file type"
+msgstr "不支持的文件类型"
+
+#: ../chirp/ui/editorset.py:368 ../chirp/ui/editorset.py:383
+#, python-brace-format
+msgid "There was an error during export: {error}"
+msgstr "导出时出错:{error}"
+
+#: ../chirp/ui/bandplans.py:96
+msgid ""
+"Band plans define default channel settings for frequencies in a region. "
+"Choose a band plan or None for completely manual channel settings."
+msgstr ""
+"频段计划定义了一个区域内频率的默认频道设置。请选择一个频段计划,或选择“无”以"
+"完全手动设置频道。"
+
+#: ../chirp/ui/common.py:246
+msgid "Completed"
+msgstr "已完成"
+
+#: ../chirp/ui/common.py:247
+msgid "idle"
+msgstr "空闲"
+
+#: ../chirp/ui/common.py:354
+msgid "Details"
+msgstr "详情"
+
+#: ../chirp/ui/common.py:357
+msgid "Proceed?"
+msgstr "要继续吗?"
+
+#: ../chirp/ui/common.py:366
+msgid "Do not show this next time"
+msgstr "下次不再出现"
+
+#: ../chirp/ui/mainapp.py:272 ../chirp/ui/mainapp.py:513
+msgid "Untitled"
+msgstr "无标题"
+
+#: ../chirp/ui/mainapp.py:326 ../chirp/ui/mainapp.py:875
+msgid "All files"
+msgstr "全部文件"
+
+#: ../chirp/ui/mainapp.py:327 ../chirp/ui/mainapp.py:876
+msgid "CHIRP Radio Images"
+msgstr "CHIRP 电台镜像"
+
+#: ../chirp/ui/mainapp.py:328 ../chirp/ui/mainapp.py:877
+#: ../chirp/ui/mainapp.py:1557
+msgid "CSV Files"
+msgstr "CSV 文件"
+
+#: ../chirp/ui/mainapp.py:329 ../chirp/ui/mainapp.py:878
+msgid "DAT Files"
+msgstr "DAT 文件"
+
+#: ../chirp/ui/mainapp.py:330 ../chirp/ui/mainapp.py:879
+msgid "EVE Files (VX5)"
+msgstr "EVE 文件 (VX5)"
+
+#: ../chirp/ui/mainapp.py:331 ../chirp/ui/mainapp.py:880
+msgid "ICF Files"
+msgstr "ICF 文件"
+
+#: ../chirp/ui/mainapp.py:332 ../chirp/ui/mainapp.py:884
+msgid "VX5 Commander Files"
+msgstr "VX5 Commander 文件"
+
+#: ../chirp/ui/mainapp.py:333 ../chirp/ui/mainapp.py:885
+msgid "VX6 Commander Files"
+msgstr "VX6 Commander 文件"
+
+#: ../chirp/ui/mainapp.py:334 ../chirp/ui/mainapp.py:886
+msgid "VX7 Commander Files"
+msgstr "VX7 Commander 文件"
+
+#: ../chirp/ui/mainapp.py:348
+msgid ""
+"ICF files cannot be edited, only displayed or imported into another file. "
+"Open in read-only mode?"
+msgstr "不能编辑 ICF 文件,只能展示或导入到其他文件中。以只读模式打开吗?"
+
+#: ../chirp/ui/mainapp.py:371
+msgid ""
+"Unable to open this image. It was generated with a newer version of CHIRP "
+"and thus may be for a radio model that is not supported by this version. "
+"Please update to the latest version of CHIRP and try again."
+msgstr ""
+"无法打开此镜像。此镜像由较新版本的 CHIRP 生成,当前版本可能还不支持对应的型"
+"号。请更新 CHIRP 后再试。"
+
+#: ../chirp/ui/mainapp.py:380
+msgid "Unable to open this image: unsupported model"
+msgstr "无法打开此镜像:型号不支持"
+
+#: ../chirp/ui/mainapp.py:400
+#, python-brace-format
+msgid "There was an error opening {fname}: {error}"
+msgstr "打开 {fname} 时出错:{error}"
+
+#: ../chirp/ui/mainapp.py:412
+#, python-brace-format
+msgid "{num} errors during open:"
+msgstr "打开文件时出现 {num} 个错误:"
+
+#: ../chirp/ui/mainapp.py:420
+msgid "Note:"
+msgstr "注意:"
+
+#: ../chirp/ui/mainapp.py:421
+#, python-brace-format
+msgid ""
+"The {vendor} {model} operates in <b>live mode</b>. This means that any "
+"changes you make are immediately sent to the radio. Because of this, you "
+"cannot perform the <u>Save</u> or <u>Upload</u> operations. If you wish to "
+"edit the contents offline, please <u>Export</u> to a CSV file, using the "
+"<b>File menu</b>."
+msgstr ""
+"此电台 {vendor} {model} 工作在<b>实时模式</b>,也就是说变更会即时发送给电台。"
+"因此,您不能进行<u>保存</u>或者<u>上传</u> 操作。如果您想离线编辑内容,请使用"
+"<b>文件菜单</b>的<u>导出</u>到 CSV 功能。"
+
+#: ../chirp/ui/mainapp.py:430
+msgid "Don't show this again"
+msgstr "不再显示"
+
+#: ../chirp/ui/mainapp.py:464
+#, python-brace-format
+msgid "{vendor} {model} image file"
+msgstr "{vendor} {model} 镜像文件"
+
+#: ../chirp/ui/mainapp.py:480
+msgid "VX7 Commander"
+msgstr "VX7 Commander"
+
+#: ../chirp/ui/mainapp.py:482
+msgid "VX6 Commander"
+msgstr "VX6 Commander"
+
+#: ../chirp/ui/mainapp.py:484
+msgid "EVE"
+msgstr "EVE"
+
+#: ../chirp/ui/mainapp.py:485
+msgid "VX5 Commander"
+msgstr "VX5 Commander"
+
+#: ../chirp/ui/mainapp.py:562
+msgid "Open recent file"
+msgstr "打开最近的文件"
+
+#: ../chirp/ui/mainapp.py:631
+#, python-brace-format
+msgid "Import stock configuration {name}"
+msgstr "导入库存配置 {name}"
+
+#: ../chirp/ui/mainapp.py:647
+#, python-brace-format
+msgid "Open stock configuration {name}"
+msgstr "打开库存配置 {name}"
+
+#: ../chirp/ui/mainapp.py:668
+msgid "Proceed with experimental driver?"
+msgstr "继续使用不稳定的驱动?"
+
+#: ../chirp/ui/mainapp.py:670
+msgid "This radio's driver is experimental. Do you want to proceed?"
+msgstr "此电台的驱动程序尚不稳定。要继续吗?"
+
+#: ../chirp/ui/mainapp.py:689
+#, python-brace-format
+msgid "{name} Information"
+msgstr "{name} 信息"
+
+#: ../chirp/ui/mainapp.py:691
+#, python-brace-format
+msgid "{information}"
+msgstr "{information}"
+
+#: ../chirp/ui/mainapp.py:695
+msgid "Don't show information for any radio again"
+msgstr "任何电台都不显示信息"
+
+#: ../chirp/ui/mainapp.py:719
+#, python-brace-format
+msgid "{name} Instructions"
+msgstr "{name} 指引"
+
+#: ../chirp/ui/mainapp.py:721
+#, python-brace-format
+msgid "{instructions}"
+msgstr "{instructions}"
+
+#: ../chirp/ui/mainapp.py:725
+msgid "Don't show instructions for any radio again"
+msgstr "任何电台都不显示指引"
+
+#: ../chirp/ui/mainapp.py:840
+msgid "Save Changes?"
+msgstr "保存变更?"
+
+#: ../chirp/ui/mainapp.py:846
+msgid "File is modified, save changes before closing?"
+msgstr "文件已更改,关闭前要保存变更吗?"
+
+#: ../chirp/ui/mainapp.py:881
+msgid "Kenwood HMK Files"
+msgstr "建伍(Kenwood)HMK 文件"
+
+#: ../chirp/ui/mainapp.py:882
+msgid "Kenwood ITM Files"
+msgstr "建伍(Kenwood)ITM 文件"
+
+#: ../chirp/ui/mainapp.py:883
+msgid "Travel Plus Files"
+msgstr "Travel Plus 文件"
+
+#: ../chirp/ui/mainapp.py:904
+msgid "DMR-MARC Repeater Database Dump"
+msgstr "DMR-MARC Repeater 数据库转存"
+
+#: ../chirp/ui/mainapp.py:1014 ../chirp/ui/mainapp.py:1121
+msgid "RepeaterBook Query"
+msgstr "RepeaterBook 查询"
+
+#: ../chirp/ui/mainapp.py:1075 ../chirp/ui/mainapp.py:1181
+msgid "RepeaterBook query failed"
+msgstr "RepeaterBook 查询失败"
+
+#: ../chirp/ui/mainapp.py:1248
+#, python-format
+msgid "Invalid value for %s"
+msgstr "%s 值无效"
+
+#: ../chirp/ui/mainapp.py:1271
+msgid "Query failed"
+msgstr "查询失败"
+
+#: ../chirp/ui/mainapp.py:1366 ../chirp/ui/mainapp.py:1431
+msgid "RadioReference.com Query"
+msgstr "RadioReference.com 查询"
+
+#: ../chirp/ui/mainapp.py:1502
+msgid "RadioReference.com Province Query"
+msgstr "RadioReference.com 省份查询"
+
+#: ../chirp/ui/mainapp.py:1603
+msgid "With significant contributions from:"
+msgstr "鸣谢:"
+
+#: ../chirp/ui/mainapp.py:1637
+msgid "Select Columns"
+msgstr "选择列"
+
+#: ../chirp/ui/mainapp.py:1654
+#, python-brace-format
+msgid "Visible columns for {radio}"
+msgstr "{radio} 的可见列"
+
+#: ../chirp/ui/mainapp.py:1717
+msgid "Reporting is disabled"
+msgstr "报告已禁用"
+
+#: ../chirp/ui/mainapp.py:1719
+msgid ""
+"The reporting feature of CHIRP is designed to help <u>improve quality</u> by "
+"allowing the authors to focus on the radio drivers used most often and "
+"errors experienced by the users. The reports contain no identifying "
+"information and are used only for statistical purposes by the authors. Your "
+"privacy is extremely important, but <u>please consider leaving this feature "
+"enabled to help make CHIRP better!</u>\n"
+"\n"
+"<b>Are you sure you want to disable this feature?</b>"
+msgstr ""
+"CHIRP 的报告功能旨在帮助<u>改善软件质量</u>,让作者能关注最常使用的电台驱动程"
+"序以及用户遇到的错误。这些报告不包含任何识别信息,仅用于作者的统计目的。您的"
+"隐私非常重要,但<u>请考虑启用这一功能,以帮助 CHIRP 变得更好!</u>\n"
+"\n"
+"<b>确定要禁用此功能吗?</b>"
+
+#: ../chirp/ui/mainapp.py:1762
+msgid ""
+"Choose a language or Auto to use the operating system default. You will need "
+"to restart the application before the change will take effect"
+msgstr "选择一种语言或自动使用操作系统的默认语言。你需要重新启动程序才能使改变生效。"
+
+#: ../chirp/ui/mainapp.py:1775
+msgid "Python Modules"
+msgstr "Python 模块"
+
+#: ../chirp/ui/mainapp.py:1776
+msgid "Modules"
+msgstr "模块"
+
+#: ../chirp/ui/mainapp.py:1980
+msgid "_File"
+msgstr "文件 (_F)"
+
+#: ../chirp/ui/mainapp.py:1983
+msgid "Open Stock Config"
+msgstr "打开库存配置"
+
+#: ../chirp/ui/mainapp.py:1984
+msgid "Open _Recent"
+msgstr "打开最近 (_R)"
+
+#: ../chirp/ui/mainapp.py:1985
+msgid "Clear Recently Opened"
+msgstr "清空最近项目"
+
+#: ../chirp/ui/mainapp.py:1989
+msgid "Load Module"
+msgstr "加载模块"
+
+#: ../chirp/ui/mainapp.py:1992
+msgid "_Edit"
+msgstr "编辑 (_E)"
+
+#: ../chirp/ui/mainapp.py:1993
+msgid "_Cut"
+msgstr "剪切 (_C)"
+
+#: ../chirp/ui/mainapp.py:1994
+msgid "_Copy"
+msgstr "复制 (_C)"
+
+#: ../chirp/ui/mainapp.py:1995
+msgid "_Paste"
+msgstr "粘贴 (_P)"
+
+#: ../chirp/ui/mainapp.py:1997
+msgid "_Delete"
+msgstr "删除 (_D)"
+
+#: ../chirp/ui/mainapp.py:1998
+msgid "Select _All"
+msgstr "全选 (_A)"
+
+#: ../chirp/ui/mainapp.py:1999
+msgid "Move _Up"
+msgstr "上移 (_U)"
+
+#: ../chirp/ui/mainapp.py:2001
+msgid "Move Dow_n"
+msgstr "下移 (_N)"
+
+#: ../chirp/ui/mainapp.py:2003
+msgid "E_xchange"
+msgstr "交换 (_X)"
+
+#: ../chirp/ui/mainapp.py:2005 ../chirp/ui/memedit.py:888
+msgid "P_roperties"
+msgstr "属性 (_P)"
+
+#: ../chirp/ui/mainapp.py:2006
+msgid "_View"
+msgstr "查看 (_V)"
+
+#: ../chirp/ui/mainapp.py:2007
+msgid "Columns"
+msgstr "列"
+
+#: ../chirp/ui/mainapp.py:2008
+msgid "Developer"
+msgstr "开发者"
+
+#: ../chirp/ui/mainapp.py:2009 ../chirp/ui/memedit.py:889
+msgid "Show Raw Memory"
+msgstr "显示原始存储"
+
+#: ../chirp/ui/mainapp.py:2011 ../chirp/ui/memedit.py:890
+msgid "Diff Raw Memories"
+msgstr "对比原始存储"
+
+#: ../chirp/ui/mainapp.py:2013
+msgid "Diff Tabs"
+msgstr "对比面板"
+
+#: ../chirp/ui/mainapp.py:2015
+msgid "Change Language"
+msgstr "更改语言 (Change Language)"
+
+#: ../chirp/ui/mainapp.py:2016
+msgid "_Radio"
+msgstr "电台 (_R)"
+
+#: ../chirp/ui/mainapp.py:2017
+msgid "Download From Radio"
+msgstr "从电台下载"
+
+#: ../chirp/ui/mainapp.py:2019
+msgid "Upload To Radio"
+msgstr "上传到电台"
+
+#: ../chirp/ui/mainapp.py:2021 ../chirp/ui/importdialog.py:576
+msgid "Import"
+msgstr "导入"
+
+#: ../chirp/ui/mainapp.py:2022 ../chirp/ui/importdialog.py:642
+msgid "Export"
+msgstr "导出"
+
+#: ../chirp/ui/mainapp.py:2023
+msgid "Import From Data Source"
+msgstr "从数据源导入"
+
+#: ../chirp/ui/mainapp.py:2025 ../chirp/ui/mainapp.py:2039
+msgid "DMR-MARC Repeaters"
+msgstr "DMR-MARC 中继"
+
+#: ../chirp/ui/mainapp.py:2026 ../chirp/ui/mainapp.py:2040
+msgid "RadioReference"
+msgstr "RadioReference"
+
+#: ../chirp/ui/mainapp.py:2027 ../chirp/ui/mainapp.py:2041
+msgid "RadioReference.com US"
+msgstr "RadioReference.com 美国"
+
+#: ../chirp/ui/mainapp.py:2029 ../chirp/ui/mainapp.py:2043
+msgid "RadioReference.com Canada"
+msgstr "RadioReference.com 加拿大"
+
+#: ../chirp/ui/mainapp.py:2031 ../chirp/ui/mainapp.py:2045
+msgid "RFinder"
+msgstr "RFinder"
+
+#: ../chirp/ui/mainapp.py:2032 ../chirp/ui/mainapp.py:2047
+msgid "RepeaterBook"
+msgstr "RepeaterBook"
+
+#: ../chirp/ui/mainapp.py:2033 ../chirp/ui/mainapp.py:2048
+msgid "RepeaterBook Political Query"
+msgstr "RepeaterBook 政策查询"
+
+#: ../chirp/ui/mainapp.py:2035 ../chirp/ui/mainapp.py:2050
+msgid "RepeaterBook Proximity Query"
+msgstr "RepeaterBook 近距离查询"
+
+#: ../chirp/ui/mainapp.py:2037 ../chirp/ui/mainapp.py:2046
+msgid "przemienniki.net"
+msgstr "przemienniki.net"
+
+#: ../chirp/ui/mainapp.py:2038
+msgid "Query Data Source"
+msgstr "查询数据源"
+
+#: ../chirp/ui/mainapp.py:2052
+msgid "CHIRP Native File"
+msgstr "CHIRP 原生文件"
+
+#: ../chirp/ui/mainapp.py:2054
+msgid "CSV File"
+msgstr "CSV 文件"
+
+#: ../chirp/ui/mainapp.py:2055
+msgid "Import From Stock Config"
+msgstr "从库存配置中导入"
+
+#: ../chirp/ui/mainapp.py:2057
+msgid "Channel Defaults"
+msgstr "频道默认值"
+
+#: ../chirp/ui/mainapp.py:2060
+msgid "Help"
+msgstr "帮助"
+
+#: ../chirp/ui/mainapp.py:2062
+msgid "Get Help Online..."
+msgstr "在线帮助..."
+
+#: ../chirp/ui/mainapp.py:2073
+msgid "Report Statistics"
+msgstr "上报统计信息"
+
+#: ../chirp/ui/mainapp.py:2075
+msgid "Hide Unused Fields"
+msgstr "隐藏未使用的字段"
+
+#: ../chirp/ui/mainapp.py:2077
+msgid "Smart Tone Modes"
+msgstr "自动选择亚音频制式"
+
+#: ../chirp/ui/mainapp.py:2079
+msgid "Show Information"
+msgstr "显示信息"
+
+#: ../chirp/ui/mainapp.py:2081
+msgid "Show Instructions"
+msgstr "显示指引"
+
+#: ../chirp/ui/mainapp.py:2083
+msgid "Enable Developer Functions"
+msgstr "启用开发者功能"
+
+#: ../chirp/ui/mainapp.py:2204
+#, python-brace-format
+msgid "A new version of CHIRP is available: {ver}. "
+msgstr "CHIRP 新版本可用:{ver}。"
+
+#: ../chirp/ui/mainapp.py:2326
+msgid "Error reporting is enabled"
+msgstr "错误报告已启用"
+
+#: ../chirp/ui/mainapp.py:2329
+msgid ""
+"If you wish to disable this feature you may do so in the <u>Help</u> menu"
+msgstr "要禁用此功能,您可在 <u>帮助</u> 菜单中操作"
+
+#: ../chirp/ui/bankedit.py:58
+#, python-format
+msgid "Retrieving %s information"
+msgstr "正在获取 %s 信息"
+
+#: ../chirp/ui/bankedit.py:81
+#, python-format
+msgid "Setting name on %s"
+msgstr "关于 %s 的设置名称"
+
+#: ../chirp/ui/bankedit.py:93 ../chirp/ui/bankedit.py:283
+#: ../chirp/ui/importdialog.py:601 ../chirp/ui/memdetail.py:334
+#: ../chirp/ui/memedit.py:67 ../chirp/ui/memedit.py:88
+#: ../chirp/ui/memedit.py:343 ../chirp/ui/memedit.py:1093
+#: ../chirp/ui/memedit.py:1150 ../chirp/ui/memedit.py:1301
+#: ../chirp/ui/memedit.py:1303
+msgid "Name"
+msgstr "名称"
+
+#: ../chirp/ui/bankedit.py:222
+#, python-brace-format
+msgid "Updating {type} index for memory {num}"
+msgstr "正在更新存储 {num} 的 {type} 索引"
+
+#: ../chirp/ui/bankedit.py:232
+#, python-brace-format
+msgid "Updating mapping information for memory {num}"
+msgstr "正在更新存储 {num} 的映射信息"
+
+#: ../chirp/ui/bankedit.py:238 ../chirp/ui/bankedit.py:269
+#, python-brace-format
+msgid "Getting memory {num}"
+msgstr "正在获取存储 {num}"
+
+#: ../chirp/ui/bankedit.py:253
+#, python-brace-format
+msgid "Setting index for memory {num}"
+msgstr "正在设置存储 {num} 的索引"
+
+#: ../chirp/ui/bankedit.py:262
+#, python-brace-format
+msgid "Getting {type} for memory {num}"
+msgstr "正在获取存储 {num} 的 {type}"
+
+#: ../chirp/ui/bankedit.py:281 ../chirp/ui/memedit.py:65
+#: ../chirp/ui/memedit.py:195 ../chirp/ui/memedit.py:342
+#: ../chirp/ui/memedit.py:426 ../chirp/ui/memedit.py:445
+#: ../chirp/ui/memedit.py:459 ../chirp/ui/memedit.py:482
+#: ../chirp/ui/memedit.py:504 ../chirp/ui/memedit.py:530
+#: ../chirp/ui/memedit.py:542 ../chirp/ui/memedit.py:566
+#: ../chirp/ui/memedit.py:568 ../chirp/ui/memedit.py:641
+#: ../chirp/ui/memedit.py:655 ../chirp/ui/memedit.py:657
+#: ../chirp/ui/memedit.py:699 ../chirp/ui/memedit.py:701
+#: ../chirp/ui/memedit.py:775 ../chirp/ui/memedit.py:909
+#: ../chirp/ui/memedit.py:983 ../chirp/ui/memedit.py:1036
+#: ../chirp/ui/memedit.py:1091 ../chirp/ui/memedit.py:1117
+#: ../chirp/ui/memedit.py:1130 ../chirp/ui/memedit.py:1148
+#: ../chirp/ui/memedit.py:1477
+msgid "Loc"
+msgstr "位置"
+
+#: ../chirp/ui/bankedit.py:282 ../chirp/ui/importdialog.py:602
+#: ../chirp/ui/memdetail.py:332 ../chirp/ui/memedit.py:66
+#: ../chirp/ui/memedit.py:89 ../chirp/ui/memedit.py:210
+#: ../chirp/ui/memedit.py:334 ../chirp/ui/memedit.py:344
+#: ../chirp/ui/memedit.py:407 ../chirp/ui/memedit.py:415
+#: ../chirp/ui/memedit.py:1094 ../chirp/ui/memedit.py:1147
+msgid "Frequency"
+msgstr "频率"
+
+#: ../chirp/ui/bankedit.py:284
+msgid "Index"
+msgstr "索引"
+
+#: ../chirp/ui/bankedit.py:375
+#, python-brace-format
+msgid "Getting {type} information for memory {num}"
+msgstr "正在获取存储 {num} 的 {type} 信息"
+
+#: ../chirp/ui/bankedit.py:401
+#, python-format
+msgid "Getting %s information"
+msgstr "正在获取 %s 信息"
+
+#: ../chirp/ui/importdialog.py:96
+#, python-brace-format
+msgid ""
+"Location {number} is already being imported. Choose another value for 'New "
+"Location' before selection 'Import'"
+msgstr "位置 {number} 已被导入。请为“新位置”选择一个新的值,然后再选择“导入”。"
+
+#: ../chirp/ui/importdialog.py:128
+msgid "Invalid value. Must be an integer."
+msgstr "无效值。必须为整数。"
+
+#: ../chirp/ui/importdialog.py:137
+#, python-brace-format
+msgid "Location {number} is already being imported"
+msgstr "位置 {number} 已被导入"
+
+#: ../chirp/ui/importdialog.py:194
+msgid "Updating URCALL list"
+msgstr "正在更新 URCALL 列表"
+
+#: ../chirp/ui/importdialog.py:199
+msgid "Updating RPTCALL list"
+msgstr "正在更新 RPTCALL 列表"
+
+#: ../chirp/ui/importdialog.py:272
+#, python-brace-format
+msgid "Setting memory {number}"
+msgstr "正在设置存储 {number}"
+
+#: ../chirp/ui/importdialog.py:277
+msgid "Importing bank information"
+msgstr "正在导入记忆库信息"
+
+#: ../chirp/ui/importdialog.py:281
+msgid "Error importing memories:"
+msgstr "导入存储时出错:"
+
+#: ../chirp/ui/importdialog.py:393
+msgid "All"
+msgstr "全选"
+
+#: ../chirp/ui/importdialog.py:399
+msgid "None"
+msgstr "全不选"
+
+#: ../chirp/ui/importdialog.py:405
+msgid "Inverse"
+msgstr "反选"
+
+#: ../chirp/ui/importdialog.py:411
+msgid "Select"
+msgstr "选择"
+
+#: ../chirp/ui/importdialog.py:457
+msgid "Auto"
+msgstr "自动"
+
+#: ../chirp/ui/importdialog.py:463
+#, fuzzy
+msgid "Reverse"
+msgstr "倒频"
+
+#: ../chirp/ui/importdialog.py:469
+msgid "Adjust New Location"
+msgstr "调整新的位置"
+
+#: ../chirp/ui/importdialog.py:479
+msgid "Confirm overwrites"
+msgstr "确认覆盖"
+
+#: ../chirp/ui/importdialog.py:485
+msgid "Options"
+msgstr "选项"
+
+#: ../chirp/ui/importdialog.py:558
+msgid "Cannot be imported because"
+msgstr "无法导入:"
+
+#: ../chirp/ui/importdialog.py:575
+msgid "Import From File"
+msgstr "导入自文件"
+
+#: ../chirp/ui/importdialog.py:599
+msgid "To"
+msgstr "到"
+
+#: ../chirp/ui/importdialog.py:600
+msgid "From"
+msgstr "从"
+
+#: ../chirp/ui/importdialog.py:603 ../chirp/ui/memdetail.py:362
+#: ../chirp/ui/memedit.py:81 ../chirp/ui/memedit.py:103
+#: ../chirp/ui/memedit.py:1108 ../chirp/ui/memedit.py:1165
+#: ../chirp/ui/memedit.py:1306
+msgid "Comment"
+msgstr "备注"
+
+#: ../chirp/ui/importdialog.py:607
+msgid "Location memory will be imported into"
+msgstr "位置存储将被导入到"
+
+#: ../chirp/ui/importdialog.py:608
+#, fuzzy
+msgid "Location of memory in the file being imported"
+msgstr "正在导入的文件中的存储的位置"
+
+#: ../chirp/ui/importdialog.py:631
+msgid "Preparing memory list..."
+msgstr "正在准备存储清单..."
+
+#: ../chirp/ui/importdialog.py:641
+msgid "Export To File"
+msgstr "导出到文件"
+
+#: ../chirp/ui/memdetail.py:237
+msgid "General"
+msgstr "通用"
+
+#: ../chirp/ui/memdetail.py:279
+msgid "Other"
+msgstr "其他"
+
+#: ../chirp/ui/memdetail.py:336 ../chirp/ui/memedit.py:68
+#: ../chirp/ui/memedit.py:101 ../chirp/ui/memedit.py:116
+#: ../chirp/ui/memedit.py:231 ../chirp/ui/memedit.py:237
+#: ../chirp/ui/memedit.py:271 ../chirp/ui/memedit.py:423
+#: ../chirp/ui/memedit.py:1095 ../chirp/ui/memedit.py:1156
+#: ../chirp/ui/memedit.py:1307 ../chirp/ui/memedit.py:1367
+msgid "Tone Mode"
+msgstr "亚音频制式"
+
+#: ../chirp/ui/memdetail.py:338 ../chirp/ui/memedit.py:69
+#: ../chirp/ui/memedit.py:90 ../chirp/ui/memedit.py:107
+#: ../chirp/ui/memedit.py:166 ../chirp/ui/memedit.py:167
+#: ../chirp/ui/memedit.py:256 ../chirp/ui/memedit.py:286
+#: ../chirp/ui/memedit.py:293 ../chirp/ui/memedit.py:298
+#: ../chirp/ui/memedit.py:306 ../chirp/ui/memedit.py:347
+#: ../chirp/ui/memedit.py:421 ../chirp/ui/memedit.py:1096
+#: ../chirp/ui/memedit.py:1152 ../chirp/ui/memedit.py:1308
+msgid "Tone"
+msgstr "亚音频"
+
+#: ../chirp/ui/memdetail.py:340 ../chirp/ui/memedit.py:70
+#: ../chirp/ui/memedit.py:91 ../chirp/ui/memedit.py:108
+#: ../chirp/ui/memedit.py:260 ../chirp/ui/memedit.py:279
+#: ../chirp/ui/memedit.py:294 ../chirp/ui/memedit.py:299
+#: ../chirp/ui/memedit.py:310 ../chirp/ui/memedit.py:348
+#: ../chirp/ui/memedit.py:421 ../chirp/ui/memedit.py:1097
+#: ../chirp/ui/memedit.py:1153 ../chirp/ui/memedit.py:1304
+msgid "ToneSql"
+msgstr "接收亚音频"
+
+#: ../chirp/ui/memdetail.py:342 ../chirp/ui/memedit.py:71
+#: ../chirp/ui/memedit.py:92 ../chirp/ui/memedit.py:109
+#: ../chirp/ui/memedit.py:244 ../chirp/ui/memedit.py:280
+#: ../chirp/ui/memedit.py:288 ../chirp/ui/memedit.py:300
+#: ../chirp/ui/memedit.py:308 ../chirp/ui/memedit.py:349
+#: ../chirp/ui/memedit.py:417 ../chirp/ui/memedit.py:1098
+#: ../chirp/ui/memedit.py:1154 ../chirp/ui/memedit.py:1296
+#: ../chirp/ui/memedit.py:1373
+msgid "DTCS Code"
+msgstr "DTCS 代码"
+
+#: ../chirp/ui/memdetail.py:344
+msgid "RX DTCS Code"
+msgstr "DTCS 接收代码"
+
+#: ../chirp/ui/memdetail.py:346 ../chirp/ui/memedit.py:73
+#: ../chirp/ui/memedit.py:94 ../chirp/ui/memedit.py:111
+#: ../chirp/ui/memedit.py:252 ../chirp/ui/memedit.py:282
+#: ../chirp/ui/memedit.py:290 ../chirp/ui/memedit.py:302
+#: ../chirp/ui/memedit.py:314 ../chirp/ui/memedit.py:351
+#: ../chirp/ui/memedit.py:1100 ../chirp/ui/memedit.py:1158
+#: ../chirp/ui/memedit.py:1298 ../chirp/ui/memedit.py:1372
+msgid "DTCS Pol"
+msgstr "DTCS 策略"
+
+#: ../chirp/ui/memdetail.py:348
+msgid "Cross mode"
+msgstr "收发使用不同亚音频"
+
+#: ../chirp/ui/memdetail.py:350 ../chirp/ui/memedit.py:75
+#: ../chirp/ui/memedit.py:96 ../chirp/ui/memedit.py:114
+#: ../chirp/ui/memedit.py:140 ../chirp/ui/memedit.py:147
+#: ../chirp/ui/memedit.py:272 ../chirp/ui/memedit.py:345
+#: ../chirp/ui/memedit.py:423 ../chirp/ui/memedit.py:1102
+#: ../chirp/ui/memedit.py:1159 ../chirp/ui/memedit.py:1309
+#: ../chirp/ui/memedit.py:1381
+msgid "Duplex"
+msgstr "差频方向"
+
+#: ../chirp/ui/memdetail.py:352 ../chirp/ui/memedit.py:76
+#: ../chirp/ui/memedit.py:97 ../chirp/ui/memedit.py:145
+#: ../chirp/ui/memedit.py:218 ../chirp/ui/memedit.py:317
+#: ../chirp/ui/memedit.py:346 ../chirp/ui/memedit.py:419
+#: ../chirp/ui/memedit.py:1103 ../chirp/ui/memedit.py:1160
+#: ../chirp/ui/memedit.py:1300
+msgid "Offset"
+msgstr "频差"
+
+#: ../chirp/ui/memdetail.py:354 ../chirp/ui/memedit.py:77
+#: ../chirp/ui/memedit.py:98 ../chirp/ui/memedit.py:112
+#: ../chirp/ui/memedit.py:159 ../chirp/ui/memedit.py:160
+#: ../chirp/ui/memedit.py:163 ../chirp/ui/memedit.py:407
+#: ../chirp/ui/memedit.py:1104 ../chirp/ui/memedit.py:1161
+#: ../chirp/ui/memedit.py:1299 ../chirp/ui/memedit.py:1366
+#: ../chirp/ui/memedit.py:1383 ../chirp/ui/memedit.py:1384
+#: ../chirp/ui/memedit.py:1564 ../chirp/ui/memedit.py:1582
+#: ../chirp/ui/memedit.py:1592
+msgid "Mode"
+msgstr "制式"
+
+#: ../chirp/ui/memdetail.py:356 ../chirp/ui/memedit.py:79
+#: ../chirp/ui/memedit.py:100 ../chirp/ui/memedit.py:115
+#: ../chirp/ui/memedit.py:150 ../chirp/ui/memedit.py:151
+#: ../chirp/ui/memedit.py:156 ../chirp/ui/memedit.py:1106
+#: ../chirp/ui/memedit.py:1163 ../chirp/ui/memedit.py:1302
+#: ../chirp/ui/memedit.py:1379
+msgid "Tune Step"
+msgstr "调谐间隔"
+
+#: ../chirp/ui/memdetail.py:358 ../chirp/ui/memedit.py:80
+#: ../chirp/ui/memedit.py:102 ../chirp/ui/memedit.py:1107
+#: ../chirp/ui/memedit.py:1164 ../chirp/ui/memedit.py:1310
+#: ../chirp/ui/memedit.py:1369
+msgid "Skip"
+msgstr "跳过"
+
+#: ../chirp/ui/memdetail.py:360 ../chirp/ui/memedit.py:78
+#: ../chirp/ui/memedit.py:99 ../chirp/ui/memedit.py:113
+#: ../chirp/ui/memedit.py:407 ../chirp/ui/memedit.py:1105
+#: ../chirp/ui/memedit.py:1162 ../chirp/ui/memedit.py:1311
+#: ../chirp/ui/memedit.py:1370 ../chirp/ui/memedit.py:1377
+msgid "Power"
+msgstr "功率"
+
+#: ../chirp/ui/memdetail.py:408
+msgid "Memory validation failed:"
+msgstr "存储验证失败:"
+
+#: ../chirp/ui/memedit.py:52
+msgid "Invalid value for this field"
+msgstr "此字段的值无效"
+
+#: ../chirp/ui/memedit.py:72 ../chirp/ui/memedit.py:93
+#: ../chirp/ui/memedit.py:110 ../chirp/ui/memedit.py:248
+#: ../chirp/ui/memedit.py:281 ../chirp/ui/memedit.py:289
+#: ../chirp/ui/memedit.py:296 ../chirp/ui/memedit.py:301
+#: ../chirp/ui/memedit.py:312 ../chirp/ui/memedit.py:350
+#: ../chirp/ui/memedit.py:417 ../chirp/ui/memedit.py:1099
+#: ../chirp/ui/memedit.py:1155 ../chirp/ui/memedit.py:1297
+#: ../chirp/ui/memedit.py:1374
+msgid "DTCS Rx Code"
+msgstr "DTCS 接收代码"
+
+#: ../chirp/ui/memedit.py:74 ../chirp/ui/memedit.py:95
+#: ../chirp/ui/memedit.py:117 ../chirp/ui/memedit.py:232
+#: ../chirp/ui/memedit.py:242 ../chirp/ui/memedit.py:264
+#: ../chirp/ui/memedit.py:273 ../chirp/ui/memedit.py:283
+#: ../chirp/ui/memedit.py:291 ../chirp/ui/memedit.py:295
+#: ../chirp/ui/memedit.py:303 ../chirp/ui/memedit.py:352
+#: ../chirp/ui/memedit.py:1101 ../chirp/ui/memedit.py:1157
+#: ../chirp/ui/memedit.py:1305 ../chirp/ui/memedit.py:1368
+msgid "Cross Mode"
+msgstr "收发使用不同亚音频"
+
+#: ../chirp/ui/memedit.py:198
+#, python-brace-format
+msgid "Erasing memory {loc}"
+msgstr "正在擦除存储 {loc}"
+
+#: ../chirp/ui/memedit.py:327
+msgid "Unable to make changes to this model"
+msgstr "无法变更此型号电台"
+
+#: ../chirp/ui/memedit.py:390
+msgid "Error setting memory"
+msgstr "设置存储时出错"
+
+#: ../chirp/ui/memedit.py:400 ../chirp/ui/memedit.py:466
+#: ../chirp/ui/memedit.py:742 ../chirp/ui/memedit.py:765
+#: ../chirp/ui/memedit.py:1541
+#, python-brace-format
+msgid "Writing memory {number}"
+msgstr "正在写入存储 {number}"
+
+#: ../chirp/ui/memedit.py:471
+msgid ""
+"This operation requires moving all subsequent channels by one spot until an "
+"empty location is reached. This can take a LONG time. Are you sure you "
+"want to do this?"
+msgstr ""
+"此操作需要移动所有相邻的频道直至出现空位。可能需要非常非常长的时间。确认要这"
+"样做吗?"
+
+#: ../chirp/ui/memedit.py:495
+#, python-brace-format
+msgid "Adding memory {number}"
+msgstr "正在添加存储 {number}"
+
+#: ../chirp/ui/memedit.py:508 ../chirp/ui/memedit.py:1137
+#, python-brace-format
+msgid "Erasing memory {number}"
+msgstr "正在擦除存储 {number}"
+
+#: ../chirp/ui/memedit.py:517 ../chirp/ui/memedit.py:625
+#: ../chirp/ui/memedit.py:672 ../chirp/ui/memedit.py:677
+#: ../chirp/ui/memedit.py:1066 ../chirp/ui/memedit.py:1399
+#, python-brace-format
+msgid "Getting memory {number}"
+msgstr "正在获取存储 {number}"
+
+#: ../chirp/ui/memedit.py:604 ../chirp/ui/memedit.py:615
+#: ../chirp/ui/memedit.py:664
+#, python-brace-format
+msgid "Moving memory from {old} to {new}"
+msgstr "正在将存储从 {old} 移动到 {new}"
+
+#: ../chirp/ui/memedit.py:686
+#, python-brace-format
+msgid "Raw memory {number}"
+msgstr "原始存储 {number}"
+
+#: ../chirp/ui/memedit.py:690 ../chirp/ui/memedit.py:718
+#: ../chirp/ui/memedit.py:723
+#, python-brace-format
+msgid "Getting raw memory {number}"
+msgstr "正在获取存储 {number}"
+
+#: ../chirp/ui/memedit.py:695
+msgid "You can only diff two memories!"
+msgstr "您只能将两个存储进行对比!"
+
+#: ../chirp/ui/memedit.py:706
+#, python-brace-format
+msgid "Memory {number}"
+msgstr "存储 {number}"
+
+#: ../chirp/ui/memedit.py:712
+#, python-brace-format
+msgid "Diff of {a} and {b}"
+msgstr "{a} 与 {b} 的对比"
+
+#: ../chirp/ui/memedit.py:746
+#, python-brace-format
+msgid "Getting original memory {number}"
+msgstr "正在获取原始存储 {number}"
+
+#: ../chirp/ui/memedit.py:784
+msgid "Memories must be contiguous"
+msgstr "存储必须是连续的"
+
+#: ../chirp/ui/memedit.py:875
+msgid "Cut"
+msgstr "剪切"
+
+#: ../chirp/ui/memedit.py:876
+msgid "Copy"
+msgstr "复制"
+
+#: ../chirp/ui/memedit.py:877
+msgid "Paste"
+msgstr "粘贴"
+
+#: ../chirp/ui/memedit.py:878
+msgid "Select All"
+msgstr "全选"
+
+#: ../chirp/ui/memedit.py:879
+msgid "Insert row above"
+msgstr "上方插入一行"
+
+#: ../chirp/ui/memedit.py:880
+msgid "Insert row below"
+msgstr "下方插入一行"
+
+#: ../chirp/ui/memedit.py:881
+msgid "Delete"
+msgstr "删除"
+
+#: ../chirp/ui/memedit.py:882
+msgid "this memory"
+msgstr "该存储"
+
+#: ../chirp/ui/memedit.py:882
+msgid "these memories"
+msgstr "这些存储"
+
+#: ../chirp/ui/memedit.py:883
+msgid "...and shift block up"
+msgstr "...并将区块上移"
+
+#: ../chirp/ui/memedit.py:884
+msgid "...and shift all memories up"
+msgstr "...并将所有存储上移"
+
+#: ../chirp/ui/memedit.py:885
+msgid "Move up"
+msgstr "上移"
+
+#: ../chirp/ui/memedit.py:886
+msgid "Move down"
+msgstr "下移"
+
+#: ../chirp/ui/memedit.py:887
+msgid "Exchange memories"
+msgstr "交换存储"
+
+#: ../chirp/ui/memedit.py:1053
+#, python-brace-format
+msgid "Internal Error: Column {name} not found"
+msgstr "内部错误:找不到名为 {name} 的列"
+
+#: ../chirp/ui/memedit.py:1177
+#, python-brace-format
+msgid "Internal Error: Invalid limit {number}"
+msgstr "内部错误:无效的限制数值 {number}"
+
+#: ../chirp/ui/memedit.py:1188
+msgid "Memory Range:"
+msgstr "存储范围:"
+
+#: ../chirp/ui/memedit.py:1215
+msgid "Refresh"
+msgstr "刷新"
+
+#: ../chirp/ui/memedit.py:1238
+msgid "Special Channels"
+msgstr "特殊频道"
+
+#: ../chirp/ui/memedit.py:1246
+msgid "Show Empty"
+msgstr "显示空项"
+
+#: ../chirp/ui/memedit.py:1258
+msgid "Properties"
+msgstr "属性"
+
+#: ../chirp/ui/memedit.py:1433
+#, python-brace-format
+msgid "Cutting memory {number}"
+msgstr "正在剪切存储 {number}"
+
+#: ../chirp/ui/memedit.py:1465
+#, python-brace-format
+msgid ""
+"Unable to paste {src} memories into {dst} rows. Increase the memory bounds "
+"or show empty memories."
+msgstr "无法将 {src} 个存储粘贴到 {dst} 行中。请增加存储上线或显示空存储。"
+
+#: ../chirp/ui/memedit.py:1481
+msgid "Yes to All"
+msgstr "全是"
+
+#: ../chirp/ui/memedit.py:1483
+msgid "Overwrite?"
+msgstr "要覆盖吗?"
+
+#: ../chirp/ui/memedit.py:1492
+#, python-brace-format
+msgid "Overwrite location {number}?"
+msgstr "要覆盖位置 {number} 吗?"
+
+#: ../chirp/ui/memedit.py:1519
+msgid "Incompatible Memory"
+msgstr "存储不兼容"
+
+#: ../chirp/ui/memedit.py:1525
+#, python-brace-format
+msgid "Pasted memory {number} is not compatible with this radio because:"
+msgstr "粘贴的存储 {number} 与此电台不兼容,原因:"
+
+#: ../chirp/ui/memedit.py:1584 ../chirp/ui/memedit.py:1599
+msgid "URCALL"
+msgstr "URCALL"
+
+#: ../chirp/ui/memedit.py:1584 ../chirp/ui/memedit.py:1600
+msgid "RPT1CALL"
+msgstr "RPT1CALL"
+
+#: ../chirp/ui/memedit.py:1584 ../chirp/ui/memedit.py:1601
+msgid "RPT2CALL"
+msgstr "RPT2CALL"
+
+#: ../chirp/ui/memedit.py:1585 ../chirp/ui/memedit.py:1602
+#, fuzzy
+msgid "Digital Code"
+msgstr "数字代码"
+
+#: ../chirp/ui/memedit.py:1640 ../chirp/ui/dstaredit.py:175
+msgid "Downloading URCALL list"
+msgstr "正在下载 URCALL 列表"
+
+#: ../chirp/ui/memedit.py:1652 ../chirp/ui/dstaredit.py:179
+msgid "Downloading RPTCALL list"
+msgstr "正在下载 RPTCALL 列表"
+
+#: ../chirp/ui/settingsedit.py:82
+#, python-format
+msgid "Error in setting value: %s"
+msgstr "设置值有误:%s"
+
+#: ../chirp/ui/settingsedit.py:114
+#, python-format
+msgid "Invalid setting value: %s"
+msgstr "设置值无效:%s"
+
+#: ../chirp/ui/settingsedit.py:175
+msgid "Enabled"
+msgstr "已启用"
+
+#: ../chirp/ui/clone.py:40
+#, python-brace-format
+msgid "{vendor} {model} on {port}"
+msgstr "{port} 上的 {vendor} {model}"
+
+#: ../chirp/ui/clone.py:111 ../chirp/ui/clone.py:112 ../chirp/ui/clone.py:172
+msgid "Detect"
+msgstr "探测"
+
+#: ../chirp/ui/clone.py:135
+msgid "Port"
+msgstr "端口"
+
+#: ../chirp/ui/clone.py:136
+msgid "Vendor"
+msgstr "厂商"
+
+#: ../chirp/ui/clone.py:137
+msgid "Model"
+msgstr "型号"
+
+#: ../chirp/ui/clone.py:150
+msgid "Radio"
+msgstr "电台"
+
+#: ../chirp/ui/clone.py:177
+#, python-brace-format
+msgid "Unable to detect radio on {port}"
+msgstr "无法在 {port} 上检测到电台"
+
+#: ../chirp/ui/clone.py:209
+#, python-brace-format
+msgid "Internal error: Unable to upload to {model}"
+msgstr "内部错误:无法上传至 {model}"
+
+#: ../chirp/ui/dstaredit.py:44
+msgid "Callsign"
+msgstr "呼号"
+
+#: ../chirp/ui/dstaredit.py:129
+msgid "Your callsign"
+msgstr "您的呼号"
+
+#: ../chirp/ui/dstaredit.py:137
+msgid "Repeater callsign"
+msgstr "中继台的呼号"
+
+#: ../chirp/ui/dstaredit.py:145
+msgid "My callsign"
+msgstr "我的呼号"
+
+#: ../chirp/ui/dstaredit.py:183
+msgid "Downloading MYCALL list"
+msgstr "正在下载 MYCALL 列表"
+
+#: ../chirp/ui/inputdialog.py:94
+msgid "An error has occurred"
+msgstr "发生错误"
+
+#: ../chirp/ui/inputdialog.py:154
+msgid "File Exists"
+msgstr "文件已存在"
+
+#: ../chirp/ui/inputdialog.py:157
+#, python-brace-format
+msgid "The file {name} already exists. Do you want to overwrite it?"
+msgstr "文件 {name} 已存在。要覆盖吗?"
+
+#: ../chirp/ui/shiftdialog.py:31
+msgid "Shift"
+msgstr "移动"
+
+#: ../chirp/ui/shiftdialog.py:65
+#, python-brace-format
+msgid "Moving {src} to {dst}"
+msgstr "正在移动 {src} 到 {dst}"
+
+#: ../chirp/ui/shiftdialog.py:85
+#, python-brace-format
+msgid "Looking for a free spot ({number})"
+msgstr "寻找空间中({number})"
+
+#: ../chirp/ui/shiftdialog.py:98
+msgid "No space to insert a row"
+msgstr "无剩余空间"
+
+#: ../chirp/ui/shiftdialog.py:146
+#, python-brace-format
+msgid "Moved {count} memories"
+msgstr "已移动 {count} 条存储"
diff --git a/requirements.txt b/requirements.txt
index e7fcfa9..514c19c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,5 @@
six
-PyGObject;python_version>="3.0"
+wxPython>=4.0,<4.2.0 # See https://github.com/wxWidgets/Phoenix/issues/2225
pyserial
future
+requests
diff --git a/share/make_supported.py b/share/make_supported.py
index 67ecebd..339f9fe 100755
--- a/share/make_supported.py
+++ b/share/make_supported.py
@@ -9,9 +9,10 @@ sys.path.insert(0, "..")
tmp = sys.stdout
sys.stdout = sys.stderr
from chirp import *
-from chirp.drivers import *
sys.stdout = tmp
+directory.safe_import_drivers()
+
RF = chirp_common.RadioFeatures()
KEYS = [x for x in sorted(RF.__dict__.keys())
if "_" in x and not x.startswith("_")]
@@ -58,7 +59,7 @@ def supported_row(radio):
try:
value = ", ".join([str(x) for x in value
if not str(x).startswith("?")])
- except Exception, e:
+ except Exception as e:
raise
if key == "memory_bounds":
@@ -149,7 +150,7 @@ models = {"Icom": [],
models = []
-exclude = [directory.DRV_TO_RADIO["Icom_7200"]]
+exclude = []
for radio in directory.DRV_TO_RADIO.values():
if radio in exclude:
@@ -167,7 +168,7 @@ for radio in directory.DRV_TO_RADIO.values():
def get_key(rc):
return '%s %s %s' % (rc.VENDOR, rc.MODEL, rc.VARIANT)
-for radio in sorted(models, cmp=lambda a, b: get_key(a) < get_key(b) and -1 or 1):
+for radio in sorted(models, key=get_key):
if counter % 10 == 0:
output(header_row())
_radio = radio(None)
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
new file mode 100644
index 0000000..4ff8d0e
--- /dev/null
+++ b/snap/snapcraft.yaml
@@ -0,0 +1,118 @@
+name: chirp-snap
+summary: A free, open-source tool for programming your amateur radio
+description: |
+ CHIRP is a free, open-source tool for programming your amateur radio.
+ It supports a large number of manufacturers and models, as well as
+ provides a way to interface with multiple data sources and formats.
+adopt-info: chirp
+grade: stable
+confinement: strict
+base: core18
+
+# This is a python2 GTK2 Application:
+# https://snapcraft.io/docs/gtk2-applications
+
+plugs:
+ gtk-2-engines:
+ interface: content
+ target: $SNAP/lib/gtk-2.0
+ default-provider: gtk2-common-themes
+ gtk-2-themes:
+ interface: content
+ target: $SNAP/data-dir/themes
+ default-provider: gtk-common-themes
+
+hooks:
+ configure:
+ plugs:
+ - home
+ - network
+ - network-bind
+ - removable-media
+ pre-refresh:
+ plugs:
+ - home
+ - network
+ - network-bind
+ - removable-media
+
+apps:
+ chirp-snap:
+ command: bin/chirpw
+ desktop: share/applications/chirp.desktop
+ environment:
+ # Fallback to XWayland if running in a Wayland session.
+ DISABLE_WAYLAND: 1
+ # Needed for fontconfig
+ XDG_DATA_HOME: ${SNAP}/usr/share
+ FONTCONFIG_PATH: ${SNAP}/etc/fonts/config.d
+ FONTCONFIG_FILE: ${SNAP}/etc/fonts/fonts.conf
+ plugs:
+ - home
+ - network
+ - network-bind
+ - removable-media
+ - desktop-legacy
+ - unity7
+ - x11
+ - raw-usb
+ - serial-port
+
+parts:
+ chirp:
+ plugin: python
+ python-version: python2
+ #python-packages: [pycairo, pygobject, pygtk, libxml2, pyserial, python-future, python-suds]
+ source: https://github.com/kk7ds/chirp.git
+ override-pull: |
+ snapcraftctl pull
+ # Set timezone to America/Los_Angeles
+ sudo sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
+ sed -i "s/CHIRP_VERSION = \".*\"/CHIRP_VERSION = \"daily-$(date +%Y%m%d)\"/" chirp/__init__.py
+ sed -i "s,^Icon=.*$,Icon=\$\{SNAP\}/share/chirp-snap.svg," share/chirp.desktop
+ # snap version cannot be longer than 32 characters
+ LATEST_COMMIT_SHORT=$(git rev-parse --short HEAD)
+ SNAP_VERSION="snap-$(date +%Y%m%d)+${LATEST_COMMIT_SHORT}"
+ snapcraftctl set-version "$SNAP_VERSION"
+ override-build: |
+ snapcraftctl build
+ cp ${SNAPCRAFT_PART_SRC}/share/chirp.svg ${SNAPCRAFT_PART_INSTALL}/share/chirp-snap.svg
+ rsync -av ${SNAPCRAFT_PART_INSTALL}/share/ ${SNAPCRAFT_PART_INSTALL}/usr/share/
+ rm ${SNAPCRAFT_PART_INSTALL}/usr/share/pixmaps/chirp.png
+ build-packages:
+ - rsync
+ stage-packages:
+ - python-gtk2
+ - python-serial
+ - python-libxml2
+ - python-future
+ after:
+ - desktop-gtk2
+ # https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml
+ desktop-gtk2:
+ source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
+ source-subdir: gtk
+ plugin: make
+ make-parameters: ["FLAVOR=gtk2"]
+ build-packages:
+ - build-essential
+ - libgtk2.0-dev
+ - gettext
+ stage-packages:
+ - libxkbcommon0 # XKB_CONFIG_ROOT
+ - ttf-ubuntu-font-family
+ - dmz-cursor-theme
+ - light-themes
+ - adwaita-icon-theme
+ - gnome-themes-standard
+ - shared-mime-info
+ - libgtk2.0-0
+ - libgdk-pixbuf2.0-0
+ - libglib2.0-bin
+ - libgtk2.0-bin
+ - unity-gtk2-module
+ - locales-all
+ - libappindicator1
+ - xdg-user-dirs
+ - ibus-gtk
+ - libibus-1.0-5
diff --git a/stock_configs/SE Jaktradio 155MHz.csv b/stock_configs/SE Jaktradio 155MHz.csv
new file mode 100644
index 0000000..34f47dc
--- /dev/null
+++ b/stock_configs/SE Jaktradio 155MHz.csv
@@ -0,0 +1,8 @@
+Location,Name,Frequency,Duplex,Offset,Tone,rToneFreq,cToneFreq,DtcsCode,DtcsPolarity,Mode,TStep,Skip,Comment,URCALL,RPT1CALL,RPT2CALL
+1,JAKT 1,155.425,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
+2,JAKT 2,155.475,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
+3,JAKT 3,155.500,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
+4,JAKT 4,155.525,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
+5,JAKT 5,156.000,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
+6,JAKT 6,156.400,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
+7,JAKT 7,156.450,,0.000000,,88.5,88.5,023,NN,NFM,5.00,,,,,
diff --git a/test-requirements.txt b/test-requirements.txt
index 1e80eb9..e5fbed1 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -2,3 +2,8 @@ mock
mox3
pytest
pytest-xdist
+pytest-html
+six
+pyserial
+future
+requests
diff --git a/tests/Python3_Driver_Testing.md b/tests/Python3_Driver_Testing.md
new file mode 100644
index 0000000..ccb0d49
--- /dev/null
+++ b/tests/Python3_Driver_Testing.md
@@ -0,0 +1,339 @@
+## Status
+| Driver | Tester | Tested | Byte Clean |
+| ------ | ------ | ------ | ---------- |
+| <a name="ARRL_Travel_Plus"></a> ARRL_Travel_Plus | | | |
+| <a name="Abbree_AR-518"></a> Abbree_AR-518 | | | |
+| <a name="Abbree_AR-63"></a> Abbree_AR-63 | | | |
+| <a name="Alinco_DJ-G7EG"></a> Alinco_DJ-G7EG | | | |
+| <a name="Alinco_DJ175"></a> Alinco_DJ175 | | | |
+| <a name="Alinco_DJ596"></a> Alinco_DJ596 | | | |
+| <a name="Alinco_DR03T"></a> Alinco_DR03T | | | |
+| <a name="Alinco_DR06T"></a> Alinco_DR06T | | | |
+| <a name="Alinco_DR135T"></a> Alinco_DR135T | | | |
+| <a name="Alinco_DR235T"></a> Alinco_DR235T | | | |
+| <a name="Alinco_DR435T"></a> Alinco_DR435T | | | |
+| <a name="AnyTone_5888UV"></a> AnyTone_5888UV | | | |
+| <a name="AnyTone_5888UVIII"></a> AnyTone_5888UVIII | | | |
+| <a name="AnyTone_778UV"></a> AnyTone_778UV | | | Yes |
+| <a name="AnyTone_778UV_VOX"></a> AnyTone_778UV_VOX | | | Yes |
+| <a name="AnyTone_OBLTR-8R"></a> AnyTone_OBLTR-8R | | | |
+| <a name="AnyTone_TERMN-8R"></a> AnyTone_TERMN-8R | | | |
+| <a name="Anysecu_WP-9900"></a> Anysecu_WP-9900 | | | Yes |
+| <a name="BTECH_FRS-A1"></a> BTECH_FRS-A1 | | | |
+| <a name="BTECH_FRS-B1"></a> BTECH_FRS-B1 | | | |
+| <a name="BTECH_GMRS-20V2"></a> BTECH_GMRS-20V2 | | | Yes |
+| <a name="BTECH_GMRS-50X1"></a> BTECH_GMRS-50X1 | | | Yes |
+| <a name="BTECH_GMRS-V1"></a> BTECH_GMRS-V1 | | | |
+| <a name="BTECH_GMRS-V2"></a> BTECH_GMRS-V2 | | | |
+| <a name="BTECH_MURS-V1"></a> BTECH_MURS-V1 | | | |
+| <a name="BTECH_UV-2501"></a> BTECH_UV-2501 | | | Yes |
+| <a name="BTECH_UV-2501+220"></a> BTECH_UV-2501+220 | | | Yes |
+| <a name="BTECH_UV-25X2"></a> BTECH_UV-25X2 | | | Yes |
+| <a name="BTECH_UV-25X4"></a> BTECH_UV-25X4 | | | Yes |
+| <a name="BTECH_UV-5001"></a> BTECH_UV-5001 | | | Yes |
+| <a name="BTECH_UV-50X2"></a> BTECH_UV-50X2 | | | Yes |
+| <a name="BTECH_UV-50X3"></a> BTECH_UV-50X3 | | | |
+| <a name="BTECH_UV-5X3"></a> BTECH_UV-5X3 | | | |
+| <a name="Baofeng_BF-888"></a> Baofeng_BF-888 | [@kk7ds](https://github.com/kk7ds) | 13-Feb-2019 | Yes |
+| <a name="Baofeng_BF-A58"></a> Baofeng_BF-A58 | | | |
+| <a name="Baofeng_BF-A58S"></a> Baofeng_BF-A58S | | | |
+| <a name="Baofeng_BF-F8HP"></a> Baofeng_BF-F8HP | | | Yes |
+| <a name="Baofeng_BF-T1"></a> Baofeng_BF-T1 | | | |
+| <a name="Baofeng_BF-T8"></a> Baofeng_BF-T8 | | | |
+| <a name="Baofeng_BF-V8A"></a> Baofeng_BF-V8A | | | |
+| <a name="Baofeng_F-11"></a> Baofeng_F-11 | | | Yes |
+| <a name="Baofeng_GT-3WP"></a> Baofeng_GT-3WP | | | |
+| <a name="Baofeng_GT-5R"></a> Baofeng_GT-5R | | | Yes |
+| <a name="Baofeng_UV-3R"></a> Baofeng_UV-3R | [@yarda](https://github.com/yarda) | 26-Sep-2022 | |
+| <a name="Baofeng_UV-5R"></a> Baofeng_UV-5R | [@lekv](https://github.com/lekv) | 23-Oct-2022 | Yes |
+| <a name="Baofeng_UV-6"></a> Baofeng_UV-6 | | | Yes |
+| <a name="Baofeng_UV-6R"></a> Baofeng_UV-6R | | | |
+| <a name="Baofeng_UV-82"></a> Baofeng_UV-82 | | | Yes |
+| <a name="Baofeng_UV-82HP"></a> Baofeng_UV-82HP | | | Yes |
+| <a name="Baofeng_UV-82WP"></a> Baofeng_UV-82WP | | | |
+| <a name="Baofeng_UV-9G"></a> Baofeng_UV-9G | | | |
+| <a name="Baofeng_UV-9R"></a> Baofeng_UV-9R | | | |
+| <a name="Baofeng_UV-B5"></a> Baofeng_UV-B5 | | | Yes |
+| <a name="Baojie_BJ-UV55"></a> Baojie_BJ-UV55 | | | Yes |
+| <a name="Boblov_X3Plus"></a> Boblov_X3Plus | | | |
+| <a name="CRT_Micron_UV"></a> CRT_Micron_UV | | | Yes |
+| <a name="CRT_Micron_UV_V2"></a> CRT_Micron_UV_V2 | | | Yes |
+| <a name="Commander_KG-UV"></a> Commander_KG-UV | | | |
+| <a name="Explorer_QRZ-1"></a> Explorer_QRZ-1 | | | |
+| <a name="Feidaxin_FD-150A"></a> Feidaxin_FD-150A | | | |
+| <a name="Feidaxin_FD-160A"></a> Feidaxin_FD-160A | | | |
+| <a name="Feidaxin_FD-268A"></a> Feidaxin_FD-268A | | | |
+| <a name="Feidaxin_FD-268B"></a> Feidaxin_FD-268B | | | |
+| <a name="Feidaxin_FD-288A"></a> Feidaxin_FD-288A | | | |
+| <a name="Feidaxin_FD-288B"></a> Feidaxin_FD-288B | | | |
+| <a name="Feidaxin_FD-450A"></a> Feidaxin_FD-450A | | | |
+| <a name="Feidaxin_FD-460A"></a> Feidaxin_FD-460A | | | |
+| <a name="Feidaxin_FD-460UH"></a> Feidaxin_FD-460UH | | | |
+| <a name="Generic_CSV"></a> Generic_CSV | | | |
+| <a name="HobbyPCB_RS-UV3"></a> HobbyPCB_RS-UV3 | | | |
+| <a name="Icom_746"></a> Icom_746 | | | Yes |
+| <a name="Icom_IC-208H"></a> Icom_IC-208H | | | Yes |
+| <a name="Icom_IC-2100H"></a> Icom_IC-2100H | | | Yes |
+| <a name="Icom_IC-2200H"></a> Icom_IC-2200H | [@kk7ds](https://github.com/kk7ds) | 24-Oct-2022 | Yes |
+| <a name="Icom_IC-2300H"></a> Icom_IC-2300H | | | Yes |
+| <a name="Icom_IC-2720H"></a> Icom_IC-2720H | | | Yes |
+| <a name="Icom_IC-2730A"></a> Icom_IC-2730A | | | Yes |
+| <a name="Icom_IC-2820H"></a> Icom_IC-2820H | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Icom_IC-7000"></a> Icom_IC-7000 | | | Yes |
+| <a name="Icom_IC-7100"></a> Icom_IC-7100 | | | Yes |
+| <a name="Icom_IC-7200"></a> Icom_IC-7200 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Icom_IC-7300"></a> Icom_IC-7300 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Icom_IC-7610"></a> Icom_IC-7610 | [@kk7ds](https://github.com/kk7ds) | 24-Oct-2022 | Yes |
+| <a name="Icom_IC-910"></a> Icom_IC-910 | [@mfncooper](https://github.com/mfncooper) | 1-Oct-2021 | Yes |
+| <a name="Icom_IC-91_92AD"></a> Icom_IC-91_92AD | | | |
+| <a name="Icom_IC-E90"></a> Icom_IC-E90 | | | Yes |
+| <a name="Icom_IC-P7"></a> Icom_IC-P7 | | | Yes |
+| <a name="Icom_IC-Q7A"></a> Icom_IC-Q7A | | | Yes |
+| <a name="Icom_IC-T70"></a> Icom_IC-T70 | | | Yes |
+| <a name="Icom_IC-T7H"></a> Icom_IC-T7H | | | Yes |
+| <a name="Icom_IC-T8A"></a> Icom_IC-T8A | | | Yes |
+| <a name="Icom_IC-V82_U82"></a> Icom_IC-V82_U82 | | | |
+| <a name="Icom_IC-V86"></a> Icom_IC-V86 | | | Yes |
+| <a name="Icom_IC-W32A"></a> Icom_IC-W32A | | | Yes |
+| <a name="Icom_IC-W32E"></a> Icom_IC-W32E | | | Yes |
+| <a name="Icom_ID-31A"></a> Icom_ID-31A | [@kk7ds](https://github.com/kk7ds) | 12-Feb-2019 | Yes |
+| <a name="Icom_ID-51"></a> Icom_ID-51 | | | Yes |
+| <a name="Icom_ID-51_Plus"></a> Icom_ID-51_Plus | | | Yes |
+| <a name="Icom_ID-800H_v2"></a> Icom_ID-800H_v2 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Icom_ID-80H"></a> Icom_ID-80H | | | Yes |
+| <a name="Icom_ID-880H"></a> Icom_ID-880H | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Intek_HR-2040"></a> Intek_HR-2040 | | | |
+| <a name="Intek_KT-980HP"></a> Intek_KT-980HP | | | Yes |
+| <a name="Jetstream_JT220M"></a> Jetstream_JT220M | | | |
+| <a name="Jetstream_JT270M"></a> Jetstream_JT270M | | | |
+| <a name="Jetstream_JT270MH"></a> Jetstream_JT270MH | | | |
+| <a name="KYD_IP-620"></a> KYD_IP-620 | | | |
+| <a name="KYD_NC-630A"></a> KYD_NC-630A | | | |
+| <a name="Kenwood_HMK"></a> Kenwood_HMK | | | |
+| <a name="Kenwood_ITM"></a> Kenwood_ITM | | | |
+| <a name="Kenwood_TH-D7"></a> Kenwood_TH-D7 | | | Yes |
+| <a name="Kenwood_TH-D72_clone_mode"></a> Kenwood_TH-D72_clone_mode | | | |
+| <a name="Kenwood_TH-D72_live_mode"></a> Kenwood_TH-D72_live_mode | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes |
+| <a name="Kenwood_TH-D74_live_mode"></a> Kenwood_TH-D74_live_mode | [@kk7ds](https://github.com/kk7ds) | 20-Oct-2022 | Yes |
+| <a name="Kenwood_TH-D7G"></a> Kenwood_TH-D7G | | | Yes |
+| <a name="Kenwood_TH-F6"></a> Kenwood_TH-F6 | | | Yes |
+| <a name="Kenwood_TH-F7"></a> Kenwood_TH-F7 | [@sv1](https://github.com/sv1) | 19-Oct-2022 | Yes |
+| <a name="Kenwood_TH-G71"></a> Kenwood_TH-G71 | | | Yes |
+| <a name="Kenwood_TH-K2"></a> Kenwood_TH-K2 | | | Yes |
+| <a name="Kenwood_TK-2180"></a> Kenwood_TK-2180 | | | Yes |
+| <a name="Kenwood_TK-260"></a> Kenwood_TK-260 | | | |
+| <a name="Kenwood_TK-260G"></a> Kenwood_TK-260G | | | |
+| <a name="Kenwood_TK-270"></a> Kenwood_TK-270 | | | |
+| <a name="Kenwood_TK-270G"></a> Kenwood_TK-270G | | | |
+| <a name="Kenwood_TK-272"></a> Kenwood_TK-272 | | | |
+| <a name="Kenwood_TK-272G"></a> Kenwood_TK-272G | | | |
+| <a name="Kenwood_TK-278"></a> Kenwood_TK-278 | | | |
+| <a name="Kenwood_TK-278G"></a> Kenwood_TK-278G | | | |
+| <a name="Kenwood_TK-3180K"></a> Kenwood_TK-3180K | | | Yes |
+| <a name="Kenwood_TK-3180K2"></a> Kenwood_TK-3180K2 | | | Yes |
+| <a name="Kenwood_TK-360"></a> Kenwood_TK-360 | | | |
+| <a name="Kenwood_TK-360G"></a> Kenwood_TK-360G | | | |
+| <a name="Kenwood_TK-370"></a> Kenwood_TK-370 | | | |
+| <a name="Kenwood_TK-370G"></a> Kenwood_TK-370G | | | |
+| <a name="Kenwood_TK-372"></a> Kenwood_TK-372 | | | |
+| <a name="Kenwood_TK-372G"></a> Kenwood_TK-372G | | | |
+| <a name="Kenwood_TK-378"></a> Kenwood_TK-378 | | | |
+| <a name="Kenwood_TK-378G"></a> Kenwood_TK-378G | | | |
+| <a name="Kenwood_TK-388G"></a> Kenwood_TK-388G | | | |
+| <a name="Kenwood_TK-7102"></a> Kenwood_TK-7102 | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Kenwood_TK-7108"></a> Kenwood_TK-7108 | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Kenwood_TK-7180"></a> Kenwood_TK-7180 | [@kk7ds](https://github.com/kk7ds) | 18-Oct-2022 | Yes |
+| <a name="Kenwood_TK-7180E"></a> Kenwood_TK-7180E | | | Yes |
+| <a name="Kenwood_TK-760"></a> Kenwood_TK-760 | | | |
+| <a name="Kenwood_TK-760G"></a> Kenwood_TK-760G | | | |
+| <a name="Kenwood_TK-762"></a> Kenwood_TK-762 | | | |
+| <a name="Kenwood_TK-762G"></a> Kenwood_TK-762G | | | |
+| <a name="Kenwood_TK-768"></a> Kenwood_TK-768 | | | |
+| <a name="Kenwood_TK-768G"></a> Kenwood_TK-768G | | | |
+| <a name="Kenwood_TK-8102"></a> Kenwood_TK-8102 | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Kenwood_TK-8108"></a> Kenwood_TK-8108 | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Kenwood_TK-8180"></a> Kenwood_TK-8180 | [@kk7ds](https://github.com/kk7ds) | 18-Oct-2022 | Yes |
+| <a name="Kenwood_TK-8180E"></a> Kenwood_TK-8180E | | | Yes |
+| <a name="Kenwood_TK-860"></a> Kenwood_TK-860 | | | |
+| <a name="Kenwood_TK-860G"></a> Kenwood_TK-860G | | | |
+| <a name="Kenwood_TK-862"></a> Kenwood_TK-862 | | | |
+| <a name="Kenwood_TK-862G"></a> Kenwood_TK-862G | | | |
+| <a name="Kenwood_TK-868"></a> Kenwood_TK-868 | | | |
+| <a name="Kenwood_TK-868G"></a> Kenwood_TK-868G | | | |
+| <a name="Kenwood_TM-271"></a> Kenwood_TM-271 | [Implied by Kenwood_TM-281](#user-content-Kenwood_TM-281) | 23-Oct-2022 | Yes |
+| <a name="Kenwood_TM-281"></a> Kenwood_TM-281 | [@kk7ds](https://github.com/kk7ds) | 23-Oct-2022 | Yes |
+| <a name="Kenwood_TM-471"></a> Kenwood_TM-471 | | | Yes |
+| <a name="Kenwood_TM-D700"></a> Kenwood_TM-D700 | [@kk7ds](https://github.com/kk7ds) | 20-Oct-2022 | Yes |
+| <a name="Kenwood_TM-D710"></a> Kenwood_TM-D710 | | | Yes |
+| <a name="Kenwood_TM-D710G"></a> Kenwood_TM-D710G | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Kenwood_TM-D710G_CloneMode"></a> Kenwood_TM-D710G_CloneMode | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes |
+| <a name="Kenwood_TM-D710_CloneMode"></a> Kenwood_TM-D710_CloneMode | | | Yes |
+| <a name="Kenwood_TM-G707"></a> Kenwood_TM-G707 | | | Yes |
+| <a name="Kenwood_TM-V7"></a> Kenwood_TM-V7 | | | Yes |
+| <a name="Kenwood_TM-V71"></a> Kenwood_TM-V71 | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes |
+| <a name="Kenwood_TS-2000"></a> Kenwood_TS-2000 | | | Yes |
+| <a name="Kenwood_TS-480_CloneMode"></a> Kenwood_TS-480_CloneMode | | | |
+| <a name="Kenwood_TS-480_LiveMode"></a> Kenwood_TS-480_LiveMode | | | Yes |
+| <a name="Kenwood_TS-590SG_CloneMode"></a> Kenwood_TS-590SG_CloneMode | | | |
+| <a name="Kenwood_TS-590S_CloneMode"></a> Kenwood_TS-590S_CloneMode | | | |
+| <a name="Kenwood_TS-590S_SG_LiveMode"></a> Kenwood_TS-590S_SG_LiveMode | | | Yes |
+| <a name="Kenwood_TS-850"></a> Kenwood_TS-850 | | | Yes |
+| <a name="LUITON_LT-316"></a> LUITON_LT-316 | | | |
+| <a name="LUITON_LT-580_UHF"></a> LUITON_LT-580_UHF | | | |
+| <a name="LUITON_LT-580_VHF"></a> LUITON_LT-580_VHF | | | |
+| <a name="LUITON_LT-588UV"></a> LUITON_LT-588UV | | | Yes |
+| <a name="Lanchonlh_HG-UV98"></a> Lanchonlh_HG-UV98 | | | Yes |
+| <a name="Leixen_VV-898"></a> Leixen_VV-898 | | | |
+| <a name="Leixen_VV-898S"></a> Leixen_VV-898S | | | |
+| <a name="MTC_UV-5R-3"></a> MTC_UV-5R-3 | | | |
+| <a name="Midland_DBR2500"></a> Midland_DBR2500 | | | Yes |
+| <a name="Polmar_DB-50M"></a> Polmar_DB-50M | | | |
+| <a name="Powerwerx_DB-750X"></a> Powerwerx_DB-750X | | | |
+| <a name="QYT_KT-8R"></a> QYT_KT-8R | | | Yes |
+| <a name="QYT_KT-UV980"></a> QYT_KT-UV980 | | | Yes |
+| <a name="QYT_KT-WP12"></a> QYT_KT-WP12 | | | Yes |
+| <a name="QYT_KT5800"></a> QYT_KT5800 | | | Yes |
+| <a name="QYT_KT7900D"></a> QYT_KT7900D | | | Yes |
+| <a name="QYT_KT8900"></a> QYT_KT8900 | | | Yes |
+| <a name="QYT_KT8900D"></a> QYT_KT8900D | | | Yes |
+| <a name="QYT_KT8900R"></a> QYT_KT8900R | | | Yes |
+| <a name="QYT_KT980PLUS"></a> QYT_KT980PLUS | | | Yes |
+| <a name="Quansheng_TG-UV2+"></a> Quansheng_TG-UV2+ | | | |
+| <a name="RT_Systems_CSV"></a> RT_Systems_CSV | | | |
+| <a name="Radioddity_DB25-G"></a> Radioddity_DB25-G | | | Yes |
+| <a name="Radioddity_GA-2S"></a> Radioddity_GA-2S | | | Yes |
+| <a name="Radioddity_GA-510"></a> Radioddity_GA-510 | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes |
+| <a name="Radioddity_R2"></a> Radioddity_R2 | | | |
+| <a name="Radioddity_UV-5G"></a> Radioddity_UV-5G | | | Yes |
+| <a name="Radioddity_UV-5RX3"></a> Radioddity_UV-5RX3 | | | Yes |
+| <a name="Radioddity_UV-82X3"></a> Radioddity_UV-82X3 | | | Yes |
+| <a name="Radtel_T18"></a> Radtel_T18 | | | |
+| <a name="Retevis_H777_Plus"></a> Retevis_H777_Plus | | | Yes |
+| <a name="Retevis_RA685"></a> Retevis_RA685 | | | Yes |
+| <a name="Retevis_RA85"></a> Retevis_RA85 | | | Yes |
+| <a name="Retevis_RB15"></a> Retevis_RB15 | | | |
+| <a name="Retevis_RB17"></a> Retevis_RB17 | | | |
+| <a name="Retevis_RB17A"></a> Retevis_RB17A | | | |
+| <a name="Retevis_RB17P"></a> Retevis_RB17P | | | |
+| <a name="Retevis_RB17V"></a> Retevis_RB17V | | | |
+| <a name="Retevis_RB18"></a> Retevis_RB18 | | | |
+| <a name="Retevis_RB19"></a> Retevis_RB19 | | | |
+| <a name="Retevis_RB19P"></a> Retevis_RB19P | | | |
+| <a name="Retevis_RB23"></a> Retevis_RB23 | | | |
+| <a name="Retevis_RB26"></a> Retevis_RB26 | | | |
+| <a name="Retevis_RB27"></a> Retevis_RB27 | | | |
+| <a name="Retevis_RB27B"></a> Retevis_RB27B | | | |
+| <a name="Retevis_RB27V"></a> Retevis_RB27V | | | |
+| <a name="Retevis_RB615"></a> Retevis_RB615 | | | |
+| <a name="Retevis_RB617"></a> Retevis_RB617 | | | |
+| <a name="Retevis_RB618"></a> Retevis_RB618 | | | |
+| <a name="Retevis_RB619"></a> Retevis_RB619 | | | |
+| <a name="Retevis_RB627B"></a> Retevis_RB627B | | | |
+| <a name="Retevis_RB75"></a> Retevis_RB75 | | | |
+| <a name="Retevis_RB85"></a> Retevis_RB85 | | | |
+| <a name="Retevis_RT1"></a> Retevis_RT1 | | | |
+| <a name="Retevis_RT16"></a> Retevis_RT16 | | | |
+| <a name="Retevis_RT19"></a> Retevis_RT19 | | | |
+| <a name="Retevis_RT21"></a> Retevis_RT21 | | | |
+| <a name="Retevis_RT22"></a> Retevis_RT22 | | | |
+| <a name="Retevis_RT22FRS"></a> Retevis_RT22FRS | | | |
+| <a name="Retevis_RT22S"></a> Retevis_RT22S | | | |
+| <a name="Retevis_RT23"></a> Retevis_RT23 | | | |
+| <a name="Retevis_RT26"></a> Retevis_RT26 | | | |
+| <a name="Retevis_RT29_UHF"></a> Retevis_RT29_UHF | | | |
+| <a name="Retevis_RT29_VHF"></a> Retevis_RT29_VHF | | | |
+| <a name="Retevis_RT40B"></a> Retevis_RT40B | | | |
+| <a name="Retevis_RT47"></a> Retevis_RT47 | | | |
+| <a name="Retevis_RT47V"></a> Retevis_RT47V | | | |
+| <a name="Retevis_RT6"></a> Retevis_RT6 | | | |
+| <a name="Retevis_RT619"></a> Retevis_RT619 | | | |
+| <a name="Retevis_RT622"></a> Retevis_RT622 | | | |
+| <a name="Retevis_RT647"></a> Retevis_RT647 | | | |
+| <a name="Retevis_RT668"></a> Retevis_RT668 | | | |
+| <a name="Retevis_RT68"></a> Retevis_RT68 | | | |
+| <a name="Retevis_RT76"></a> Retevis_RT76 | | | |
+| <a name="Retevis_RT76P"></a> Retevis_RT76P | | | |
+| <a name="Retevis_RT85"></a> Retevis_RT85 | | | |
+| <a name="Retevis_RT87"></a> Retevis_RT87 | | | |
+| <a name="Retevis_RT9000D_136-174"></a> Retevis_RT9000D_136-174 | | | |
+| <a name="Retevis_RT9000D_220-260"></a> Retevis_RT9000D_220-260 | | | |
+| <a name="Retevis_RT9000D_400-490"></a> Retevis_RT9000D_400-490 | | | |
+| <a name="Retevis_RT9000D_66-88"></a> Retevis_RT9000D_66-88 | | | |
+| <a name="Retevis_RT95"></a> Retevis_RT95 | | | Yes |
+| <a name="Retevis_RT95_VOX"></a> Retevis_RT95_VOX | | | Yes |
+| <a name="Retevis_RT98"></a> Retevis_RT98 | | | |
+| <a name="Rugged_RH5R-V2"></a> Rugged_RH5R-V2 | | | |
+| <a name="TDXone_TD-Q8A"></a> TDXone_TD-Q8A | | | |
+| <a name="TIDRADIO_TD-H6"></a> TIDRADIO_TD-H6 | [@kk7ds](https://github.com/kk7ds) | 21-Oct-2022 | Yes |
+| <a name="TID_TD-M8"></a> TID_TD-M8 | | | |
+| <a name="TYT_TH-350"></a> TYT_TH-350 | | | Yes |
+| <a name="TYT_TH-7800"></a> TYT_TH-7800 | | | |
+| <a name="TYT_TH-7800_File"></a> TYT_TH-7800_File | | | |
+| <a name="TYT_TH-9800"></a> TYT_TH-9800 | | | |
+| <a name="TYT_TH-9800_File"></a> TYT_TH-9800_File | | | |
+| <a name="TYT_TH-UV8000"></a> TYT_TH-UV8000 | | | |
+| <a name="TYT_TH-UV88"></a> TYT_TH-UV88 | | | |
+| <a name="TYT_TH-UVF1"></a> TYT_TH-UVF1 | | | |
+| <a name="TYT_TH-UVF8D"></a> TYT_TH-UVF8D | | | |
+| <a name="TYT_TH9000_144"></a> TYT_TH9000_144 | | | |
+| <a name="TYT_TH9000_220"></a> TYT_TH9000_220 | | | |
+| <a name="TYT_TH9000_440"></a> TYT_TH9000_440 | | | |
+| <a name="Vertex_Standard_FTL-1011"></a> Vertex_Standard_FTL-1011 | | | |
+| <a name="Vertex_Standard_FTL-2011"></a> Vertex_Standard_FTL-2011 | | | |
+| <a name="Vertex_Standard_FTL-7011"></a> Vertex_Standard_FTL-7011 | | | |
+| <a name="Vertex_Standard_FTL-8011"></a> Vertex_Standard_FTL-8011 | | | |
+| <a name="Vertex_Standard_VXA-700"></a> Vertex_Standard_VXA-700 | | | |
+| <a name="WACCOM_MINI-8900"></a> WACCOM_MINI-8900 | | | Yes |
+| <a name="WLN_KD-C1"></a> WLN_KD-C1 | | | |
+| <a name="Wouxun_KG-935G"></a> Wouxun_KG-935G | | | |
+| <a name="Wouxun_KG-UV8D"></a> Wouxun_KG-UV8D | | | |
+| <a name="Wouxun_KG-UV8D_Plus"></a> Wouxun_KG-UV8D_Plus | | | |
+| <a name="Wouxun_KG-UV8E"></a> Wouxun_KG-UV8E | | | |
+| <a name="Wouxun_KG-UV920P-A"></a> Wouxun_KG-UV920P-A | | | |
+| <a name="Wouxun_KG-UV9D_Plus"></a> Wouxun_KG-UV9D_Plus | | | |
+| <a name="Yaesu_FT-1500M"></a> Yaesu_FT-1500M | | | Yes |
+| <a name="Yaesu_FT-1802M"></a> Yaesu_FT-1802M | | | Yes |
+| <a name="Yaesu_FT-25R"></a> Yaesu_FT-25R | | | Yes |
+| <a name="Yaesu_FT-2800M"></a> Yaesu_FT-2800M | | | Yes |
+| <a name="Yaesu_FT-2900R_1900R"></a> Yaesu_FT-2900R_1900R | | | Yes |
+| <a name="Yaesu_FT-2900R_1900RTXMod_Opened_Xmit"></a> Yaesu_FT-2900R_1900RTXMod_Opened_Xmit | | | Yes |
+| <a name="Yaesu_FT-4VR"></a> Yaesu_FT-4VR | | | Yes |
+| <a name="Yaesu_FT-4XE"></a> Yaesu_FT-4XE | | | Yes |
+| <a name="Yaesu_FT-4XR"></a> Yaesu_FT-4XR | | | Yes |
+| <a name="Yaesu_FT-50"></a> Yaesu_FT-50 | | | Yes |
+| <a name="Yaesu_FT-60"></a> Yaesu_FT-60 | | | Yes |
+| <a name="Yaesu_FT-65E"></a> Yaesu_FT-65E | | | Yes |
+| <a name="Yaesu_FT-65R"></a> Yaesu_FT-65R | | | Yes |
+| <a name="Yaesu_FT-70D"></a> Yaesu_FT-70D | | | Yes |
+| <a name="Yaesu_FT-7100M"></a> Yaesu_FT-7100M | | | Yes |
+| <a name="Yaesu_FT-7800_7900"></a> Yaesu_FT-7800_7900 | [@kk7ds](https://github.com/kk7ds) | 24-Oct-2022 | Yes |
+| <a name="Yaesu_FT-8100"></a> Yaesu_FT-8100 | | | Yes |
+| <a name="Yaesu_FT-817"></a> Yaesu_FT-817 | [@kk7ds](https://github.com/kk7ds) | 14-Feb-2019 | Yes |
+| <a name="Yaesu_FT-817ND"></a> Yaesu_FT-817ND | | | Yes |
+| <a name="Yaesu_FT-817ND_US"></a> Yaesu_FT-817ND_US | | | Yes |
+| <a name="Yaesu_FT-818"></a> Yaesu_FT-818 | | | Yes |
+| <a name="Yaesu_FT-818ND_US"></a> Yaesu_FT-818ND_US | | | Yes |
+| <a name="Yaesu_FT-857_897"></a> Yaesu_FT-857_897 | | | Yes |
+| <a name="Yaesu_FT-857_897_US"></a> Yaesu_FT-857_897_US | | | Yes |
+| <a name="Yaesu_FT-8800"></a> Yaesu_FT-8800 | [@kk7ds](https://github.com/kk7ds) | 24-Oct-2022 | Yes |
+| <a name="Yaesu_FT-8900"></a> Yaesu_FT-8900 | | | Yes |
+| <a name="Yaesu_FT-90"></a> Yaesu_FT-90 | | | Yes |
+| <a name="Yaesu_FTM-350"></a> Yaesu_FTM-350 | | | Yes |
+| <a name="Yaesu_VX-170"></a> Yaesu_VX-170 | | | Yes |
+| <a name="Yaesu_VX-2"></a> Yaesu_VX-2 | | | Yes |
+| <a name="Yaesu_VX-3"></a> Yaesu_VX-3 | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Yaesu_VX-5"></a> Yaesu_VX-5 | | | Yes |
+| <a name="Yaesu_VX-6"></a> Yaesu_VX-6 | | | Yes |
+| <a name="Yaesu_VX-7"></a> Yaesu_VX-7 | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Yaesu_VX-8DR"></a> Yaesu_VX-8DR | [@kk7ds](https://github.com/kk7ds) | 15-Feb-2019 | Yes |
+| <a name="Yaesu_VX-8GE"></a> Yaesu_VX-8GE | | | Yes |
+| <a name="Yaesu_VX-8R"></a> Yaesu_VX-8R | | | Yes |
+| <a name="Yedro_YC-M04VUS"></a> Yedro_YC-M04VUS | | | Yes |
+| <a name="Zastone_ZT-X6"></a> Zastone_ZT-X6 | | | |
+## Stats
+
+**Drivers:** 329
+
+**Tested:** 10% (35/294)
+
+**Byte clean:** 45% (151/178)
diff --git a/tests/__init__.py b/tests/__init__.py
index d04e516..7fc393e 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,3 +1,4 @@
+import functools
import glob
import logging
import os
@@ -7,6 +8,7 @@ import sys
import tempfile
import unittest
+import pytest
import six
from chirp import directory
@@ -15,6 +17,24 @@ from tests import run_tests
LOG = logging.getLogger('testadapter')
+PY3_XFAIL = []
+
+
+def if_enabled(fn):
+ name = fn.__name__.replace('test_', '')
+ if 'CHIRP_TESTS' in os.environ:
+ tests_enabled = os.environ['CHIRP_TESTS'].split(',')
+ enabled = name in tests_enabled
+ else:
+ enabled = True
+
+ def wrapper(*a, **k):
+ if enabled:
+ return fn(*a, **k)
+ else:
+ raise unittest.SkipTest('%s not enabled' % name)
+
+ return wrapper
class TestAdapterMeta(type):
@@ -27,6 +47,7 @@ class TestAdapter(unittest.TestCase):
SOURCE_IMAGE = None
RADIO_INST = None
testwrapper = None
+ XFAIL = False
def shortDescription(self):
test = self.id().split('.')[-1].replace('test_', '').replace('_', ' ')
@@ -48,6 +69,17 @@ class TestAdapter(unittest.TestCase):
def tearDownClass(cls):
os.remove(cls.testimage)
+ def setUp(self):
+ self._out = run_tests.TestOutputANSI()
+ rid = "%s_%s_" % (self.RADIO_CLASS.VENDOR, self.RADIO_CLASS.MODEL)
+ rid = rid.replace("/", "_")
+ basefn, ext = os.path.splitext(self.testimage)
+ self.testimage = tempfile.mktemp('.%s' % ext, rid)
+ shutil.copy(self.SOURCE_IMAGE, self.testimage)
+
+ def tearDown(self):
+ os.remove(self.testimage)
+
def _runtest(self, test):
tw = run_tests.TestWrapper(self.RADIO_CLASS,
self.testimage,
@@ -65,27 +97,37 @@ class TestAdapter(unittest.TestCase):
finally:
testcase.cleanup()
+ @if_enabled
def test_copy_all(self):
self._runtest(run_tests.TestCaseCopyAll)
+ @if_enabled
def test_brute_force(self):
self._runtest(run_tests.TestCaseBruteForce)
+ @if_enabled
def test_edges(self):
self._runtest(run_tests.TestCaseEdges)
+ @if_enabled
def test_settings(self):
self._runtest(run_tests.TestCaseSettings)
+ @if_enabled
def test_banks(self):
self._runtest(run_tests.TestCaseBanks)
+ @if_enabled
def test_detect(self):
self._runtest(run_tests.TestCaseDetect)
+ @if_enabled
def test_clone(self):
self._runtest(run_tests.TestCaseClone)
+ def test_py3_expected(self):
+ assert self.SOURCE_IMAGE not in PY3_XFAIL
+
def _get_sub_devices(rclass, testimage):
try:
@@ -93,22 +135,43 @@ def _get_sub_devices(rclass, testimage):
except Exception as e:
tw = run_tests.TestWrapper(rclass, testimage)
- rf = tw.do("get_features")
+ try:
+ rf = tw.do("get_features")
+ except Exception as e:
+ print('Failed to get features for %s: %s' % (rclass, e))
+ # FIXME: If the driver fails to run get_features with no memobj
+ # we should not arrest the test load. This appears to happen for
+ # the Puxing777 for some reason, and not all the time. Figure that
+ # out, but until then, assume crash means "no sub devices".
+ return [rclass]
if rf.has_sub_devices:
return tw.do("get_sub_devices")
else:
return [rclass]
+class TestAdapterXFAIL(TestAdapter):
+ @pytest.mark.xfail(reason=('Driver not expected to run in python3. '
+ 'Remove from py3_remaining.txt'), strict=True)
+ def test_py3_expected(self):
+ pass
+
+
class RadioSkipper(unittest.TestCase):
def test_is_supported_by_environment(self):
raise unittest.SkipTest('Running in py3 and driver is not supported')
-def load_tests(loader, tests, pattern, suite=None):
+def _load_tests(loader, tests, pattern, suite=None):
if not suite:
suite = unittest.TestSuite()
+ if 'CHIRP_TESTIMG' in os.environ:
+ images = os.environ['CHIRP_TESTIMG'].split()
+ else:
+ images = glob.glob("tests/images/*.img")
+ tests = [os.path.splitext(os.path.basename(img))[0] for img in images]
+
base = os.path.dirname(os.path.abspath(__file__))
base = os.path.join(base, 'images')
images = glob.glob(os.path.join(base, "*"))
@@ -118,13 +181,29 @@ def load_tests(loader, tests, pattern, suite=None):
# This default is meaningless for us
pattern = None
+ py3_remaining = [x.strip() for x in open(os.path.join(
+ base, '..', 'py3_remaining.txt')).readlines()
+ if not x.startswith('#')]
+
for image, test in tests.items():
try:
rclass = directory.get_radio(test)
+ if os.path.basename(image) in py3_remaining:
+ PY3_XFAIL.append(image)
+
except Exception:
- if six.PY3 and 'CHIRP_DEBUG' in os.environ:
+ if not six.PY3:
+ raise
+
+ if 'CHIRP_DEBUG' in os.environ:
LOG.error('Failed to load %s' % test)
+
+ if os.path.basename(image) in py3_remaining:
+ # We expect this to fail to import in py3, so do not
+ # abort the test run.
continue
+ print('%s not in py3 exclusion list %s...' % (
+ os.path.basename(image), ','.join(py3_remaining)))
raise
for device in _get_sub_devices(rclass, image):
class_name = 'TestCase_%s' % (
@@ -135,10 +214,16 @@ def load_tests(loader, tests, pattern, suite=None):
else:
dst = device
device = device.__class__
+
+ if image in PY3_XFAIL:
+ cls = TestAdapterXFAIL
+ else:
+ cls = TestAdapter
+
tc = TestAdapterMeta(
- class_name, (TestAdapter,), dict(RADIO_CLASS=device,
- SOURCE_IMAGE=image,
- RADIO_INST=dst))
+ class_name, (cls,), dict(RADIO_CLASS=device,
+ SOURCE_IMAGE=image,
+ RADIO_INST=dst))
tests = loader.loadTestsFromTestCase(tc)
if pattern:
@@ -149,3 +234,13 @@ def load_tests(loader, tests, pattern, suite=None):
suite.addTests(tests)
return suite
+
+
+def load_tests(loader, tests, pattern, suite=None):
+ try:
+ return _load_tests(loader, tests, pattern, suite=suite)
+ except Exception as e:
+ import traceback
+ print('Failed to load: %s' % e)
+ print(traceback.format_exc())
+ raise
diff --git a/tests/images/Abbree_AR-518.img b/tests/images/Abbree_AR-518.img
new file mode 100644
index 0000000..c40e4a4
--- /dev/null
+++ b/tests/images/Abbree_AR-518.img
Binary files differ
diff --git a/tests/images/Abbree_AR-63.img b/tests/images/Abbree_AR-63.img
new file mode 100644
index 0000000..5edcccf
--- /dev/null
+++ b/tests/images/Abbree_AR-63.img
Binary files differ
diff --git a/tests/images/AnyTone_5888UV.img b/tests/images/AnyTone_5888UV.img
new file mode 100644
index 0000000..9f0e7df
--- /dev/null
+++ b/tests/images/AnyTone_5888UV.img
Binary files differ
diff --git a/tests/images/AnyTone_5888UVIII.img b/tests/images/AnyTone_5888UVIII.img
new file mode 100644
index 0000000..17e9676
--- /dev/null
+++ b/tests/images/AnyTone_5888UVIII.img
Binary files differ
diff --git a/tests/images/AnyTone_778UV.img b/tests/images/AnyTone_778UV.img
new file mode 100644
index 0000000..e1f2f65
--- /dev/null
+++ b/tests/images/AnyTone_778UV.img
Binary files differ
diff --git a/tests/images/Anysecu_WP-9900.img b/tests/images/Anysecu_WP-9900.img
new file mode 100644
index 0000000..6ca11c1
--- /dev/null
+++ b/tests/images/Anysecu_WP-9900.img
Binary files differ
diff --git a/tests/images/BTECH_FRS-A1.img b/tests/images/BTECH_FRS-A1.img
new file mode 100644
index 0000000..549f946
--- /dev/null
+++ b/tests/images/BTECH_FRS-A1.img
Binary files differ
diff --git a/tests/images/BTECH_FRS-B1.img b/tests/images/BTECH_FRS-B1.img
new file mode 100644
index 0000000..565ea0c
--- /dev/null
+++ b/tests/images/BTECH_FRS-B1.img
Binary files differ
diff --git a/tests/images/BTECH_GMRS-20V2.img b/tests/images/BTECH_GMRS-20V2.img
new file mode 100644
index 0000000..8a53729
--- /dev/null
+++ b/tests/images/BTECH_GMRS-20V2.img
Binary files differ
diff --git a/tests/images/BTECH_GMRS-V2.img b/tests/images/BTECH_GMRS-V2.img
new file mode 100644
index 0000000..8c05c4f
--- /dev/null
+++ b/tests/images/BTECH_GMRS-V2.img
Binary files differ
diff --git a/tests/images/Baofeng_BF-T8.img b/tests/images/Baofeng_BF-T8.img
new file mode 100644
index 0000000..f948048
--- /dev/null
+++ b/tests/images/Baofeng_BF-T8.img
Binary files differ
diff --git a/tests/images/CRT_Micron_UV.img b/tests/images/CRT_Micron_UV.img
new file mode 100644
index 0000000..e1f2f65
--- /dev/null
+++ b/tests/images/CRT_Micron_UV.img
Binary files differ
diff --git a/tests/images/Explorer_QRZ-1.img b/tests/images/Explorer_QRZ-1.img
new file mode 100644
index 0000000..a53beb9
--- /dev/null
+++ b/tests/images/Explorer_QRZ-1.img
Binary files differ
diff --git a/tests/images/Kenwood_TM-D710G_CloneMode.img b/tests/images/Kenwood_TM-D710G_CloneMode.img
new file mode 100644
index 0000000..2324564
--- /dev/null
+++ b/tests/images/Kenwood_TM-D710G_CloneMode.img
Binary files differ
diff --git a/tests/images/Kenwood_TM-D710_CloneMode.img b/tests/images/Kenwood_TM-D710_CloneMode.img
new file mode 100644
index 0000000..83d84ed
--- /dev/null
+++ b/tests/images/Kenwood_TM-D710_CloneMode.img
Binary files differ
diff --git a/tests/images/LUITON_LT-580_UHF.img b/tests/images/LUITON_LT-580_UHF.img
new file mode 100644
index 0000000..7b03472
--- /dev/null
+++ b/tests/images/LUITON_LT-580_UHF.img
Binary files differ
diff --git a/tests/images/LUITON_LT-580_VHF.img b/tests/images/LUITON_LT-580_VHF.img
new file mode 100644
index 0000000..6795db5
--- /dev/null
+++ b/tests/images/LUITON_LT-580_VHF.img
Binary files differ
diff --git a/tests/images/Lanchonlh_HG-UV98.img b/tests/images/Lanchonlh_HG-UV98.img
new file mode 100644
index 0000000..ab20bb1
--- /dev/null
+++ b/tests/images/Lanchonlh_HG-UV98.img
Binary files differ
diff --git a/tests/images/Midland_DBR2500.img b/tests/images/Midland_DBR2500.img
new file mode 100644
index 0000000..e1f2f65
--- /dev/null
+++ b/tests/images/Midland_DBR2500.img
Binary files differ
diff --git a/tests/images/QYT_KT-8R.img b/tests/images/QYT_KT-8R.img
new file mode 100644
index 0000000..debc2ee
--- /dev/null
+++ b/tests/images/QYT_KT-8R.img
Binary files differ
diff --git a/tests/images/QYT_KT-WP12.img b/tests/images/QYT_KT-WP12.img
new file mode 100644
index 0000000..93e92df
--- /dev/null
+++ b/tests/images/QYT_KT-WP12.img
Binary files differ
diff --git a/tests/images/Quansheng_TG-UV2+.img b/tests/images/Quansheng_TG-UV2+.img
new file mode 100644
index 0000000..71ed9aa
--- /dev/null
+++ b/tests/images/Quansheng_TG-UV2+.img
Binary files differ
diff --git a/tests/images/Radioddity_GA-510.img b/tests/images/Radioddity_GA-510.img
new file mode 100644
index 0000000..cadbe21
--- /dev/null
+++ b/tests/images/Radioddity_GA-510.img
Binary files differ
diff --git a/tests/images/Radioddity_UV-5G.img b/tests/images/Radioddity_UV-5G.img
new file mode 100644
index 0000000..1fa459e
--- /dev/null
+++ b/tests/images/Radioddity_UV-5G.img
Binary files differ
diff --git a/tests/images/Retevis_RA85.img b/tests/images/Retevis_RA85.img
new file mode 100644
index 0000000..aa6efc0
--- /dev/null
+++ b/tests/images/Retevis_RA85.img
Binary files differ
diff --git a/tests/images/Retevis_RB15.img b/tests/images/Retevis_RB15.img
new file mode 100644
index 0000000..2630dbc
--- /dev/null
+++ b/tests/images/Retevis_RB15.img
Binary files differ
diff --git a/tests/images/Retevis_RB17.img b/tests/images/Retevis_RB17.img
new file mode 100644
index 0000000..7c061ab
--- /dev/null
+++ b/tests/images/Retevis_RB17.img
Binary files differ
diff --git a/tests/images/Retevis_RB17A.img b/tests/images/Retevis_RB17A.img
new file mode 100644
index 0000000..36ed38e
--- /dev/null
+++ b/tests/images/Retevis_RB17A.img
Binary files differ
diff --git a/tests/images/Retevis_RB17P.img b/tests/images/Retevis_RB17P.img
new file mode 100644
index 0000000..eb9f559
--- /dev/null
+++ b/tests/images/Retevis_RB17P.img
Binary files differ
diff --git a/tests/images/Retevis_RB17V.img b/tests/images/Retevis_RB17V.img
new file mode 100644
index 0000000..4a7811e
--- /dev/null
+++ b/tests/images/Retevis_RB17V.img
Binary files differ
diff --git a/tests/images/Retevis_RB18.img b/tests/images/Retevis_RB18.img
new file mode 100644
index 0000000..c60af0a
--- /dev/null
+++ b/tests/images/Retevis_RB18.img
Binary files differ
diff --git a/tests/images/Retevis_RB19.img b/tests/images/Retevis_RB19.img
new file mode 100644
index 0000000..0576e84
--- /dev/null
+++ b/tests/images/Retevis_RB19.img
Binary files differ
diff --git a/tests/images/Retevis_RB19P.img b/tests/images/Retevis_RB19P.img
new file mode 100644
index 0000000..89293f0
--- /dev/null
+++ b/tests/images/Retevis_RB19P.img
Binary files differ
diff --git a/tests/images/Retevis_RB23.img b/tests/images/Retevis_RB23.img
new file mode 100644
index 0000000..b9c8a00
--- /dev/null
+++ b/tests/images/Retevis_RB23.img
Binary files differ
diff --git a/tests/images/Retevis_RB26.img b/tests/images/Retevis_RB26.img
new file mode 100644
index 0000000..b39c873
--- /dev/null
+++ b/tests/images/Retevis_RB26.img
Binary files differ
diff --git a/tests/images/Retevis_RB27.img b/tests/images/Retevis_RB27.img
new file mode 100644
index 0000000..3dbb4f5
--- /dev/null
+++ b/tests/images/Retevis_RB27.img
Binary files differ
diff --git a/tests/images/Retevis_RB27B.img b/tests/images/Retevis_RB27B.img
new file mode 100644
index 0000000..c10f2b4
--- /dev/null
+++ b/tests/images/Retevis_RB27B.img
Binary files differ
diff --git a/tests/images/Retevis_RB27V.img b/tests/images/Retevis_RB27V.img
new file mode 100644
index 0000000..52f8580
--- /dev/null
+++ b/tests/images/Retevis_RB27V.img
Binary files differ
diff --git a/tests/images/Retevis_RB615.img b/tests/images/Retevis_RB615.img
new file mode 100644
index 0000000..c60f2b5
--- /dev/null
+++ b/tests/images/Retevis_RB615.img
Binary files differ
diff --git a/tests/images/Retevis_RB617.img b/tests/images/Retevis_RB617.img
new file mode 100644
index 0000000..22a20ea
--- /dev/null
+++ b/tests/images/Retevis_RB617.img
Binary files differ
diff --git a/tests/images/Retevis_RB618.img b/tests/images/Retevis_RB618.img
new file mode 100644
index 0000000..7681b15
--- /dev/null
+++ b/tests/images/Retevis_RB618.img
Binary files differ
diff --git a/tests/images/Retevis_RB619.img b/tests/images/Retevis_RB619.img
new file mode 100644
index 0000000..620e81c
--- /dev/null
+++ b/tests/images/Retevis_RB619.img
Binary files differ
diff --git a/tests/images/Retevis_RB627B.img b/tests/images/Retevis_RB627B.img
new file mode 100644
index 0000000..b7f06ee
--- /dev/null
+++ b/tests/images/Retevis_RB627B.img
Binary files differ
diff --git a/tests/images/Retevis_RB75.img b/tests/images/Retevis_RB75.img
new file mode 100644
index 0000000..304c04c
--- /dev/null
+++ b/tests/images/Retevis_RB75.img
Binary files differ
diff --git a/tests/images/Retevis_RB85.img b/tests/images/Retevis_RB85.img
new file mode 100644
index 0000000..a9e83ba
--- /dev/null
+++ b/tests/images/Retevis_RB85.img
Binary files differ
diff --git a/tests/images/Retevis_RT1.img b/tests/images/Retevis_RT1.img
new file mode 100644
index 0000000..cac0d24
--- /dev/null
+++ b/tests/images/Retevis_RT1.img
Binary files differ
diff --git a/tests/images/Retevis_RT16.img b/tests/images/Retevis_RT16.img
new file mode 100644
index 0000000..72d08f2
--- /dev/null
+++ b/tests/images/Retevis_RT16.img
Binary files differ
diff --git a/tests/images/Retevis_RT19.img b/tests/images/Retevis_RT19.img
new file mode 100644
index 0000000..62b5aa0
--- /dev/null
+++ b/tests/images/Retevis_RT19.img
Binary files differ
diff --git a/tests/images/Retevis_RT22FRS.img b/tests/images/Retevis_RT22FRS.img
new file mode 100644
index 0000000..cafce14
--- /dev/null
+++ b/tests/images/Retevis_RT22FRS.img
Binary files differ
diff --git a/tests/images/Retevis_RT22S.img b/tests/images/Retevis_RT22S.img
new file mode 100644
index 0000000..e0a9fa6
--- /dev/null
+++ b/tests/images/Retevis_RT22S.img
Binary files differ
diff --git a/tests/images/Retevis_RT29_UHF.img b/tests/images/Retevis_RT29_UHF.img
new file mode 100644
index 0000000..381ee00
--- /dev/null
+++ b/tests/images/Retevis_RT29_UHF.img
Binary files differ
diff --git a/tests/images/Retevis_RT29_VHF.img b/tests/images/Retevis_RT29_VHF.img
new file mode 100644
index 0000000..ee275c0
--- /dev/null
+++ b/tests/images/Retevis_RT29_VHF.img
Binary files differ
diff --git a/tests/images/Retevis_RT40B.img b/tests/images/Retevis_RT40B.img
new file mode 100644
index 0000000..2d3d480
--- /dev/null
+++ b/tests/images/Retevis_RT40B.img
Binary files differ
diff --git a/tests/images/Retevis_RT47.img b/tests/images/Retevis_RT47.img
new file mode 100644
index 0000000..9aea994
--- /dev/null
+++ b/tests/images/Retevis_RT47.img
Binary files differ
diff --git a/tests/images/Retevis_RT47V.img b/tests/images/Retevis_RT47V.img
new file mode 100644
index 0000000..b95d9a0
--- /dev/null
+++ b/tests/images/Retevis_RT47V.img
Binary files differ
diff --git a/tests/images/Retevis_RT619.img b/tests/images/Retevis_RT619.img
new file mode 100644
index 0000000..6db1598
--- /dev/null
+++ b/tests/images/Retevis_RT619.img
Binary files differ
diff --git a/tests/images/Retevis_RT622.img b/tests/images/Retevis_RT622.img
new file mode 100644
index 0000000..13a3419
--- /dev/null
+++ b/tests/images/Retevis_RT622.img
Binary files differ
diff --git a/tests/images/Retevis_RT647.img b/tests/images/Retevis_RT647.img
new file mode 100644
index 0000000..33fdae0
--- /dev/null
+++ b/tests/images/Retevis_RT647.img
Binary files differ
diff --git a/tests/images/Retevis_RT668.img b/tests/images/Retevis_RT668.img
new file mode 100644
index 0000000..9ff00d0
--- /dev/null
+++ b/tests/images/Retevis_RT668.img
Binary files differ
diff --git a/tests/images/Retevis_RT68.img b/tests/images/Retevis_RT68.img
new file mode 100644
index 0000000..7c14049
--- /dev/null
+++ b/tests/images/Retevis_RT68.img
Binary files differ
diff --git a/tests/images/Retevis_RT76.img b/tests/images/Retevis_RT76.img
new file mode 100644
index 0000000..e716ae9
--- /dev/null
+++ b/tests/images/Retevis_RT76.img
Binary files differ
diff --git a/tests/images/Retevis_RT87.img b/tests/images/Retevis_RT87.img
new file mode 100644
index 0000000..383716a
--- /dev/null
+++ b/tests/images/Retevis_RT87.img
Binary files differ
diff --git a/tests/images/Retevis_RT9000D_136-174.img b/tests/images/Retevis_RT9000D_136-174.img
new file mode 100644
index 0000000..3cb8813
--- /dev/null
+++ b/tests/images/Retevis_RT9000D_136-174.img
Binary files differ
diff --git a/tests/images/Retevis_RT9000D_220-260.img b/tests/images/Retevis_RT9000D_220-260.img
new file mode 100644
index 0000000..d1f16fb
--- /dev/null
+++ b/tests/images/Retevis_RT9000D_220-260.img
Binary files differ
diff --git a/tests/images/Retevis_RT9000D_400-490.img b/tests/images/Retevis_RT9000D_400-490.img
new file mode 100644
index 0000000..bfa52f3
--- /dev/null
+++ b/tests/images/Retevis_RT9000D_400-490.img
Binary files differ
diff --git a/tests/images/Retevis_RT9000D_66-88.img b/tests/images/Retevis_RT9000D_66-88.img
new file mode 100644
index 0000000..2bf04e0
--- /dev/null
+++ b/tests/images/Retevis_RT9000D_66-88.img
Binary files differ
diff --git a/tests/images/Retevis_RT95.img b/tests/images/Retevis_RT95.img
new file mode 100644
index 0000000..e1f2f65
--- /dev/null
+++ b/tests/images/Retevis_RT95.img
Binary files differ
diff --git a/tests/images/Rugged_RH5R-V2.img b/tests/images/Rugged_RH5R-V2.img
new file mode 100644
index 0000000..56c3e80
--- /dev/null
+++ b/tests/images/Rugged_RH5R-V2.img
Binary files differ
diff --git a/tests/images/TYT_TH-UV88.img b/tests/images/TYT_TH-UV88.img
new file mode 100644
index 0000000..8796711
--- /dev/null
+++ b/tests/images/TYT_TH-UV88.img
Binary files differ
diff --git a/tests/images/Vertex_Standard_FTL-2011.img b/tests/images/Vertex_Standard_FTL-2011.img
new file mode 100644
index 0000000..5eff340
--- /dev/null
+++ b/tests/images/Vertex_Standard_FTL-2011.img
Binary files differ
diff --git a/tests/images/Wouxun_KG-935G.img b/tests/images/Wouxun_KG-935G.img
new file mode 100644
index 0000000..033f0d7
--- /dev/null
+++ b/tests/images/Wouxun_KG-935G.img
Binary files differ
diff --git a/tests/images/Wouxun_KG-UV920P-A.img b/tests/images/Wouxun_KG-UV920P-A.img
new file mode 100644
index 0000000..6fc02f8
--- /dev/null
+++ b/tests/images/Wouxun_KG-UV920P-A.img
Binary files differ
diff --git a/tests/images/Yaesu_FTM-7250D_R.img b/tests/images/Yaesu_FTM-7250D_R.img
new file mode 100755
index 0000000..2ec6832
--- /dev/null
+++ b/tests/images/Yaesu_FTM-7250D_R.img
Binary files differ
diff --git a/tests/py3_driver_testers.txt b/tests/py3_driver_testers.txt
new file mode 100644
index 0000000..ed5a37d
--- /dev/null
+++ b/tests/py3_driver_testers.txt
@@ -0,0 +1,41 @@
+# Format is:
+# Driver_ID,Tester,Test Date
+# Tester is preferred as a github id, but obfuscated email or name is
+# acceptable. If a driver is literally identical to another, use
+# +DRIVER_KEY to mark it as implied-tested.
+# Actually Arcshell AR-6 which is a direct clone
+Baofeng_BF-888,@kk7ds,13-Feb-2019
+Baofeng_UV-3R,@yarda,26-Sep-2022
+Baofeng_UV-5R,@lekv,23-Oct-2022
+Icom_IC-2200H,@kk7ds,24-Oct-2022
+Icom_IC-2820H,@kk7ds,22-Oct-2022
+Icom_IC-7200,@kk7ds,22-Oct-2022
+Icom_IC-7300,@kk7ds,22-Oct-2022
+Icom_IC-7610,@kk7ds,24-Oct-2022
+Icom_IC-910,@mfncooper,1-Oct-2021
+Icom_ID-31A,@kk7ds,12-Feb-2019
+Icom_ID-800H_v2,@kk7ds,22-Oct-2022
+Icom_ID-880H,@kk7ds,22-Oct-2022
+Kenwood_TH-D72_live_mode,@kk7ds,21-Oct-2022
+Kenwood_TH-D74_live_mode,@kk7ds,20-Oct-2022
+Kenwood_TH-F7,@sv1,19-Oct-2022
+Kenwood_TM-271,+Kenwood_TM-281,23-Oct-2022
+Kenwood_TM-281,@kk7ds,23-Oct-2022
+Kenwood_TM-D700,@kk7ds,20-Oct-2022
+Kenwood_TM-D710G,@kk7ds,22-Oct-2022
+Kenwood_TM-D710G_CloneMode,@kk7ds,22-Oct-2022
+Kenwood_TM-V71,@kk7ds,21-Oct-2022
+Kenwood_TK-7102,@kk7ds,15-Feb-2019
+Kenwood_TK-7108,@kk7ds,15-Feb-2019
+Kenwood_TK-7180,@kk7ds,18-Oct-2022
+Kenwood_TK-8102,@kk7ds,15-Feb-2019
+Kenwood_TK-8108,@kk7ds,15-Feb-2019
+Kenwood_TK-8180,@kk7ds,18-Oct-2022
+Radioddity_GA-510,@kk7ds,21-Oct-2022
+TIDRADIO_TD-H6,@kk7ds,21-Oct-2022
+Yaesu_FT-7800_7900,@kk7ds,24-Oct-2022
+Yaesu_FT-8800,@kk7ds,24-Oct-2022
+Yaesu_FT-817,@kk7ds,14-Feb-2019
+Yaesu_VX-3,@kk7ds,15-Feb-2019
+Yaesu_VX-8DR,@kk7ds,15-Feb-2019
+Yaesu_VX-7,@kk7ds,15-Feb-2019
diff --git a/tests/py3_remaining.txt b/tests/py3_remaining.txt
new file mode 100644
index 0000000..3f406d1
--- /dev/null
+++ b/tests/py3_remaining.txt
@@ -0,0 +1,17 @@
+Baojie_BJ-9900.img
+LUITON_LT-725UV.img
+Puxing_PX-2R.img
+Puxing_PX-777.img
+Puxing_PX-888K.img
+TYT_TH-UV3R-25.img
+TYT_TH-UV3R.img
+Wouxun_KG-816.img
+Wouxun_KG-818.img
+Wouxun_KG-UV6.img
+Wouxun_KG-UVD1P.img
+Yaesu_FT-1D_R.img
+Yaesu_FT2D_R.img
+Yaesu_FT3D_R.img
+Yaesu_FT-450D.img
+Yaesu_FTM-3200D_R.img
+Yaesu_FTM-7250D_R.img
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 195f4c4..671b3dc 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -451,7 +451,9 @@ class TestCaseBruteForce(TestCase):
tmp = copy.deepcopy(m)
if mode not in chirp_common.MODES:
continue
- if mode == "DV":
+ if mode == "DV" and \
+ isinstance(self._wrapper._dst,
+ chirp_common.IcomDstarSupport):
tmp = chirp_common.DVMemory()
try:
ensure_urcall(tmp.dv_urcall)
@@ -895,8 +897,9 @@ class TestCaseDetect(TestCase):
elif issubclass(radio.__class__, self._wrapper._dstclass):
pass
elif radio.__class__ != self._wrapper._dstclass:
- raise TestFailedError("%s detected as %s" %
- (self._wrapper._dstclass, radio.__class__))
+ raise TestFailedError("%s detected as %s for %s" %
+ (self._wrapper._dstclass, radio.__class__,
+ filename))
return []
TESTS["Detect"] = TestCaseDetect
@@ -1342,8 +1345,10 @@ Available tests:
test_out = TestOutputHTML(options.html)
else:
stdout = sys.stdout
- if not os.path.exists("logs"):
+ try:
os.mkdir("logs")
+ except FileExistsError:
+ pass
sys.stdout = open("logs/verbose", "w")
test_out = TestOutputANSI(stdout)
diff --git a/tests/unit/base.py b/tests/unit/base.py
index 1e112ce..8b90a44 100644
--- a/tests/unit/base.py
+++ b/tests/unit/base.py
@@ -48,3 +48,12 @@ def mock_gtk():
def unmock_gtk():
for module in pygtk_mocks:
del sys.modules[module]
+
+
+class BaseGTKTest(BaseTest):
+ def setUp(self):
+ super(BaseGTKTest, self).setUp()
+ try:
+ import gtk
+ except ImportError:
+ self.skipTest('pygtk not available')
diff --git a/tests/unit/test_directory.py b/tests/unit/test_directory.py
index d48bb48..c447173 100644
--- a/tests/unit/test_directory.py
+++ b/tests/unit/test_directory.py
@@ -1,5 +1,7 @@
import base64
+import glob
import json
+import os
import tempfile
from tests.unit import base
@@ -67,3 +69,26 @@ class TestDirectory(base.BaseTest):
self.assertEqual('Barmaster 2000', radio.MODEL)
self.assertEqual('A', radio.VARIANT)
+
+class TestDetectBruteForce(base.BaseTest):
+ def test_detect_all(self):
+ # Attempt a brute-force detection of all test images.
+ #
+ # This confirms that no test image is detected by more than one
+ # radio class. If it is, fail and report those classes.
+
+ path = os.path.dirname(__file__)
+ path = os.path.join(path, '..', 'images', '*.img')
+ test_images = glob.glob(path)
+ self.assertNotEqual(0, len(test_images))
+ for image in test_images:
+ detections = []
+ filedata = open(image, 'rb').read()
+ for cls in directory.RADIO_TO_DRV:
+ if not hasattr(cls, 'match_model'):
+ continue
+ if cls.match_model(filedata, image):
+ detections.append(cls)
+ if len(detections) > 1:
+ raise Exception('Detection of %s failed: %s' % (image,
+ detections))
diff --git a/tests/unit/test_memedit_edits.py b/tests/unit/test_memedit_edits.py
index fdf971c..b024353 100644
--- a/tests/unit/test_memedit_edits.py
+++ b/tests/unit/test_memedit_edits.py
@@ -6,21 +6,13 @@ from tests.unit import base
__builtins__["_"] = lambda s: s
-memedit = None
-
-
-class TestEdits(base.BaseTest):
- def setUp(self):
- global memedit
- super(TestEdits, self).setUp()
- base.mock_gtk()
- from chirp.ui import memedit as memedit_module
- memedit = memedit_module
+try:
+ from chirp.ui import memedit
+except ImportError:
+ memedit = None
- def tearDown(self):
- super(TestEdits, self).tearDown()
- base.unmock_gtk()
+class TestEdits(base.BaseGTKTest):
def _test_tone_column_change(self, col,
ini_tmode='', ini_cmode='',
exp_tmode=None, exp_cmode=None):
diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py
index ccc4308..3fb84f0 100644
--- a/tests/unit/test_settings.py
+++ b/tests/unit/test_settings.py
@@ -54,6 +54,28 @@ class TestSettingValues(base.BaseTest):
self._set_and_catch(value, "Jkl", "Xyz")
self.assertEqual(value.get_options(), opts)
+ def test_radio_setting_value_list_by_index(self):
+ opts = ["Abc", "Def", "Ghi"]
+ value = settings.RadioSettingValueList(opts, current_index=1)
+ self.assertEqual(value.get_value(), "Def")
+ self.assertEqual(int(value), 1)
+ self._set_and_test(value, "Def", "Ghi", "Abc")
+ self._set_and_catch(value, "Jkl", "Xyz")
+ self.assertEqual(value.get_options(), opts)
+
+ # Make sure we int() the index, as we may pass a bitwise object
+ value = settings.RadioSettingValueList(opts, current_index='1')
+ self.assertEqual(value.get_value(), "Def")
+
+ value.set_index(0)
+ self.assertEqual(value.get_value(), 'Abc')
+
+ # Same here, int() the index
+ value.set_index('0')
+ self.assertEqual(value.get_value(), 'Abc')
+
+ self.assertRaises(IndexError, value.set_index, 7)
+
def test_radio_setting_value_string(self):
value = settings.RadioSettingValueString(1, 5, "foo", autopad=False)
self.assertEqual(value.get_value(), "foo")
@@ -111,6 +133,8 @@ class TestSettingContainers(base.BaseTest):
self.assertEqual(rs.value, val)
rs.value = False
self.assertEqual(val.get_value(), False)
+ self.assertEqual('foo:False', str(rs))
+ self.assertEqual('[RadioSetting foo:False]', repr(rs))
def test_radio_setting_multi(self):
val1 = settings.RadioSettingValueBoolean(True)
diff --git a/tests/unit/test_shiftdialog.py b/tests/unit/test_shiftdialog.py
index fe0b62d..227c1af 100644
--- a/tests/unit/test_shiftdialog.py
+++ b/tests/unit/test_shiftdialog.py
@@ -5,6 +5,10 @@ except ImportError:
from mox3 import mox
from tests.unit import base
+try:
+ from chirp.ui import shiftdialog
+except ImportError:
+ shiftdialog = None
from chirp import chirp_common
from chirp import errors
@@ -50,18 +54,7 @@ class FakeRadioThread(object):
pass
-class ShiftDialogTest(base.BaseTest):
- def setUp(self):
- global shiftdialog
- super(ShiftDialogTest, self).setUp()
- base.mock_gtk()
- from chirp.ui import shiftdialog as shiftdialog_module
- shiftdialog = shiftdialog_module
-
- def tearDown(self):
- super(ShiftDialogTest, self).tearDown()
- base.unmock_gtk()
-
+class ShiftDialogTest(base.BaseGTKTest):
def _test_hole(self, fn, starting, arg, expected):
radio = FakeRadio(*tuple(starting))
radio.get_features().memory_bounds = (0, 5)
diff --git a/tests/unit/test_wxui_radiothread.py b/tests/unit/test_wxui_radiothread.py
new file mode 100644
index 0000000..c60da8c
--- /dev/null
+++ b/tests/unit/test_wxui_radiothread.py
@@ -0,0 +1,105 @@
+import sys
+import time
+from unittest import mock
+
+sys.modules['wx'] = wx = mock.MagicMock()
+
+from tests.unit import base
+from chirp.wxui import radiothread
+
+
+class TestRadioThread(base.BaseTest):
+ def setUp(self):
+ super().setUp()
+
+ def test_radiojob(self):
+ radio = mock.MagicMock()
+ editor = mock.MagicMock()
+ job = radiothread.RadioJob(editor, 'get_memory', [12], {})
+ self.assertIsNone(job.dispatch(radio))
+ radio.get_memory.assert_called_once_with(12)
+ self.assertEqual(job.result, radio.get_memory.return_value)
+
+ def test_radiojob_exception(self):
+ radio = mock.MagicMock()
+ radio.get_memory.side_effect = ValueError('some error')
+ editor = mock.MagicMock()
+ job = radiothread.RadioJob(editor, 'get_memory', [12], {})
+ self.assertIsNone(job.dispatch(radio))
+ radio.get_memory.assert_called_once_with(12)
+ self.assertIsInstance(job.result, ValueError)
+
+ def test_thread(self):
+ radio = mock.MagicMock()
+ radio.get_features.side_effect = ValueError('some error')
+ editor = mock.MagicMock()
+ # Simulate an edit conflict with the first event by returning
+ # False for "delivered" to force us to queue an event.
+ editor.radio_thread_event.side_effect = [False, True, True, True]
+ thread = radiothread.RadioThread(radio)
+ mem = mock.MagicMock()
+ job1id = thread.submit(editor, 'get_memory', 12)
+ job2id = thread.submit(editor, 'set_memory', mem)
+ job3id = thread.submit(editor, 'get_features')
+ # We have to start the thread after we submit the main jobs so
+ # the order is stable for comparison.
+ thread.start()
+
+ # Wait for the main jobs to be processed before we signal exit
+ while not all([radio.get_memory.called,
+ radio.set_memory.called,
+ radio.get_features.called]):
+ time.sleep(0.1)
+
+ thread.end()
+ thread.join(5)
+ self.assertFalse(thread.is_alive())
+ radio.get_memory.assert_called_once_with(12)
+ radio.set_memory.assert_called_once_with(mem)
+ radio.get_features.assert_called_once_with()
+ self.assertEqual(4, editor.radio_thread_event.call_count)
+
+ # We expect the jobs to be delivered in order of
+ # priority. Since we return False for the first call to
+ # radio_thread_event(), job2 should be queued and then
+ # delivered first on the next cycle.
+ expected_order = [job2id, job2id, job3id, job1id]
+ for i, (jobid, call) in enumerate(
+ zip(expected_order,
+ editor.radio_thread_event.call_args_list)):
+ job = call[0][0]
+ self.assertEqual(jobid, job.id)
+
+ # We should call non-blocking for every call except the last
+ # one, when the queue is empty
+ editor.radio_thread_event.assert_has_calls([
+ mock.call(mock.ANY, block=False),
+ mock.call(mock.ANY, block=False),
+ mock.call(mock.ANY, block=False),
+ mock.call(mock.ANY, block=True),
+ ])
+
+ def test_thread_abort_priority(self):
+ radio = mock.MagicMock()
+ radio.get_features.side_effect = ValueError('some error')
+ editor = mock.MagicMock()
+ thread = radiothread.RadioThread(radio)
+ mem = mock.MagicMock()
+ job1id = thread.submit(editor, 'get_memory', 12)
+ job2id = thread.submit(editor, 'set_memory', mem)
+ job3id = thread.submit(editor, 'get_features')
+ thread.end()
+ # We have to start the thread after we submit the main jobs so
+ # the order is stable for comparison.
+ thread.start()
+
+ thread.join(5)
+ self.assertFalse(thread.is_alive())
+
+ # Our end sentinel should have gone to the head of the queue
+ # so that exiting the application does not leave a thread
+ # running in the background fetching hundreds of memories.
+ radio.get_memory.assert_not_called()
+ radio.set_memory.assert_not_called()
+ radio.get_features.assert_not_called()
+ wx.PostEvent.assert_not_called()
diff --git a/tools/cpep8.manifest b/tools/cpep8.manifest
index 368c6d2..57a6982 100644
--- a/tools/cpep8.manifest
+++ b/tools/cpep8.manifest
@@ -13,9 +13,13 @@
./chirp/drivers/__init__.py
./chirp/drivers/alinco.py
./chirp/drivers/anytone.py
+./chirp/drivers/anytone_ht.py
+./chirp/drivers/anytone778uv.py
./chirp/drivers/ap510.py
+./chirp/drivers/baofeng_common.py
./chirp/drivers/baofeng_uv3r.py
./chirp/drivers/baofeng_wp970i.py
+./chirp/drivers/bf-t8.py
./chirp/drivers/bjuv55.py
./chirp/drivers/btech.py
./chirp/drivers/ft1500m.py
@@ -33,8 +37,11 @@
./chirp/drivers/ft857.py
./chirp/drivers/ft90.py
./chirp/drivers/ftm350.py
+./chirp/drivers/ga510.py
./chirp/drivers/generic_csv.py
./chirp/drivers/generic_tpe.py
+./chirp/drivers/gmrsuv1.py
+./chirp/drivers/gmrsv2.py
./chirp/drivers/h777.py
./chirp/drivers/ic208.py
./chirp/drivers/ic2100.py
@@ -60,33 +67,59 @@
./chirp/drivers/id800.py
./chirp/drivers/id880.py
./chirp/drivers/idrp.py
+./chirp/drivers/iradio_uv-5118.py
./chirp/drivers/kenwood_hmk.py
./chirp/drivers/kenwood_itm.py
./chirp/drivers/kenwood_live.py
+./chirp/drivers/kg935g.py
./chirp/drivers/kguv8d.py
+./chirp/drivers/kguv920pa.py
./chirp/drivers/kguv9dplus.py
./chirp/drivers/kyd.py
./chirp/drivers/leixen.py
+./chirp/drivers/lt725uv.py
+./chirp/drivers/mursv1.py
./chirp/drivers/puxing.py
./chirp/drivers/radioddity_r2.py
+./chirp/drivers/radtel_t18.py
+./chirp/drivers/retevis_rb15.py
+./chirp/drivers/retevis_rb17p.py
+./chirp/drivers/retevis_rt1.py
+./chirp/drivers/retevis_rt21.py
+./chirp/drivers/retevis_rt22.py
+./chirp/drivers/retevis_rt23.py
+./chirp/drivers/retevis_rt26.py
+./chirp/drivers/retevis_rt76p.py
+./chirp/drivers/retevis_rt87.py
+./chirp/drivers/retevis_rt98.py
./chirp/drivers/rfinder.py
+./chirp/drivers/tdxone_tdq8a.py
./chirp/drivers/template.py
+./chirp/drivers/tg_uv2p.py
./chirp/drivers/th350.py
./chirp/drivers/th9800.py
./chirp/drivers/th_uv3r.py
./chirp/drivers/th_uv3r25.py
./chirp/drivers/th_uv8000.py
+./chirp/drivers/th_uv88.py
./chirp/drivers/th_uvf8d.py
+./chirp/drivers/th9000.py
+./chirp/drivers/th9800.py
./chirp/drivers/thd72.py
./chirp/drivers/thuv1f.py
+./chirp/drivers/tk760.py
./chirp/drivers/tk8102.py
./chirp/drivers/tk8180.py
+./chirp/drivers/tmd710.py
./chirp/drivers/tmv71.py
./chirp/drivers/tmv71_ll.py
./chirp/drivers/ts480.py
./chirp/drivers/ts590.py
./chirp/drivers/uv5r.py
+./chirp/drivers/uv5x3.py
+./chirp/drivers/uv6r.py
./chirp/drivers/uvb5.py
+./chirp/drivers/vgc.py
./chirp/drivers/vx170.py
./chirp/drivers/vx2.py
./chirp/drivers/vx3.py
diff --git a/tools/cpep8.py b/tools/cpep8.py
index 2bf55d0..b073f48 100755
--- a/tools/cpep8.py
+++ b/tools/cpep8.py
@@ -44,7 +44,7 @@ args = parser.parse_args()
def file_to_lines(name):
- fh = file(name, "r")
+ fh = open(name, "r")
lines = fh.read().split("\n")
lines.pop()
fh.close()
@@ -64,7 +64,7 @@ if args.scan:
if f.endswith('.py'):
manifest.append(filename)
continue
- with file(filename, "r") as fh:
+ with open(filename, "r") as fh:
shebang = fh.readline()
if shebang.startswith("#!/usr/bin/env python"):
manifest.append(filename)
@@ -90,25 +90,25 @@ def get_exceptions(f):
return ignore
if args.update:
- print "Starting update of %d files" % len(manifest)
+ print("Starting update of %d files" % len(manifest))
bad = []
for f in manifest:
checker = pep8.StyleGuide(quiet=True, ignore=get_exceptions(f))
results = checker.check_files([f])
if results.total_errors:
bad.append(f)
- print "%s: %s" % (results.total_errors and "FAIL" or "PASS", f)
+ print("%s: %s" % (results.total_errors and "FAIL" or "PASS", f))
- with file(blacklist_filename, "w") as fh:
- print >>fh, """\
+ with open(blacklist_filename, "w") as fh:
+ fh.write("""\
# cpep8.blacklist: The list of files that do not meet PEP8 standards.
# DO NOT ADD NEW FILES!! Instead, fix the code to be compliant.
-# Over time, this list should shrink and (eventually) be eliminated."""
- print >>fh, "\n".join(sorted(bad))
+# Over time, this list should shrink and (eventually) be eliminated.""")
+ fh.write("\n".join(sorted(bad)))
if args.scan:
- with file(manifest_filename, "w") as fh:
- print >>fh, "\n".join(sorted(manifest))
+ with open(manifest_filename, "w") as fh:
+ fh.write("\n".join(sorted(manifest)))
sys.exit(0)
if args.files:
@@ -126,7 +126,7 @@ check_list = sorted(check_list)
total_errors = 0
for f in check_list:
if args.verbose:
- print "Checking %s" % f
+ print("Checking %s" % f)
checker = pep8.Checker(f, quiet=args.stats, ignore=get_exceptions(f))
results = checker.check_all()
diff --git a/tools/img2thd72.py b/tools/img2thd72.py
index 407bdf7..2ed1082 100644
--- a/tools/img2thd72.py
+++ b/tools/img2thd72.py
@@ -9,7 +9,7 @@
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
-# This sofware is distributed in the hope that it will be useful, but WITHOUT
+# This software is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
diff --git a/tools/py3_driver_progress.py b/tools/py3_driver_progress.py
new file mode 100644
index 0000000..52a9e2f
--- /dev/null
+++ b/tools/py3_driver_progress.py
@@ -0,0 +1,96 @@
+#!/usr/bin/python3
+
+import argparse
+import csv
+import sys
+
+from chirp import directory
+
+directory.safe_import_drivers()
+
+
+def tester_link(text):
+ if text.startswith('@'):
+ return '[%s](https://github.com/%s)' % (text, text[1:])
+ elif text.startswith('+'):
+ assert text[1:] in directory.DRV_TO_RADIO, \
+ '%s is not in the driver directory' % text[1:]
+ return '[Implied by %s](#user-content-%s)' % (text[1:], text[1:])
+ else:
+ return text
+
+
+def main():
+ p = argparse.ArgumentParser()
+ p.add_argument('testers')
+ p.add_argument('-o', '--output', default='-')
+ args = p.parse_args()
+
+ headers = ['Driver', 'Tester', 'Tested']
+ testers = {}
+
+ if args.output == '-':
+ output = sys.stdout
+ else:
+ output = open(args.output, 'w')
+
+ line = 0
+ for fields in csv.reader(open(args.testers)):
+ line += 1
+ if fields[0][0] == '#':
+ continue
+
+ if len(fields) != len(headers):
+ print('Error on line %i: invalid number of fields in: %s' % (
+ line, ','.join(fields)),
+ file=sys.stderr)
+ return 1
+
+ if fields[0] in testers:
+ print('Error: duplicate driver %r in testers file' % fields[0],
+ file=sys.stderr)
+ return 2
+
+ testers[fields[0]] = fields[1:]
+
+ print('## Status', file=output)
+
+ print('| Driver | Tester | Tested | Byte Clean |', file=output)
+ print('| ------ | ------ | ------ | ---------- |', file=output)
+
+ drivers = sorted([ident for ident in directory.DRV_TO_RADIO])
+ drvstested = 0
+ byteclean = 0
+ for driver in drivers:
+ cls = directory.get_radio(driver)
+ tester, tested = testers.pop(driver, ('', ''))
+ if tester:
+ drvstested += 1
+ if not cls.NEEDS_COMPAT_SERIAL:
+ byteclean += 1
+ print('| <a name="%s"></a> %s | %s | %s | %s |' % (
+ driver, driver, tester_link(tester), tested,
+ '' if cls.NEEDS_COMPAT_SERIAL else 'Yes'),
+ file=output)
+
+ print('## Stats', file=output)
+ print('\n**Drivers:** %i' % (len(drivers)), file=output)
+ print('\n**Tested:** %i%% (%i/%i)' % (
+ drvstested / len(drivers) * 100,
+ drvstested, len(drivers) - drvstested),
+ file=output)
+ print('\n**Byte clean:** %i%% (%i/%i)' % (
+ byteclean / len(drivers) * 100,
+ byteclean,
+ len(drivers) - byteclean),
+ file=output)
+
+ for driver, (tester, tested) in testers.items():
+ print('Error in testers file; driver %s by %s on %s unknown' % (
+ driver, tester, tested), file=sys.stderr)
+ if testers:
+ return 3
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/tools/serialsniff.c b/tools/serialsniff.c
index 7a80ac4..02037d7 100644
--- a/tools/serialsniff.c
+++ b/tools/serialsniff.c
@@ -94,7 +94,7 @@ void hexdump(char *buf, int len, FILE *dest)
*
* The amendment of this procedure to support the "total_hex" variable
* allows for the user to pass a command line argument instantiating a
- * desired number of hexadecimal bytes (and their ASCII equivelent) to
+ * desired number of hexadecimal bytes (and their ASCII equivalent) to
* be displayed.
*
*/
diff --git a/tox.ini b/tox.ini
index 32f367e..dc44ec8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -5,7 +5,7 @@ skipsdist = True
[testenv]
basepython = python2.7
sitepackages = True
-passenv = HOME
+passenv = HOME CHIRP_TESTS CHIRP_TESTIMG
whitelist_externals = bash
deps = future
@@ -29,11 +29,15 @@ commands =
pytest --disable-warnings -v tests/test_drivers.py {posargs}
[testenv:style]
+basepython = python3
+sitepackages = False
deps =
- pep8==1.6.2
+ pep8
future
+ flake8
commands =
- python ./tools/cpep8.py
+ python3 ./tools/cpep8.py
+ flake8 --builtins="_" chirp/wxui
[textenv:py3clean]
commands =
@@ -45,10 +49,9 @@ sitepackages = False
setenv =
PYTHONPATH=../..
deps =
- -rrequirements.txt
-rtest-requirements.txt
commands =
- pytest --disable-warnings -v tests/unit {posargs}
+ pytest --disable-warnings --html=unit_report.html -v tests/unit {posargs}
[testenv:py3driver]
basepython = python3
@@ -56,6 +59,23 @@ sitepackages = False
setenv =
PYTHONPATH=../..
CHIRP_DEBUG=y
-deps = {[testenv:py3unit]deps}
+deps =
+ {[testenv:py3unit]deps}
+ pytest-xdist
commands =
- pytest --disable-warnings -v tests/test_drivers.py {posargs}
+ pytest --disable-warnings --html=driver_report.html -v tests/test_drivers.py -n auto {posargs}
+
+[pytest]
+xfail_strict = true
+
+[testenv:makesupported]
+basepython = python3
+sitepackages = False
+whitelist_externals = git
+deps =
+ -rtest-requirements.txt
+commands =
+ python3 share/make_supported.py model_support.html
+ python3 setup.py develop
+ python3 tools/py3_driver_progress.py -o tests/Python3_Driver_Testing.md tests/py3_driver_testers.txt
+ git diff --exit-code tests/Python3_Driver_Testing.md