Exemple #1
0
/*
 * Receive and process QDA packets.
 *
 * Receive and process QDA packets, until the communication becomes idle (i.e.,
 * no data is received for a certain amount of time).
 */
void qda_receive_loop()
{
	int len;

	do {
		/*
		 * Receive a new packet using XMODEM.
		 *
		 * xmodem_receive() is blocking: the function returns when the
		 * XMODEM transfer is completed or an unrecoverable reception
		 * error occurs (e.g., a transmission starts, but then
		 * timeouts or the maximum number of retries is exceeded). The
		 * function returns the length of the received data on success,
		 * a negative error code otherwise.
		 */
		len = xmodem_receive_package(qda_buf, sizeof(qda_buf));
		if (len > 0) {
			qda_process_pkt(qda_buf, len);
		}
		/*
		 * NOTE: for this function to work properly, XMODEM must be
		 * changed to return a special value when the failure is due to
		 * a timeout and not an error.
		 *
		 * For now we do not distinguish between a timeout and an
		 * unrecoverable error.
		 */
	} while (len > 0);
}
Exemple #2
0
/* called from QDA */
size_t dfu_util_qda_receive(uint8_t *data, size_t len)
{
	int ret;

	printd("QDA receive: (%d)\n", len);
	ret = xmodem_receive_package(data, len);

	return (ret==-1)?0:ret;
}