Ram Symbols
From NESTFE Wiki
Overview
RamSymbolsM is a module that allows the user to get or set any variable in a nesC application. The pc-side tool must know the sizes and memory addresses of all variables on the heap. This component is made to be used with the nescDecls system and the pytos RamSymbols module. See Development Environment Demo for more information on the RamSymbols module
The implementation of Ram Symbols can be found in tos/lib/RamSymbols
API
The RamSymbolsM module has two functions: "poke" and "peek". Poke is used to copy a value into a memory address and peek is used to read the value at a memory address. In pythos, all of a nesc application's ram symbols are imported into the environment as objects with poke and peek functions.
In pythos, the poke and peek functions can both take "arrayIndex" and "dereference" options to index into an array symbol or dereference a pointer symbol. For example:
>>> app.DrainM.sendPackets.poke(150)
.
[<class 'pytos.util.nescDecls.TosMsg'> object at 0x4caf6c0c:
TosMsg(am=5742) PokeResponseMsg, nodeID=1:
result_t value : 1
]
>>> app.DrainM.sendPackets.peek()
.
[<class 'pytos.util.nescDecls.TosMsg'> object at 0x4cafaaac:
TosMsg(am=5742) uint16_t, nodeID=1:
uint16_t value : 151
]
>>> app.TimerM.m_period.peek(arrayIndex=0)
.
[<class 'pytos.util.nescDecls.TosMsg'> object at 0x4cafa0cc:
TosMsg(am=5626) int32_t, nodeID=1:
int32_t value : 32000
]
>>> app.TestRpcM.testPtr.peek(dereference=True)
.
[<class 'pytos.util.nescDecls.TosMsg'> object at 0x4cb0022c:
TosMsg(am=5498) uint8_t, nodeID=1:
uint8_t value : 0
]
Setting Up
In order to use the API described above, the user must:
- use the new makesystem by setting the Makerules environment variable to point to the tinyos-1.x/tools/make/Makerules file
- add the following include directories to their makefile
CFLAGS += -I$(TOSDIR)/../tos/lib/RamSymbols
- include the RamSymbolsM module somewhere in their application
- invoke both the nescDecls.extra and the rpc.extra files in their make process by either declaring "nescDecls" on the command line when making the application as follows
make telosb rpc nescDecls
or adding it to the GOALS variable in their makefile
GOALS+=rpc GOALS+=nescDecls
For problems, the Pytos Installation Instructions setup instructions may contain more details.
