Created
August 24, 2025 01:20
-
-
Save Juan-Severiano/e9df02f187605002ab94e23be0395543 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import serial | |
| import time | |
| # Configura a porta serial | |
| ser = serial.Serial( | |
| port='/dev/ttyS4', # <-- muda se necessário | |
| baudrate=9600, # padrão da Elgin I9 | |
| bytesize=8, | |
| parity='N', | |
| stopbits=1, | |
| timeout=1 | |
| ) | |
| def send_command(cmd: bytes): | |
| ser.write(cmd) | |
| ser.flush() | |
| time.sleep(0.1) # pequena pausa para garantir envio | |
| # Teste básico de texto | |
| send_command(b"*** TESTE DE IMPRESSORA ELGIN I9 ***\n") | |
| send_command(b"Texto normal\n") | |
| send_command(b"\x1b!\x08Negrito\n\x1b!\x00") # ESC ! 8 → negrito, depois reseta | |
| send_command(b"Alinhado ao centro\n") | |
| send_command(b"\x1b\x61\x01Centralizado\x1b\x61\x00\n") # ESC a 1 → centraliza | |
| send_command(b"\n\n") | |
| # Corte de papel | |
| send_command(b"\x1D\x56\x00") # GS V 0 | |
| ser.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment