view target-utils/loadagent/sertimeout.c @ 644:69acf5e0a21d

loadagent: implemented sertimeout calibration command
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 01 Mar 2020 23:49:31 +0000
parents
children 880c6d31e487
line wrap: on
line source

/*
 * Here we are going to implement a function for serial input with a timeout.
 */

#include <stdlib.h>

serial_in_timeout(count)
	unsigned count;
{
	int c;

	do
		c = serial_in_poll();
	while (c < 0 && --count);
	return c;
}

void
cmd_sertimeout(argbulk)
	char *argbulk;
{
	char *argv[2];
	int count, c;

	if (parse_args(argbulk, 1, 1, argv, 0) < 0)
		return;
	count = atoi(argv[0]);
	c = serial_in_timeout(count);
	if (c >= 0)
		printf("Got char\n");
	else
		printf("Timeout\n");
}