PDA

View Full Version : generic serial plugin not configured when girder starts



codyzu
January 15th, 2008, 09:32 PM
When girder 5.0.0 build 523 starts the serial port does not appear to send commands. To get it to work I have to:


Goto settings->plugins->serial tab
Click on Com 3
Click on Change Device
Select any device other than the one I'm using
Select the device I'm using
Click OK Change


It works perfectly after performing the above procedure. I added some debug messages to my custom serial device lua file that is included in the bottom of the post.

Here is my lua console log from when girder starts to when I have it working. I've highlighted where I do the above procedure:


Loaded LGTV Class
Loaded LGTV component
Welcome to Promixis Girder 5.0.0 build 523
Serial: cody : Opened Device: cody Port: 3 Settings: 9600 N 0 8 0
Serial: cody : Callback Installed 2
Serial: cody : Simple Send: 6B 61 20 30 30 20 30 30 0D 0A ka 00 00..
test
nil
Serial: cody : Simple Receive: Data Code: 16384
Serial: cody : ERROR: No response to last command
Serial: cody : Simple Send: 6B 61 20 30 30 20 30 30 0D 0A ka 00 00..
test
nil
Serial: cody : Simple Receive: Data Code: 16384
Serial: cody : ERROR: No response to last command


Here is where I performed the above precedure



Serial: cody : Opened Device: cody Port: 3 Settings: 9600 N 0 8 0
test
0
Serial: cody : Callback Installed 2
Serial: cody : Simple Receive: Data 30 0 Code: 65536
Serial: cody : Simple Send: 6B 61 20 30 30 20 30 30 0D 0A ka 00 00..
test
ka 00 00
1
OK
Serial: cody : Simple Receive: Data 6B 61 20 30 30 20 30 30 ka 00 00 Code: 1
test
a 00 OK00x
1
OK
Serial: cody : Simple Receive: Data 61 20 30 30 20 4F 4B 30 30 78 a 00 OK00x Code: 1
test
Serial: cody : Simple Receive: Data 00 . Code: 8192
Serial: cody : ERROR: Incomplete response to last command
Serial: cody : Simple Send: 6B 61 20 30 30 20 30 31 0D 0A ka 00 01..
test
þ
Serial: cody : Simple Receive: Data FE þ Code: 8192
Serial: cody : ERROR: Incomplete response to last command
test
Âý
Serial: cody : Simple Receive: Data C2 FD Âý Code: 8192
Serial: cody : ERROR: Incomplete response to last command
test
1
OK
Serial: cody : Simple Receive: Data Code: 1
test
Application Initialization Success
1
OK
Serial: cody : Simple Receive: Data 20 41 70 70 6C 69 63 61 74 69 6F 6E 20 49 6E 69 74 69 61 6C 69 7A 61 74 69 6F 6E 20 53 75 63 63 65 73 73 20 Application Initialization Success Code: 1



Here is my log:



Time Date Source Details Payloads
20:58:43:562 1/15/2008 Serial Send TV Power On treescript okcody LGTV.gml:\Power On\Serial Send TV Power On
20:58:39:015 1/15/2008 Serial Send TV Power Off treescript okcody LGTV.gml:\Power Off\Serial Send TV Power Off
20:56:33:328 1/15/2008 Girder IR Passthrough Registered IR Handler
20:56:33:281 1/15/2008 Girder2Girder Started
20:56:32:140 1/15/2008 WebServer Webserver Started
20:56:32:140 1/15/2008 Communication Server: Servers Server (GIRDER): cody2, @ 10.90.123.3:20005
20:56:32:140 1/15/2008 Audio Mixer Plugin Loaded, Version: 2.0.0.1
20:56:31:531 1/15/2008 NetRemote Enabled


Here is my custom serial device cody.lua:


--local Super = serial.Classes.Queued2
local Super = serial.Classes.Simple
local device = Super:New({
Name = "cody",
GlobalName = "cody",
Description = "cody",

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

BaudRate = 9600,
Parity = 0,
DataBits = 8,
StopBits = 0,
FlowControl = 'N',

--IntraCharacterDelay = 0,
CallbackType = serial.CB_TERMINATED,
ReceiveTerminator = '\r\n',
--SendTerminator = serial.hextobyte ("0D"),
--ReceiveTerminator = serial.hextobyte('0D0A'),

SendStartByte = '',
SendTerminator = '\r\n',
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)
print("test")
print(data)
if math.band(code, serial.RXCHAR) > 0 then
-- add code here to process the data parameter
print(serial.RXCHAR)
--if (math.band(code, serial.RXCHAR) > 0) or (math.band(code, serial.INCOMPLETERESPONSETIMEOUT) > 0) then
--code = math.zerobits(code, serial.INCOMPLETERESPONSETIMEOUT) -- clear that bit so we don't get an error message
--gir.TriggerEvent('ECS.'..(data or ''), 18)
print("OK")
end
Super.ReceiveResponse(self, data, code) -- must call the parent's ReceiveResponse
end,

})

serial.AddDevice(device)


Not sure if this is unique to girder 5. I just started using the serial plugin after I installed girder 5.

Ron
January 15th, 2008, 09:47 PM
Are you using the Generic X10 Remote plugin?

codyzu
January 16th, 2008, 09:00 AM
Yes, I use the Generic X10 plugin for my Firefly remote. Also, I left out that I use the serial plugin to control my LG TV and that I use a USB to serial adapter to provide a serial port. As you can see from the lua console log, when serial communication is working, the TV echos the serial characters back to girder, hence the extra recieve messages before the commands are acknowledged. Thanks!

Ron
January 16th, 2008, 11:49 AM
Give this modified plugin a try. It grabs the comports before the X10 object can and then releases them ASAP before lua starts-up and thus blocks the generic transport plugin ( e.g. serial comms.)

codyzu
January 16th, 2008, 06:45 PM
It works! Thank you!

Is this an issue that will be resolved in a future release? Or should make sure that I hold on to that file when upgrading Girder versions?

I just found another reason why I love Girder...super fast support!

Ron
January 16th, 2008, 06:57 PM
Unless issues come up with this work-around this file will be in every future release. However you might want to hang on to the file just to be sure.