28 July 2016

The Flex API

It all started off innocuously enough. As the development of the Flex Controller gets closer to a usable system, I have started looking into integration issues. Notably, the Flex radio and/or controller needs to work with my home brew logging program, StarLog. Specifically, The logging program needs to be able to pull frequency/mode information from the radio and send frequency, mode and split commands to the radio.

The simplest option appears to be to use the Flex CAT add-on. This separate application becomes another client of the Flex radio and provides an Icom-like CAT interface via a virtual com port. All well and good but not really a very satisfying solution for at least the following reasons:
  1. The use of legacy RS232 com ports. Although they are virtual ports (they don't really exist, certainly not in any physical form) they still require com port support in the logging program and it seems faintly ridiculous to use this approach in a modern system designed from the ground up.
  2. The different architecture of the Flex radio means that concepts like split operation are realised in a quite different way, meaning that the standard Icom CAT protocol is inadequate. FlexRadio has added a number of Flex-specific CAT-like commands to bridge the gap but that's a fudge and, of course, it means that I would have to write new code in the logging program.
There is another way. The logging program can be made to become a client of the Flex radio, using the Flex Application Programming Interface (API). This is the gold star way to do it but it needs considerably more code and a lot of knowledge of the API that I certainly did not possess.

And so it happens that I have spent most of this week writing a Delphi Pascal program for my PC. It started out as a project to explore how CAT could be implemented via API but has become so much more.

Getting under the bonnet of the API turned out to be a difficult but fascinating voyage of discovery, at least in part because of the relative paucity of documentation. Fortunately there is the existing FlexAPI, the code for which is published and there is also a good forum community. As I've progressed my understanding has grown and now the program does far more than the tasks required for a logbook API.

The test program lets me play with the various facets of the interface protocol and see precisely what the radio responds with when I poke it with commands. Before I could make sense of that I spent a head banging evening looking at the actual packet data on the Ethernet interface, using Wireshark. You can't get much lower level than that.

Anyway, the result is that something really quite interesting has happened. I can now see my way to producing a complete API library that could be used with Windows applications to create a PC-based Flex Radio Controller. Now think back to my Blog entry a while back in which I contemplated a second generation controller based on something like the soon to be released Udoo X86 board. Suddenly things start coming together!

Another possibility is that this new code could be made into a DLL, meaning that it could be used with any PC application written in any language. I'm not sure that I'm ready to go there yet but it's certainly something to keep in mind for the future.

So I now have a solution to integrating my logging program into the Flex radio architecture via the Ethernet API. That's the next job I reckon.

No comments:

Post a comment