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");
|
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 (;;) {
|
for (;;) {
|
||||||
n = p_read(chan, buf, sizeof(buf));
|
n = p_read(chan, buf, 1);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
p_printf("read err %d\n", n);
|
p_printf("<err %d>", n);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
continue;
|
continue;
|
||||||
p_printf("n=%d:", n);
|
i = buf[0];
|
||||||
for (i = 0; i < n; i++)
|
p_printf(" %d", i);
|
||||||
p_printf(" %d", buf[i]);
|
if (i == 13 || i == 10)
|
||||||
p_printf(" \"");
|
p_printf(" <EOL>\n");
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
p_putch(buf[i] >= ' ' ? buf[i] : '.');
|
|
||||||
p_printf("\"\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user