Replace auto-cut toggle with --cut bit flags (default 011), wire flags through C/Ruby APIs, and document the new cut/debug-dump behavior in both READMEs. Made-with: Cursor
78 lines
2.3 KiB
C
78 lines
2.3 KiB
C
#include "libptouch_protocol.h"
|
|
|
|
#include "libptouch.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
static const ptouch_printer_profile_t prof_fixture_p700 = {
|
|
.family = LIBPTOUCH_FAMILY_P700,
|
|
};
|
|
|
|
static const ptouch_printer_profile_t prof_fixture_p900 = {
|
|
.family = LIBPTOUCH_FAMILY_P900,
|
|
};
|
|
|
|
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, &prof_fixture_p700, 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_n1_flags", iz[3], 0x84);
|
|
fail |= expect_int("iz_media_kind_fixed", iz[4], 0x00);
|
|
fail |= expect_int("iz_media_width", iz[5], 0x0C);
|
|
fail |= expect_int("iz_lines_lsb", iz[7], 70);
|
|
fail |= expect_int("iz_page_control_p700", iz[11], 0x00);
|
|
fail |= expect_int("iz_last_fixed", iz[12], 0x00);
|
|
|
|
ptouch_fill_esc_iz(iz, &prof_fixture_p900, 0x0Cu, 70u);
|
|
fail |= expect_int("iz_page_control_p900_single", iz[11], 0x02);
|
|
|
|
/* ESC i K: bit2=ハーフカット、bit3=ChainPrintしない */
|
|
fail |= expect_int(
|
|
"esc_ik_p750w_half_chain",
|
|
(int)ptouch_esc_ik_extended_mode(
|
|
LIBPTOUCH_USB_PID_PTP750W, LIBPTOUCH_RASTER_FLAGS_DEFAULT),
|
|
0x04);
|
|
fail |= expect_int(
|
|
"esc_ik_p710bt_no_half",
|
|
(int)ptouch_esc_ik_extended_mode(
|
|
LIBPTOUCH_USB_PID_PTP710BT, LIBPTOUCH_RASTER_FLAGS_DEFAULT),
|
|
0x00);
|
|
fail |= expect_int(
|
|
"esc_ik_p900w_auto_half_no_chain",
|
|
(int)ptouch_esc_ik_extended_mode(
|
|
LIBPTOUCH_USB_PID_PTP900W,
|
|
LIBPTOUCH_RASTER_FLAG_AUTO_CUT |
|
|
LIBPTOUCH_RASTER_FLAG_HALF_CUT),
|
|
0x0C);
|
|
|
|
return fail ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
}
|