feat(inventory): Phase 1 - scan and validate UPC barcodes #1
@@ -56,20 +56,20 @@ GLDEF_C INT main(VOID)
|
||||
|
||||
p_printf("\nScan a barcode. System screen to exit.\n\n");
|
||||
|
||||
/* Read ONE byte per call: with tmask=0 a multi-byte P_FREAD waits for the
|
||||
full requested count and would block on a short scan. Streaming single
|
||||
bytes returns each character as it arrives, whatever the terminator. */
|
||||
for (;;) {
|
||||
n = p_read(chan, buf, sizeof(buf));
|
||||
n = p_read(chan, buf, 1);
|
||||
if (n < 0) {
|
||||
p_printf("read err %d\n", n);
|
||||
p_printf("<err %d>", n);
|
||||
continue;
|
||||
}
|
||||
if (n == 0)
|
||||
continue;
|
||||
p_printf("n=%d:", n);
|
||||
for (i = 0; i < n; i++)
|
||||
p_printf(" %d", buf[i]);
|
||||
p_printf(" \"");
|
||||
for (i = 0; i < n; i++)
|
||||
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
||||
p_printf("\"\n");
|
||||
i = buf[0];
|
||||
p_printf(" %d", i);
|
||||
if (i == 13 || i == 10)
|
||||
p_printf(" <EOL>\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user