Skip to content

Commit cda8523

Browse files
authored
For some unknown reason, every printing file need sleep a little time on first transmit (OpenPrinting#431)
serial: Add a 10-msec sleep and at the end add a tcdrain() For some unknown reason, every printing file need sleep a little time to make sure the serial printer receive data is right.
1 parent 1557119 commit cda8523

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

backend/serial.c

+12
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
108108
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
109109
struct sigaction action; /* Actions for POSIX signals */
110110
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
111+
char print_sleep = 0; /* Print first sleep flag on every transmit */
111112

112113

113114
/*
@@ -652,6 +653,16 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
652653
}
653654
}
654655

656+
/*
657+
* on every transmit need to wait a little
658+
* even though the DSR is OK for some unknown reasons.
659+
*/
660+
if (print_sleep == 0)
661+
{
662+
usleep(10000);
663+
print_sleep = 1;
664+
}
665+
655666
if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
656667
{
657668
/*
@@ -674,6 +685,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
674685
}
675686
else
676687
{
688+
tcdrain(device_fd);
677689
fprintf(stderr, "DEBUG: Wrote %d bytes.\n", (int)bytes);
678690

679691
print_bytes -= bytes;

0 commit comments

Comments
 (0)