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
45 lines
1.3 KiB
C
45 lines
1.3 KiB
C
#include "libptouch_protocol.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
static int expect_int(const char *name, int got, int want)
|
|
{
|
|
if (got == want)
|
|
return 0;
|
|
fprintf(stderr, "%s mismatch: got=%d want=%d\n", name, got, want);
|
|
return 1;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int fail = 0;
|
|
|
|
fail |= expect_int("line_payload_128", (int)ptouch_line_payload_bytes(128u), 16);
|
|
fail |= expect_int("line_payload_560", (int)ptouch_line_payload_bytes(560u), 70);
|
|
|
|
uint8_t gf[3];
|
|
ptouch_fill_gf_header(gf, 16u);
|
|
fail |= expect_int("gf16_cmd", gf[0], 0x47);
|
|
fail |= expect_int("gf16_n1", gf[1], 0x10);
|
|
fail |= expect_int("gf16_n2", gf[2], 0x00);
|
|
|
|
ptouch_fill_gf_header(gf, 70u);
|
|
fail |= expect_int("gf70_cmd", gf[0], 0x47);
|
|
fail |= expect_int("gf70_n1", gf[1], 0x46);
|
|
fail |= expect_int("gf70_n2", gf[2], 0x00);
|
|
|
|
uint8_t iz[13];
|
|
ptouch_fill_esc_iz(iz, 0x01u, 0x0Cu, 70u);
|
|
fail |= expect_int("iz_cmd_0", iz[0], 0x1B);
|
|
fail |= expect_int("iz_cmd_1", iz[1], 0x69);
|
|
fail |= expect_int("iz_cmd_2", iz[2], 0x7A);
|
|
fail |= expect_int("iz_media_kind_map", iz[4], 0x09);
|
|
fail |= expect_int("iz_media_width", iz[5], 0x0C);
|
|
fail |= expect_int("iz_lines_lsb", iz[7], 70);
|
|
fail |= expect_int("iz_page_index", iz[11], 0x00);
|
|
fail |= expect_int("iz_last_fixed", iz[12], 0x00);
|
|
|
|
return fail ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
}
|