Fixed sim_write_serial to return 0 when the non blocking write fails with the expected errno of EAGAIN

This commit is contained in:
Mark Pizzolato 2012-12-14 03:27:18 -08:00
parent c71e0c39dc
commit 883ad6bf5c

View file

@ -205,7 +205,11 @@ for (i=0; i<serial_open_device_count; ++i)
static void sim_error_serial (char *routine, int error) static void sim_error_serial (char *routine, int error)
{ {
extern FILE *sim_debug;
fprintf (stderr, "Serial: %s fails with error %d\n", routine, error); fprintf (stderr, "Serial: %s fails with error %d\n", routine, error);
if (sim_debug)
fprintf (sim_debug, "Serial: %s fails with error %d\n", routine, error);
return; return;
} }
@ -1244,8 +1248,11 @@ int written;
written = write (port, (void *) buffer, (size_t) count); /* write the buffer to the serial port */ written = write (port, (void *) buffer, (size_t) count); /* write the buffer to the serial port */
if ((written == -1) && (errno != EAGAIN)) /* write error? */ if (written == -1)
sim_error_serial ("write", errno); /* report unexpected error */ if (errno != EAGAIN) /* unexpected error? */
sim_error_serial ("write", errno); /* report it */
else
written = 0; /* not an error, but nothing written */
return (int32) written; /* return number of characters written */ return (int32) written; /* return number of characters written */
} }