-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added driver for Baofeng UV-17 fixes #10865 #819
Conversation
38dc90d
to
ae822ea
Compare
I somehow can't manage to reduce the overlapping code with the UV-17 Pro driver. Any suggestions? |
c608f21
to
944f273
Compare
Yeah, there's still a lot that is shared between them, so there's plenty of room to re-use code I think. Some of your closures like |
Don't merge this one yet. It seems that some people are not able to connect to their radio, using this driver.. I am trying to figure out if the problem is the driver or that there is another UV-17 radio out there which I haven't heard of yet. |
People were trying to use the Pro driver for this non-pro driver. :-) How do we fix the fact that it is all so confusing?? So don't put it on hold for merging.. I will try to fix the code reuse issue first... But I'm afraid that's going to be a challenge.. And I don't have infinite time.. |
649fcae
to
023bfda
Compare
I have modified this driver to use a lot of code from the UV-17Pro driver. In order to do so, I also had to modify the UV-17Pro driver. The new version of the Pro driver needs to be merged before this one. |
We should just put both commits in this PR, so we can see it tested together. They're definitely related enough to be merged as a unit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it's a holiday weekend here so I've been a bit tied up with other stuff.
chirp/drivers/baofeng_uv17.py
Outdated
|
||
def set_memory(self, mem): | ||
offset = 0 | ||
# skip 16 bytes at memory block boundary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this comment refer to the conditional offsets below?
You can use #skip
in your memory format to move forward a specific amount, if it helps. When I've written drivers that don't store memories all linearly, I generally try to define the format declaratively instead of doing stuff like this. Something like:
struct mem lowmems[252];
#skip 0x0x10;
struct mem highmems[506];
// ... etc
Your comment in get_memory()
mentions that there's a 16-byte "page number". Not really sure what that means but you can also do something like this:
struct {
struct mem memories[252];
u8 page_stuff[16];
} mem_page[3];
The reason to define it like this instead of just papering over it the way you are doing here, is that these "page number" structures will be represented in the browser as memories with non-sensical data in them, which is not great.
At the very least, you should probably make this logic a helper so you don't have to repeat it in get_memory()
and set_memory()
, especially if you ever have to tweak it.
Oh and this makes me realize - you didn't implement get_raw_memory()
here or for the pro one. You should do that, because it makes it much easier to iterate and fix things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Added get_raw_memory and removed the offset stuff..
Thanks for looking at the code!! |
27010df
to
2eb2842
Compare
Ah, looks like you squashed the refactor and new driver commits together. I had just brought the other commit in there. I know it's probably maddening to understand my preferences here but: commit history should be clean, methodical changes that build on each other and don't do and then undo things in one epoch of development. So, refactoring one driver in a commit so the next commit can make a change on its own is totally cool, and means that reviewing one commit alone is still easy. So, if it's cool with you I'll split this back in two (commits) before I merge, since it's trivial to do so and then I promise to take my pill. Also, I didn't notice before but you need to be adding these drivers to the test matrix as "python3 tested" which is why the existing two drivers show up on the front page with an asterisk. I'll do that for you while I'm splitting this. |
Prepare this driver to be subclassed with better re-use. Related to #10865
This driver adds support for the Baofeng UV-17 radio with the blue background screen. It fixes issue #10865
Related to #10865
This driver adds support for the Baofeng UV-17 radio with the blue background screen. It fixes issue #10865
CHIRP PR Checklist
The following must be true before PRs can be merged:
tests/images
(except for thin aliases where the driver is sufficiently tested already).Please also follow these guidelines:
six
,future
, etc).NEEDS_COMPAT_SERIAL=False
and useMemoryMapBytes
.tox -emakesupported
and include it in your commit.