Arduino-FatFs icon indicating copy to clipboard operation
Arduino-FatFs copied to clipboard

disk_ioctl not actually implemented?

Open alessandrofrancesconi opened this issue 4 years ago • 1 comments

Currently, the disk_ioctl() function is

DRESULT disk_ioctl( BYTE pdrv,    // Physical drive nmuber (0..)
                    BYTE cmd,     // Control code
                    void *buff )  // Buffer to send/receive control data
{
  return sd_disk_ioctl( cmd );
}

While sd_disk_ioctl()seems to be actually "broken" (no return, no cmd handling, ...)

extern "C" int sd_disk_ioctl( uint8_t cmd )
{
  DRESULT res = RES_ERROR;
  
  switch( cmd )
  {
    case CTRL_SYNC :   // Make sure that data has been written  
      res = RES_OK;
      // res = spiRec() == 0XFF ? RES_OK : RES_NOTRDY ;
      // res = card.waitNotBusy( SD_WRITE_TIMEOUT ) ? RES_OK : RES_NOTRDY ;  
      break;  

    default:  
      res = RES_PARERR;  
  }
}

So this function actually does not work. Is it expected?

alessandrofrancesconi avatar Aug 29 '21 09:08 alessandrofrancesconi

Hi Alessandro Yes, without a doubt, we should add “return res;" at the end of the sd_disk_ioctl () function. And modify the first line, too


extern "C" DRESULT sd_disk_ioctl( uint8_t cmd )
{
  DRESULT res = RES_ERROR;
  
  switch( cmd )
  {
    case CTRL_SYNC :   // Make sure that data has been written  
      res = RES_OK;
      // res = spiRec() == 0XFF ? RES_OK : RES_NOTRDY ;
      // res = card.waitNotBusy( SD_WRITE_TIMEOUT ) ? RES_OK : RES_NOTRDY ;  
      break;  
    default:  
      res = RES_PARERR;  
  }
  return res;
}

Currently I don't have time to check, especially the consequences when the cmd parameter is different from CTRL_SYNC

gallegojm avatar Aug 30 '21 21:08 gallegojm