# UDP driver altering data

**URL:** <https://forum.inductiveautomation.com/t/udp-driver-altering-data/10322>\
**Category:** Ignition\
**Created:** [August 8, 2015, 9:49am UTC](https://forum.inductiveautomation.com/t/udp-driver-altering-data/10322 "2015-08-08T09:49:51Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [August 13, 2015, 10:32pm UTC](https://forum.inductiveautomation.com/t/udp-driver-altering-data/10322/13 "2015-08-13T22:32:40Z")

</div>

Hi Al,

I just finished implementing and testing controlled, organized, supported global storage in Ignition.

It is called “gstore”, short for Global Storage. It provides a simple way to have and use global state in Ignition.

Global project state is stored in a global dictionary at pa.gstore. pa.gstore is global to each project. It can be used in Gateway scripts or client/designer scripts.

Here’s the code to use in your circumstance:

Put this code in a Gateway Startup Script:[code]def read\_udp():  
import socket  
import binascii

UDP\_IP = “192.168.1.250”  
UDP\_PORT = 5005

sock = socket.socket(socket.AF\_INET, socket.SOCK\_DGRAM)  
pa.gstore[“sock”] = sock  
sock.bind((UDP\_IP, UDP\_PORT))

while True:  
data, addr = sock.recvfrom(1024)  
print “Received %s from %s” % (binascii.hexlify(data), addr)  
system.tag.write("[default]udp\_byte", data)

system.util.invokeAsynchronous(read\_udp)[/code]  
The only difference to your code is adding the socket to gstore.

Then add the following code to the Gateway Shutdown Script:`pa.gstore["sock"].close()`gstore has more functionality than this but I haven’t updated the documentation yet, but I will soon. If you want to use this and need any help let me know.

gstore is the newest capability in the [PA Power Scripting Module](http://marketplace.inductiveautomation.com/moduledetail?22&moduleId=87).

Edit: getting rid of GStore: [nickmudge.info/post/getting-rid-of-gstore](http://nickmudge.info/post/getting-rid-of-gstore)  
Use Python module level variables instead: [nickmudge.info/post/python-modul … lient-tags](http://nickmudge.info/post/python-module-level-variables-vs-client-tags)

Best,

---

_[View the full topic](https://forum.inductiveautomation.com/t/udp-driver-altering-data/10322)._
