Retrieving events from OmniRig Software (python)

Viewed 107

I'm building a small app to interface with OmniRig (COM server for ham radio control). I am very new to event handling in Windows. When I perform my SendCustomCommand , I am sending the radio the command and expecting a return of 6 characters ending with the char ";". Below is my testing code:

import win32com.client, time, pythoncom

w = win32com.client.gencache.EnsureDispatch("Omnirig.OmnirigX")
defaultNamedNotOptArg = pythoncom.Empty

class Listener():
def OnVisibleChange(self):
    print(1)
def OnRigTypeChange(self, RigNumber=defaultNamedNotOptArg):
    print(2)
def OnStatusChange(self, RigNumber=defaultNamedNotOptArg):
    print(3)
def OnParamsChange(self, RigNumber=defaultNamedNotOptArg, Params=defaultNamedNotOptArg):
    print(4)
def OnCustomReply(self, RigNumber=defaultNamedNotOptArg, Command=defaultNamedNotOptArg, 
Reply=defaultNamedNotOptArg):
    print(5)

w.Rig1.SendCustomCommand(bytes("MG;", "utf-8"),6,";")

pythoncom.PumpWaitingMessages()

I need to figure out how to return the message received from the radio. It should be returned in a format like "MG005;" I generated a type library for the exe using makepy and it included the following information:

# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing, .Empty and .ArgNotFound
defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty   

....(snip)

# Event Handlers
# If you create handlers, they should have the following prototypes:
#   def OnVisibleChange(self):
#   def OnRigTypeChange(self, RigNumber=defaultNamedNotOptArg):
#   def OnStatusChange(self, RigNumber=defaultNamedNotOptArg):
#   def OnParamsChange(self, RigNumber=defaultNamedNotOptArg, Params=defaultNamedNotOptArg):
#   def OnCustomReply(self, RigNumber=defaultNamedNotOptArg, Command=defaultNamedNotOptArg, 
Reply=defaultNamedNotOptArg):

Any help on how to structure an eventhandler for this situation would be appreciated.

0 Answers
Related