Set a Q-SYS named control over ECP
TL;DR. Q-SYS ECP is ASCII on TCP 1702 while a design is in Run mode. csv gain1 5 sets that Named Control and the test reply is cv "gain1" "5.00dB" 5 0.75.
This is a commercial product. AgentOnStage isn't paid for this listing.
Commercial productAudioIntermediateQ-SYSECPTCP
What it does
Q-SYS Help calls the External Control Protocol the original Named Control protocol, available since version 1.0 of Q-SYS Designer and firmware. The overview says QRC has superseded it, and that ECP is still supported in every version, so existing third-party code does not have to be rewritten to speak QRC. The commands page is the ASCII list for a Core in Run mode, on TCP port 1702.
A Core has to have a design loaded and be in Run mode before an external system can connect. In Emulate mode the design has to be open in Designer and already emulating. The overview says that connection can use localhost, the computer's name, or an IP address, still on port 1702. The test page says F6 enters Emulate mode, and that the localhost port will not open if you are not in that mode. For a live Core, the same page says to load the design and press F5 to enter Run mode, then Telnet to open <hostname of Core>.local 1702 or open <IP address> 1702.
Messages are ASCII. There is no start character. After the previous null, whitespace is discarded and the next non-whitespace character starts the message. Every command and every response ends with the end-of-message character, which the commands page defines as <LF> (0x0A). The Core waits for that byte before it parses. A <CR> (0x0D) immediately before the line feed is ignored, which is how Telnet's Enter key works: Telnet sends <CR><LF>. Responses come back terminated with <CR><LF>, and the page says the client has to ignore the carriage return. Extra arguments before the line feed return bad_command "expected EOM". The printed example is cg text extra.
Command strings are case sensitive and contain no spaces. The invalid-command note says CG is not recognized because the commands are lower case and case sensitive, and the example response is bad_command "CG". A control id is the name in the Named Controls list. The test page says those ids are case sensitive, and that a name with a space has to be wrapped in double quotes, as in "My Control". A string that itself contains a quotation mark or a backslash has to escape it with a backslash. A line feed inside a string is written \n, and a carriage return inside a string is written \r.
Control Get is cg plus the control id. For an ordinary control the reply is cv, then the id, the string, the value, and the position. Position runs from 0.00 to 1.0 inclusive. The test page's worked read, typed as get gain1, returns cv "gain1" "-20.0dB" -20 0.444444. The commands table spells the get as cg, not get. Control Set Value is csv plus the id and a number. The same test types csv gain1 5 and shows cv "gain1" "5.00dB" 5 0.75. csp sets the position instead of the value. css sets the string. A set against a read-only control returns cro and the id. A set, a snapshot load or save, or a trigger against the standby Core of a redundant pair returns core_not_active. An unknown id returns bad_id and that id.
A vector control, such as a meter, answers cg with cvv. The meter's printed example is four strings, four values, and four positions, in the order RMS, Max RMS, Peak, and Max Peak. The page says you cannot set a vector control.
Change groups are how a client watches controls without reading each one. cgc creates a group. The id is a 32-bit unsigned integer, and the page recommends a small number. You can create four groups on one client connection. Creating a fifth, or pushing the system past 512 groups, returns too_many_change_groups. Creating an id that already exists is ignored. cga adds a Named Control. cgp returns the controls that changed since the last poll, then cgpa. If nothing changed, cgpa arrives alone. cgs schedules that poll. The period is in milliseconds, and anything under 30 is raised to 30. A period of 0 turns the schedule off. The group id belongs to the socket that created it. The page says a second socket to the same Core cannot poll a group the first socket created.
sg is Status Get. The reply is sr, then the design name, the design id, whether this Core is primary, and whether it is active. Those last two are 1 or 0. The overview says a redundant pair is followed by polling Status Get in the background, then building a change group on the Core that has become active. The first poll of that group returns every control in it.
ssl loads a snapshot: bank name, snapshot number, and a ramp time in seconds. The number runs from 1 through the count of snapshots in the bank. The page's example is ssl snapshot1 2 5, which loads snapshot 2 of bank snapshot1 over 5 seconds. sss and ssl return nothing. csvr, the ramped set, also returns nothing. The page says to send cg after the ramp if you need the final value.
If the Core requires a login, an attempt to use it returns login_required. The command is login, then the user name, then the PIN. The user is created on the Users (Administrator) page and needs external-control privileges. The response table lists login_success and login_failed. A failed login closes the socket. The command quick reference prints the success word as login_succes.
The keep-alive note is on both pages. A client has to send something at least once every 60 seconds or the Core closes the socket. A change-group poll does that. Otherwise send sg, or a csv on a control you do not care about when you do not want a reply. If communication stops, the Core sends response close or rc, then drops the connection.
Inspect and control a Q-SYS Core from an AI agent is a separate client. It speaks QRC, JSON on port 1710, and it refuses a live write unless you allow one. This page is the ASCII protocol on port 1702.
How to set it up
- In Designer, drag each control you want an external system to reach into the Named Controls list and give it a short name. The test page says the name is case sensitive. A space in the name has to be sent inside double quotes.
- For a bench test, press F6 so the design is in Emulate mode, then Telnet with
open localhost 1702. For a Core, press F5 to enter Run mode and Telnet toopen <hostname of Core>.local 1702oropen <IP address> 1702. - Read before you write. The commands page's get is
cg gain1. The test page's worked example typesget gain1and showscv "gain1" "-20.0dB" -20 0.444444. End the line with Enter. The Core treats the Telnet<CR><LF>as the required line feed. - Set the value with
csv gain1 5. The test page's reply iscv "gain1" "5.00dB" 5 0.75. Usecspwhen you mean a position from 0 to 1, andcsswhen you mean the string.bad_idmeans that name is not in Named Controls.core_not_activemeans you reached the standby Core. - If the socket must stay up, send
sgor poll a change group at least once every 60 seconds.cgc 1, thencga 1 gain1, thencgp 1, returns the current state and ends withcgpa. A scheduled poll cannot be shorter than 30 ms.
Source: ECP commands, External Control Protocol overview, and Test External Controls.
FAQ
Is the get command cg or get?
The commands table lists Control Get as cg plus the control id, and it says command strings are case sensitive. The test page, which says to type commands according to that table, prints the worked example as get gain1 and the return as cv "gain1" "-20.0dB" -20 0.444444. The set on that same page is csv gain1 5.
What closes the socket?
The Core closes it when the client has sent nothing for 60 seconds, after it first sends response close or rc. A login_failed response also closes the socket. Four change groups are the limit on one connection, and the page also caps the system at 512.
Does a ramped set come back with the new value?
csv returns cv. csvr returns nothing. The commands page says to send cg after the ramp if you need the value the control landed on. Snapshot load, ssl, also returns nothing.
Also on this rig
Original source: https://help.qsys.com/content/External_Control_APIs/ECP/ECP_Commands.htm