Jump to content
C4 Forums | Control4

Serial port integration driver


Antek

Recommended Posts

Hi,

I am starting to create new driver to integrate our smart home solution with Control4.

I have access to DriverEditor and documentation, we want to integrate through serial port.

Is this forum right for technical questions about creating drivers?

Any hints for new creator? I am new with LUA.

If I understand it right there is only some list of driver types and I do not know which type to choose, our goal is to integrate Inputs, Outputs, both analog and digital (I think that it will be some bridge between two systems).

Documentation list is so huge, I am not sure which documents would suit me.

 

Best regards,

Link to comment
Share on other sites


Hi Antek,

The driver type that you'd want to choose depends largely upon what inputs and outputs you need to integrate, and what you need to do with them. There's not enough information in your post to determine which I'd recommend. Can you give me a better idea what you are trying to accomplish?

 

As for documentation, I typically find these documents to be the most helpful for most of my drivers.

 

Control4's Github also has a lot of good resources for learning/modelling, including more documentation and some example projects.

Do you have any specific questions or things that you're trying to accomplish that we could help you figure out?

Link to comment
Share on other sites

Hi Andrew,

In our network we have binary inputs, binary outputs, linear inputs/outputs (values 0-255), temperature data and a lot more.

Probably the best approach would translate all data types in one configuration file to Control4 and also from Control4 to our system.

But maybe we can start with binary values, how can I send 1/0 data through serial port to control some Control4 device?

The same question about data from Control4 to serial port.

Maybe "generic_proxy" template is good place to start? But I cant find c4zproj file for this one.

How do I know which proxyBindingId I should set?

Link to comment
Share on other sites

As Ryan said, a proxy mostly serves as a way to give interaction to your end users through the C4 UI. If you will not need UI integration, a proxyless driver is the best way to go. To do this, your driver should effectively reference itself as its own proxy. You'll need to set an additional flag in your xml file

<combo>true</combo>

 

As for your proxy tag:

<proxies>
  <proxy> My Driver Name </proxy>
</proxies>

 

The templates are still a good place to start and to learn how C4 driver structure works, but I'd recommend writing your own for your application. Without knowing how the other (non C4) side of your device will work, my guess would be that you should look specifically at C4:SendToSerial() and ReceivedFromSerial() in the C4 API.

 

Another thing worth noting if you're just getting started is that DriverEditor works for creating drivers, but I'd recommend using Visual Studio Code with the Control4 extension instead. C4 provides a python tool on their Github for packaging your driver as well. These two tools work much better than DriverEditor in my opinion.

 

Link to comment
Share on other sites

Thanks for the info about Visual Studio Code, so with this python tool I will be able to generate .c4z files?

 

I am playing with blind_proxy_template, I am editing lua/xml source filles and checking how it works.

Print function works nice and I can see effect in Lua Output.

C4:SendToSerial() also works fine and I can see it in my serial port.

But I do not see any effect from ReceivedFromSerial().

 

What kind of category should I set for my serial bridge device?

Link to comment
Share on other sites

C4's Python tool (called driverpackeger) does allow you to generate .c4z files.

 

What are you doing with ReceivedFromSerial()? If you haven't yet, try adding the line

print(sData) 

as the first line in the function ReceivedFromSerial() in the file c4_serial_connection.lua (found in the common folder). This will show you what exactly C4 is reading in on your serial binding.

 

I'm not quite sure I understand your last question. Are you asking about navigator and composer categories? Those are used for driver organization inside of C4, so choose whichever looks closest to the intended application of your driver.

Link to comment
Share on other sites

I am trying to print something or send back to serial. But I see no effect at all.

I am testing my serial port connection from realterm, data from serial are fine.

But when I am sending to serial, there is no effect at all, nothing is printed.

function SerialConnectionBase:ReceivedFromSerial(idBinding, sData)
    print(sData)
	self:ReceivedFromCom(sData)
	
end

Maybe this function is not implemented right in blind_proxy_template?

 

Yes, I meant composer categories, I have not found anything that matches my bridge so I will choose whatever will be closest.

Can I find wizard to create driver from scratch?

Link to comment
Share on other sites

So you have your computer running realterm and connected to your C4 processor, correct?

And you can see data sent from C4 to your computer but not the other way around? I've never used realterm, so I'm not very sure where to begin troubleshooting on that side. If you can not see any data coming back from to Control4, make sure your serial settings such as baud rate are set the same on both systems. I would have to think that you have that correct if you are seeing data even one way, but again I'm not familiar with realterm to know how it works.

 

The only graphical wizard that I am aware of for creating drivers is DriverEditor. If you're comfortable writing the lua and xml in an external editor, you can open your project in DriverEditor to generate the c4z if you are more comfortable doing that. I would suggest though that you don't have your project open in both DriverEditor and an external editor at the same time as I've had this cause issues from the DriverEditor side.

Link to comment
Share on other sites

Yes, it is connected to C4 control unit through serial port. And communication is visible in only one direction.

Speed and everything is set the same as in driver xml file.

Has anyone ever try to communicate in two directions with this blind_proxy_template?

Link to comment
Share on other sites

I tested the blind_proxy_template this afternoon using PuTTY on my computer, and I was able to get serial data to communicate both ways. Are you seeing anything at all in the Lua Output window of your blind proxy driver? Any errors or anything that I could possibly help you troubleshoot?

Link to comment
Share on other sites

Thank you for test.

On my Lua Output I am able to see print when I am sending data C4->terminal.

But when I send terminal->C4 I do not see anything at all.

So maybe its some hardware problem at my desk. 

I am connecting jack cable to my C4-EA2-V2 slot serial 1 and through adapter to my PCs USB.

Are you doing the same? 

Link to comment
Share on other sites

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.