Page 1 of 1

How to get errors from FATFS_STREAM element?

Posted: Tue Sep 13, 2022 3:25 am
by felixcollins
Hi,
I'm using the fatfs_stream audio element to play music from an SD card. It is working well and has removed a whole lot of code I had to open and read files. However, when something goes wrong (e.g. SD card is removed) I need to know that the file read has failed and try demounting and remounting the SD card. It seems that the element is very quiet about errors. It logs them to the console but does not send an event to the pipeline. What is the correct approach for detecting these i/o errors?
Regards,
Felix

Re: How to get errors from FATFS_STREAM element?

Posted: Tue Sep 13, 2022 10:57 pm
by felixcollins
It can be done with the status report msg. A code fragment follows...

Code: Select all

	if (msg->source == (void *)fatfs_stream_element_handle)
		{
			ESP_LOGW(TAG, "message from fatfs reader %i", msg->cmd);
			if (msg->cmd == AEL_MSG_CMD_REPORT_STATUS)
			{
				audio_element_status_t fatfs_status = (audio_element_status_t)msg->data;
				if (fatfs_status >= AEL_STATUS_ERROR_OPEN && fatfs_status <= AEL_STATUS_ERROR_UNKNOWN)
				{
					ESP_LOGW(TAG, "Error from fatfs reader %i", fatfs_status);