PDA

View Full Version : Need HELP! Creating an Event from Serial Recieve. I'm LOST.



abarhorst
August 23rd, 2007, 06:14 PM
I want to trigger an action in girder when I recieve a certain serial command on the serial port. I set up a .lua serial description for my device, and can get girder to recieve the commands. This is EXACTLY what I see on the lua console every time the serial command is initiated:

Serial: RTI RP6 : Simple Receive: Data 80 70 C0 3F €pÀ? Code: 1


How to I learn this event in Girder? I tried to click on the event properties box and press the Learn Button. I then issue the command, but nothing is picked up as the Event String. This is how I learned all of my X-10 and Netremote events. The Event Filter is set to Any Source. Do I need to be doing this another way?? I Also tried to cut and paste the entire line in the Event String box, but that did not work either. Can anyone help me out, I'm stuck. Thanks.

quixote
August 23rd, 2007, 07:12 PM
I've never worked with serial devices like you are, but have you looked at this?

http://promixis.com/forums/showpost.php?p=118339&postcount=4

Rob was talking about this recently. Maybe it's a good place to start?

abarhorst
August 24th, 2007, 04:42 AM
Thanks. Didn't know that tool existed. I tried it, and had it generate new lua code. That part worked well. However, I get the same response in the lua console:

Serial: RTI RP6 : Simple Receive: Data 80 70 C0 3F €pÀ? Code: 1

How do I associate this with an event??

Rob H
August 24th, 2007, 06:45 AM
You need to generate the event yourself in the ReceiveResponse method.

e.g. something like


gir.TriggerEvent(serial.bytetohex(data), 18)

18 means to treat it as a Girder event. You may want to request a plugin id in the TreeScript DUI Registry thread - http://www.promixis.com/forums/showthread.php?t=12038

abarhorst
August 24th, 2007, 07:08 AM
Like This??

local Super = serial.Classes.Simple
local device = Super:New({
Name = "RPTEST",
GlobalName = "RPTEST",
Description = "test",

LogLevel = 0,-- change this to a higher number or false when the device is working

BaudRate = 4800,
Parity = 0,
DataBits = 8,
StopBits = 1,
FlowControl = 'N',

CallbackType = serial.CB_FIXEDLENGTH,
ReceiveFixedLength = 5,

SendStartByte = '',
SendTerminator = '',
IncompleteResponseTimeout = 100,
NoResponseTimeout = 1000,

Initialize = function(self)
if Super.Initialize(self) then
-- add your own initializations here
self.Status = 'Initialized'
return true
end
end,

ReceiveResponse = function(self, data, code)
gir.TriggerEvent(serial.bytetohex(data), 18)
if math.band(code, serial.RXCHAR) > 0 then
-- add code here to process the data parameter
end
Super.ReceiveResponse(self, data, code) -- must call the parent's ReceiveResponse
end,

})

serial.AddDevice(device)

Rob H
August 24th, 2007, 08:23 AM
Nearly. Move the call to gir.TriggerEvent inside the if statement - ie where comment is.

abarhorst
August 27th, 2007, 06:16 AM
I just wanted to follow up and say this worked!!!!!.
Now, I can use a very high end, customizable remote:

http://www.remoteshoppe.com/index.php?itemid=348&catid=30

with RF and serial triggering events in girder. (IR was too slow and a little eratic). I had gone the pocket PC route, but this is a much better solution for use in a home theater.

Rob H
August 27th, 2007, 06:59 AM
Great, glad it's working.