Posts: 171
Threads: 41
Joined: Sep 2016
At the moment I use Windows Task Scheduler to turn off my PC at a particular time.
What I would like it to do is send the "Turn Off" CAT command to my FT817ND ( and my IC7300) prior to shutting down my PC.
I have no knowledge of how to write pc software. I stopped at Qbasic umpteen years ago and I think I have had too many birthdays to start learning.
Is there anyone out there who could do this for me?
It would be much appreciated.
Regards,
Nev
Posts: 256
Threads: 43
Joined: Sep 2016
Hello Nev,
I have some scripting code in Python I use to turn off my main Icom rigs when needed. A question for you, are these radio's normally connected to digital mode software like WSJT-X or JTDX etc. when you want them to turn off ? The reason I ask about that, is access to the CAT serial port is locked when this sort of software is running and it (WSJT-X / JTDX etc) would need to be closed first before a power off could be sent to the radio.
otherwise it can be done via a script which could be part of the power-down process you use now.
Peter Sumner, vk5pj
You have enemies? Good. That means you've stood up for something, sometime in your life.
- Winston Churchill
Posts: 171
Threads: 41
Joined: Sep 2016
Thank you Peter for answering my post. Yes, I am running WSJT-X and yes, I did discover that the com port is locked, much to my annoyance. I was trying to get Spectran to connect!
I would be very interested to find out how you achieved the turn off of the rigs.
Task Scheduler is not a simple matter to set up. I have been looking at the different "commands" it has and I can't find a 'close' or similar command to terminate a program like WSJT-X. The shut down command turns off the PC.
I look forward to your suggestions.
Nev
Posts: 256
Threads: 43
Joined: Sep 2016
Hi Nev,
to kill off the digital software before hand, you can use the utility built into windows called TASKKILL
as an example on my PC where I am writing this I had the outlook mail program running (outlook.exe), from a CMD prompt I issued
taskkill /IM outlook.exe /F
This killed outlook for me, not in the most gracious manner but it exited and then when I started it again manually it was no worse for the experience. What I am thinking is that you could create some building blocks to do what you need and glue it together in a small BATCH file that task scheduler will run for you.
here is an example (untried as yet) I will test during the weekend
--- Batch file start ---
@echo off
rem kill off wsjt-x in case its running
taskkill /IM wsjt-x.exe /F
rem kill off JTDX in case that's running
taskkill /IM jtdx.exe /F
rem turn off the icon 7600
C:\Python27\python.exe C:\ham_radio\IC-7600\icom-power-off-com3.py
rem shutdown after a 15 sec wait
shutdown /S /T 15
--- Batch file End ---
Peter Sumner, vk5pj
You have enemies? Good. That means you've stood up for something, sometime in your life.
- Winston Churchill
Posts: 171
Threads: 41
Joined: Sep 2016
Thanks Peter,
That looks promising. I presume I will have to install Python, unless it already exists in Windows.
I await your experiments.
Nev
Posts: 256
Threads: 43
Joined: Sep 2016
Hello Nev,
well the testing went well, I made a couple of tweaks but otherwise it was a success,, I watch WSJT-X exit, then after 5 seconds, JTDX, then 5 seconds later my IC-7600 turned off then the PC shut down.. I inserted some PING commands to act as delays between commands, the beauty of using PING is that it needs no extra utility too do the delay and the '-n ' value used on PING is in seconds, my final script looks like this
Code: @echo off
rem kill off wsjt-x in case its running
taskkill /IM wsjtx.exe /F
ping 8.8.8.8 -n 5
rem kill off JTDX in case that's running
taskkill /IM jtdx.exe /F
ping 8.8.8.8 -n 5
rem turn off the icom 7600
C:\Python27\python.exe C:\ham_radio\IC-7600\icom-power-off-com3.py
ping 8.8.8.8 -n 5
rem shutdown after a 15 sec wait
shutdown /S /T 15
Nev, I have no way to test any CAT control on a FT-817 so you may need to find that extra peace for his puzzle as the python script I have is specific to ICOM gear. I can send you the Python script and yes you will need some of the Python 2.7 script engine files to be copied to your PC (not a full install)
Peter Sumner, vk5pj
You have enemies? Good. That means you've stood up for something, sometime in your life.
- Winston Churchill
Posts: 381
Threads: 56
Joined: Oct 2016
Could you not use TIMEOUT or SLEEP DOS methods for the delay?
I am sure that's what we used to do in the dim dark past, when I used to use more scripts than programs...
Posts: 256
Threads: 43
Joined: Sep 2016
A reference web site for sending commands: https://www.pa7lim.nl/212/ while this is for a different model of the FT series, the structures might be of help. Could not post the python code as the forum software said no.
Peter Sumner, vk5pj
You have enemies? Good. That means you've stood up for something, sometime in your life.
- Winston Churchill
Posts: 256
Threads: 43
Joined: Sep 2016
(24-06-2023, 12:39 PM)VK2CSW Wrote: Could you not use TIMEOUT or SLEEP DOS methods for the delay?
I am sure that's what we used to do in the dim dark past, when I used to use more scripts than programs...
Hello Colin, there is no SLEEP tool native to any modern Windows install, it is a utility that must be installed, hence why I avoid referring to it. Yes there are other ways to do it, including timeout, I just find PING is handy and is universal across most Operating systems, which streamlines my scripting efforts.
Peter.
Posts: 270
Threads: 35
Joined: Jul 2017
Hi Peter
I have a sleep icon on my desktop which uses the following command to activate sleep mode
C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState sleep
could that be coded to work?
Posts: 381
Threads: 56
Joined: Oct 2016
(24-06-2023, 01:14 PM)VK5PJ Wrote: Hello Colin, there is no SLEEP tool native to any modern Windows install, it is a utility that must be installed, hence why I avoid referring to it. Yes there are other ways to do it, including timeout, I just find PING is handy and is universal across most Operating systems, which streamlines my scripting efforts.
I stand corrected.
One advantage to using TIMEOUT is that a keystroke during the timer period will exit the timeout timer.
Posts: 171
Threads: 41
Joined: Sep 2016
Peter,
In the line below I take it that c:\ ham_radio contains the CAT commands for various Icom rigs.
C:\Python27\python.exe C:\ham_radio\IC-7600\icom-power-off-com3.py
I would appreciate it if you could send me the Python script and could you tell me which Python files to download and install.
Nev
Posts: 256
Threads: 43
Joined: Sep 2016
Hi Nev,
the CMD batch file is used to call the python script and these can be found here: https://vk5pj.com/icom
there should be only one thing that needs to be changed in the python script (7300-power-off-com3.py) and that is the COM port value, this should match what you have set in WSJT-X. The python script is currently set to be COM3 you just need to change that value to suite your setup.
The files for Python can be found here, the package is not very big: 'https://www.python.org/download/releases/2.7/' select one of the MSI packages to suite your PC type, (x86 or X86-64)
I do not remember which package type I downloaded as it was ages ago, there are later major versions of Python around ( v3.x ) but the script was written around python 2.7 and I have not tried it on the later versions as once it was working I was happy to leave it alone. The python script is not mine and I claim no authorship of it, was found on the WWW when searching for power off scripts for icom. All I have done is adapt is version of it for power ON.
Now be aware that when running the script, it might throw you an error about a missing module, I have a vague memory of needing to add a 'module' which is quite easy to do from the CMD line (will help you through that if it occurs).
I have adapted a version for power OFF and one for power ON as I do a lot of my radio activity from a remote PC in the house and its nice to be able to do both. Not sure about the 7300 but both the 7600 and 7610 have a standby mode you can enable that makes them respond to power on commands even though the radio is 'off'
That's it for this instalment, please try the python script on its own to confirm the 7300 power's off before you go the whole hog.
Peter Sumner, vk5pj
You have enemies? Good. That means you've stood up for something, sometime in your life.
- Winston Churchill
Posts: 171
Threads: 41
Joined: Sep 2016
Thanks Peter.
I will try it over the next few days. We are going on hols soon so it will be a while until I get back to radio stuff again.
Thanks again.
Nev
PS the first file on your server gives me a forbidden message!
|