cancel
Showing results for 
Search instead for 
Did you mean: 

ASPEP -> add own commands / endpoints?

j-fischer-gundlach
Associate III

Hello there
-
Is there a way to add own commands/requests to the ASPEP protocol like retrieving own custom introduced values?
I´m running the B-G431B-ESC1 board and adapted the esc.c file to my needs and it now holds a value I´d like to be able to retrieve. 

As far as I understand from looking at the code, callbacks are registered through 
uint8_t MCP_RegisterCallBack (uint8_t callBackID, MCP_user_cb_t fctCB)
defined in mcp.h / implemented in mcp.c
-
Searching the project for this text I didn´d find locations where it is called / callbacks registered. 


- br, Justus

4 REPLIES 4
STuser2
Senior III

As per my understanding it is not possible, the profiler software is ST proprietary, and it comes as .lib file. 

j-fischer-gundlach
Associate III

What exactly you mean with "the profiler software"?

The code the toolchain of MC_Workbench -> CubeMX generates, specifically the tools MC Workbench and Motor Pilot?

I´m not intending to add guages to the Motor Pilot - only a way to request custom values from the µC when connecting it with other controllers. 

Specifically I have implemented a virtual transmission with virtual gears, which are shifted in an incremental fashion, not by absolute input. So I´d like to read out the currently selected gear. 

Sorry for confusion profiler software is the Motor Pilot software. 

When you say want to read out the current gear, i hope you want to do using the ASPEP protocol. Please check the file sync_registers.c if it is useful.

j-fischer-gundlach
Associate III

I´ll spend a moment considreing that
-
though I currently think the intended way by ST to do custom things is different, and that the RegisterCallback() I mentioned is the way to do it. 
-
I found a document "Motor Control Protocol Suite" which has a section


5.1.6
The USER_CMD command
Purpose:
The
USER_CMD
commands are a set of command codes reserved for application use that will never be allocated to MCP commands. So, users are free touse these code for their own needs. In the ST MCSDK firmware implementation of the MCP, a call-back mechanism is provided for the application tohandle them if it needs. Up to 32 such commands can be implemented. See the documentation of ST MCSDK firmware for more details on how to usethem in the context of the firmware.

Looking in the file mcp.c there is a function "void MCP_ReceivedPacket(MCP_Handle_t *pHandle)"
which distinguishes based on bitmasks if there was a USER_CMD incomming. 

 


if ((command & MCP_USER_CMD_MASK) == MCP_USER_CMD)

{

userCommand = ((uint8_t)(command & 0xF8U) >> 3U);

command = MCP_USER_CMD;

}


The purpose of "command = MCP_USER_CMD;" is becomming clear when seeing the switch-case
structure in that function which has a relating case which uses the exact callback-array
which is filled when calling MCP_RegisterCallBack(...)
-
Also the xF8>>3 explains why the documentation says "up to 32" since xF8>>3 = 0b11111 which

are 32 combinations


case MCP_USER_CMD:

{

if ((userCommand < MCP_USER_CALLBACK_MAX) && (MCP_UserCallBack[userCommand] != NULL))

{

MCPResponse = MCP_UserCallBack[userCommand](pHandle->rxLength, pHandle->rxBuffer, txSyncFreeSpace,

&pHandle->txLength, pHandle->txBuffer);

}

else

{

MCPResponse = MCP_ERROR_CALLBACK_NOT_REGISTRED;

}

break;

}