Get_relay_status_by_index error

When I use this method to read the status of certain relay pin in a loop, this error occurred after several loops. Can you tell me why ?

image

ERROR:
Traceback (most recent call last):
File “C:/Users/maq10/PycharmProjects/NR4_Function Test/main.py”, line 62, in
keyStatus = board2.get_relay_status_by_index(10)
File “C:\Users\maq10\PycharmProjects\NR4_Function Test\venv\lib\site-packages\ncd_industrial_relay.py”, line 85, in get_relay_status_by_index
return self.process_read_command_return(self.send_command(command, 4))
File “C:\Users\maq10\PycharmProjects\NR4_Function Test\venv\lib\site-packages\ncd_industrial_relay.py”, line 169, in process_read_command_return
bytes_back = self.check_bytes_back(data)
File “C:\Users\maq10\PycharmProjects\NR4_Function Test\venv\lib\site-packages\ncd_industrial_relay.py”, line 187, in check_bytes_back
return ord(data[1:2]) == (len(data)-3)
TypeError: ord() expected a character, but string of length 0 found

Hi,

Based on the error it looks like nothing is being returned by the relay controller.

Can you let me know what the sku of the board is that you have and what the settings for the TPC or Serial port you’re using to communicate with the board?

It may be that the timeout should be longer on the port. If the relay controller is currently processing an internal function on the board it may take slightly longer than usual to return data.

Sku of the board you mean amount of the board I have? I have 3 relay boards.

The info printed on the relay board is: ZADSR16xPROXR. I guess it should be ‘Industrial Relay Controller 16-Channel SPDT + 8-Channel ADC’ with Ethernet port on the website.

The Ethernet port is configured as:

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
board2 = ncd_industrial_relay.Relay_Controller(sock)
IP_ADDRESS = “169.254.232.1”
PORT = 2101
sock.connect((IP_ADDRESS, PORT))
sock.settimeout(.5)

This issue also occurs when I use turn_on/off_relay_by_index in While loop.
image