====== Relay Ports CFLink Protocol ====== The following documentation describes the CFLink protocol for controlling relay ports on any device with relays.\\ This includes relay modules, cards and standalone devices such as the CF Mini ===== Queries ===== ==== STA - Query Status ==== The ''STA'' (Status) query returns the status of all relays in a single module/device. === Data === // Modular devices > [F2][F3]QRLYSTA[F4][F5][F5] // Standalone devices > [F2][F3]QRLYSTA[F4][F5][F5] * **** = The module number to request the status of. 2 chars, uppercase 'M' followed by the module number. * eg. ''M1'' = Module 1, ''M4'' = Module 4. === Reply === // Modular devices < [F2][F3]RRLYSTA[F4]|[F5][F5] // Standalone devices < [F2][F3]RRLYSTA[F4][F5][F5] * **** = For each relay port in the module/device, the port status is returned in ''P##:'' format. Multiple relay ports are included in a single reply using the Port Separator ''|'' (Pipe character) * **** = Single digit, 0 = Relay Open, 1 = Relay Closed. === Example === // Query the state of relays in Module 2 of a modular device on CFLink ID [04] > [F2][04][F3]QRLYSTA[F4]M2[F5][F5] // Reply, Module has 4 relay ports, all are open except port 1 which is closed. < [F2][04][F3]RRLYSTA[F4]M2|P01:1|P02:0|P03:0|P04:0[F5][F5] // Query the state of relays in a CF Mini on CFLink ID [06] > [F2][06][F3]QRLYSTA[F4][F5][F5] // Reply - CF Mini has 4 relay ports, all are open except port 1 which is closed. < [F2][06][F3]RRLYSTA[F4]P01:1|P02:0|P03:0|P04:0[F5][F5] === Error === * 004 = Invalid Module Number ==== POS - Query Power On State ==== The ''POS'' (Power On State) query returns the power on state for all relays in a single module/device.\\ This determines the state a relay will be set to when the device starts up (eg. after a power failure, restart, etc). === Data === // Modular devices > [F2][F3]QRLYPOS[F4][F5][F5] // Standalone devices > [F2][F3]QRLYPOS[F4][F5][F5] * **** = The module number to request the power on status of. 2 chars, uppercase 'M' followed by the module number. * eg. ''M1'' = Module 1, ''M4'' = Module 4. === Reply === // Modular devices < [F2][F3]RRLYPOS[F4]|[F5][F5] // Standalone devices < [F2][F3]RRLYPOS[F4][F5][F5] = Repeated for each relay port in the module/device, the port status is returned in P##: format. Multiple relay ports are included in a single reply using the Port Separator | (Pipe character) = Single character: 0 = Relay open on power on (Default) 1 = Relay closed on power on L = Resume last state on power on === Example === // Query the power on state of relays in Module 1 of a modular device on CFLink ID [04] > [F2][04][F3]QRLYPOS[F4]M1[F5][F5] // Reply, Module has 4 relay ports < [F2][04][F3]RRLYPOS[F4]M1|P01:0|P02:0|P03:1|P04:L[F5][F5] // Port 1 and 2 = Relay open on power on // Port 3 = Relay closed on power on // Port 4 = Resume last relay state on power on // Query the power on state of relays in CF Mini on CFLink ID [06] > [F2][06][F3]QRLYPOS[F4][F5][F5] // Reply, CF Mini has 4 relay ports < [F2][06][F3]RRLYPOS[F4]P01:0|P02:0|P03:1|P04:L[F5][F5] // Port 1 and 2 = Relay open on power on // Port 3 = Relay closed on power on // Port 4 = Resume last relay state on power on === Error === * 004 = Invalid Module Number ===== Configuration Messages ===== ==== POS - Configure Power On States ==== The POS (Power On State) command is used to configure the power on state of all relays in one or more modules/devices.\\ This determines the state a relay will be set to when the device starts up (eg. after a power failure, restart, etc).\\ If some relay port configurations are to remain unchanged, simply omit them from the message. === Data === // Modular devices > [F2][F3]CRLYPOS[F4]|[F5][F5] // Standalone devices > [F2][F3]CRLYPOS[F4][F5][F5] * **** = Any relay port in the module/device that needs to be configured must be entered in ''P##:'' format. Multiple relays can be configured in a single command by using the Port Separator ''| ''(Pipe character) * **** = Single character: * ''0'' = Relay open on power on (Default) * ''1'' = Relay closed on power on * ''L'' = Resume last state on power on === Reply === The changes take affect immediately. See the POS Query Reply for more details. === Example === // Set relay ports 1 and 2 to be open on power up, port 3 to be unchanged and port 4 to resume last state on power up // For module 3 in a modular device on CFLink ID [05] > [F2][05][F3]CRLYPOS[F4]M3|P01:0|P02:0|P04:L[F5][F5] // Reply (relay port 3 was previously set to open on power up, default behavior) < [F2][05][F3]RRLYPOS[F4]M3|P01:0|P02:0|P03:0|P04:L[F5][F5] // Set relay ports 1 and 2 to be closed on power up, port 3 to be open on power up and port 4 to resume last state on power up // For both modules 1 and 2 in a modular device on CFLink ID [05] > [F2][05][F3]CRLYPOS[F4]M1|P01:1|P02:1|P03:0|P04:L,M2|P01:0|P02:0|P03:1|P04:L[F5][F5] // Reply < [F2][05][F3]RRLYPOS[F4]M1|P01:1|P02:1|P03:0|P04:L[F5][F5] < [F2][05][F3]RRLYPOS[F4]M2|P01:1|P02:1|P03:0|P04:L[F5][F5] // Set relay ports 1 and 2 to be open on power up, port 3 to be unchanged and port 4 to resume last state on power up // For CF Mini on CFLink ID [06] > [F2][06][F3]CRLYPOS[F4]P01:0|P02:0|P04:L[F5][F5] // Reply (relay port 3 was previously set to open on power on, default behavior) < [F2][06][F3]RRLYPOS[F4]P01:0|P02:0|P03:0|P04:L[F5][F5] === Error === * 003 = Invalid Port Number * 004 = Invalid Module Number * 401 = Invalid Relay Power On State ==== TGT - Configure Notification Targets ==== The ''TGT'' (Target) command is a Common Command used across all CFLink devices. For relay modules, this command will configure where ''STA'' (Status) notifications are sent. The ''STA'' notification can be sent from a relay under the following circumstances: - Physical 'test' switch on the modular base unit is pressed. - A SET command is issued, including a second notification for Pulse commands. === Data === > [F2][F3]CRLYTGT[F4]::::[F5][F5] See the ''TGT'' [[hardware:cflink:common-device-protocol##tgt-configure-notification-targets|common command]] for more information. === Reply === < [F2][F3]RRLYTGT[F4]::::[F5][F5] See the ''TGT'' [[hardware:cflink:common-device-protocol##tgt-configure-notification-targets|common command]] for more information. ===== Transmission Messages ===== ==== SET - Set Relay States ==== The ''SET'' command is used to set the state (open or closed) of relay ports across one or more modules/devices. === Data === // Modular devices > [F2][F3]TRLYSET[F4]|[F5][F5] // Standalone devices > [F2][F3]TRLYSET[F4][F5][F5] * **** = The module number to change the state of. 2 chars, uppercase 'M' followed by the module number. * eg. ''M1'' = Module 1, ''M4'' = Module 4. * **** = For each relay port in the command, the port state is written in ''P##:'' format. Multiple relays can be changed in a single command by using the [[hardware:cflink:cflink-introduction#port-separator|Port Separator]] ''|'' * **** = Single character: * ''0'' = Open relay * ''1'' = Close relay. * ''T'' = Toggle relay state. If relay was closed, it will open. If relay was open, it will close. * ''P'' = Pulse relay. This requires a third parameter to the message: ''P##:P: