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?
Hi, AJ
I Can not find the function GetConfigFile in any header file. Where is it? Does the function-GetConfigFile read the config.nxd from my computer's local disk default? Which directory should I put the config.nxd in my computer? How can I use my own config.nxd file?
Thank you!
Best Regards
lovett
Hilscher Gesellschaft fuer Systemautomation mbH
Hello lovett,
you will find the function "GetConfigFile" in the HostPC Example on the Hilscher protocol stack product CD.
There you will find a module and a header named "GetConfigFiles".
Yes, this function reads the config file from your computer's local disk. The directory is not important, because you provide a pointer to the file data.
To create your own nxd configuration file you need the Sycon.net application. Here with you create the needed configuration of your network and you can export the configuration.
Regards
AJ
Hi, AJ
I Can only find USER_GetConfigurationFile in cifX Device Driver Document. And it is different with the GetConfigFile, Could you send me a project using GetConfigFile? Also I want to know whether the programming below (the same as you referred in your upstair reply to TomP) is running in a Host PC such as in Linux OS? Could you explain it for me?
Now I only have NXHX500-RE(master) and NXHX50-RE(slave), how can I use the config.nxd? Can I use config.nxd file wiithout another HostPC ? Could you give me some ideas?
Programms:
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");
}
...
}
Hilscher Gesellschaft fuer Systemautomation mbH
Hello lovette,
If you have the Hilscher product CDs you should also have the the described Host Example (HostPC Example) on this CD.
You can also use the USER_GetConfigurationFile but it returns the number of configuration files associated with the card and is not what you are looking for.
Inside of the C-Toolkit exists also a command to download files. I think the function is named DEV_DownloadFile. Not for 100% sure.
The code can also run on a HOST. The HOST can be a 2nd microprocessor or a PC system. It doesn't matter which OS is running. That is the advantage of this general API from Hilscher.
Regards
AJ
Hi AJ
I just have NXDRV-Linux CD and there are cifxsample and libcifx-0.9.4.6, and cifX (F) CD with cifXDemo ,cifXTest,cifXTest_Console, I don't have a project using GetConfigFile. Could you give me a project?
I'm sorry for my not clear question. My point is : I just use a NXHX500-RE(Master) and running the CD-NXLOR-DPM-2009-07 (F) 's protocal,using a linkable profibus protocal. I don't use a Host, which means I can't download the config.nxd file to the NXHX-500RE from a Host. I just use the protocal pprograms like shmDemo.
I want to know If I don't use a Host ,how Can I download the config.nxd file in local disk to NXHX500-RE(master)? Is it possible?
Here shmDemo use the g_abConfig array to changed to config.nxd file. Now I want to use the config.nxd file in local disk which generated by SYCON.net, How I modify the protocal program? Could you give me some idea?
Program: CD-NXLOR-DPM-2009-07 (F) 's protocal's shmDemo part
TLR_RESULT TaskProcess_ShmDemo(SHM_DEMO_RSC_T FAR* ptRsc)
{
TLR_RESULT eRslt = TLR_S_OK;
long lTemp = CIFX_NO_ERROR;
HANDLE hDriver = NULL;
HANDLE hChannel = NULL;
TLR_MAKE_USED(ptRsc);
if(CIFX_NO_ERROR == (lTemp = xDriverOpen(&hDriver)))
{
/* Driver successfully opened */
if(CIFX_NO_ERROR == (lTemp = xChannelOpen(hDriver, "cifX0", 0, &hChannel)))
{
/* Channel successfully opened, so query basic information */
unsigned long ulState = 0;
/* Download contents of config.nxd configuration parameters */
lTemp = xChannelDownload(hChannel, DOWNLOAD_MODE_CONFIG, "config.nxd", (unsigned char*)&g_abConfig[0], sizeof(g_abConfig), NULL, NULL, NULL);
/* Set Channel Init Reset after Configuration Download */
lTemp = xChannelReset(hChannel, CIFX_CHANNELINIT, 2000);
/* Waiting for netX configuration assumption */
lTemp = xChannelHostState(hChannel, CIFX_HOST_STATE_READY, &ulState, 0);
while(CIFX_DEV_NO_COM_FLAG == lTemp)
{
lTemp = xChannelHostState(hChannel, CIFX_HOST_STATE_READY, &ulState, 0);
TLR_TSK_SLEEP(TLR_TIM_TIME_TO_TICK(100));
}
//cyclic Exchange data
}
Best Regards
lovett
Hilscher Gesellschaft fuer Systemautomation mbH
Hi lovett,
I sent you the requested GetConfigFiles via PN, because it is not possible to upload files in the forum.
Include this array into your project:
/* Hex-array of the master configuration including the slaves */
const unsigned char g_abConfig[]=
{ 0x2e,....
};
Then you need to modify the xChannelDownload command:
xChannelDownload( hChannel, DOWNLOAD_MODE_CONFIG, "config.nxd", (unsigned char*)&g_abConfig[0], sizeof( g_abConfig ), NULL, NULL, NULL );
Regards
AJ
Andreas Jacob
Hilscher Gesellschaft fuer Systemautomation mbH
Hello TomP,
maybe the following code snippet will help.
Regards
AJ