vbs script for UCH

Discussion about the UCH, our industrial grade, smart USB3 Hub
Post Reply
stellario
Posts: 1
Joined: Fri Jan 19, 2024 4:41 pm

vbs script for UCH

Post by stellario »

Hi there,
I'm not an expert developer, so as usual I had my hard time browsing the web to collect pieces of info for writing automation scripts for my remote observatory.
This time I wanted to control the Pegasus hub remotely via ASCOM. I checked this forum but found nothing apart a python code. I prefer to stay with .vbs scripts, as I have built a small library of these over the years.
So, just in case anyone else had the same need, here is an example of a .vbs script for power cycling a given USB port (bear in mind that ASCOM uses numbers 0-5 instead 1-6 for the USB ports). Of course, you need to install first the ASCOM driver for the UCH, from the Pegasus download page.

dim UCH
set UCH = CreateObject("ASCOM.UCH.Switch")
UCH.Connected = True
UCH.SetSwitch 4, False
wscript.sleep(10)
UCH.SetSwitch 4, True

In the example, the switched port is the 5th one according to hub numeration also displayed by Unity.
In my case I need to quit Unity app before running the script, otherwise the script won't access the COM port of the device (not an issue, since when running robotic operation I don’t need Unity).
I hope this will spare someone a tedious web search!

Antonio
Post Reply