Fix PT-P710BT raster protocol handling and add regression coverage.
Align print command payload generation with model-specific protocol requirements, add verbose CLI diagnostics and robust status retries, and introduce protocol regression tests to prevent future GF/ESC i z regressions. Made-with: Cursor
This commit is contained in:
41
src/lib/libptouch_protocol.c
Normal file
41
src/lib/libptouch_protocol.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "libptouch_protocol.h"
|
||||
|
||||
size_t ptouch_line_payload_bytes(unsigned head_dots)
|
||||
{
|
||||
return (size_t)((head_dots + 7u) / 8u);
|
||||
}
|
||||
|
||||
void ptouch_fill_gf_header(uint8_t out[3], size_t line_payload_bytes)
|
||||
{
|
||||
out[0] = 0x47u;
|
||||
out[1] = (uint8_t)(line_payload_bytes & 0xFFu);
|
||||
out[2] = (uint8_t)((line_payload_bytes >> 8) & 0xFFu);
|
||||
}
|
||||
|
||||
void ptouch_fill_esc_iz(uint8_t out[13], uint8_t media_kind, uint8_t media_width,
|
||||
uint32_t raster_lines)
|
||||
{
|
||||
uint8_t n2_paper = 0x09u;
|
||||
if (media_kind == 0x03u)
|
||||
n2_paper = 0x00u;
|
||||
else if (media_kind == 0x11u)
|
||||
n2_paper = 0x11u;
|
||||
else if (media_kind == 0x17u)
|
||||
n2_paper = 0x17u;
|
||||
else if (media_kind == 0x13u)
|
||||
n2_paper = 0x13u;
|
||||
|
||||
out[0] = 0x1Bu;
|
||||
out[1] = 0x69u;
|
||||
out[2] = 0x7Au;
|
||||
out[3] = 0x0Eu;
|
||||
out[4] = n2_paper;
|
||||
out[5] = media_width;
|
||||
out[6] = 0x00u;
|
||||
out[7] = (uint8_t)(raster_lines & 0xFFu);
|
||||
out[8] = (uint8_t)((raster_lines >> 8) & 0xFFu);
|
||||
out[9] = (uint8_t)((raster_lines >> 16) & 0xFFu);
|
||||
out[10] = (uint8_t)((raster_lines >> 24) & 0xFFu);
|
||||
out[11] = 0x00u; /* first page */
|
||||
out[12] = 0x00u; /* fixed */
|
||||
}
|
||||
Reference in New Issue
Block a user