Jump to content
C4 Forums | Control4

DriverWorks - Log In required every time (HC800)


DLM

Recommended Posts

Hi guys!
First time coding for Control4 and already have adapted a driver to a COMFORT II ULTRA alarm from Cytech, which uses a RS-232 connection to the Control4.

 

But I have an issue with Log In because every time I make the connection for the first time, I need to execute the command in ComposerPro:
C4:SendToSerial(1,tohex("03") .. "LI1234" .. tohex("0D"))

I added the following in the beginning my code but I suppose it's not working:

CMDS = {    SIGNON1          =  tohex("03") .. "LI1234" .. tohex("0D"),}

Any thoughts or suggestions?

Link to comment
Share on other sites


Just putting a command in a Lua table (CMDS) does not ensure that the command will be executed at any particular point to the serial port.

 

You probably want code in your OnBindingChanged for your serial binding ID (probably 1), where it sends the login command:

 

function OnBindingChanged(idBinding, bIsBound)

  if (idBinding == 1) and (bIsBound == true) then

    C4:SendToSerial(1,tohex("03") .. "LI1234" .. tohex("0D"))

  end

end

 

That's of course just from my brain, so it may be incorrect, but that's where I'd start.

 

RyanE

Link to comment
Share on other sites

That worked just good RyanE, and for that I thank you ;)

Now I'm trying to convert this driver from RS-232 to an ethernet connection and I'm having some trouble doing it.

 

Just one more connection before "close" this topic:
Considering I'm using an ethernet connection what should I use from the two solutions:
- make the login executing the command in ComposerPro C4:SendToSerial(1,tohex("03") .. "LI1234" .. tohex("0D"))*

- use OnBindingChanged function

*Adapted to SendToNetwork or similiar

Link to comment
Share on other sites

You shouldn't ever require the installer to type in a command in ComposerPro to cause your driver to start working.

 

If you were to do that, what happens when the device and Control4 controller get rebooted?  The device would be uncontrollable until the installer typed the login command in with ComposerPro.

 

Your driver should handle it, just like it does for serial.

 

RyanE

Link to comment
Share on other sites

If you were to do that, what happens when the device and Control4 controller get rebooted? 

 

For when there is a power failure I did this:

for Reboot in string.gmatch(strData, "V?FE071") do 		       C4:SendToSerial(1,tohex("03") .. "LI1234" .. tohex("0D"))end

But that's not the point because I totally agreed with when you say one shouldn't ever require the installer to type in a command in ComposerPro to cause a driver to start working.

My question above was made because I read on "DriverWorks SDK 2.5.3 API Reference Guide".pdf about OnBindingChanged:

 

Remarks

Protocol drivers do not get OnBindingChanged notifications for AV and Room bindings

beingbound, only *control*-type bindings (Serial, IR, etc.). It is intended to be used

specifically for when serial bindings are made, so the driver knows it can send

initialization, etc. to the now-connected device.

 

So from what I'm reading, this will not work with a Network Connection-type binding, is that correct?

Link to comment
Share on other sites

Well... RyanE solution about OnBindingChanged worked really well on the serial driver.
But now I'm working with the same driver with an Ethernet connection, and I'm having trouble solving this problem when the energy fails, what functions should I include to correct this problems?

Link to comment
Share on other sites

Sorry for the double post but I might found the right function, but I'm not getting right because login command via ComposerPro is still required.

I coded the following

function OnNetworkBindingChanged(idBinding, bIsBound)  if (idBinding == 6001) and (bIsBound == true) then    C4:SendToNetwork(6001, 1001, tohex("03") .. "LI1234" .. tohex("0D"))  endend

Some notes that may help you to help me.
6001 - Id of the network binding
1001 - Port number of the UCM Ethernet module
Login command required: C4:SendToNetwork(6001, 1001, tohex("03") .. "LI1234" .. tohex("0D"))

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.