How to get errors from FATFS_STREAM element?

felixcollins
Posts: 125
Joined: Fri May 24, 2019 2:02 am

How to get errors from FATFS_STREAM element?

Postby felixcollins » Tue Sep 13, 2022 3:25 am

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

felixcollins
Posts: 125
Joined: Fri May 24, 2019 2:02 am

Re: How to get errors from FATFS_STREAM element?

Postby felixcollins » Tue Sep 13, 2022 10:57 pm

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);

Who is online

Users browsing this forum: No registered users and 41 guests