# Using Ignition to communicate and control an AX350i Domino inkjet printer

**URL:** <https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 13, 2024, 3:42pm UTC](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780 "2024-04-13T15:42:32Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [April 16, 2024, 10:32am UTC](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780/21 "2024-04-16T10:32:04Z")

</div>

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

```auto
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

```auto
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 🙂

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

```

And ours are setup as PacketBased

---

<div class="post-metadata">

**Author:** ![cdrizzy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cdrizzy/32/59051_2.png) [@cdrizzy](https://forum.inductiveautomation.com/u/cdrizzy)\
**Post date:** [April 19, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780/22 "2024-04-19T18:00:51Z")

</div>

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:

```python
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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/a/3a43c2db00cd224748341c40722271fabc69b0f1.png)

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

```python
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](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37b7ef422bbad92195be7bf959f6396907c6b93a.png)

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

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [April 22, 2024, 10:22am UTC](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780/23 "2024-04-22T10:22:22Z")

</div>

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 :

```python
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

```python
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)

```

---

<div class="post-metadata">

**Author:** ![cdrizzy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cdrizzy/32/59051_2.png) [@cdrizzy](https://forum.inductiveautomation.com/u/cdrizzy)\
**Post date:** [April 22, 2024, 8:10pm UTC](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780/24 "2024-04-22T20:10:57Z")

</div>

> [@automatisation](#):
>
> to avoid the lag induced by the tags

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.

---

<div class="post-metadata">

**Author:** ![uy\_huynh](https://avatars.discourse-cdn.com/v4/letter/u/54ee81/32.png) [@uy\_huynh](https://forum.inductiveautomation.com/u/uy_huynh)\
**Post date:** [October 6, 2024, 9:12pm UTC](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780/25 "2024-10-06T21:12:38Z")

</div>

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.

[Previous page](https://forum.inductiveautomation.com/t/using-ignition-to-communicate-and-control-an-ax350i-domino-inkjet-printer/88780.md?page=1)
