/* Decodes the escape sequences and copies the result into the destination buffer.  */
static uint16_t _decode_copy(uint8_t *puc_dest, uint8_t *puc_orig, uint16_t us_size)
/* Decodes the escape sequences and copies the result into the destination buffer.  */
static uint16_t _decode_copy(uint8_t *puc_dest, uint8_t *puc_orig, uint16_t us_size)
{
	uint16_t i = 0;
	uint16_t j = 0;
	while (i < us_size) {
		if (puc_orig[i] == ESCMARK) {
			if (puc_orig[i + 1] == ESC_MSGMARK) {
				puc_dest[j++] = MSGMARK;
				i += 2;
			} else if (puc_orig[i + 1] == ESC_ESCMARK) {
				puc_dest[j++] = ESCMARK;
				i += 2;
			} else {
				return (uint16_t)USI_STATUS_FORMAT_ERROR;
			}
		} else {
			puc_dest[j++] = puc_orig[i];
			i++;
		}
	}
	return(j);
}