Sending ASCII over Ethernet from Ignition

EDIT: Refresh links and code format.
Hi there! Welcome to the forums! :smiley:

It just so happens I have a bit of code I use in a gateway timer script. I use it to display data on an EZAutomation Marquee Display.

The message string is generated through SQLTag expressions. This lets me see what the message format looks like and is a bit easier to troubleshoot rather than generating it within the script. :wink:

import socket


pointer = "[]3701_Rampf/Marquee/Message Pointer"          # SQLTag stroing pointer value
pointerval = system.tag.getTagValue(pointer)              # Get Value of pointer SQLTag

if pointerval < 1:                                        # Set initial limits of pointer value
	pointerval = 1
if pointerval > 3:
	pointerval = 1


tagname = "[]3701_Rampf/Marquee/Message"+ str(pointerval) # Grab message by pointer value (ex. Message1, Message2, Message3, etc)
val = system.tag.getTagValue(tagname)                     # Messages are generated elsewhere through Tranaction Groups and expresions.

HOST = '192.168.140.206'                                  # The remote host
PORT = 49999                                              # Remote host's port

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)     # Create a socket
s.connect((HOST, PORT))                                   # Connect the socket

s.send(val)                                               # Send Message

s.close()

pointerval += 1                                           # Increment pointer value

system.tag.writeToTag(pointer,pointerval)                 # Write pointer value back to its SQLTag