Precision Simulator update 10.172 (20 October 2023) is now available.
Navburo update 13 (23 November 2022) is now available.
NG FMC and More is released.

Main Menu

Pushover App- integration with PSX PRINT function?

Started by cavaricooper, Fri, 17 Jan 2020 22:51


Dear Jeroen,
Thank you for this brief intro. Very useful!
It is greatly appreciated. Similar to the old proverb, "Give a man a fish and you feed him for a day, teach him how to fish and you feed him for a lifetime", I rather learn to code. :)



Jeroen Hoppenbrouwers

My pleasure.

Remember that this program, though short, uses a lot of complex techniques such as asynchronous event handling that are guaranteed to make you wonder what's going on here. This is the unfortunate truth of programming, just as of flying an airplane: there is no such thing as an easy start. Once you lift off, it's all-out full everything at once. So I gladly be your instructor on these first flights  :-P

(Simon: I made sure I have barf bags in reach)

PS. And if people push me enough, I will also show how you could FAA-certify this kind of stuff for real-world commercial aviation use under DO-178C, but that may take a few more postings  :-P


 :) Well: I have loads of them at home now, but quitted flying. Shall I send them over?




After a few sessions of head scratching and reading your post over about 50 times, I arrived at

but more importantly this on my iPhone

I can't thank you enough- this is just splendid!

Carl Avari-Cooper, KTPA



Whilst you are in the teaching mode- is there a way I can make that command prompt py file a clickable executable and assign an icon to it? That way it can be run with a mouse click instead of the keyboard?

Ta- C
Carl Avari-Cooper, KTPA

Jeroen Hoppenbrouwers

Sure. Create a Shortcut where you want it (Background click >> new >> shortcut) and point it at the python.exe interpreter. Name it Pushover. Then right-click on it and select Properties. After the python.exe in Target, BEHIND the quotes, add the path to your file. You may change the window type to minimized and give it a new icon.

That's it!



DONE!  Many thanks Hoppie!  Off to work on the Mac now...

Carl Avari-Cooper, KTPA


... and with STILL MORE OF HOPPIE'S HELP- success on the Mac!

FINALLY!  Thank-you Hoppie!

Now, I get PSX Pushovers to my iPhone and iPad which I can reference indefinitely, and delete when done- fantastic!

Carl Avari-Cooper, KTPA


This is NOT my code- it is HOPPIES.  Please check with him BEFORE uploading it anywhere.

Carl Avari-Cooper, KTPA

Greg Hateley

Hey Hoppie,
Can you please explain, with a bit of example code how to asyncio a function into the current code.
I need to pole (read) some switches (using RPi.GPIO) and return a switch is, pressed or not, back to the main program.
(I am using the class).
I recall doing something like this last time for reading pots n the radar panel"await  asyncio.gather(PSX.connect(host, port),SendWxRdrPanelTurnQ())"

Main PSX Code:

VERSION = "Some kinda Greg version 000000 0.0-alpha-1"

import asyncio
import argparse
import sys
from dsptoolkit import DSPToolkit
mydsp = DSPToolkit()
xmlfile =open('747acp_V3.xml')
data =

from PSX import Client
from PSX import MCDU

if __name__ == "__main__":
  """ Try to connect to the PSX Main Server and see what happens. """

##  import datetime
##  import time
  def  RotSelAudioL(key, value):
    mystring4 =str(value)
    vhfvol = int(int(list1[0])/2 -30)
    print(f"RotSelAudioL: {mystring4}")
  def ReceiverSelL(key, value):
    mystring = str(bin(int(value)))
    mystring2 = int(value) & 1
    mystring3 = int((int(value) & 8)/8)
    print(f"ReceiverselL Val: {mystring}")
    print(f" Cpt VHF L Green Light: {mystring2}")
    print(f" Cpt FLT : {mystring3}")
    if mystring2 == 1:
    if mystring2 == 0:

  ##### MAIN #############################################################

  print(f"Self-test for the PSX Client Module, version {VERSION}\n")

  # Create a PSX Client and install a custom logger.
  with Client() as psx:
    psx.logger = lambda msg: print(f"   {msg}")

    # Register some PSX variables we are interested in, and some callbacks.
    # NOTE: These subscriptions are registered in the connector module, but
    # until the PSX connection is activated, nothing will happen.
    psx.subscribe("version", lambda key, value:
      print(f"Connected to PSX {value} as client #{psx.get('id')}"))

    # A simple thing to play with EICAS.
    #psx.subscribe("TimeEarth", TimeEarth)
    psx.subscribe("ReceiverSelL", ReceiverSelL)
    psx.subscribe("RotSelAudioL", RotSelAudioL)

      # Make and maintain a PSX Main Server connection until stopped.
      # Only here something actually happens!
    except KeyboardInterrupt:
      print("\nStopped by keyboard interrupt (Ctrl-C)")


Button Press code.
    GPIO.setup(CAPT_PTT, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    pressed = False

    while True:
        # button is pressed when pin is LOW (True)
        if not GPIO.input(CAPT_PTT):
            if not pressed:
                print("CAPT_PTT pressed!")
                pressed = True
        # button not pressed (or released)
            if pressed:
                print("CAPT_PTT released!")
                pressed = False

Rgds Greg

Jeroen Hoppenbrouwers

So for each poll you want to open a PSX connection, wait until you get all variables, pick out the one you need, and then close the connection?

I don't understand yet what you try to achieve at the higest level. Inject hardware switch positions into PSX? Read variables from PSX?


Greg Hateley

Hi Hoppie,
Sorry for the delayed reply, So here I hope is a better basic description.
I can send and receive from PSX, that part works great.

The Python PSX is running on a Raspberry PI, and I want to read if a real switch also connected to the same Raspberry Pi (GPIO Ports) has been pressed or not within the body of the PSX code you did using the PSX Class.
To read the gpio switch, or switches I need to read the gpio input on the Pi constantly in a loop. (ie pole the inputs) "while True:"  loop.
I have written a function " def Pole_GPIO1" to read the switch 1 and return a pressed True False . this function needs to loop.
So for this function "Pole_GPIO1" it only looks to see if a switch has been pressed or not.

Once the real gpio switch is read,  if the state changes from pressed or to released, then send a code, or do something, IE PSX.send or light a LED for example, PTT vatsim. Im my case this gpio inputs are the PTT switches on the yoke.

something like this
-->->->PSX ->->->Pole(read)Switch -> Do Something else-> Loop

Jeroen Hoppenbrouwers

You will need to add a new asyncio Task to the running main loop. In that Task, you can poll and process, then wait, but you need to use asyncio.sleep() else you lock up the whole thing.

Asyncio is not the same as threads, where you may within limits assume that your tasks run independently of each other in parallel. Asyncio requires you to explicitly have your tasks yield the CPU back to the main loop often, but you get back a cleaner structure that is easier to coordinate exactly because only one task runs at any moment.

I will see when I find time to make an example. It's a bit hectic at this moment.


Jeroen Hoppenbrouwers

Actual airline business case.

The Boeing 787 uses 2 rolls/flight.
That is 2 flt/day * 2 rolls/flight * 365 days/year * $13/roll = $18k/aircraft/year.

Including other types, 300 aircraft ... some fly more, not all print the same, but...
$18k * 300 AC = $5M/year for the airline.