v0l / radio_tool

Radio firmware tool
https://discord.gg/V596cyatmv
GNU General Public License v3.0
82 stars 16 forks source link

Refactor device interfaces #9

Closed v0l closed 2 years ago

v0l commented 2 years ago

Description

This PR refactors the device communication and operations interfaces to be more generic (remove DFU like interface)

This is a follow on from #8

Current state of this PR includes listing serial device on windows:

> radio_tool.exe -l
[0483:df11]: idx=000, AnyRoad Technology Digital Radio in USB mode
[COM1]: idx=1, Generic serial radio
[COM4]: idx=2, Generic serial radio

This is currently listing all serial ports as options, hopefully i can find a way to add VID:PID filtering on top of the full serial device list.

Dependency graph

Basic interface looks like this:

[RadioFactory] -> [RadioOperations] -> [RadioDevice]

Implementations

[RadioFactory]
- USBRadioFactory
- SerialRadioFactory
[RadioOperations]
- TYTRadio
- AilunceRadio
[RadioDevice]
- TYTDevice
- YModemDevice
v0l commented 2 years ago

@n1zzo Could you test this on a windows machine for HD1 radio? I added some windows serial code but i dont have this radio to test, it seems like its trying to transmit data on my serial ports but i cant be sure that its working.

You can download the builds here: https://ci.appveyor.com/project/v0l/radio-tool/builds/42203077/job/q2gf12daavh2ryew/artifacts

n1zzo commented 2 years ago

Hi v0l, I'm getting this error message: immagine Which additional library do I need to run radio_tool?

v0l commented 2 years ago

You need to install MSVC Runtime:

Try this one: https://aka.ms/vs/17/release/vc_redist.x64.exe

n1zzo commented 2 years ago

Uhm, nope I still see the error on both my windows machines, here are the MSVC versions I have installed:

immagine

v0l commented 2 years ago

MSVCP140D.dll is the C++ runtime dll so not sure why its not working for you... I was able to run it ok..

You could also build it on your machine but you need to install CMake and vcpkg

image

v0l commented 2 years ago

@n1zzo Any luck? Also if you could test on any other OS you have access from.

Or maybe you can ask other people you know who have that radio and are able to test the build: https://github.com/v0l/radio_tool/releases/tag/v0.2.0-beta.1

n1zzo commented 2 years ago

Hi @v0l I will test tomorrow on linux and ask the community to test on WIndows.

Congratulations again for the nice work you are putting into this project!

Niccolò

n1zzo commented 2 years ago

Hi @v0l, sorry for the late review. Flashing from linux leads to a segfault. The issue is in the file fymodem.c:

 56 char __ym_getchar(int timeout_ms)
 57 {
 58     char c = 0;
 59 #ifdef _WIN32
 60     ReadFile((HANDLE)global_fd, &c, (DWORD)1, NULL, NULL);
 61 #else
 62     fread(&c, 1, 1, global_fd);
 63 #endif
 64     return c;
 65 }

The fread on line 62 is segfaulting. I will try to fix the issue.

n1zzo commented 2 years ago

Found the issue, fread expects a FILE* pointer, you're passing a file descriptor instead.

v0l commented 2 years ago

ah, probably i didn't finish converting this to FILE* type then or got mixed up somewhere.

n1zzo commented 2 years ago

Yeah, probably, let me know when the fix is out so that I can test it! :wink:

v0l commented 2 years ago

@n1zzo I pushed some fixes here: 0afaac56de44f1370cd941585e55deef69a9f782

Just went back to using FD, sems to work on Macbook..

n1zzo commented 2 years ago

I confirm that this works also on linux! Thanks, will point OpenRTX toolchain to the new version of radio_tool.