Antek Posted August 9, 2021 Share Posted August 9, 2021 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, Quote Link to comment Share on other sites More sharing options...
Andrew H Posted August 9, 2021 Share Posted August 9, 2021 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? Quote Link to comment Share on other sites More sharing options...
Antek Posted August 10, 2021 Author Share Posted August 10, 2021 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? Quote Link to comment Share on other sites More sharing options...
RyanE Posted August 10, 2021 Share Posted August 10, 2021 If your driver has no UI, it should have no proxy. Proxies are primarily to provide something consistent for the Navigator UI to communicate with in a standardized way. RyanE Quote Link to comment Share on other sites More sharing options...
Andrew H Posted August 10, 2021 Share Posted August 10, 2021 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. Quote Link to comment Share on other sites More sharing options...
Antek Posted August 11, 2021 Author Share Posted August 11, 2021 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? Quote Link to comment Share on other sites More sharing options...
Andrew H Posted August 11, 2021 Share Posted August 11, 2021 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. Quote Link to comment Share on other sites More sharing options...
Antek Posted August 12, 2021 Author Share Posted August 12, 2021 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? Quote Link to comment Share on other sites More sharing options...
Andrew H Posted August 12, 2021 Share Posted August 12, 2021 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. Quote Link to comment Share on other sites More sharing options...
Antek Posted August 17, 2021 Author Share Posted August 17, 2021 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? Quote Link to comment Share on other sites More sharing options...
Andrew H Posted August 17, 2021 Share Posted August 17, 2021 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? Quote Link to comment Share on other sites More sharing options...
Antek Posted August 18, 2021 Author Share Posted August 18, 2021 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? Quote Link to comment Share on other sites More sharing options...
Andrew H Posted August 18, 2021 Share Posted August 18, 2021 I have my computer connected to serial port 2 (DB9) on my EA5. This is connected to my computer using a DB9-to-USB adapter. Have you tried your setup using a second serial cable? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.