HL2 IP protocol implementation / sample cli interface

194 views
Skip to first unread message

Rafael Diniz

unread,
Jan 27, 2022, 1:45:51 AM1/27/22
to Hermes-Lite
Hi there,

Which protocol implementation (C or C++) should I look to have the
simplest possible (yet complete, if possible) implementation of the
communication protocol of the HL2 for me to start with? I wonder if
there is some simple cli with which I can set and get parameters from
the HL2.

I already gave a good read here:
https://github.com/softerhardware/Hermes-Lite2/wiki/Protocol

But certainly I don't need to start from scratch.

HL2 is really a wonderful piece of software, Quisk gave me a glimpse of
its sensitivity!

73,
Rafael
OpenPGP_signature

ron.ni...@gmail.com

unread,
Jan 27, 2022, 12:40:46 PM1/27/22
to Hermes-Lite
There is HL2 protocol documentation on the HL2 wiki:
The HPSDR USB-port protocol documentation is here:
Some documentation on how the USB-port protocol is wrapped inside network UDP packets is here:
There are a few command-line examples for connecting to the HL2 that are not overly complicated.
One is the hl2setup application:
The other is my hl2_tcp server (which converts/transcodes HL2 UDP into even simpler rtl_tcp TCP):
Or, if you prefer python code, see:

73,
Ron
n6ywu


Jim Ancona

unread,
Jan 27, 2022, 1:16:48 PM1/27/22
to Hermes-Lite
I'm not aware of a C library that does what you want, although that would be a nice thing to have. To Ron's list, l'll add Pihpsdr and linhpsdr as C examples, but not libraries (see https://github.com/g0orx/ or https://github.com/dl1ycf/pihpsdr) and my own Go library: https://github.com/jancona/hpsdr

Jim
N1ADJ


--
You received this message because you are subscribed to the Google Groups "Hermes-Lite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hermes-lite...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hermes-lite/c2ca5bb2-5066-4c52-83fc-cc715cbf3086n%40googlegroups.com.

Matthew

unread,
Jan 27, 2022, 3:09:36 PM1/27/22
to Hermes-Lite
Personally, when I first looked at code examples and the protocol, I was fairly confused. Terms like metis, ozy, alex etc. were all alien to me. I think it helps to understand that the HPSDR protocol 1 evolved from USB hardware and hardware modules associated with this. See here if you haven't already.

As a result of this, a lot of the functions in code I found were named around these modules. Looking at the pihpsdr or linhpsdr code you will see it is not a simple library call to get the IQ, but once you study the code and understand it, it does make sense. It just takes effort.

There is an additional layer to add to this, the HPSDR protocol document talks in the control bytes C0, C1 etc. The HL2 protocol page you found present the address map slightly differently. I have a piece of paper with a hand drawn table to convert between the ADDR on the wiki and the C0 etc. bytes for my own quick reference.

I attempted to write some C++ code a few years ago that had some abstraction. I never finished it, but I have just uploaded my code here:


It might provide a starting point for you if you want to go down a C++ route. I adapted the code for this:


Again, I am only suggesting this for reference, not as a finished product/library. I must credit (and do in my code/licence) N5EG for a lot of this code. You will also notice N5EG used some C code from G0ORX too.

I'm not sure if the HL2 watchdog timer is on by default in gateware now, but if it isn't, I tripped up by not sending a steady stream of packets to the HL2 and stopped get IQ data.

Good luck and don't expect working code in 5 minutes.

73 Matthew M5EVT.

ron.ni...@gmail.com

unread,
Jan 27, 2022, 3:22:08 PM1/27/22
to Hermes-Lite
hl2_tcp.c has 2 parts, connecting and extracting IQ data from HL2 UDP streams, and serving that IQ data to an rtl_tcp TCP socket.
You can remove the 2nd TCP part, and use the remainder as a C library for HL2 connectivity (which I've done for a couple of my own iOS and macOS apps).  I haven't bothered to write a clean C API to these libraries (as I use them as bridges to Apple's Swift language), so that's left as an exercise for the student (someone who has an interest in C APIs).
73,
Ron
n6ywu

Steve Haynal

unread,
Jan 27, 2022, 3:23:03 PM1/27/22
to Hermes-Lite
Hi Rafael,

For starting out, I recommend looking at rx4000.py:

This <150 lines of Python code which implements IQ receive-only and then passes IQ files to a ft8 decoder. It uses a special 4kHz gateware variant. It disables the watchdog so you do not need to worry about sending packets to the HL2. It is based on hermeslite.py, a Python library which I use for all command line testing:

On the protocol wiki page, the two links to openhpsdr documents in the first paragraph are both essential as the wiki page primarily covers HL2-specific changes:

73,

Steve
kf7o

Roger David Powers

unread,
Jan 27, 2022, 8:11:38 PM1/27/22
to Hermes-Lite
Here are some comments on Steve's rx4000.py that may be of use if you want to use it to stream data from the radio:


If you just want to get/set parameters, have a look at:


which shows a good set of Python get/set commands.

Regards,
RDP


Rafael Diniz

unread,
Jan 28, 2022, 3:10:04 AM1/28/22
to Hermes-Lite
Thanks a lot Ron and Jim!

Wow, I did not know about hl2setup!

I'll share my code here in the list as I publish in github.

Cheers,
Rafael PU2UIT


On 1/27/22 21:16, Jim Ancona wrote:
> I'm not aware of a C library that does what you want, although that
> would be a nice thing to have. To Ron's list, l'll add Pihpsdr and
> linhpsdr as C examples, but not libraries (see https://github.com/g0orx/
> <https://github.com/g0orx/> or https://github.com/dl1ycf/pihpsdr
> <https://github.com/dl1ycf/pihpsdr>) and my own Go library:
> https://github.com/jancona/hpsdr <https://github.com/jancona/hpsdr>
>
> Jim
> N1ADJ
>
>
> On Thu, Jan 27, 2022, 12:40 PM ron.ni...@gmail.com
> <mailto:ron.ni...@gmail.com> <ron.ni...@gmail.com
> <mailto:ron.ni...@gmail.com>> wrote:
>
> There is HL2 protocol documentation on the HL2 wiki:
> https://github.com/softerhardware/Hermes-Lite2/wiki
> <https://github.com/softerhardware/Hermes-Lite2/wiki>
> The HPSDR USB-port protocol documentation is here:
> https://github.com/TAPR/OpenHPSDR-SVN/tree/master/Documentation
> <https://github.com/TAPR/OpenHPSDR-SVN/tree/master/Documentation>
> Some documentation on how the USB-port protocol is wrapped inside
> network UDP packets is here:
> https://github.com/TAPR/OpenHPSDR-Firmware/blob/master/Protocol%201/Documentation/Metis-%20How%20it%20works_V1.33.pdf
> <https://github.com/TAPR/OpenHPSDR-Firmware/blob/master/Protocol%201/Documentation/Metis-%20How%20it%20works_V1.33.pdf>
> There are a few command-line examples for connecting to the HL2 that
> are not overly complicated.
> One is the hl2setup application:
> https://github.com/softerhardware/Hermes-Lite2/tree/master/software/hl2setup
> <https://github.com/softerhardware/Hermes-Lite2/tree/master/software/hl2setup>
> The other is my hl2_tcp server (which converts/transcodes HL2 UDP
> into even simpler rtl_tcp TCP):
> https://github.com/hotpaw2/hl2_tcp <https://github.com/hotpaw2/hl2_tcp>
> Or, if you prefer python code, see:
> http://james.ahlstrom.name/quisk/ <http://james.ahlstrom.name/quisk/>
> <mailto:hermes-lite...@googlegroups.com>.
> <https://groups.google.com/d/msgid/hermes-lite/c2ca5bb2-5066-4c52-83fc-cc715cbf3086n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Hermes-Lite" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hermes-lite...@googlegroups.com
> <mailto:hermes-lite...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hermes-lite/CAKYY9A%2BF6js%2Bf9vWHTZ-%2B1PdBcoRfjNRYwEswFsuSSBocRFF9w%40mail.gmail.com
> <https://groups.google.com/d/msgid/hermes-lite/CAKYY9A%2BF6js%2Bf9vWHTZ-%2B1PdBcoRfjNRYwEswFsuSSBocRFF9w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
OpenPGP_signature

Ramakrishnan Muthukrishnan

unread,
Jan 30, 2022, 2:12:55 AM1/30/22
to herme...@googlegroups.com
Hi Rafael,

Some time ago, I started writing a Go program to talk to HL2/Radioberry. The idea was mainly self-education and also see if I can decouple UI vs radio/DSP logic and talk to it only via messages. But I didn't go very far with it. But the code, I think, is very readable and I haven't used any fancy programming language features.

The part of code you want to look at to understand the protocol docs is this (read it along with the protocol docs wiki page):

<https://github.com/vu3rdd/gosdr/tree/master/radios/hl2>

If you find any inconsistencies or bugs, please let me know.

73
Ram VU3RDD
> an email to hermes-lite...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hermes-lite/bea04bba-0c23-5665-44c2-b0e316426747%40rhizomatica.org.
>
> Attachments:
> * OpenPGP_signature

--
Ramakrishnan

Rafael Diniz

unread,
Jan 30, 2022, 2:19:18 PM1/30/22
to Hermes-Lite
Hi all,

Thanks again for all the advice. I'm compiling all the info here (for
myself... but it might be useful for someone else):
https://github.com/DigitalHERMES/hermes_controller/blob/main/README.md


Rafael
> --
> You received this message because you are subscribed to the Google
> Groups "Hermes-Lite" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hermes-lite...@googlegroups.com
> <mailto:hermes-lite...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/hermes-lite/1180681916.3384706.1643332287299%40mail.yahoo.com
> <https://groups.google.com/d/msgid/hermes-lite/1180681916.3384706.1643332287299%40mail.yahoo.com?utm_medium=email&utm_source=footer>.
OpenPGP_signature

Roger David Powers

unread,
Jan 30, 2022, 3:25:49 PM1/30/22
to Hermes-Lite
Thanks, that's a great resource!

Regards,
RDP
Reply all
Reply to author
Forward
0 new messages