Hello, I am working with the NetX500 controller on the NXSB100 board and I am using rcX.
I have got following problem:
I have an EtherCAT demo stack which can send two bytes and I use demo code. The the demo works but only with the cifX Driver. Is there any demo code, which can access the EtherCAT stack over the queue?
In the SHM_DEMO the two bytes are written by the xChannelIOWrite() function but I want to write the two bytes over the queuing mechanism.
RX_RESULT TaskProcess_ShmDemo(SHM_DEMO_RSC_T* ptRsc)
{
long lRet = CIFX_NO_ERROR;
CIFXHANDLE hDriver = NULL;
CIFXHANDLE hChannel = NULL;
...
/* Open Driver */
lRet = xDriverOpen(&hDriver);
if(CIFX_NO_ERROR == lRet)
{
/* Driver successfully opened */
/* Open channel */
lRet = xChannelOpen(hDriver, "cifX0", 0, &hChannel);
if(CIFX_NO_ERROR == lRet)
{
unsigned char abRData[SHM_IO_DATA_LEN] = {0};
unsigned char abWData[SHM_IO_DATA_LEN] = {0};
//unsigned char bInputData=0;
unsigned long ulState = 0;
unsigned long ulTimeout = 8000;
CIFX_PACKET tSendPkt = {{0}};
CIFX_PACKET tRecvPkt = {{0}};
UINT8 bErrCounter = 0;
/* Toggle Application Ready State Flag */
lRet = xChannelHostState(hChannel, CIFX_HOST_STATE_READY, &ulState, ulTimeout);
if(CIFX_DEV_NOT_RUNNING == lRet)
{
/* Set Warmstart Parameters Packet */
ShmDemo_SetWarmstartParamsPkt(ptRsc, (void*)&tSendPkt);
/* Send Warmstart Request Packet */
lRet = xChannelPutPacket(hChannel, &tSendPkt, ulTimeout);
/* Get Warmstart Response Packet */
lRet = xChannelGetPacket(hChannel, sizeof(tRecvPkt), (void*)&tRecvPkt, ulTimeout);
}
/* Set Channel Init Reset after Warmstart Request Packet */
lRet = xChannelReset(hChannel, CIFX_CHANNELINIT, ulTimeout);
/* Waiting for netX warmstarting */
do
{
/* Toggle Application Ready State Flag */
lRet = xChannelHostState(hChannel, CIFX_HOST_STATE_READY, &ulState, 10);
}
while (CIFX_DEV_NOT_RUNNING == lRet);
/* Check netX state */
if((CIFX_NO_ERROR == lRet) || (CIFX_DEV_NO_COM_FLAG == lRet))
{
/* Cyclic exchange IO data if COM_FLAG is detected */
while(1)
{
/* Communication is established */
if(CIFX_NO_ERROR == lRet)
{
lRet = xChannelIORead(hChannel, 0, 0, SHM_IO_DATA_LEN, abRData, 10);
...
Andreas Jacob
Hilscher Gesellschaft fuer Systemautomation mbH
Hi D.H.,
I am not sure which example do you have. If it is from the NXHX CD you have only the SHM demo available.
As far as I know are the protocol stack CDs delivered with both examples; SHM and packet API.