Posts

"Reverse Engineering" in different programming languages?

A lot of engineers in one point of another needs to look through usually undocumented open source code, in order to modify/implement additional features. Using editor for bigger projects built in C/C++ (without OOP) can be unbelievably painful (my own experience). Two software that helped me a lot to reverse engineer my any source code are: 1) Doxygen : Creates nice documentation of all the functions in the project. It gives links to definition of each function, but more interesting is also can create call/caller graphs (for each function it gives graph of functions which it calls, and another graph of the function which call that function). It is completely a freeware, and the graphs are done using the dot program. 2) Understand : the free trial version of this application (14 days) is very handy, and is a bit more powerful comparing to Doxygen.

Multiline Regular Expressions

There are a lot of text editors that offer regular expression search and replace, but rare are those that support multiline regular expressions. In my case I need to find all the function headers with starting body bracket. example: "int a(int b, int c) {" should be changed with "int a(int b, int c) { printf("Entered function a");" Text editor that supports such thing is called "EditPad Pro". Besides multiline regular expression support, it also have coloring system for your regular expression, so u can debug your regex easier. To be edited with regular expressions that solved my problem

Same useful links while learning TinyOS

http://www.eecs.iu-bremen.de/wiki/index.php/TinyOS

Changing parameters in TinyOS via Makefile

Changing the Radio channel - Radio channel numbers have range between 11 to 26 - Add the following line in the Makefile before the Makerules CC2420_CHANNEL=x where x = [11 26] Changing the Radio Transmit power - Transmit power valid levels are 1 to 31 with power 1 equals to -25dBm and 31 equals to max (0dBm) - add the following line in the Makefile before the Makerules CFlags = -DCC2420_DEF_RFPower= x where x = [1 31] Changing the Active message group ID Add DEFAULT_LOCAL_GROUP = X to the makefile where X = [0×10 0×50]

Working with floating point in TinyOS

There are two ways to represent float in nesc. One way, is to do it through by convention using the exponent and mantissa, where you need to use 2^exponent. The function that does that is called powf(). The problem with using that function is that it is reaaaaallly slow. [QUOTE] ----8 DbgOut_P20_ON; r = logf((float)v / 10000.0); // takes up about 10 ms (!!) DbgOut_P20_OFF; ----8 and a ----8 DbgOut_P20_ON; r = powf (10,(float)v / 10000.0); // takes up about 32 ms (!!!!!!) DbgOut_P20_OFF; ----8 [/QUOTE] In case you need to have fast response, this function might not be your choice. One way to optimize the speed of those operations are: "I'd like to mention that pow (a,b) is MUCH harder to implement than exp(b). Use the latter whenever possible. In particular, if a is fixed, use exp(b * log(a)) rather than pow (a,b). ( In fact, that's a common low-precision implementation technique even when a is not fixed.) Also note that keeping ...

File Sharing between to PCs under Windows

Several times I badly needed the connection between to PCs and I never actually managed to make it working :( One thing I always forget to set is that both PCs have the same Workgroup, besides the part where you set your folder to be shared among PCs in the network.

Finally, clear explanation of TinyOS 2.x serial packet structure

Image
TinyOS 2.x A message sent through serial ports from motes to PC will typically look like this: 00 FF FF 00 00 08 00 09 19 77 02 07 00 13 00 00 The first byte 00 is the leading zero. After that, the whole packet is of the type " serial_packet_t ", defined in tinyos-2.x/tos/lib/serial/Serial.h . Inside the serial_packet_t structure, the first 7 bytes are of the type " serial_header_t" , which is also defined in tinyos-2.x/tos/lib/serial/Serial.h . In the case above, it would be FF FF 00 00 08 00 09 . Within the "serial_header_t", the following structure takes place: nx_am_addr_t dest // Destination (2 bytes) nx_am_addr_t src // Source (2 bytes) nx_uint8_t length // Payload Length (1 byte) nx_am_group_t group // Group ID (1 byte) nx_am_id_t type // Active Message Handler Type (1 byte), some enum value that you can def...