industrialNETworXnetx

TomP

TomP

| 04.02.2010 | 14:08 | 1 reply

DP-Stack handling on a CIFX 50-DP card

Hello,

I run the card with the Toolkit-Functions (the Hilscher driver is not used). I created a CONFIG.nxd with the SYCON tool and tested the configuration with it successfuly.Then i start the card with the firmware for the Profibus stack and the CONFIG file. After this i did the following:

xChannelOpen();

xChannelHostState(...CIFX_HOST_STATE_READY...);

xChannelConfigLock(CIFX_CONFIGURATION_UNLOCK);

// Stack Configuration ...

xChannelConfigLock(...CIFX_CONFIGURATION_LOCK...);

xChannelBusState(...CIFX_BUS_STATE_ON...);

Cyclic Data Transfer should work from here.

This does not work because the stack does not have any bus or slave parameters. But those parameters are saved in the CONFIG file. If I write the bus and slave params with the PROFIBUS_FSPMM_CMD_INIT_REQ and PROFIBUS_FSPMM_CMD_DOWNLOAD_REQ between xChannelConfigLock(CIFX_CONFIGURATION_UNLOCK) and xChannelConfigLock(...CIFX_CONFIGURATION_LOCK...) the bus works fine in the end.

My question is now: How can I tell the stack that it is supposed to use the params from the CONFIG file?

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 05.02.2010 | 13:37

Hello TomP,

maybe the following code snippet will help.     

if(CIFX_DEV_NOT_RUNNING == lRet)
      {
        /* Download slave configuration */
        unsigned char* pabFileData = NULL;
        unsigned long ulFileSize = 0;
        
        lRet = GetConfigFile(&pabFileData, &ulFileSize);
        if(lRet==0)
        {
          lRet = xChannelDownload(hChannel, DOWNLOAD_MODE_FILE, CONFIG_FILENAME, pabFileData, ulFileSize, NULL, NULL, NULL);
          if(lRet != CIFX_NO_ERROR)
          {
            printf("Error Downloading Config file!\r\n");
          }
          
          lRet = xChannelReset(hChannel, CIFX_CHANNELINIT, 2000);
          if(lRet != CIFX_NO_ERROR && lRet != CIFX_DEV_NOT_RUNNING)
          {  
            printf("Error Channel Reset!\r\n");
          }
        }else
        {
          printf("Error getting Config file!\r\n");
        }
        
        if(pabFileData != NULL)
        {
          free(pabFileData);
        }
      }

Regards
AJ

Login