[WT-support] Access to antenna controller from LUA-script

Bob Wilson, N6TV n6tv at arrl.net
Sun Dec 11 02:29:23 CET 2016


Here's a LUA example that you can follow or modify to suit your purpose.
It sends the "P" command to power on an Elecraft KPA500.  First it prompts
for the COM port number of the amplifier, opens the COM port, and writes to
the port.  After that it won't prompt for the COM port again unless you
restart Win-Test (or type REOPENNOW).

73,
Bob, N6TV

-- KPA500_ON -- Power on KPA500
-- Time-stamp: "11 February 2015 05:32 UTC"
-- Assign to:  Text command KPAON
--
-- See also:  KPA500_OFF.wts
-- Written by N6TV

MB_ICONWARNING = 0x00000030

local ComPortNum = 0
if KPA500_COM_PORT == nil then
   ComPortNum = wtApp:InputInteger("Enter serial port number used by
KPA500\n" ..
"Enter 1 for COM1:, 2 for COM2:, etc.", wtCurrentScript)
   if ComPortNum == nil or ComPortNum == 0 or ComPortNum > 99 then
      return -1
   end
   KPA500_COM_PORT = string.format("COM%d:", ComPortNum)
end

local modeCommand = string.format("mode %s 38400,N,8,1", KPA500_COM_PORT)
local rc = os.execute( modeCommand )
if rc ~= 0 then
   wtApp:MessageBox(
      string.format("The following command failed:\n  %s\nReturn code =
%d\nNo action taken.",
modeCommand, rc),
      MB_ICONWARNING, wtCurrentScript)
   return -1
end

local kpa500 = io.open(KPA500_COM_PORT,"w")
if kpa500 ~= nil then
   kpa500:write("P")
end
kpa500:close()
return -1


73,
Bob, N6TV

On Sat, Dec 10, 2016 at 4:25 PM, <gt-i at gmx.net> wrote:

> Hello,
>
> I have an antenna controller running on a com-port which I would like
> operate from within Win-Test. I got the protocol and can do this on a
> terminal program, but switching programs during the contest is not what I
> want.
>
> Is there a way to have that using a lua-script?
>
> mni tnx, 73
>
> Gernot DF5RF
>
> _______________________________________________
> Support mailing list
> support at win-test.com
> http://lists.f5mzn.org/cgi-bin/mailman/listinfo/support
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.f5mzn.org/pipermail/support/attachments/20161210/7b820c47/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KPA500_ON.wts
Type: application/octet-stream
Size: 1006 bytes
Desc: not available
URL: <http://lists.f5mzn.org/pipermail/support/attachments/20161210/7b820c47/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KPA500_OFF.wts
Type: application/octet-stream
Size: 1012 bytes
Desc: not available
URL: <http://lists.f5mzn.org/pipermail/support/attachments/20161210/7b820c47/attachment-0001.obj>


More information about the Support mailing list