View Full Version : Problems with Serial Commands
J F B
April 3rd, 2006, 11:27 AM
I want to send a single character at 1200 8N1 to a microcontroller in order to close a specific relay. I can control them perfectly using Hyperterminal, but I'd prefer to activate the relays using Girder.
Per the documentation, it seems like I need to create a device driver and save that file in the Plugins\serial directory. So, I typed up the following and saved it as basic.lua :
local device = serial.Classes.Simple:New({
Name = "Basic",
Description = "Description of my serial device.",
Baudrate = 1200,
})
serial.AddDevice(device)
However, when I add this device to COM1, it says the status is "Not Running" and when I pull up Serial Send under the actions menu, it doesn't list my device under the pull-down. I also tried embedding this function into the device driver description:
Send1 = function (self)
self:Write (1)
gir.TriggerEvent ("sent 1", 18)
end
But then the driver wouldn't load at all.
Can anyone tell me what I'm doing wrong?
Rob H
April 3rd, 2006, 12:40 PM
The first thing is that it's BaudRate rather than Baudrate (Lua is case sensitive).
I couldn't see anything obviously wrong with your Send1 function, so it might be to do with the placement. It should work providing it's the last thing in the serial device.
If you open the Interactive Lua Console you'll see any errors.
Promixis
April 3rd, 2006, 01:18 PM
I want to send a single character at 1200 8N1 to a microcontroller in order to close a specific relay. I can control them perfectly using Hyperterminal, but I'd prefer to activate the relays using Girder.
Per the documentation, it seems like I need to create a device driver and save that file in the Plugins\serial directory. So, I typed up the following and saved it as basic.lua :
local device = serial.Classes.Simple:New({
Name = "Basic",
Description = "Description of my serial device.",
Baudrate = 1200,
})
serial.AddDevice(device)
However, when I add this device to COM1, it says the status is "Not Running" and when I pull up Serial Send under the actions menu, it doesn't list my device under the pull-down. I also tried embedding this function into the device driver description:
Send1 = function (self)
self:Write (1)
gir.TriggerEvent ("sent 1", 18)
end
But then the driver wouldn't load at all.
Can anyone tell me what I'm doing wrong?
can you attach your .lua file?
J F B
April 3rd, 2006, 02:13 PM
Here is the lua file. I changed the BaudRate, thanks. It still isn't showing up in the actions menu, though, and lua says that the function is nil when I try to call it. Maybe I'm not calling it correctly.
Rob H
April 3rd, 2006, 03:10 PM
You may want to try giving it a GlobalName property as well.
jmonier
April 4th, 2006, 09:30 AM
I've found that GlobalName is necessary for it to show on the list of devices. My devices do show "Not Running", however, and still work fine.
Promixis
April 4th, 2006, 11:49 AM
I've found that GlobalName is necessary for it to show on the list of devices. My devices do show "Not Running", however, and still work fine.
the "status" of the device is set by your intiialization code...
maybe just change it "Port Opened" :)
J F B
April 5th, 2006, 02:41 PM
Yes, the GlobalName setting was all I needed. Well, that and figuring out that I needed to be using \-slashes instead of /-slashes (\r\n) when I was trying to transmit a carriage return :D
Thanks everyone for your help.
Promixis
April 5th, 2006, 05:52 PM
Yes, the GlobalName setting was all I needed. Well, that and figuring out that I needed to be using \-slashes instead of /-slashes (\r\n) when I was trying to transmit a carriage return :D
Thanks everyone for your help.
Great,
would you mind uploading your .lua file to http://www.promixis.com/uploads_list.php
in case someone has a similar project?
J F B
April 7th, 2006, 01:28 PM
Sure thing. I'll send it once I clean the file up a bit and add some comments. Ultimately I'm trying to write a driver for a Digitech scrolling LED display. I'll post that too if I have any success.
Promixis
April 10th, 2006, 03:33 AM
Sure thing. I'll send it once I clean the file up a bit and add some comments. Ultimately I'm trying to write a driver for a Digitech scrolling LED display. I'll post that too if I have any success.
thanks.
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.