This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Dear TI
I have the PROFINET Device v2.00.01 "Compact IO-Device Example Project" running on an LP-AM243 (revision E2) using the AM243x MCU+ SDK 08.02.00. Without modifications this example project is running fine and I can communicate via with an AM64x Evaluation Module (using the PROFINET protocol).
I see that in the function APP_runProfinetStack() I can get the input and output buffer addresses via PN_API_DEV_getBufferInputData() and PN_API_DEV_getBufferOutputData(). But these buffers pBufOut and pBufIn seem to be unstructured.
So within I APP_runProfinetStack() tried using PN_API_DEV_getExpectedSubmodule() to get to the actual data in a submodule / subslot. Here's my full code of the full function APP_runProfinetStack():
uint32_t APP_runProfinetStack ( void) { uint32_t result = 0; uint8_t *pBufOut = NULL; uint8_t *pBufIn = NULL; static uint8_t incrementValue = 0; PN_API_DEV_EAr_t ar_p = PN_API_DEV_eAR_DA; PN_API_DEV_SModule_t Module_p = {0}; PN_API_DEV_SSubmodule_t Submodule_p = {0}; uint16_t index_p = 0; /*This function must be called regularly.*/ result = PN_API_PDEV_run (); if (result != PN_API_PDEV_eOK) { goto laError; } result = PN_API_DEV_getBufferOutputData (&pBufOut); if (result != PN_API_DEV_eOK) { goto laError; } result = PN_API_DEV_getBufferInputData (&pBufIn); if (result != PN_API_DEV_eOK) { goto laError; } /*Input data is updated before being sent to controller.*/ //pBufIn[0] = pBufOut[0]; //pBufIn[1] = ++incrementValue; /******************************************************* * TEST CODE BEGIN *******************************************************/ Module_p.slotNumber = 1; Module_p.moduleIdNumber = 0x00000005; Module_p.moduleState = 1; Module_p.numberOfSubModules = 1; Submodule_p.subSlot = 0; Submodule_p.id = 0; Submodule_p.state = 0; index_p = 0; ar_p = PN_API_DEV_eAR_DA; result = PN_API_DEV_getExpectedSubmodule(ar_p, &Module_p, index_p, &Submodule_p); /******************************************************* * TEST CODE END *******************************************************/ result = PN_API_DEV_releaseBufferInputData (); if (result != PN_API_DEV_eOK) { goto laError; } return result; laError: OSAL_printf("\r[APP] ERROR: Error during PROFINET stack run. Error code: 0x%8.8x\n", result); return result; }
However the return value of PN_API_DEV_getExpectedSubmodule() on line 53 is always PN_API_DEV_eERROR_PARAMETER_OUT_OF_RANGE (HEX: 0x38030402, DEC: 939721730). What am I doing wrong?
Is ar_p = PN_API_DEV_eAR_DA;
correct?
What should Module_p.moduleState =
be?
Thank you and best regards
Thomas
Hi Thomas,
Thanks for your query let me get feedback from internal team and I will get back here.
BR
Nilabh A.
HI Thomas,
We are working on the same, will be providing response by EOW.
BR
Nilabh A.
Hi Thomas,
PN_API_DEV_getExpectedSubmodule is not designed to get data from a submodule. It is used to get information about the module configuration which is sent by the PLC. Normally you do this in the Connect Indication. I think that is not what you want.
You are interested in the processdata offsets. The offsets are set from the application during startup. This is done in APP_configureSubmodules(). You can structure the In/Out as you want. For example here the Demo App Slot 1:
Regards
Nilabh A.
Dear Nilabh
Thank you for your support. I think I start understand more, but I'm not quite there yet. Sorry this is my first involvement with PROFINET, so I'm really new at that.
I think you are right, I am interested in the process data offsets, but I don't understand how I can recover those offsets, that were set during the execution of APP_configureSubmodules(), when APP_runProfinetStack() is called continuously.
I I think I understand that in APP_runProfinetStack() I can get the pointers to the cyclic data input and output buffers using PN_API_DEV_getBufferInputData (&pBufIn) and PN_API_DEV_getBufferOutputData (&pBufOut).
So let's say I want to do two things: read some output data that I received from the IO-Controller and write some input data to be sent to the IO-Controller.
So from the configuration in APP_configureSubmodules() I see that Slot 10, Subslot 0x0001 is a buffer with 16 bytes of output data from the IO-Controller to me as the IO-Device. I would like to access this data somewhat like this:
uint32_t result = 0;
uint8_t *pBufOut = NULL;
uint8_t aBufOutSlot10[16] = {0}; result = PN_API_PDEV_run ();
if (result != PN_API_PDEV_eOK)
{
goto laError;
}
result = PN_API_DEV_getBufferOutputData (&pBufOut);
if (result != PN_API_DEV_eOK)
{
goto laError;
}
memcpy(aBufOutSlot10, pBufOut + OFFSET_FOR_SLOT10, 16);
Or from the configuration in APP_configureSubmodules() I see that Slot 1, Subslot 0x0001 is a buffer with 16 bytes input data from me the IO-Device to the IO-Controller. I would like to write my data to this buffer somewhat like this:
uint32_t result = 0;
uint8_t *pBufIn = NULL;
uint8_t aBufInSlot1[16] = {0};result = PN_API_PDEV_run ();
if (result != PN_API_PDEV_eOK)
{
goto laError;
}
result = PN_API_DEV_getBufferInputData (&pBufIn);
if (result != PN_API_DEV_eOK)
{
goto laError;
}
getDataFromMyApplicationForSlot1(aBufInSlot1); // just an example to get 16 bytes of data to be sent to the IO-Controller
memcpy(pBufIn + OFFSET_FOR_SLOT1, aBufInSlot1, 16);
What I don't understand is: how do I know what OFFSET_FOR_SLOT1 and OFFSET_FOR_SLOT10 are in the function APP_runProfinetStack()? (The HEX-Values.)
Best regards
Thomas
Dear Nilabh
Thank you for your support. I think I start understand more, but I'm not quite there yet. Sorry this is my first involvement with PROFINET, so I'm really new at that.
I think you are right, I am interested in the process data offsets, but I don't understand how I can recover those offsets, that were set during the execution of APP_configureSubmodules(), when APP_runProfinetStack() is called continuously.
I I think I understand that in APP_runProfinetStack() I can get the pointers to the cyclic data input and output buffers using PN_API_DEV_getBufferInputData (&pBufIn) and PN_API_DEV_getBufferOutputData (&pBufOut).
So let's say I want to do two things: read some output data that I received from the IO-Controller and write some input data to be sent to the IO-Controller.
So from the configuration in APP_configureSubmodules() I see that Slot 10, Subslot 0x0001 is a buffer with 16 bytes of output data from the IO-Controller to me as the IO-Device. I would like to access this data somewhat like this:
uint32_t result = 0;
uint8_t *pBufOut = NULL;
uint8_t aBufOutSlot10[16] = {0}; result = PN_API_PDEV_run ();
if (result != PN_API_PDEV_eOK)
{
goto laError;
}
result = PN_API_DEV_getBufferOutputData (&pBufOut);
if (result != PN_API_DEV_eOK)
{
goto laError;
}
memcpy(aBufOutSlot10, pBufOut + OFFSET_FOR_SLOT10, 16);
Or from the configuration in APP_configureSubmodules() I see that Slot 1, Subslot 0x0001 is a buffer with 16 bytes input data from me the IO-Device to the IO-Controller. I would like to write my data to this buffer somewhat like this:
uint32_t result = 0;
uint8_t *pBufIn = NULL;
uint8_t aBufInSlot1[16] = {0};result = PN_API_PDEV_run ();
if (result != PN_API_PDEV_eOK)
{
goto laError;
}
result = PN_API_DEV_getBufferInputData (&pBufIn);
if (result != PN_API_DEV_eOK)
{
goto laError;
}
getDataFromMyApplicationForSlot1(aBufInSlot1); // just an example to get 16 bytes of data to be sent to the IO-Controller
memcpy(pBufIn + OFFSET_FOR_SLOT1, aBufInSlot1, 16);
What I don't understand is: how do I know what OFFSET_FOR_SLOT1 and OFFSET_FOR_SLOT10 are in the function APP_runProfinetStack()? (The HEX-Values.)
Best regards
Thomas
Edit: I guess I have to write a function for use in APP_configureSubmodules() that allows me to remember the offsets in an (global or module global) array.
Hi Thomas,
You can try writing the function. Let me know if you need any further help.
BR
Nilabh A.