I'm using FreeMaster to be my runtime debuging tool, I need a function: the target can put out some log(string type) when I debug the target. so I read the FreeMaster User Manual . PIPE Maybe can be done ,but I don't know how to use this function,can give me an example?
I'm using the S32k1 series . please
Solved! Go to Solution.
Hi @baiRB,
There is an example application available in FreeMASTER Communication driver folder.
where S32DS.x.y is your Design Studio version.
On a high level you use FMSTR_PipeOpen to create a Pipe with unique ID, assign pipe message handler and assign read and write buffers ex:
FMSTR_HPIPE hpipe;
static unsigned char pipe1_rxb[10];
static unsigned char pipe1_txb[100];
hpipe = FMSTR_PipeOpen(1, my_pipe_handler,
(FMSTR_ADDR)pipe1_rxb, sizeof(pipe1_rxb),
(FMSTR_ADDR)pipe1_txb, sizeof(pipe1_txb));
and inside your pipe handler you read incoming data, process it and return an output:
static void my_pipe_handler(FMSTR_HPIPE hpipe)
{
static const char* names[10] =
{
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"
};
static char buff[4];
char* n;
char c;
/* This simple handler translates the digits into number names.
* Other characters are just echoed back. */
while(FMSTR_PipeRead(hpipe, (FMSTR_ADDR)buff, 1, 0))
{
c = buff[0];
if(c >= '0' && c <= '9')
{
/* A tiny strlen */
n = (char*) names[c-'0'];
FMSTR_PipeWrite(hpipe, (FMSTR_ADDR)n, my_strlen(n), 0);
}
else
{
/* Echo */
FMSTR_PipeWrite(hpipe, (FMSTR_ADDR)buff, 1, 0);
}
}
}
this is a default example that reads digits from the host and returns their numeric representation (1→one, 2→two etc.).
One last detail - do not forget to add corresponding configuration to freemaster_cfg.h
/*****************************************************************************
* Pipes as data streaming over FreeMASTER protocol
******************************************************************************/
#define FMSTR_USE_PIPES 3 /* Enable/Disable pipes */
#define FMSTR_MAX_PIPES_COUNT 3 /* 3 pipes for demo purposes */
Hope it helps,
Iulian
Hi @baiRB,
There is an example application available in FreeMASTER Communication driver folder.
where S32DS.x.y is your Design Studio version.
On a high level you use FMSTR_PipeOpen to create a Pipe with unique ID, assign pipe message handler and assign read and write buffers ex:
FMSTR_HPIPE hpipe;
static unsigned char pipe1_rxb[10];
static unsigned char pipe1_txb[100];
hpipe = FMSTR_PipeOpen(1, my_pipe_handler,
(FMSTR_ADDR)pipe1_rxb, sizeof(pipe1_rxb),
(FMSTR_ADDR)pipe1_txb, sizeof(pipe1_txb));
and inside your pipe handler you read incoming data, process it and return an output:
static void my_pipe_handler(FMSTR_HPIPE hpipe)
{
static const char* names[10] =
{
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine"
};
static char buff[4];
char* n;
char c;
/* This simple handler translates the digits into number names.
* Other characters are just echoed back. */
while(FMSTR_PipeRead(hpipe, (FMSTR_ADDR)buff, 1, 0))
{
c = buff[0];
if(c >= '0' && c <= '9')
{
/* A tiny strlen */
n = (char*) names[c-'0'];
FMSTR_PipeWrite(hpipe, (FMSTR_ADDR)n, my_strlen(n), 0);
}
else
{
/* Echo */
FMSTR_PipeWrite(hpipe, (FMSTR_ADDR)buff, 1, 0);
}
}
}
this is a default example that reads digits from the host and returns their numeric representation (1→one, 2→two etc.).
One last detail - do not forget to add corresponding configuration to freemaster_cfg.h
/*****************************************************************************
* Pipes as data streaming over FreeMASTER protocol
******************************************************************************/
#define FMSTR_USE_PIPES 3 /* Enable/Disable pipes */
#define FMSTR_MAX_PIPES_COUNT 3 /* 3 pipes for demo purposes */
Hope it helps,
Iulian