Skip to content
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

Add support for KSUN M6 #1060

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Add support for KSUN M6 #1060

merged 1 commit into from
Jun 13, 2024

Conversation

wavexx
Copy link
Contributor

@wavexx wavexx commented Jun 6, 2024

This PR adds support for the KSUN M6 (https://it.aliexpress.com/item/1005005096348552.html).

I've been working this on-an-off in the past months and it's my first attempt, so I apologize if that's not perfect. I only have one of these radios at my disposal so my testing is limited to this specific sample I have.

The radio can be purchased with the cable (just a regular baofeng-to-usb ch341-uart driver), but came with no software. The "official" website download (http://www.qzksun.com/index.php?m=content&c=index&a=lists&catid=37) doesn't work. I've been comparing the results with the "LED Radio program 1.03" software which I was able to find on some forums after extensive searching, which doesn't seem the most recent version. It only works on windows, fails to do anything about 70% of the time I run it, and it's absolutely horrifying to use which is what prompted me to write this driver.

All the channel memory features are supported (all tone/dtcs/cross modes), including the "hopping/compander/scrambler" features. All settings, with the exception of the "password", are supported too.

There are still some unexplained fields in the settings/channel memory. A few bytes could be explained by the password field, but the rest is a mystery. I've seen screenshots of a more recent version of the original software, but I couldn't get my hands on it to actually reverse it.

@wavexx wavexx force-pushed the ksun_m6 branch 5 times, most recently from 3dff287 to c541c32 Compare June 6, 2024 16:22
Copy link
Owner

@kk7ds kk7ds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks pretty clean. Just a couple suggestions, if you're willing. It'll be a few days before we do another build since we just had one today.

serial = radio.pipe

addr = struct.pack(">H", block_addr)
cmd = b"R" + addr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, but might as well, let struct pack the command too:

struct.pack(">BH", b"R", addr)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

+ (_mem.freq[3] << 8) + _mem.freq[4])

mem.freq = int(rx_freq / 2000 * 1000000)
mem.offset = int(tx_freq / 2000 * 1000000)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use // which is integer division and then you won't need the int() cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

tx_freq = rx_freq

rx_freq = round(rx_freq / 1000000 * 2000)
tx_freq = round(tx_freq / 1000000 * 2000)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional so that the target frequency is snapped to the closest representation and not to the lowest representable integer. This is something that bugs me with most other drivers.

@kk7ds
Copy link
Owner

kk7ds commented Jun 13, 2024

Rebased, squashed and tagged the issue (per the guidelines)

@kk7ds kk7ds merged commit c523fff into kk7ds:master Jun 13, 2024
6 checks passed
@wavexx
Copy link
Contributor Author

wavexx commented Jun 16, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants