Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Unable to return data to client application using devctl: (1 Item)
   
Unable to return data to client application using devctl  
For the following code the client application is not receiving any data back from the server application. While printing
 the data in client application same old value is being displayed. Can anyone please point out, what is the problem here
?


/*devctl command*/
typedef enum 
{
  CMD_READ = __DIOTF(_DCMD_MISC, 1, Data_st),  /*selection of read*/
}DevCtlCmd_et;

/*different channels*/
typedef enum
{
  CH_SELCTION_00, /*channel 1*/
  
  CH_SELCTION_01, /*channel 2*/
}ChSelection_et;

/*structure containing data and chanel information*/
typedef struct{
  int iData;
  
  ChSelection_et etChSelectionInfo;
}Data_st;


/*#####  CLIENT APPLICATION PROCESS  #####*/
int ReadCh01Data(Data_st * pstData)
{
  int iRet;
  
  int iFileDes;
  
  iFileDes = 0;
  
  pstData->iData = 0;
  
  pstData->etChSelectionInfo = CH_SELCTION_01;
  
  iFileDes = open("<ResourceManagerPathNameSpace>", (O_CREAT), (S_IRUSR | S_IRGRP | S_IROTH));
  
  if(iFileDes > 0)
  {
    iRet = devctl(iFileDes, CMD_READ, (void *)pstData, (size_t)sizeof(*pstData), NULL);
    
    if(iRet == 0)
    {
      printf("\nData Read : %xn", pstData->iData); /*##  NO DATA IS RECEIVED FROM THE CLIENT APPLICATION, 0x0 IS PRINTED
 INSTEAD OF 0x89abcdef  ##*/
    }
  }
  
  return (iRet);
}


/*#####  SERVER APPLICATION PROCESS  #####*/
static sint Custom_Devctl (resmgr_context_t *ctp,
io_devctl_t *msg, RESMGR_OCB_T *ocb)
{
  /*return value*/
  int etRetValue;
  
  /*local variables to store Devctl command type*/
  DevCtlCmd_et etDevctlCmmdType;
  
  /*local data*/
  static Data_st stData;
  
  etRetValue = 0;
  
  etDevctlCmmdType = CMD_MAX;
  
  /*initialize the local data with 0 using memset*/
  (void)memset((void *)&stData, 0, 
  (size_t)sizeof(stData));
  
  /*invoke iofunc_devctl_default to set all the attributes as default*/
  etRetValue = iofunc_devctl_default(ctp, msg, ocb);
  
  /*check if return value of iofunc_devctl_default is _RESMGR_DEFAULT or not*/
  if (etRetValue == _RESMGR_DEFAULT)
  {
   /*Store the Devctl command type into the local variables*/
   etDevctlCmmdType = msg->i.dcmd;
   
   /*check the type of command being sent using devctl()*/
   switch(etDevctlCmmdType)
    {
      /*if the command is CMD_READ*/
      case CMD_READ:
      {
        /*get the data being sent using devctl into local instance using memcpy*/
        (void)memcpy((void *)&stData, _DEVCTL_DATA (msg->i), 
        (size_t) sizeof(stData));
        
        /*check the type of data requested*/
        switch(stData.etChSelectionInfo)
        {
          /*if the data requested from channel CH_SELCTION_00*/
          case CH_SELCTION_00:
          {
            etRetValue = -1;
            /*break statement*/
            break;
          }
          
          /*if the data requested from channel CH_SELCTION_01*/
          case CH_SELCTION_01:
          {
            /*set the data as 0x89abcdef*/
             stData.iData = 0x89abcdef;
            
            break;
          }
          
          /*else the default case*/
          default:
          {
            etRetValue = -2;
            
            break;
          }
        }
        
        /*set the return value for devctl*/
        msg->o.ret_val = etRetValue;
        
        /*check if return value indicates success or not*/
        if(etRetValue == 0)
        {
          /*set the size of data for the reply structure of for devctl*/
          msg->o.nbytes= sizeof(stData);
          
          /*get the data being sent using devctl into local instance using memcpy*/
          (void)memcpy((void *)_DEVCTL_DATA (msg->o), (void *) &stData, 
          (size_t)msg->o.nbytes);  /*##  DATA IS FILLED IN THE MEMORY LOCATION 
AFTER THE UNION OF TYPE "io_devctl_t"  ##*/
        }
        
        /*if return value indicates failure*/
        else
        {
         ...
View Full Message
Attachment: Text devctl_problem_dibas.txt 4.25 KB