Skip to content

Commit

Permalink
For some unknown reason, every printing file need sleep a little time…
Browse files Browse the repository at this point in the history
… on first transmit (#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.
  • Loading branch information
fengyuewuhen committed Jan 17, 2022
1 parent 1557119 commit cda8523
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/serial.c
Expand Up @@ -108,6 +108,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
char print_sleep = 0; /* Print first sleep flag on every transmit */


/*
Expand Down Expand Up @@ -652,6 +653,16 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
}
}

/*
* on every transmit need to wait a little
* even though the DSR is OK for some unknown reasons.
*/
if (print_sleep == 0)
{
usleep(10000);
print_sleep = 1;
}

if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0)
{
/*
Expand All @@ -674,6 +685,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
}
else
{
tcdrain(device_fd);
fprintf(stderr, "DEBUG: Wrote %d bytes.\n", (int)bytes);

print_bytes -= bytes;
Expand Down

0 comments on commit cda8523

Please sign in to comment.