BeeStack definition

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

BeeStack definition

跳至解决方案
3,257 次查看
ming_
Contributor I

HI, I study on the BeeStack.

I show the macro and variables use prefix (g, m or gm) and suffix (_d,_c or _t).

Could you explain what's meaning of the prefix and suffix?

Is any other rules to know for better understanding the Freescale's code?

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
3,029 次查看
AlanCollins
Contributor V

s - stands for "static"

g - is used for global constants and enums

gm - is used for global variables.

User is the one that provides the private-public categories, by following standard rules. For example, if you are writing code for a protocol stack. You definetely need to manage public vs private categories while encapsulating the layers of the stack. In a communication stack, the network layer must have functions and variables only accesible by itself, to prevent other processes to change those internal-private variables. This guarantees proper functionaility of the layer itself , as a black box. The public functions and variables are the ones available for the upper layer (e.g. application framework) to use and modify as pleased.

So basically it all depends on encapsultating services, or processes in the form of libraries or black boxes. You dont need to know whats happening inside, you just need to understand the inputs signals and the expected outputs. So this is not pertinent of the language itself, its more like a "doing readable code", "fancy code", "quality assurance code"... 

在原帖中查看解决方案

0 项奖励
回复
6 回复数
3,029 次查看
AlanCollins
Contributor V

_d - means a configuration definition that helps to solve pre-compilation configuration. For example:

     PlatformToUse_d      FRMD_K64F

     Inside the code it is used:

     #if FRMD_K64F  == PlatformToUse_d     

         // configure GPIOs for FRDM board....

     ......

_c - means a constant value.

     PlatformToUse_c     (2000)      

_t - means a type definition.

     uint8_t means unisigned char.

Hope this helps.

3,029 次查看
ming_
Contributor I

Dear Alan

Thanks for good answer.

Could you explain about the prefix?

Here is example.

mNwkProtocolVersion_c

gAppStackProfile_c

if( gmUserInterfaceMode == gApplicationMode_c)

And any other prefix and/or suffix??

0 项奖励
回复
3,029 次查看
AlanCollins
Contributor V

g is for Global variables.

m is for modular variables. Meaning the variable is defined inside a module / library, and only accesible by that specific .c file. Even that linker saves an specific memory location for it. This module variable works inside a black box. :smileyhappy:

gm is quite interesting. I dont remember seeing that in the code. Could you please share where you've seen this?

Update:

talking with a peer, looks like g is related to global constants and enums. while gm is more for variables. Please help me to review that while using our stack, and let me know anything that goes outside this statement. :smileyhappy:

3,029 次查看
ming_
Contributor I

Dear Alan

I found the prefix 'gm' on the ASL

And it looks like ... ( I am not quite understand 'gm' yet....)

prefix g : global  (It make sense to me)

prefix m: moulder (local)

prefix s: looks like constant

prefix p: pointer

prefix z:

On the 'ASL_Userinterface.c'

/******************************************************************************

*******************************************************************************

* Private memory declarations

*******************************************************************************

******************************************************************************/

const uint8_t gsASL_LeaveNetwork[] = "Leave network";

#if (gCoordinatorCapability_d)

  const uint8_t gsASL_StartingNwk[] = "Starting Network";

#else

  const uint8_t gsASL_StartingNwk[] = "Joining Network";

#endif

.....

.....

uint8_t *gpszAslAppName;

const uint8_t gszAslCfgMode[] = "Cfg";

const uint8_t gszAslAppMode[] = "App";

const uint8_t gszAslNoNwkAddr[] = "----";

......

......

/******************************************************************************

*******************************************************************************

* Public memory declarations

*******************************************************************************

******************************************************************************/

/* Variables to keep track of the status of the Display on the AppMode or ConfigMode */

// ASL_DisplayStatus_t gAppModeDisplay;

// ASL_DisplayStatus_t gConfigModeDisplay;

// uint8_t gmUserInterfaceMode;

ASL_Data_t gAslData;

uint8_t gmUserInterfaceMode;

++++++++++++++++++

And additional question.

How It categorize Public and Private in C?

I don't think C can inheritance...

0 项奖励
回复
3,030 次查看
AlanCollins
Contributor V

s - stands for "static"

g - is used for global constants and enums

gm - is used for global variables.

User is the one that provides the private-public categories, by following standard rules. For example, if you are writing code for a protocol stack. You definetely need to manage public vs private categories while encapsulating the layers of the stack. In a communication stack, the network layer must have functions and variables only accesible by itself, to prevent other processes to change those internal-private variables. This guarantees proper functionaility of the layer itself , as a black box. The public functions and variables are the ones available for the upper layer (e.g. application framework) to use and modify as pleased.

So basically it all depends on encapsultating services, or processes in the form of libraries or black boxes. You dont need to know whats happening inside, you just need to understand the inputs signals and the expected outputs. So this is not pertinent of the language itself, its more like a "doing readable code", "fancy code", "quality assurance code"... 

0 项奖励
回复
3,029 次查看
ming_
Contributor I

Thanks for good info.

That's why all private variable or parameter has const and static. and I think it should be better to defined at the initialize time.  

0 项奖励
回复