def cut(self): self.ser.write(b'\x1D\x56\x01')
Application → ioctl/write → Driver Core → FIFO Buffer → HAL (UART/GPIO) → TZ30-M01 | Interface | Pinout | Mode | |-----------|----------------------------|--------------------------| | TTL Serial| TX, RX, GND, DTR (busy) | 9600–115200 baud, 8N1 | | Parallel | 8-bit data, STB, BUSY, ACK | Compatibility mode | 3. Control Command Set (ESC/POS Subset) The TZ30-M01 emulates a subset of ESC/POS. Below are the core driver commands implemented. 3.1. Initialization | Command | Hex Sequence | Description | |---------|------------------|------------------------------| | Reset | 1B 40 | Clear buffer, reset margins | | Wake | 1B 1A 01 | Exit sleep/low-power mode | 3.2. Printing | Command | Hex Sequence | Description | |------------------------|---------------------|--------------------------------------| | Print text | Raw ASCII | Prints stored data in buffer | | Line feed | 0A | Feeds 1 line (4.23 mm) | | Full cut | 1D 56 01 | Full cut after print | | Partial cut (keep) | 1D 56 00 | Partial cut (one point remains) | | Paper feed (dots) | 1B 4A n | Feed n dots (max 255) | 3.3. Barcode / Graphics (Optional) | Command | Hex Sequence | Description | |----------------------|------------------------------|----------------------------| | Print raster bitmap | 1D 76 30 m xL xH yL yH d1…dk | 203 dpi raster graphic | | Code128 barcode | 1D 6B 73 m d1…dk NUL | Barcode generation | 3.4. Status Read (Serial) | Command | Hex | Response (1 byte) | Bit mask meaning | |--------------|-----|------------------|------------------| | Real-time status | 10 04 01 | 0x00–0xFF | Bit0=Paper low, Bit1=Paper out, Bit2=Cover open, Bit3=Head overtemp, Bit6=Busy | 4. Linux Kernel Driver (Pseudo-implementation) Below is a skeletal Linux cdev driver handling the TZ30-M01 via UART. citizen tz30-m01 driver
static long tz30_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct tz30_device *dev = filp->private_data; switch(cmd) case TZ30_CMD_CUT: tz30_send(dev, "\x1D\x56\x01", 3); // full cut break; case TZ30_CMD_STATUS: return tz30_get_status(dev); def cut(self): self
// citizen_tz30.h #define TZ30_MAJOR 240 #define TZ30_CMD_RESET 0x01 #define TZ30_CMD_CUT 0x02 #define TZ30_CMD_STATUS 0x03 struct tz30_device struct uart_port *uart; struct cdev cdev; wait_queue_head_t write_wait; spinlock_t lock; bool paper_out; bool cover_open; ; Barcode / Graphics (Optional) | Command | Hex