LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   About errno:70, writing data to Fm1188 voice chip (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/about-errno-70-writing-data-to-fm1188-voice-chip-4175525865/)

ylmzekrm 11-19-2014 06:33 AM

About errno:70, writing data to Fm1188 voice chip
 
Hi friends,
I try to write to a voice processesor,

The i2c-2 device open succesfully, and Slave adress set successfully
But "write" returns -1 value and I get errno:70(Commnication error on send)

Anyone have detailed information about Errno:70, what caused errno:70? I couldnt find useful info yet about it.

Part of my code below:

Code:

JNIEXPORT jint JNICALL Java_com_I2CInterface_i2cwrite
  (JNIEnv * env, jclass jc, jintArray data)
{
  jint rc = -1;

  jint *buffer = (*env)->GetByteArrayElements(env, data, NULL);

  if (NULL == buffer)
  {
      LOGE("Buffer empty");
      return 0;
  }
  // Get data length
  jsize data_len = (*env)->GetArrayLength(env, data);
  LOGI("data_len = %d", data_len);

  // i2c-dev open
  int fd = open("/dev/i2c-2", O_RDWR);
  LOGI("fd return value = %d",fd);

  if(fd > 0)
  { 
int SLAVEADDR=0x60;
int in=ioctl(fd, I2C_SLAVE_FORCE, SLAVEADDR);
LOGI("IOCTL value: %d",in);

      if( in < 0)
      {
            char* error_str = strerror(errno);
        LOGE("Slave Address could not set, errno = %d (%s)", errno, error_str);
        goto _error;

      }
// writing data
int mq=write(fd, buffer, data_len);
LOGI("Write retun value: %d",mq);
   
    if(mq != data_len)
    {
    char* error_str = strerror(errno);
    LOGE("Couldnt write data!, errno = %d (%s)", errno, error_str);
    goto _error;
    }

      LOGI("Data write succesfully \n");
   
      rc = 0;

  _error:
      close(fd);
  }
  else
  {
      char* error_str = strerror(errno);
      LOGE("i2c device couldnt open-> I2C port 1, errno = %d (%s)", errno, error_str);
  }

  return (rc);
}



All times are GMT -5. The time now is 02:29 PM.