cancel
Showing results for 
Search instead for 
Did you mean: 

why NFC_IO_WriteReg16 function's ioctl function return error code 6? how to resolve it ?

Mpraj.19
Associate II

I am using st25dv04k. when i am using NFC_IO_WriteReg16() it return error no 6.

when i am using it print below message:

NFC_IO_WriteReg16(ae,0,7edbfb66,1)

Error -6 while writing @0 (devAddr=AE)

How to resolve this issue ?

int32_t  NFC_IO_ReadReg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length) 
{
  int8_t ret = -8;
  uint8_t regAddr[2];
  regAddr[0] = Reg>>8;
  regAddr[1] = Reg & 0xFF;
 
#ifdef ST25DVI2C_DBG_ENABLE
  printf("NFC_IO_ReadReg16(%x,%x,%x,%d)\r\n",DevAddr,Reg,pData,Length);
#endif
  struct i2c_msg messages[2] = {
        {
            .addr = DevAddr >>1,
            .buf = regAddr,
            .len = 2,
            .flags = 0,
        },
        {
            .addr = DevAddr >>1,
            .buf = pData,
            .len = Length,
            .flags = I2C_M_RD | I2C_M_NOSTART,
        }
    };
 
 struct i2c_rdwr_ioctl_data payload = {
        .msgs = messages,
        .nmsgs = 2,
    };
 
    ret = ioctl(filehandle, I2C_RDWR, &payload);
    if (ret < 0) {
        ret = -errno;
        printf("\r\nError %d while reading @%X (devAddr=%X)\r\n", ret,Reg,DevAddr);
        return ret;
    }
 
  /* todo check return status for nack detection */
  /*  return NFC_I2C_ERROR_NACK; */
#ifdef ST25DVI2C_DBG_ENABLE
  printf("NFC_IO_ReadReg16 OK\r\n");
  for (int i = 0 ; i < Length ; i++)
    printf("%x ",pData[i]);
  printf("\n");
#endif
  return NFC_I2C_STATUS_SUCCESS;
 
}

1 ACCEPTED SOLUTION

Accepted Solutions
Ulysses HERNIOSUS
ST Employee

Hi Mpraj,

I assume 6 means ENXIO /* No such device or address */ (https://kernel.googlesource.com/pub/scm/linux/kernel/git/nico/archive/+/v0.97/include/linux/errno.h). Likely nobody answering on that address.

Check the connections, power supplies and use a scope/logic analyzer.

Regards, Ulysses

View solution in original post

2 REPLIES 2
Brian TIDAL
ST Employee

Hi,

this issue seems to be related to the configuration of your Embedded Linux for iMX. To increase your chance to get some help on his issue, I would suggest to post your question on the iMX forum.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Ulysses HERNIOSUS
ST Employee

Hi Mpraj,

I assume 6 means ENXIO /* No such device or address */ (https://kernel.googlesource.com/pub/scm/linux/kernel/git/nico/archive/+/v0.97/include/linux/errno.h). Likely nobody answering on that address.

Check the connections, power supplies and use a scope/logic analyzer.

Regards, Ulysses