# ASCII commands to printer

**URL:** <https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202>\
**Category:** Ignition\
**Created:** [September 16, 2010, 3:24pm UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202 "2010-09-16T15:24:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![winspa1](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@winspa1](https://forum.inductiveautomation.com/u/winspa1)\
**Post date:** [September 16, 2010, 3:24pm UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202/1 "2010-09-16T15:24:47Z")

</div>

I am looking for ways to send and receive ascii commands to some ink jet printers over Ethernet. Is this possible with ignition.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 16, 2010, 4:38pm UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202/2 "2010-09-16T16:38:35Z")

</div>

With the module SDK it is possible. You can create your own device driver to do this.

---

<div class="post-metadata">

**Author:** ![Step7](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Step7](https://forum.inductiveautomation.com/u/Step7)\
**Post date:** [September 16, 2010, 4:58pm UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202/3 "2010-09-16T16:58:22Z")

</div>

I’ve done a couple of projects where I send data to printers and RFID devices over ethernet, and I just use python sockets. Very simple, and very reliable.

Here’s a simple code snippet that uses UDP, but could be modified for TCP:

```auto
if event.propertyName == 'Send':
	import socket
	import struct

	# Define the data somehow
	data = 'This is a test'

	# Define the IP Address and Port
	IPAddress = '192.168.10.100'
	Port = 16000

	# Create Socket
	fd=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)

	# Create Format; refer to python STRUCT docs to get the various data type format characters.
	# The format can easily be created dynamically, and this format string handles 14 characters
	fm = '=14c'

	# Build Message
	message =struct.pack(fm,data)
	fd.sendto(message,(IPAddress,Port))
```

---

<div class="post-metadata">

**Author:** ![winspa1](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@winspa1](https://forum.inductiveautomation.com/u/winspa1)\
**Post date:** [September 16, 2010, 10:59pm UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202/4 "2010-09-16T22:59:31Z")

</div>

Thanks for the idea’s. I’m pretty much a newby at python but I’ll play around with this tonight. Travis what does it take to get the sdk module and how hard is it to set up.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 17, 2010, 12:00am UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202/5 "2010-09-17T00:00:23Z")

</div>

The Module SDK is free to download. You can get it from the downloads page [http://www.inductiveautomation.com/downloads/ignition](http://www.inductiveautomation.com/downloads/ignition). There is sample code and instructions on how to get started with the Module SDK in the zip file.

---

<div class="post-metadata">

**Author:** ![winspa1](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@winspa1](https://forum.inductiveautomation.com/u/winspa1)\
**Post date:** [September 17, 2010, 12:51am UTC](https://forum.inductiveautomation.com/t/ascii-commands-to-printer/2202/6 "2010-09-17T00:51:48Z")

</div>

Thanks!!
