Using Ignition to communicate and control an AX350i Domino inkjet printer

We have Domino here too and we just write in plain text.
The important thing is to encapsulate your commands with these :

ESC = '1B'.decode('hex')	# Escape
EOT = '04'.decode('hex')	# End Of Transmission

So, let's say you want to read the ink/make up levels, you would send

msg = ESC + 'y?' + EOT
system.tag.writeBlocking(['%s/Writable' %(printer_path)], [msg])

Bigger commands would look the same, with a lot of ESC in it :slight_smile:

ESC + "u1" + ESC +"o1A001" + ESC + "o1C000HELLO WORLD/" + ESC + "j1N04000099990001YN0030400000N/DATE+1YEAR:" + ESC + "n1F-" + ESC + "n1E/" + EOT

And ours are setup as PacketBased

It's been a couple of days but I wanted to let you know that I have been able to confirm this method works as well, however I do not seem to have the same luck as you with combining multiple commands. I used a modification of my script as well as yours to get:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):

	ESC='1B'.decode('hex') #ESC
	EOT='04'.decode('hex') #Endo of Transmission
	#pathToTagA="[.]RequestCommandtoByteArray"
	#pathToTagB="[.]7000/WritableBytes"
	pathToTagB="[.]7000/Writable"
	#tagAValue=system.tag.readBlocking(pathToTagA)
	#tageAValue=ESC+'31433F'+EOT
	#system.tag.writeBlocking(pathToTagB, tagAValue)
	
	msg = ESC + '1C?' + ESC + 'y?' + EOT
	system.tag.writeBlocking(pathToTagB, [msg])

which returns:

image

1C? and y? both work independently but combining them doesn't seem to work. I also tried:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):

	ESC='1B'.decode('hex') #ESC
	EOT='04'.decode('hex') #Endo of Transmission

	pathToTagA="[.]7000/Message"
	pathToTagB="[.]7000/Writable"
	pathToTagC="[.]Msg1"
	pathToTagD="[.]Msg2"

	tagAValue=system.tag.readBlocking(pathToTagA)
	
	ret1 = ESC + '1C?' + EOT
	system.tag.writeBlocking(pathToTagB, [ret1])
	sytem.tag.writeBlocking(pathToTagC,tagAValue)
	
	ret2=ESC + 'y?' + EOT
	system.tag.writeBlocking(pathToTagB, [ret2])
	sytem.tag.writeBlocking(pathToTagD,tagAValue)

Which returned:

image

Right now I am not sure which of the methods I will use, but thank you for helping me understand alternative methods.

I don't think you can combine multiple queries request as the Domino won't combine the answers into one reply.
I just tried on my side and it's not working either.
By bigger commands, I was thinking about commands to create a label, which combines multiple fields/commands into one query.

I can see you have a valueChanged script on the Message tag.
We were using that before but we switched to direct TCP send/receive to avoid the lag induced by the tags (we had to do that for another brand of printers that had 1 controller for multiple printing heads and that was missing a label sometimes when multiple labels were sent at the same time).
Anyhow, if you want to have a "direct" answer from your printer, you can use that code :

from java.net import Socket, InetSocketAddress ,ConnectException ,SocketTimeoutException
from java.io import BufferedReader, InputStreamReader, PrintWriter
import time
port = 7000
ESC = '1B'.decode('hex')	# Escape
EOT = '04'.decode('hex')	# End Of Transmission
ACK = '06'.decode('hex')	# Positive acknowledge
NAK = '15'.decode('hex')	# Negative acknowledge

def tcpSend(msg ,ip):
	try:
		socket = Socket()
		socket.tcpNoDelay = True
		socket.setSoTimeout(5000)	# timeout for an answer
		socket.connect(InetSocketAddress(ip, port), 2000) # timeout at the socket opening
		
		# input et output streams for the socket
		mes2dev = PrintWriter(socket.getOutputStream(), True)
		dev2mes = BufferedReader(InputStreamReader(socket.getInputStream()))
        
		mes2dev.println(msg)	# Send the message
		reponse = ''
		i = 0
		while not dev2mes.ready() and i < 30:	# Wait for answer
			time.sleep(0.01)
			i += 1
		while dev2mes.ready():	# Retrieve answer
			c = dev2mes.read()
			c_hex = format(c ,'02x').decode('hex')
			if c_hex == EOT:
				break
			elif c_hex == ACK:
				code ,reponse = 200 ,chr(c)
				break
			elif c_hex == NAK:
				code ,reponse = 406 ,chr(c)
				break
			reponse += chr(c)
		socket.close()	# Close the socket
		code ,reponse = 200 ,reponse
	except ConnectException:	# Timeout at socket opening
		code ,reponse = 504 ,None
	except SocketTimeoutException:	# Timeout at answer
		code ,reponse = 504 ,None
	except Exception as e:
		code ,reponse = 400 ,None
	finally:	# Just to be sure we are clean at the end
		try:
			if socket.isConnected():
				dev2mes.close()
				mes2dev.close()
		except:
			pass
		socket.close()
	return code ,reponse

I scraped some code off it but the main part should be here.
Changing to that won't help you with the multi-query command but splitting them won't be that much of an issue with that

tags, w_tags, w_vals = {}, [], []
tags[pathToTagB] = tcpSend(ESC + '1C?' + EOT, printer_ip)[1]
tags[pathToTagC] = tcpSend(ESC + 'y?' + EOT, printer_ip)[1]
for tag, val in tags.iteritems():
	w_tags.append(tag)
	w_vals.append(val)
system.tag.writeBlocking(w_tags, w_vals)
1 Like

Yes this is something I was experiencing and trying to figure out on my end. Thank you for sharing the code. I am going to take some time to pick this apart, but in the meantime I am going to mark your post as the solution. I appreciate it.

1 Like

Hi cdrizzy,

How do you store printer recipes/messages? I have an upcoming project that uses a controllogix and Ignition to store and control 100 recipes. Not sure where to start. If you have some info, please share so I can dig in.