Wednesday, September 28, 2005


During a software design I had to store a huge frame inside variables that were valid data that needed further processing . Instead of using a simple solution, which will be given next, I declared a bunch of variables to accomplish it. Suppose you have a frame:

void processFrame( unsigned char * uFrame )
/* copy it to several variables here */
memcpy( &myvar[0], &uFrame[0], 12 );

The above code will save the 12 bytes in a myvar variable. Suppose you have a huge list of bytes, instead of copying each one of them to variables, simply declare a struct to store everything.

struct MyStruct{
unsigned char a[12];
unsigned char b[2];
/* and it may go further*/
} myStructReal;

Next, just point to the first address of the structure and sum up the total of bytes:

memcpy( &myStructReal, &fFrame[0], totalofbytes);

Ok, you will have to be sure of how many bytes will come inside the data frame, but generally you know it. It is a major ellegant and simpler solution. As, C treats structures as a series of data addresses, it will fit your huge array of bytes into a struct, piece of cake right?

Thursday, September 15, 2005

They say that president Lula is stupid


I can acuse him of several faults, but most people mention that he´s not intelligent or that he does not speak portuguese properly. As a former PT and Lula supporter I can say that I read many Lula interviews and articles and also heard interviews given on TV and believe me, although he didn´t have formal education, the guy has a huge cultural knowledge.

However, it won´t take away all the accusations ....

Tuesday, September 13, 2005

Programmer or hobbyst?

I make a living programming embedded systems in C, could also program in C++ or programming PLCs or being an automation engineer. But, I consider programming a hobby also. For many years, Java was my hobby but I became disappointed with it because I thought I´d work with Java professionally. After sometime, I still find Java funny, although I bash it, and usefull for a certain usage but I got annoyed with Java programmers or J2EE programmers. So, as hobby I´ll use python, which I like a lot too.

Daily, ANSI C comes all the day. With some free time, it is python.

Wednesday, September 07, 2005


Forget anything I said about Java. I hate it ...

It does not mean that I will refuse to code Java. Java programmers are most of times too arrogant and produce a bunch of senseless terms and APIs.