D’ale Programatorilor. Partea a 2-a

Am dat peste o mostra de geniu intr-un cod scris de unii care voiau sa scrie ceva pe CAN.

Daca nu stiti ce-i ala CAN, sau in general daca nu aveti notiuni generale de programare si logica matematica, v-as sfatui sa va opriti aici.  Pentru ceilalti, urmeaza niste bucati de cod care fac un scurt rezumat a logicii de necombatut a voinicului programator. Nu va luati de greseli de sintaxa, concentrati-va la cea de logica.

Avem urmatoarele structuri de date (fara sa verific daca nu-s probleme de sintaxa, presupunem ca-s declarate ok)

struct stCanNetwork {
    uint8 u8Index;
    unint16 u16BaudRate
} tstCanNetwork;

tstCanNetwork astListOfNetworks[2] ={
{3, 19000};
{7, 25000}
};

#define IsValidCanNetwork (astListOfNetworks[0].u8Index ||  astListOfNetworks[1].u8Index)

Apoi avem o functie

void vSendDataOnNetwork(u8MyNetworkIndex, *pu16AddressOfBuffer){
…..
if (u8MyNetworkIndex == IsValidCanNetwork)
    transmite chestii
else
    da eroare
…..
}

Atat. Acu sa facem un sondaj de opinie. Ce ziceti ca se intampla? Se vor transmite chestii sau va da eroare ?

Advertisements

About Josef Svejk
Through possibly-feigned idiocy or incompetence he repeatedly manages to frustrate military authority and expose its stupidity in a form of passive resistance: the reader is left unclear, however, as to whether Švejk is genuinely incompetent, or acting quite deliberately with dumb insolence. These absurd events reach a climax when Švejk, wearing a Russian uniform, is mistakenly taken prisoner by his own troops. Source: Wikipedia

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: