Skip to content

Commit

Permalink
X
Browse files Browse the repository at this point in the history
  • Loading branch information
John Major committed Oct 31, 2023
1 parent e13b5cf commit 39760a3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
Binary file modified zebra_day/__pycache__/print_mgr.cpython-310.pyc
Binary file not shown.
35 changes: 35 additions & 0 deletions zebra_day/cmd_mgr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Tools to get and (soon) set varios zebra printer config.
"""

import socket

class ZebraPrinter:

def __init__(self, ip_address, port=9100, buffer_size=1024):
self.ip_address = ip_address
self.port = port
self.buffer_size = buffer_size


def send_command(self, command):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((self.ip_address, self.port))
s.sendall(command.encode())
response = s.recv(self.buffer_size)
return response.decode()


def get_configuration(self):
"""Retrieve printer configuration using ^HH command"""
return self.send_command("^XA^HH^XZ")


def set_configuration(self, config):
"""
Set printer configuration.
The `config` parameter should contain the necessary ZPL commands to adjust the configuration.
After sending the configuration commands, the ^JUS command saves the configuration.
"""
self.send_command(config)
return self.send_command("^XA^JUS^XZ")
15 changes: 15 additions & 0 deletions zebra_day/corner_square.zpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
^XA
^FO30,10
^ADN,30,20
^FD{XX}^FS
^FO300,10
^ADN,30,20
^FD{YY}^FS
^FO300,200
^ADN,25,12
^FD{ZZ}^FS
^FO250,10
^FO30,170
^ADN,30,20
^FD{WW}^FS
^XZ
5 changes: 4 additions & 1 deletion zebra_day/print_mgr.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
Primay zebra_day module. Primary functions: consistent and clear management
Primay zebra_day module. Primary functions: consistent and clear management
of 1+ networked zebra printers, automated discovery of printers on a
network. Clear formulation and delivery of ZPL strings to destination
printers. Management of zpl template files, which may have format value
components for inserting data on the fly. (elsewhere, a simple ui on
top of this).
This module is primarily focused on print request and package config mgmt.
See 'cmd_mgr' for interacting with zebras printer config capabilties.
"""

import os
Expand Down

0 comments on commit 39760a3

Please sign in to comment.