I have used slua801 to get response of standard command.
As per SLUUBO7. we need to write 2-byte standard commands
write(Fd_file, pData, 2);
But below function write one byte command and though it respond correct data.
Why this respond correctly ? i want to know where is mistake ?
int FuelCheck::gauge_read(int &Fd_file, unsigned char nRegister, unsigned char *pData, unsigned char nLength)
{
int n = 0;
if (nLength< 1)
return 0;
pData[0]= nRegister;
n = write(Fd_file, pData, 1);
#if BOARD
if(n == -1)
{
#ifdef QDEBUG_ENABLE
pMainApp.ObjSettings.DebugStation("Failed to write fuel gauge register address");
#endif
}
#endif
n = read(Fd_file, pData, nLength);
usleep(200);
#if BOARD
if((n == -1) || (n == 0))
{
#ifdef QDEBUG_ENABLE
pMainApp.ObjSettings.DebugStation("Failed to read fuel gauge register address");
#endif
}
#endif
return n;
}