Reputation: 1
its my first question on this forum, so im sorry if i made any mistakes in its review. Im trying to set a connection and send a command to printer, using this code:
import socket
# Connection options
HOST = 'IP_Adress'
PORT = 3001
def connect_to_printer():
try:
# socket creation
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# connecting to the printer
s.connect((HOST, PORT))
print("Connection established.")
# trying to send a command
command = b'GST\r>' # There was many different
s.sendall(command)
# receaving of an answer
response = s.recv(4096)
print("Printer answer:", response.decode())
except socket.error as e:
print(f"Connection error: {e}")
if __name__ == "__main__":
connect_to_printer()
but im recieving an empty answer on any form of ASCII command i've tried.
socket opens successfully. I've tried to write different forms of command, but nothing could help. I think I have made a mistake in ASCII command coding, but I couldn't find clear rules for writing them when it comes to the printer of this model.
could you please tell me, how should i write ASCII command correctly, or is it just a connection problem?
Upvotes: 0
Views: 108