2018-01-19 12:51 AM
Hi.
The below function is called by a few events.
int sendDeviceEvent(int idx, char type){
int result; char *buff; if(type == TYPE_REG) { makeRegInfo(idx,buff); sendInfoToSlave(buff, sizeof(sRegPoll)); } else if(type == TYPE_128) { make128Info(idx,buff); sendInfoToSlave(buff, sizeof(s128Poll)); } else if(type == TYPE_INV) { makeInvInfo(idx,buff); sendInfoToSlave(buff, sizeof(sInvPoll)); }return waitInfoFromSlave(idx);
}If this function is called by EVENT_A(
sendDeviceEvent(1,
TYPE_REG
)),sendInfoToSlave(buff, sizeof(sRegPoll)) is executed normally.
But If this function is called by EVENT_B(
sendDeviceEvent(1,
TYPE_REG
)),sendInfoToSlave(buff, sizeof(sRegPoll)) is not executed. That is, is not branched to sendInfoToSlave().
Which point should I check? (IAR, ST32F2xx series)
Thanks.
2018-01-19 12:58 AM
So have you stepped through it in the debugger to see exactly what's happening?
Any particular reason for not using a switch here?
2018-01-19 01:43 AM
How strongly do you know that TYPE_REG is the same thing in both calls?
My guess is that somewhere in your code you have #define TYPE_REG value
Are EVENT_A and EVENT_B in the same (c or c++) source-code file?
If they are from different source-code files, it is possible that the #defines are different - unless you put the #define in a single header that you #include in both source-code files.
Please don't feel insulted that I raised this as a possibility. It is an easy mistake to make.
Danish
2018-01-19 03:09 AM
Hi, Danish.
By EVENT_A and EVENT_B, the function,
makeRegInfo(idx,buff) is executed normally.
Only the function,
sendInfoToSlave(buff, sizeof(sRegPoll) is not executed.
So it is a mistake to think that the definition of
TYPE_REG would be wrong.
Thanks.
2018-01-19 04:35 AM
So, again, have you stepped through it in the
debuggerto see exactly what's happening?