PDA

View Full Version : Assigning Comm Port to Actions



esnipes
October 4th, 2006, 04:10 PM
I have created a Lua script to configure a device through the Generic Serial Plugin. The comm port is successfully configured/attached to the Lua script and the status reads "port open".

The problem is I cannot see any comm ports listed in the pulldown menu when configuring the Serial Send Action. Am I missing any steps?:confused:

Promixis
October 4th, 2006, 06:00 PM
This is for G4 correct?

What OS are you using?

esnipes
October 5th, 2006, 01:17 PM
Using free trial G4.
WinXP for OS.

Promixis
October 5th, 2006, 02:13 PM
Ok, can you post the script?

esnipes
October 5th, 2006, 03:14 PM
The script is as follows:


--[[
--]]

local device = serial.Classes.Simple:New({

Name = "MtScript",
Description = "My serial driver",

BaudRate = 9600,
Parity = 0,
StopBits = 0,
DataBits = 8,
FlowControl = 'N',
Status = "Not Running",

Initialize = function (self)

self.Serial:SetDTR(false)
self.Serial:SetRTS(false)
win.Sleep(500)
self.Serial:SetDTR(true)
self.Serial:SetRTS(true)
win.Sleep(500)
self.Serial:RxClear()
self.Serial:Write('+++')
win.Sleep(1000)
local x,e = self.Serial:Read(2)

if x ~= 'OK' then
gir.LogMessage('MtScript', 'Initialization Failed',2)
self:UpdateStatus ('Initialization Failed')
self:Close()
return false
end

gir.LogMessage('MtScript', 'Module Enabled',3)
self:UpdateStatus ("Enabled")

return true
end,
})
serial.AddDevice (device)

Promixis
October 5th, 2006, 03:16 PM
ok, did you enable the script on that com port in the serial settings dialog?

no errors in the lua consoe?

esnipes
October 5th, 2006, 05:53 PM
Yes, Com1 reads "Com 1 - MyScript" and the Status is Enabled.

Promixis
October 5th, 2006, 05:55 PM
ah, I see the problem....

Add a property to the table

Global = 'MySerialDevice',

esnipes
October 6th, 2006, 01:00 PM
That did it! Thanks.