I have a High-Power Relay Controller 2-Channel + 8 Channel ADC ProXR Lite. In NCD Base Comm Operator I am able to open a TCP client connection and send API codes in decimal format to turn it on and off. Turn on 254 108 1 and to turn it off I send 254 100 1. Is there a way to turn on and off this relay switch in python? Below is what I have been trying in python but seem to have no luck! Any help would be greatly appreciated!
#importing packages import socket import serial from industrial_relay.ncd_industrial_relay import Relay_Controller #connect the socket using IP address and Port IP_ADD = '192.168.1.54' PORT = 2101 #set up socket with desired settings #AF_INET refers to the address family ipv4 #SOCK_STREAM means connection oriented TCP protocol sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) board = Relay_Controller(sock) sock.connect((IP_ADD, PORT)) board.turn_on_relay_by_index(1) #sock.close()
Am I using the ncd industrial relay package wrong? Or is there a way that I can send the API code directly to the controller once the socket is open? All I need to to is turn the controller on and off.