Hi,
I am trying to read data from a TCP-connected printer. The connection has been verified using PowerShell, and the printer is reachable. However, when attempting to communicate via Python or from Ignition, the connection fails even after restarting the printer.
Here is the Python script I used:
import socket
host = "<Printer_IP>"
port = <Printer_Port>
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
print("Connection Successful!")
command = "\n" # Sending a newline to test response
s.sendall(command.encode())
response = s.recv(4096).decode()
print("Printer Response:", response)
s.close()
except Exception as e:
print("Connection Failed:", e)
Despite the TCP connection test passing in PowerShell, the script fails to establish communication. Ignition also reports a connection failure.