Jump to content
C4 Forums | Control4

driver development


Recommended Posts

Hi guys, Just wanted to asked a question regarding driver development. I am in the process of studying c++ not because i want to write drivers but because i always wanted to learn c . I know drivers are developed using lua specifically and really great things this came come from it. But my real qusetion is, is it really worth writing drivers if there are so many drivers out there for free as well as for sale? Is it worth the time and effort?

 

Any advise would be greatful...

Link to comment
Share on other sites


Are you writing drivers for yourself or to create solutions for other dealers? Is your goal to sell the drivers?

Learning Lua won't be an issue, it's an easy move from any language. Gaining the knowledge of the underlying protocols being used to talk between devices (Websockets, HTTP, etc) will be the more difficult part unless you are already familiar. It will also take a bit of time to get used to the Control4 environment from a Driverworks perspective.

Webviews seem to be the cool new thing so it likely won't just be Lua you'd be writing drivers in. It will be other common web languages and markups, HTML, CSS, Javascript, etc.

Link to comment
Share on other sites

Is it worth writing drivers?

It completely depends on what you're writing them for.

If you're writing drivers for something that Control4 or 3rd-parties already have drivers for?  Probably not worth it.

Your time is likely worth more than the cost of the driver, and the 3rd-parties and/or Control4 produce fairly 'bulletproof' drivers, that you'd be unlikely to improve to the point of making it worth it.

If you're writing drivers for something specific to your install (custom hardware / cloud integration / etc), and/or you think you can sell the driver, then sure.  I have a handful of drivers I've created in my home project that are *only* found in my project, but were totally worth my time in writing them.  Some of those are now offered by Control4, as they were deemed useful to the general Control4 crowd.

RyanE

 

Link to comment
Share on other sites

5 hours ago, Zauberer said:

is it really worth writing drivers if there are so many drivers out there for free as well as for sale? Is it worth the time and effort?

The answer to that question depends on why you want to create drivers.  Is it for your personal system? Is it as a business?

Regardless as both @TheWizard mentions writing drivers isn't about the language but more about the underlying communications protocols that the products require for communications.  A solid understanding of TCP, UDP, HTTP, UPnP, Websockets and more is required to get started.

From a business standpoint though it is a niche market so you have a limited amount of potential sales.  The maximum drivers you can ever sell is limited based on the number of systems installed (which is at current 1100 Control4 systems per week).  That is of course if you go by licencing.  You can always contract your services to manufacturers.  That however is a bit harder as they need to have a reason to go to you for development rather than the competition.

Hope that helps.

Link to comment
Share on other sites

i agree, it really depends on the specific driver. Try buying the BiAmp and Kramer driver!! Was well over 5K. I wrote myself and saved organization a ton. If you are familiar with CCS, HTML and or C(+) you are golden. 2 Way drivers are another story due to lack of buffering and parsing data. That's what i have found at least. If anyone has an example id love to hear from you! Writing in UDP, HDDP and UPnP are mainly used for IP Controlled gear. If you Have RS-232/485 ability its a decent reliable option.

 

CR

Link to comment
Share on other sites

On 5/7/2018 at 6:17 PM, CRE2000 said:

... 2 Way drivers are another story due to lack of buffering and parsing data ...

Not sure what you mean by lack of buffering and parsing data.

I've only *very* rarely had issues buffering and parsing in DriverWorks.

Buffering is just a global string variable that the input string gets concatenated to.

Parsing is pretty simple using string.pack / string.unpack and/or bitlib functions (or JSON / XML libraries).

RyanE

 

Link to comment
Share on other sites

In C+, AMX coding  for example is the buffering or analyzing the string feedback from the device you are trying to control. You might only need parts of it so you can use as true feedback. A prime example is Aprilaire and Jandy products as the receive string is so long and all you want is the status along with current temp you to a variable text window created in touchpanel design. Takes counting charachters to display true feedback. Example Below:

 

You could maybe also take a look at AMXX's parse native? I think it does what you want, except obviously it's coded as a native right now... Looks kind of long, though.
 

PHP Code:
/* Gets parameters from text.
* Example: to split text: "^"This is^" the best year",
* call function like this: parse(text,arg1,len1,arg2,len2,arg3,len3,arg4,len4)
* and you will get: "This is", "the", "best", "year"
* Function returns number of parsed parameters. */

native parse(const text[], ... );

static 
cell AMX_NATIVE_CALL parse(AMX *amxcell *params/* 3 param */
{
    
int inum = *params sizeof(cell), iarg 2c;
    
chararg, *parse get_amxstring(amxparams[1], 0c);
    
cell *cptr;
    
int state;
    
    while (*
parse)
    {
        
arg parse_arg(&parse,state);
        
        if (
state)
        {
            if (
inum <= iarg)
                return ((
iarg 2)>>1);
            
            
cptr get_amxaddr(amxparams[iarg++]);
            
= *get_amxaddr(amxparams[iarg++]);
            
            while (
c-- && *arg)
                *
cptr++ = (cell)*arg++;
            *
cptr 0;
        }
    }

    return ((
iarg 2)>>1);
}
Link to comment
Share on other sites

Parsing in Lua is *much* easier than that.

You can often just use Lua pattern matching.

 

-- For example, lets say the protocol gives us this:
local inputstring = "The Temperature is 100F and the humidity is 90%"

-- One line, and you have parsed out the decimal value strings:
local _, _, temp, humidity = inputstring:find("The Temperature is (%d+)F and the humidity is (%d+)%%")

-- Convert them to numbers:
temp, humidity = tonumber(temp), tonumber(humidity)

-- Print them out:
print("Temp: " .. temp .. " Humid: " .. humidity)  -- prints out: Temp: 100 Humid: 90

RyanE

 

Link to comment
Share on other sites

  • 2 years later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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