Making Use of UDP Messages (Log4OM Web Status)

General discussions V2
Post Reply
nq4t
Novice Class
Posts: 7
Joined: 02 Feb 2023, 07:32
Location: Manassas, VA (FM18)
Contact:

Making Use of UDP Messages (Log4OM Web Status)

Post by nq4t »

Hello all,

This is not a "how do I" post more than just showing an example of what I'm doing with the UDP Message feature found in the most recent version. I thought I would share it with the group in case anyone else wanted to implement something similar.

A few weeks ago, actually a little over a month ago; I rebuilt/relaunched my personal ham website to use static site generation. One of the things I decided to do was have Log4OM output my realtime log to a locally hosted httpd that would then get embedded in my site. I figure if I'm doing a ham website one of the easy and automatic things I could do was have it display my local log as well as a few other logbooks that support embedding. I even went as far as to reverse-proxy my Pi-Star dashboard so people can see that output but not interact with it. This went along with a few other Pi-Star scripts I built to display some "realtime" text-only information on various profiles from it...mostly what TGs/reflectors I might be on.

As I was doing all of this, I realized it might be neat to display my HF rig's status somewhere on the site. I started attempting to hook in to OmniRig to poll the radio for this data; but this was something a little beyond my basic programming skills. But then the most recent version of Log4OM came out with its automatic UDP messages. This provided an even better solution. Not only could my basic programming skills work with UDP messages sent out over the local network; but it would also allow me to just worry about having Log4OM running on the shack PC.

Image

A Python script on my local httpd waits for the UDP Messages sent to it from Log4OM. From there it picks out the information I need and then stuffs it in an HTML file. As you can see, it displays your VFO frequency, split frequency if applicable, and even has an on-air indicator. The html file is configured to automatically update every five seconds (the above is a screenshot); giving you "very close to" realtime information about where I might be on the bands. A thread in the script checks for when data hasn't been received in a specific amount of time and indicates such. It takes longer than 5 seconds for it to display the radio might be off. The script is setup to run as a service on my server, so I don't have to think about anything except booting up Log4OM on the shack PC. I have the habit of leaving Log4OM running most of the day; so it automatically picks up when the radio is turned on and starts sending messages again.

You can see how it's implemented on my webpage (listed on my profile) after I added in all the required CSS to make it fit. The actual file being served is here, it's just iframed into the main page.

A copy of the Python script can be found here. Please feel free to use this if you wish to implement something similar and modify it as you need.
Last edited by nq4t on 06 Apr 2023, 00:01, edited 1 time in total.
User avatar
IW3HMH
Site Admin
Posts: 2926
Joined: 21 Jan 2013, 14:20
Location: Quarto d'Altino - Venezia (ITA)
Contact:

Re: Making Use of UDP Messages

Post by IW3HMH »

Cool :)
Let me know if you need more info to be sent out through UDP (or received from Log4OM eventually)
Daniele Pistollato - IW3HMH
nq4t
Novice Class
Posts: 7
Joined: 02 Feb 2023, 07:32
Location: Manassas, VA (FM18)
Contact:

Re: Making Use of UDP Messages

Post by nq4t »

Thank you for the offer. If I come across some data that's not sent, I will let you know. At the current time everything I want to display is supported; in fact there's a lot more information coming over the UDP messages than I use. I didn't want to do anything real fancy and complex; frequency, mode, and on-air status were the three things I wanted to display. Some things, like determining split; I just do in math even though a specific entry is added. I suppose I could do the "proper" thing and pull that value then only do the math if needed; but I think that's splitting hairs in terms of efficiency.

I haven't bothered configuring it to send any UDP data out yet. I think my next step is going to be modifying the thread to detect stoppage of UDP data to send the alive request every few minutes and determine if it's just the radio being turned off or if Log4OM is actually shut down.
N1FG
Advanced Class
Posts: 89
Joined: 23 Jul 2021, 08:47

Re: Making Use of UDP Messages

Post by N1FG »

NQ4T - That is one of the neatest QRZ pages I have ever seen, very nice work!

73 - Larry N1FG
nq4t
Novice Class
Posts: 7
Joined: 02 Feb 2023, 07:32
Location: Manassas, VA (FM18)
Contact:

Re: Making Use of UDP Messages (Log4OM Web Status)

Post by nq4t »

Rather than make a new thread I decided to just continue in this one.

My Log4OM Web Status script has been updated; in fact, it's been practically rewritten. It has one new outward feature:
  • Can now indicate difference between the radio being off or Log4OM not loaded
Internally, the code was rewritten to remove the use of the monitoring thread, accomplishing this using a timeout. The new code that checks to see if it's a radio being off or Log4OM not being loaded will only run every 60 seconds. The timeout for the UDP messages was set to six seconds; the response timeout for when messages stop is 2 seconds. It currently takes about 15 seconds to indicate the radio is off/log4OM not loaded. Frequency updates are "instant" within the 5 second auto-refresh.

Everything is in the repository.
WA2SQQ
Old Man
Posts: 326
Joined: 16 Feb 2015, 20:13
Location: New Jersey US

Re: Making Use of UDP Messages (Log4OM Web Status)

Post by WA2SQQ »

I totally agree - this is really a very nice page. I like the "pop out" feature an I'm wondering if you have ever published the instruction how to do this. Such programming is NOT something I'm familiar with.
nq4t
Novice Class
Posts: 7
Joined: 02 Feb 2023, 07:32
Location: Manassas, VA (FM18)
Contact:

Re: Making Use of UDP Messages (Log4OM Web Status)

Post by nq4t »

WA2SQQ wrote: 06 Apr 2023, 15:59 I totally agree - this is really a very nice page. I like the "pop out" feature an I'm wondering if you have ever published the instruction how to do this. Such programming is NOT something I'm familiar with.
Thanks for the feedback.

On the QRZ side it's literally just an iframe that embeds https://nq4t.com/qrz:

Code: Select all

<p><iframe align="top" frameborder="0" height="800" name="iframe" scrolling="yes" src="https://nq4t.com/qrz/" width="100%"></iframe></p>
Of course this means that QRZ only hosts the 184 bytes or so this code makes up; everything else comes off my server. I figure if anyone ever complained I could defend it with "hey...I'm saving you guys bandwidth".

The pop-out is also just standard HTML:

Code: Select all

<a href="https://nq4t.com/qrz/" target="_blank">pop-out</a>
Now the actual website itself is a bit more complicated. That's a mixture of HTML, CSS, and the syntax a static-site generator uses for generating pages. So like the main index site contains code to generate the paginated posts; the layout contains code that makes sure the sidebar/menu is generated for every single page; there's a lot of CSS to make it all look right. For example, if you visit the "Posts" section (https://nq4t.com/blog), you will see a list of blog postings organized by tag/category. The actual page source for the index.html looks like this:

Code: Select all

---
layout: page2
title: Posts
order: 1
sidebar: 1
---

<p class="message">
  Here you can find all blog postings made to the site sorted by tag.
</p>
{% assign sorted_tags = site.tags | sort %}
<ul>
{% for tag in sorted_tags %}
<h3>{{ tag[0] }}</h3>
{% for post in tag[1] %}
<li>
      <a href="{{ post.url }}">{{ post.title }} | {{ post.date | date: "%d-%^b-%Y" }}</a>
    </li>
  {% endfor %}
{% endfor %}
</ul>
So every time I make a post to the site...the *entire* site gets rebuilt and that code is used to generate the final HTML. There's a lot more going on too...as there are layouts that determine additional content. Posts I write are actually in Markdown syntax...with a mixture of HTML sprinkled in; the software can automatically (most of the time) figure out what's being used. But essentially it allows me to have a full static/pre-rendered website without having to manually update 300 pages if I change a menu or something. I think I spent about 4 days modifying an existing theme to "behave" the way I wanted it to and figuring out workarounds for limitations.

I have bash scripts on my server I can call with a few arguments to automatically drop me in to an editor with a lot of stuff filled-in. Then when I save and exit the editor it runs spell check and then automatically places the file in the proper location. I simply push the repository to my git and then a githook script automatically calls everything needed to rebuild the site. Since it's all hosted on the same server it works well. I have most of the benefits I would want from a Wordpress site with none of the security risks. I largely just want to write a post, publish it, and be done. The build process is quite fast; I think from the time I push the updates to the repository to the time it's finished is less than 5 seconds. There's an additional script called that symlinks content not contained in the repository back in to the site folder. All the images on the site are an example; they live in /var/www/nq4t-static while the main website lives in /var/www/nq4t. Jekyll (the site generator) deletes everything in the nq4t folder every time it runs; so another script comes behind it and links everything in nq4t-static back over.

And since I'm doing this with git; the actual site source is open to look at.

It may seem like a bit much...but with the reputation of ham sites being what they are I wanted to take it to the next level. Granted...there was a lot of coding and debugging involved. Ham radio stuff is actually what pushed me in to getting more serious in to coding things. I mean I'm not going to develop the next killer desktop application or anything; but I have found there are things I'd like to do that don't have a solution, so I'll sit and figure out one. The web-status is a prime example.
Post Reply