Jump to content
C4 Forums | Control4

Lua programming


mehroz

Recommended Posts

i have started reading driverWorkds SDK, its documentation. lua code... and tried to edit some drivers myself

But i am still blank how to write 2 way serial drivers??..... Can anyone guide me where to seek help and how to?

Link to comment
Share on other sites


i have started reading driverWorkds SDK, its documentation. lua code... and tried to edit some drivers myself

But i am still blank how to write 2 way serial drivers??..... Can anyone guide me where to seek help and how to?

The other approach is to pull an existing lua (driverworks) based serial driver and use it as a point of reference/template. That's likely the easiest way to start.

Link to comment
Share on other sites

Driverworks is not for everybody. 3 years of university helped me alot:) however based upon what i've seen of driverworks a basic understanding to a 1st year university level is a must.

To give you an example of how complicated Driverworks can be. Our Clipsal CBUS driver has taken us 400 hours of development so far and 14,000 lines of code. The driver is done by one of my tech's who was working part time for us and was lecturing c++ programming at one of melbourne's prestigious universities.

For a new programmer expect to spend at least 100+ hours before you can get the knowledge needed to make a basic working driver. You do need basic programming skills but you do not need to understand c++. My recommendation is to download a lua compiler/interpreter and program a few hello world type programs first. Lua.org has some great tutorials on how to learn lua so i recommend going through those. Learn the basics such as loops, conditional statements, functions. Move onto tables and strings. Once you have grasped this concept you can then learn driverworks.

To learn driverworks i suggest reading the getting started guide, API and reverse engineering as many drivers as possible. Driverworks is really simple once you have grasped the lua side of things. Control4 have done an excellent job at providing the information necessary to learn the software development kit.

I hope this helps. Yet again only attempt this if you are willing to put the time in.

* Read the Driverworks getting started guide

* Read the Driverworks API

* reverse engineer the template drivers, weatherbug driver and any other driver you can get a hold of

* Read up the LUA.org examples on TABLES and String manipulation.

Link to comment
Share on other sites

Thankx a lot for replying and for your suggestions.........

Well, by profession, i am an engineer, and works on networks and VOIP...

I have taken 3 courses on c++, and quite confident in its grip....but still, i was little down towards lua and driverWorkds stuff....

Well, as u said, ill give another try following your procedure.... Hoping for progress this time :)

Link to comment
Share on other sites

  • 5 months later...

Hey Hi guys,

I am a new with control4 and lua programming too, I am a computer engg and hence i am well aware of c,c++ compilers.

I am worried about few things in lua.

1) how to get .c4i extension if using notepad for coding. I am using Windows 7.

2) where can i compile and test codes anywhere without loading into program.

3) how driverworks get help from interactive lua, do i need to connect with the device with computer.

Link to comment
Share on other sites

1) At the DOS prompt, use the 'rename' command. i.e. rename MyDriver.xml MyDriver.c4i

2) You can run code within the driver, in ComposerPro. Just put the Lua code into the 'Lua Code' window, and press 'Execute'.

3) Yes, you need to connect ComposerPro with your controller to be able to interact with the device.

This may be helpful: http://lua-users.org/wiki/LuaShortReference

It's a PDF reference of Lua 5.1 Language and Syntax. I use it and refer to it extensively.

RyanE

Link to comment
Share on other sites

FYI you can also buy that in a book/manual version too on amazon. I bought 3 lua books when I "dove" into it as I come from a web programming background (asp.net, js, etc.) and I wanted to get up to speed with the syntax. Most have not been as helpful as I had hoped but the reference is handy.

Link to comment
Share on other sites

Thanks for support,

May i able to right codes for IP devices also?

Can anyone send me the sample IP driver if possible, C4 online Ip drivers are with the scripts.

Correct me if i am wrong for IP drivers

1) I should say send network setting in lua instead of serial settings.

2) It should identified by the Network by controller?

How can I do that.

Please guide.

Link to comment
Share on other sites

Yes, you can write IP drivers in DriverWorks, just like Serial drivers.

There isn't a single sample IP driver, but the Weatherbug driver shows an HTTP driver, which is in many ways similar to a straight IP driver.

The biggest code difference is that instead of using:

ReceivedFromSerial(idBinding, strData)

C4:SendToSerial(idBinding, strData)

you use:

ReceivedFromNetwork(idBinding, nPort, strData)

C4:SendToNetwork(idBinding, nPort, strData).

RyanE

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.