lib/fw.c
/**
 * @brief Print an error string to stdout
 * @param[in] s		String that will be prefixed to the error message
 * @param[in] ret 	The value returned by the firmware function
 *
 * This can be called after Switchtec firmware function returned an error
 * to find out what caused the problem.
 */
@brief Print an error string to stdout
@param[in] s         String that will be prefixed to the error message
@param[in] ret       The value returned by the firmware function

This can be called after Switchtec firmware function returned an error
to find out what caused the problem.
@brief Print an error string to stdout @param [ in ] s String that will be prefixed to the error message @param [ in ] ret The value returned by the firmware function This can be called after Switchtec firmware function returned an error to find out what caused the problem .
void switchtec_fw_perror(const char *s, int ret)
{
	const char *msg;
	if (ret <= 0) {
		perror(s);
		return;
	}
	switch(ret) {
	case SWITCHTEC_DLSTAT_HEADER_INCORRECT:
		msg = "Header incorrect";  break;
	case SWITCHTEC_DLSTAT_OFFSET_INCORRECT:
		msg = "Offset incorrect";  break;
	case SWITCHTEC_DLSTAT_CRC_INCORRECT:
		msg = "CRC incorrect";  break;
	case SWITCHTEC_DLSTAT_LENGTH_INCORRECT:
		msg = "Length incorrect";  break;
	case SWITCHTEC_DLSTAT_HARDWARE_ERR:
		msg = "Hardware Error";  break;
	case SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT:
		msg = "Download Timeout";  break;
	default:
		fprintf(stderr, "%s: Unknown Error (%d)\n", s, ret);
		return;
	}
	fprintf(stderr, "%s: %s\n", s, msg);
}
void switchtec_fw_perror ( const char * s , int ret ) { const char * msg ; if ( ret <= 0 ) { perror ( s ) ; return ; } switch ( ret ) { case SWITCHTEC_DLSTAT_HEADER_INCORRECT : msg = " " ; break ; case SWITCHTEC_DLSTAT_OFFSET_INCORRECT : msg = " " ; break ; case SWITCHTEC_DLSTAT_CRC_INCORRECT : msg = " " ; break ; case SWITCHTEC_DLSTAT_LENGTH_INCORRECT : msg = " " ; break ; case SWITCHTEC_DLSTAT_HARDWARE_ERR : msg = " " ; break ; case SWITCHTEC_DLSTAT_DOWNLOAD_TIMEOUT : msg = " " ; break ; default : fprintf ( stderr , " \n " , s , ret ) ; return ; } fprintf ( stderr , " \n " , s , msg ) ; }
@brief Print an error string to stdout
 @param[in] s         String that will be prefixed to the error message
 @param[in] ret       The value returned by the firmware function
@brief Print an error string to stdout @param [ in ] s String that will be prefixed to the error message @param [ in ] ret The value returned by the firmware function