⚲
Project
General
Profile
Sign in
Register
Home
Projects
Search
:
CHIRP
All Projects
CHIRP
Home
Download
Documentation
Activity
Roadmap
Issues
Repository
Download (1.62 KB)
New Model #4129
» mcp_dump_d74.py
Use the MCP protocol to get a dump of the settings memory -
Angus Ainslie
, 06/13/2020 10:23 AM
#!/usr/bin/python3
import
ast
import
serial
import
argparse
import
socket
import
select
import
string
import
struct
from
time
import
sleep
DEBUG
=
True
parser
=
argparse
.
ArgumentParser
(
description
=
'
MCP dump the radio memories
'
)
parser
.
add_argument
(
'
device
'
,
nargs
=
1
,
help
=
'
radio serial port
'
)
START_MCP
=
b
'
0M PROGRAM
\r
'
START_ACK
=
b
'
0M
\r
'
STOP_MCP
=
b
'
E
'
STOP_ACK
=
b
'
\x06\r\x00
'
MCP_SUCCESS
=
b
'
\x06
'
MCP_FAIL
=
b
'
\x0f
'
#name table offset
# 0x00010100
OFFSET_ADDR
=
0x00010100
args
=
parser
.
parse_args
()
def
wait_serial
(
ser
):
timeout
=
20
while
timeout
>
0
:
sleep
(
0.1
)
nbytes
=
ser
.
in_waiting
if
nbytes
:
data
=
ser
.
read
(
nbytes
)
#if DEBUG:
# print("Bytes %s" % data)
return
data
timeout
=
timeout
-
1
return
None
ser
=
serial
.
Serial
(
str
(
args
.
device
[
0
]),
9600
)
dump_file
=
open
(
"
dumpfile.txt
"
,
'
wb
'
)
ser
.
write
(
b
'
ID
\r
'
)
print
(
"
ID %s
"
,
wait_serial
(
ser
))
ser
.
write
(
START_MCP
)
data
=
wait_serial
(
ser
)
print
(
"
Command %s data %s
"
%
(
START_MCP
,
data
))
for
i
in
range
(
0
,
int
(
0xffffff
/
256
)):
addr2
=
((
i
*
256
)
>>
16
)
&
0xff
addr1
=
((
i
*
256
)
>>
8
)
&
0xff
addr0
=
(
i
*
256
)
&
0xff
print
(
"
reading address %s %s %s
"
%
(
hex
(
addr2
),
hex
(
addr1
),
hex
(
addr0
)))
cmd
=
struct
.
pack
(
'
>cBBBB
'
,
b
'
R
'
,
addr2
,
addr1
,
addr0
,
0
)
ser
.
write
(
cmd
)
data
=
wait_serial
(
ser
)
# get data
ser
.
write
(
MCP_SUCCESS
)
status
=
ser
.
read
(
1
)
print
(
"
Command %s data %s status %s
"
%
(
cmd
,
data
,
status
))
dump_file
.
write
(
data
[
5
:]
)
ser
.
write
(
STOP_MCP
)
data
=
wait_serial
(
ser
)
print
(
"
Command %s data %s
"
%
(
STOP_MCP
,
data
))
dump_file
.
close
()
ser
.
close
()
« Previous
1
…
4
5
6
7
8
…
10
Next »
(6-6/10)
Loading...