What I would like to be able to do is to write a program in Kotlin, Python, or whatever and have it send commands to gtopo over a network socket. A pipe could be used, but would be problematic to set up. The first command would probably be to send lat/long coordinates and ask Gtopo to put a marker of some sort (likely just a colored dot) on the map at that location.
Various questions immediately arise. Should a subsequent command add yet another dot, or should it move the first dot. Both behaviors are interesting and useful, so two commands should be provided. Once a protocol is in place, it could be augmented to allow entire tracks to be sent.
On the Gtopo side, the issue will be how to handle this with respect to the GTK event loop. My first idea would be to have a thread to listen (and block) on the socket. That is easy enough and could use Pthreads. When a command is received, it could be posted in some shared memory and some kind of signal sent to inform GTK that a command is waiting for its attention.
A crude but simple way to have GTK recognize a command would be to set up a timer event that watches for a command to appear in shared memory. This would in effect be polling at some rate.
Another question is whether a queue of commands would be required. One would be unless the listener thread did some handshaking with the client to indicate when a command was finished and it was ready for more commands.
Some links to think about some fine day:
I have some cleaning up to do relative to my github repository. My origin is a non-existant repository on an observatory computer. The remote for github is "github" and I would like to change that to "origin".
/u1/Projects/Topo/gtopo git help remote git remote remove origin git remote rename github originThis is all tidy and clean, so the first order of business is to be sure that my working copy of the sources compiles clean:
cd src make clean ; makeI get a warning about use of strncat in gpx.c that I fix and it compiles clean. I am still using gtk2. If I had nothing better to do, I might take on the task of converting this to gtk3, but why? It works fine as it is.
I currently do have a timer being run by gtk. It fires every 500 milliseconds and calls my "cursor" function to blink my little "+" cursor at map center.
It turns out that the code I need is in overlay.c, which I put together 2 years ago to display GPX tracks. It also can display waypoints, so I can use the existing waypoint code to do what I want.
I don't need to do anything special to link in pthread libraries (much to my surprise). Getting the header file boilerplate for the TCP stuff is a pain, as usual.
I select port 5555 and a "telnet localhost 5555" lets me do testing.
I will try this for my first test. I paste the following line into telnet
and ....
M -110.870457273 31.692344025And it works! Just that line with "M" for mark does the job. The info from my GPS was:
2211.200 0.120000
By the end of the day, I have this working and a python script communicating with it.
So I am going to allow "C" for center and "M" for mark. Or both together as center and mark, i.e.
M -110.870457273 31.692344025The logic to center is already in place (and is used by the current places file. Worth considering is that now an external GUI could handle a places file, perhaps in a fancier way.
Gtopo / [email protected]