SOP 001-Programmation » Historique » Version 68
  Patrice Nadeau, 2018-03-31 16:05 
  
| 1 | 17 | Patrice Nadeau | # SOP 001-Programmation  | 
|---|---|---|---|
| 2 | 1 | Patrice Nadeau | |
| 3 | Mes standards autant au niveau du style que de la documentation.  | 
||
| 4 | |||
| 5 | 11 | Patrice Nadeau | La plate-forme (logiciel et matériel) est documenté dans le [[SOP_002-Environnement_informatique]].  | 
| 6 | 1 | Patrice Nadeau | |
| 7 | {{lastupdated_at}} {{lastupdated_by}} | 
||
| 8 | |||
| 9 | ---  | 
||
| 10 | |||
| 11 | {{toc}} | 
||
| 12 | |||
| 13 | 17 | Patrice Nadeau | ## Diagrammes  | 
| 14 | 1 | Patrice Nadeau | |
| 15 | Les représentations des différents processus d’un programme ou d’un circuit.  | 
||
| 16 | |||
| 17 | Les diagrammes DOIVENT être faits avec le logiciel Dia.  | 
||
| 18 | Ils PEUVENT être exportés en d’autre format.  | 
||
| 19 | |||
| 20 | 17 | Patrice Nadeau | ### LibreOffice Draw  | 
| 21 | 14 | Patrice Nadeau | |
| 22 | Icônes :  | 
||
| 23 | 17 | Patrice Nadeau | |
| 24 | 15 | Patrice Nadeau | * Cisco : http://www.cisco.com/web/about/ac50/ac47/3015_jpeg.zip  | 
| 25 | 16 | Patrice Nadeau | * http://www.vrt.com.au/downloads/vrt-network-equipment ou http://extensions.libreoffice.org/extension-center/vrt-network-equipment/  | 
| 26 | 14 | Patrice Nadeau | |
| 27 | 17 | Patrice Nadeau | ## Système de gestion de version  | 
| 28 | 1 | Patrice Nadeau | |
| 29 | 42 | Patrice Nadeau | Le logiciel [Git](http://www.git-scm.com/) DOIT être utilisé.  | 
| 30 | 1 | Patrice Nadeau | |
| 31 | 42 | Patrice Nadeau | La version DOIT être en format: *majeur*.*mineur*.*revision*.  | 
| 32 | Les nombres *majeur*, *mineur* NE DOIVENT PAS contenir de zéro non significatif et DEVRAIT se limiter à deux chiffres.  | 
||
| 33 | 1 | Patrice Nadeau | |
| 34 | Ex.  | 
||
| 35 | > Version 1.2.06  | 
||
| 36 | |||
| 37 | 42 | Patrice Nadeau | Les modifications DOIVENT se faire avec **git commit**, de la manière suivante :  | 
| 38 | 17 | Patrice Nadeau | |
| 39 | 1 | Patrice Nadeau | * nom du fichier modifié,  | 
| 40 | * 1 espace,  | 
||
| 41 | * nom de l’item modifié entre parenthèses,  | 
||
| 42 | * un deux- points (<notextile>:</notextile>) sans espace avec l’item précédent,  | 
||
| 43 | * 1 espace,  | 
||
| 44 | * le texte du changement en anglais, commençant par une majuscule, au présent,  | 
||
| 45 | * un point (.)  | 
||
| 46 | |||
| 47 | Ex. :  | 
||
| 48 | > Modification ajouté manuellement  | 
||
| 49 | 40 | Patrice Nadeau | |
| 50 | |||
| 51 | git commit -m "usart.c (usart_Init): Add a new variable ctr."  | 
||
| 52 | |||
| 53 | 1 | Patrice Nadeau | > Modification par un éditeur texte  | 
| 54 | |||
| 55 | 40 | Patrice Nadeau | git commit  | 
| 56 | |||
| 57 | 17 | Patrice Nadeau | Si les commit sont fait sans l’option **-m**, chaque fichier DOIT être séparé par une ligne vide.  | 
| 58 | 1 | Patrice Nadeau | |
| 59 | 17 | Patrice Nadeau | ## Code source  | 
| 60 | 1 | Patrice Nadeau | |
| 61 | Les différents type de langage et de script décrit dans ce SOP.  | 
||
| 62 | |||
| 63 | 17 | Patrice Nadeau | ### Généralités  | 
| 64 | 1 | Patrice Nadeau | |
| 65 | 17 | Patrice Nadeau | #### Langue  | 
| 66 | 1 | Patrice Nadeau | |
| 67 | La langue (macros, variables, fonctions, commentaires, etc...) DOIT être l’anglais.  | 
||
| 68 | |||
| 69 | 17 | Patrice Nadeau | #### Commentaires  | 
| 70 | 1 | Patrice Nadeau | |
| 71 | Les commentaires DOIVENT être :  | 
||
| 72 | 17 | Patrice Nadeau | |
| 73 | 1 | Patrice Nadeau | * sur la ligne précédent l’item à documenter  | 
| 74 | * en minuscules et commencer par une majuscule  | 
||
| 75 | |||
| 76 | 17 | Patrice Nadeau | |
| 77 | 1 | Patrice Nadeau | #### Nombre magique  | 
| 78 | 17 | Patrice Nadeau | |
| 79 | 40 | Patrice Nadeau | L’utilisation de [nombre magique](:http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Unnamed_numerical_constants) ne DOIT PAS être utilisé directement dans le code.  | 
| 80 | 1 | Patrice Nadeau | Il DOIVENT être définis dans une macro ou une variable globale.  | 
| 81 | |||
| 82 | 17 | Patrice Nadeau | ## C  | 
| 83 | 1 | Patrice Nadeau | |
| 84 | Le langage C, version C99 (ISO/IEC 9899:1999) utilisé avec le compilateur GCC.  | 
||
| 85 | |||
| 86 | 17 | Patrice Nadeau | ### Commentaires  | 
| 87 | 1 | Patrice Nadeau | |
| 88 | Les commentaires ne devant pas être inclus dans une documentation, DOIVENT être de style « C » :  | 
||
| 89 | |||
| 90 | 65 | Patrice Nadeau | ``` c  | 
| 91 | /* Une seule ligne... */  | 
||
| 92 | 1 | Patrice Nadeau | |
| 93 | 65 | Patrice Nadeau | ...  | 
| 94 | 17 | Patrice Nadeau | |
| 95 | 65 | Patrice Nadeau | /*  | 
| 96 | * Sur  | 
||
| 97 | * plusieurs  | 
||
| 98 | * lignes  | 
||
| 99 | */  | 
||
| 100 | ```  | 
||
| 101 | 1 | Patrice Nadeau | |
| 102 | 17 | Patrice Nadeau | ### Doxygen  | 
| 103 | 1 | Patrice Nadeau | |
| 104 | 17 | Patrice Nadeau | Chaque item DOIT être documentés de manière à générer une documentation avec le logiciel [Doxygen](http://www.stack.nl/~dimitri/doxygen/index.html).  | 
| 105 | 1 | Patrice Nadeau | |
| 106 | Seulement les items définis dans les fichiers d’en-tête sont documentés par défaut.  | 
||
| 107 | Un commentaire Doxygen commence par *<notextile> /** </notextile>* , le compilateur le comprenant comme un commentaire ordinaire.  | 
||
| 108 | |||
| 109 | Les règles typographiques du [[SOP_000-Documentation]] s’appliquent :  | 
||
| 110 | 17 | Patrice Nadeau | |
| 111 | 44 | Patrice Nadeau | * Gras (**@b**) : Items devant être inscrit tel quel.  | 
| 112 | * Italique & emphase (**@e**) : Items à remplacer par un choix ou nécessitant une attention particulière.  | 
||
| 113 | 1 | Patrice Nadeau | |
| 114 | > Doxygen version ≥ 1.8.8 : Le bogue "737472":https://bugzilla.gnome.org/show_bug.cgi?id=737472 oblige de forcer le langage de la fonction dans l’exemple si on ne veut pas de numéro de ligne.  | 
||
| 115 | |||
| 116 | Les items DOIVENT être inscrit dans cet ordre :  | 
||
| 117 | 6 | Patrice Nadeau | |
| 118 | 55 | Patrice Nadeau | ``` c  | 
| 119 | /**  | 
||
| 120 | * @brief Short description  | 
||
| 121 | * @param[in,out] var Description. @n Possible values :  | 
||
| 122 | * − @b value1  | 
||
| 123 | * − @b value2  | 
||
| 124 | * @return  | 
||
| 125 | * @retval @b value Description  | 
||
| 126 | * @par Example :  | 
||
| 127 | * Example Title  | 
||
| 128 | * @code{.c} | 
||
| 129 | * ...  | 
||
| 130 | * @endcode  | 
||
| 131 | * @pre Requirements  | 
||
| 132 | * @post Changes after the call to this function  | 
||
| 133 | * @see See also ...  | 
||
| 134 | * @note  | 
||
| 135 | * @warning  | 
||
| 136 | * @bug  | 
||
| 137 | * @todo  | 
||
| 138 | */  | 
||
| 139 | ```  | 
||
| 140 | 1 | Patrice Nadeau | |
| 141 | 45 | Patrice Nadeau | Des **@todo**, **@warning** et **@bug** supplémentaires PEUVENT être ajoutés dans le code.  | 
| 142 | L’item **@brief** DOIT toujours exister.  | 
||
| 143 | 1 | Patrice Nadeau | |
| 144 | 17 | Patrice Nadeau | ### Code  | 
| 145 | 1 | Patrice Nadeau | |
| 146 | Le code est dans le style K&R, variante 1TBS  | 
||
| 147 | 17 | Patrice Nadeau | |
| 148 | 1 | Patrice Nadeau | * Le « tab » DOIT être équivalent à 4 espaces.  | 
| 149 | * Le « backslah » DOIT être utilisé pour les lignes de plus de 80 caractères.  | 
||
| 150 | * Une instruction par ligne.  | 
||
| 151 | 46 | Patrice Nadeau | * Un espace avant et après un opérateur sauf pour les opérateurs « [unary](http://en.wikipedia.org/wiki/Unary_operation).  | 
| 152 | 1 | Patrice Nadeau | |
| 153 | One True Brace Style  | 
||
| 154 | 25 | Patrice Nadeau | |
| 155 | 56 | Patrice Nadeau | ``` c  | 
| 156 | int fonction (void)  | 
||
| 157 | { | 
||
| 158 | int x;  | 
||
| 159 | /* the comment goes here, before the loop */  | 
||
| 160 |     if (var != 1) { | 
||
| 161 | x = x + 1;  | 
||
| 162 | y++;  | 
||
| 163 |         printf("This is a long\ | 
||
| 164 | line that should be splitted");  | 
||
| 165 |     } else { | 
||
| 166 | /** @warning this is a Doxygen warning */  | 
||
| 167 | x--;  | 
||
| 168 | }  | 
||
| 169 | return(0);  | 
||
| 170 | }  | 
||
| 171 | ```  | 
||
| 172 | 17 | Patrice Nadeau | |
| 173 | 1 | Patrice Nadeau | #### Fichier entête  | 
| 174 | 17 | Patrice Nadeau | |
| 175 | 1 | Patrice Nadeau | Avertissement  | 
| 176 | 46 | Patrice Nadeau | >Le gabarit **template.h** DOIT être utilisé.  | 
| 177 | 1 | Patrice Nadeau | |
| 178 | 25 | Patrice Nadeau | Les fichiers « header » DOIVENT contenir les déclarations des fonctions, macros et la partie « mainpage » de Doxygen.  | 
| 179 | 1 | Patrice Nadeau | |
| 180 | Le nom du fichier DOIT être composé de la manière suivante :  | 
||
| 181 | |||
| 182 | 17 | Patrice Nadeau | * en minuscule  | 
| 183 | 1 | Patrice Nadeau | * 8 caractères maximum  | 
| 184 | 47 | Patrice Nadeau | * l’extension DOIT être **.h**  | 
| 185 | 1 | Patrice Nadeau | |
| 186 | Une définition macro DOIT être faite pour éviter de ré-inclure le fichier.  | 
||
| 187 | La macro DOIT être dans le format *_fichier_h*  | 
||
| 188 | 25 | Patrice Nadeau | |
| 189 | 57 | Patrice Nadeau | ``` c  | 
| 190 | #ifndef _usart_h  | 
||
| 191 | #define _usart_h  | 
||
| 192 | ...  | 
||
| 193 | 58 | Patrice Nadeau | |
| 194 | 57 | Patrice Nadeau | #endif /*_usart.h*/  | 
| 195 | ```  | 
||
| 196 | 25 | Patrice Nadeau | |
| 197 | 1 | Patrice Nadeau | #### Fichier source  | 
| 198 | 17 | Patrice Nadeau | |
| 199 | 1 | Patrice Nadeau | Le nom du fichier DOIT être composé de la manière suivante :  | 
| 200 | 25 | Patrice Nadeau | |
| 201 | 1 | Patrice Nadeau | * en minuscule  | 
| 202 | * 8 caractères maximum  | 
||
| 203 | 60 | Patrice Nadeau | * l’extension DOIT être **.c**  | 
| 204 | 1 | Patrice Nadeau | |
| 205 | 17 | Patrice Nadeau | #### Librairies  | 
| 206 | 1 | Patrice Nadeau | |
| 207 | Fichiers comprenant plusieurs déclarations et définitions reliés entre eux.  | 
||
| 208 | |||
| 209 | * Le nom DOIT respecter les standards ([[SOP_001-Programmation#Fichiers-Entêtes|1]] & [[SOP_001-Programmation#Fichiers-Sources|2]]) et être significatifs.  | 
||
| 210 | * Un fichier d’entête DOIT toujours exister.  | 
||
| 211 | * Les items sont précédés du nom de la librairie (minuscule) et séparés par un « underscore » (_).  | 
||
| 212 | |||
| 213 | L’utilisation de macros DOIT être utilisé au lieu de constates globales.  | 
||
| 214 | Il NE DEVRAIT PAS exister de de variables globales.  | 
||
| 215 | |||
| 216 | #### Déclarations locales  | 
||
| 217 | 17 | Patrice Nadeau | |
| 218 | 1 | Patrice Nadeau | Une déclaration n’ayant qu’une visibilité locale DOIT être précédé d’un « underscore » (_) et être de classe *static*.  | 
| 219 | |||
| 220 | 59 | Patrice Nadeau | ``` c  | 
| 221 | 58 | Patrice Nadeau | /**  | 
| 222 | * @brief Local function  | 
||
| 223 | **/  | 
||
| 224 | static void _LocalFunc(void)  | 
||
| 225 | { | 
||
| 226 | ...  | 
||
| 227 | return;  | 
||
| 228 | }  | 
||
| 229 | 1 | Patrice Nadeau | ```  | 
| 230 | |||
| 231 | 17 | Patrice Nadeau | #### Items désuets  | 
| 232 | 1 | Patrice Nadeau | |
| 233 | Les déclarations ne devant plus être utilisés, DOIVENT générer un message lors de la compilation (*-Wall*) si un appel est effectué.  | 
||
| 234 | 48 | Patrice Nadeau | |
| 235 | 1 | Patrice Nadeau | L’attribut **__attribute\_\_((deprecated))** DOIT être ajouté à la déclaration.  | 
| 236 | La documentation DOIT indiquer les substituts à utiliser.  | 
||
| 237 | 25 | Patrice Nadeau | |
| 238 | 65 | Patrice Nadeau | ``` c  | 
| 239 | 58 | Patrice Nadeau | /**  | 
| 240 | * @brief OldFunction  | 
||
| 241 | * @detail will generate a warning if used  | 
||
| 242 | * @see @b NewFunction  | 
||
| 243 | */  | 
||
| 244 | int OldFunction(void) __attribute__((deprecated));  | 
||
| 245 | ```  | 
||
| 246 | 1 | Patrice Nadeau | |
| 247 | #### Constantes  | 
||
| 248 | |||
| 249 | 29 | Patrice Nadeau | La déclaration DOIT inclure aussi la définition.  | 
| 250 | 1 | Patrice Nadeau | |
| 251 | 29 | Patrice Nadeau | Utilisé au lieu d’une macro quand le type ou la visibilité de la variable doit être définis.  | 
| 252 | 26 | Patrice Nadeau | |
| 253 | * En majuscule  | 
||
| 254 | * Séparé par un «underscore» (_) si contient plusieurs mots  | 
||
| 255 | * De classe _static_ ou _extern_ selon le besoin  | 
||
| 256 | 1 | Patrice Nadeau | |
| 257 | 26 | Patrice Nadeau | Ex. :  | 
| 258 | |||
| 259 | 65 | Patrice Nadeau | ``` c  | 
| 260 | 58 | Patrice Nadeau | /**  | 
| 261 | * @name List of constants  | 
||
| 262 | * @{ | 
||
| 263 | */  | 
||
| 264 | 26 | Patrice Nadeau | |
| 265 | 58 | Patrice Nadeau | /**  | 
| 266 | * @brief Local const  | 
||
| 267 | */  | 
||
| 268 | static int _PI = 3.15;  | 
||
| 269 | /**  | 
||
| 270 | * @brief The initialization string of the project  | 
||
| 271 | */  | 
||
| 272 | static const char INIT_STR[6] = {'P', 'O', 'W', 'E', 'R'}; | 
||
| 273 | /**  | 
||
| 274 | * @brief Global const in the random library  | 
||
| 275 | */  | 
||
| 276 | extern int random_MAX = 25;  | 
||
| 277 | 30 | Patrice Nadeau | |
| 278 | 58 | Patrice Nadeau | /**  | 
| 279 | * @}  | 
||
| 280 | */  | 
||
| 281 | ```  | 
||
| 282 | 1 | Patrice Nadeau | |
| 283 | 30 | Patrice Nadeau | #### Typedef  | 
| 284 | |||
| 285 | Format :  | 
||
| 286 | |||
| 287 | 66 | Patrice Nadeau | * En minuscule, suivie de **_t**  | 
| 288 | 31 | Patrice Nadeau | |
| 289 | Définition de typedef  | 
||
| 290 | |||
| 291 | 65 | Patrice Nadeau | ``` c  | 
| 292 | 31 | Patrice Nadeau | /** Unsigned integer 8 bits */  | 
| 293 | typedef unsigned int new_t  | 
||
| 294 | /** Type of structure in the ds1305 library */  | 
||
| 295 |     typedef struct { | 
||
| 296 | /** @brief last two digits : ≥ 00, ≤ 99 */  | 
||
| 297 | uint8_t year;  | 
||
| 298 | /** @brief 01 - 12 */  | 
||
| 299 | uint8_t month;  | 
||
| 300 | /** @brief 01 - 31 */  | 
||
| 301 | 30 | Patrice Nadeau | uint8_t date;  | 
| 302 | 1 | Patrice Nadeau | /** @brief 1 - 7 */  | 
| 303 | uint8_t day;  | 
||
| 304 | /** @brief 00 - 23 */  | 
||
| 305 | uint8_t hours;  | 
||
| 306 | 49 | Patrice Nadeau | /** @brief 00 - 59 */  | 
| 307 | uint8_t minutes;  | 
||
| 308 | 1 | Patrice Nadeau | /** @brief 00 - 59 */  | 
| 309 | uint8_t seconds;  | 
||
| 310 | } ds1305_time_t;  | 
||
| 311 | 65 | Patrice Nadeau | ```  | 
| 312 | 1 | Patrice Nadeau | |
| 313 | #### Variables  | 
||
| 314 | 40 | Patrice Nadeau | |
| 315 | Format :  | 
||
| 316 | |||
| 317 | * En minuscule.  | 
||
| 318 | 1 | Patrice Nadeau | * Séparé par un « underscore » (_) si contient plusieurs mots.  | 
| 319 | 40 | Patrice Nadeau | |
| 320 | 1 | Patrice Nadeau | Définition de variables  | 
| 321 | |||
| 322 | 65 | Patrice Nadeau | ``` c  | 
| 323 | 1 | Patrice Nadeau | /** @brief Local variable */  | 
| 324 | int _ctr;  | 
||
| 325 | /** @brief Global variable from the random librairy */  | 
||
| 326 | int random_ctr;  | 
||
| 327 | 65 | Patrice Nadeau | ```  | 
| 328 | 40 | Patrice Nadeau | |
| 329 | #### Structures  | 
||
| 330 | |||
| 331 | Format  | 
||
| 332 | * En minuscule, séparé par des «underscores» si nécessaire.  | 
||
| 333 | |||
| 334 | Définition de structures  | 
||
| 335 | |||
| 336 | 65 | Patrice Nadeau | ``` c  | 
| 337 | 40 | Patrice Nadeau | /**  | 
| 338 | 1 | Patrice Nadeau | * @brief Structure for a local menu  | 
| 339 | 40 | Patrice Nadeau | * @see MenuSelect  | 
| 340 | 17 | Patrice Nadeau | */  | 
| 341 | 1 | Patrice Nadeau |     struct menu { | 
| 342 | /** @brief Character used for the item */  | 
||
| 343 | 5 | Patrice Nadeau | char choice;  | 
| 344 | /** @brief Description of the item */  | 
||
| 345 | 32 | Patrice Nadeau | char *item;  | 
| 346 | 5 | Patrice Nadeau | };  | 
| 347 | 65 | Patrice Nadeau | ```  | 
| 348 | 5 | Patrice Nadeau | |
| 349 | 1 | Patrice Nadeau | #### Fonctions  | 
| 350 | |||
| 351 | Le nom est formé d’une lettre majuscule pour chacune des premières lettres des mots.  | 
||
| 352 | |||
| 353 | Le nom DOIT être dans un deux formats suivants :  | 
||
| 354 | |||
| 355 | * ActionItemAttribut, où _Action_ signifie :  | 
||
| 356 | ** *Get* : Lis un registre  | 
||
| 357 | ** *Read*, *Write* : Lis ou écris dans un fichier  | 
||
| 358 | ** *Set* : Écris une valeur prédéfini dans un registre  | 
||
| 359 | ** *Init* : Fonction d’initialisation  | 
||
| 360 | * isItemEtat  | 
||
| 361 | 32 | Patrice Nadeau | ** *is* : Verifie si _Item_ est dans l’état _Etat_  | 
| 362 | |||
| 363 | Exception  | 
||
| 364 | 50 | Patrice Nadeau | > Les fonctions définies dans une librairie de bas niveau pour du matériel (« driver »). Dans ce cas, le nom définis dans le « datasheet » aura préséance. Ex. ReadRegister.  | 
| 365 | 32 | Patrice Nadeau | |
| 366 | 1 | Patrice Nadeau | Une fonction DEVRAIT retourner une valeur.  | 
| 367 | |||
| 368 | 32 | Patrice Nadeau | Dans le cas d'un « oui/non », la valeur DOIT être :  | 
| 369 | |||
| 370 | 1 | Patrice Nadeau | * Succès : **0**  | 
| 371 | 32 | Patrice Nadeau | * Erreur : **1**  | 
| 372 | 1 | Patrice Nadeau | |
| 373 | 32 | Patrice Nadeau | > L'utilisation d'un type booléen (*true* & *false*) est permise avec la librairie **\<stbool.h\>** (C99).  | 
| 374 | |||
| 375 | Dans le cas d'une fonction retournant un pointeur :  | 
||
| 376 | |||
| 377 | * Erreur : **NULL**  | 
||
| 378 | * Autre valeur : adresse du pointeur  | 
||
| 379 | |||
| 380 | |||
| 381 | Définition de fonctions  | 
||
| 382 | |||
| 383 | 63 | Patrice Nadeau | ``` c  | 
| 384 | /**  | 
||
| 385 | * @brief Check if a timer is set  | 
||
| 386 | * @param[in] nb Timer number. @n Possible values :  | 
||
| 387 | * − @b TIMER_1  | 
||
| 388 | * − @b TIMER_2  | 
||
| 389 | * @return  | 
||
| 390 | * @retval true Timer @e nb is set  | 
||
| 391 | * @retval false Timer @e nb is NOT set  | 
||
| 392 | * @par Example :  | 
||
| 393 | * Check if the timer is set  | 
||
| 394 | * @code{.c} | 
||
| 395 | * ...  | 
||
| 396 | * result = isTimerSet();  | 
||
| 397 | * ...  | 
||
| 398 | * @endcode  | 
||
| 399 | * @pre TimerInit  | 
||
| 400 | **/  | 
||
| 401 | |||
| 402 | static bool isTimerSet(uint8_t nb);  | 
||
| 403 | /**  | 
||
| 404 | * @brief Set the led to green  | 
||
| 405 | **/  | 
||
| 406 | SetLedColor(GREEN);  | 
||
| 407 | /**  | 
||
| 408 | * @brief Set register of the chip XYZ  | 
||
| 409 | *  | 
||
| 410 | * The name does not follow the standards but does match the datatsheet  | 
||
| 411 | * This is a local function not meant to be called outside this librairy  | 
||
| 412 | **/  | 
||
| 413 | static void _WriteReg(void);  | 
||
| 414 | ```  | 
||
| 415 | |||
| 416 | 1 | Patrice Nadeau | ### Macros  | 
| 417 | |||
| 418 | Les directives du préprocesseur C.  | 
||
| 419 | |||
| 420 | 23 | Patrice Nadeau | * Utilisé dans le code source et les fichiers entête.  | 
| 421 | * DOIT toujours commencer à la colonne 0.  | 
||
| 422 | |||
| 423 | 1 | Patrice Nadeau | #### #include  | 
| 424 | 40 | Patrice Nadeau | |
| 425 | 1 | Patrice Nadeau | Pour inclure d’autres fichier comme les fichiers entête.  | 
| 426 | 40 | Patrice Nadeau | >N’est pas documenté dans Doxygen.  | 
| 427 | 24 | Patrice Nadeau | |
| 428 | 67 | Patrice Nadeau | ```c  | 
| 429 | #### ifdef / ifndef  | 
||
| 430 | ```  | 
||
| 431 | 1 | Patrice Nadeau | |
| 432 | 52 | Patrice Nadeau | Surtout utiliser pour des options de compilation sur différentes plateforme.  | 
| 433 | 67 | Patrice Nadeau | > N’est pas documenté dans Doxygen.  | 
| 434 | 1 | Patrice Nadeau | |
| 435 | ``` c  | 
||
| 436 | 67 | Patrice Nadeau | |
| 437 | 64 | Patrice Nadeau | #ifndef usart_AVR  | 
| 438 | 68 | Patrice Nadeau | ```  | 
| 439 | 1 | Patrice Nadeau | |
| 440 | 64 | Patrice Nadeau | #error "usart.h is not supported on this AVR !"  | 
| 441 | 34 | Patrice Nadeau | |
| 442 | 64 | Patrice Nadeau | #endif  | 
| 443 | ```  | 
||
| 444 | 33 | Patrice Nadeau | |
| 445 | 37 | Patrice Nadeau | #### #error  | 
| 446 | 1 | Patrice Nadeau | |
| 447 | Affiche une erreur et arrête la compilation  | 
||
| 448 | >N’est pas documenté dans Doxygen.  | 
||
| 449 | |||
| 450 | ``` c  | 
||
| 451 | |||
| 452 | 62 | Patrice Nadeau | #ifndef __test__  | 
| 453 | 1 | Patrice Nadeau | |
| 454 | 62 | Patrice Nadeau | #error "Error !"  | 
| 455 | 1 | Patrice Nadeau | |
| 456 | #endif  | 
||
| 457 | 65 | Patrice Nadeau | ```  | 
| 458 | 38 | Patrice Nadeau | |
| 459 | 53 | Patrice Nadeau | #### #warning  | 
| 460 | 17 | Patrice Nadeau | |
| 461 | 1 | Patrice Nadeau | Affiche une erreur mais n’arrête la compilation  | 
| 462 | 53 | Patrice Nadeau | >N’est pas documenté dans Doxygen.  | 
| 463 | |||
| 464 | 65 | Patrice Nadeau | ``` c  | 
| 465 | 1 | Patrice Nadeau | #ifndef __test__  | 
| 466 | 39 | Patrice Nadeau | |
| 467 | 1 | Patrice Nadeau | #warning "Warning !"  | 
| 468 | 39 | Patrice Nadeau | |
| 469 | #endif  | 
||
| 470 | 65 | Patrice Nadeau | ```  | 
| 471 | 39 | Patrice Nadeau | |
| 472 | #### #define  | 
||
| 473 | 1 | Patrice Nadeau | |
| 474 | Définis une valeur au moment de la compilation.  | 
||
| 475 | |||
| 476 | 39 | Patrice Nadeau | * Format  | 
| 477 | * En majuscule.  | 
||
| 478 | * Séparé par un «underscore» si contient plusieurs mots.  | 
||
| 479 | * Doxygen  | 
||
| 480 | * @brief  | 
||
| 481 | * @name pour les listes de macros (regroupement dans la documentation)  | 
||
| 482 | |||
| 483 | 40 | Patrice Nadeau | Définition de macros  | 
| 484 | |||
| 485 | 65 | Patrice Nadeau | ``` c  | 
| 486 | 40 | Patrice Nadeau | /**  | 
| 487 | * @name Mathematical macros listed together  | 
||
| 488 |     * @{ | 
||
| 489 | */  | 
||
| 490 | 1 | Patrice Nadeau | /** @brief Value for PI */  | 
| 491 | |||
| 492 | #define _PI 3.14  | 
||
| 493 | 17 | Patrice Nadeau | /** @brief Another number */  | 
| 494 | 1 | Patrice Nadeau | #define _MAGIC_NUMBER 42  | 
| 495 | /**  | 
||
| 496 | 3 | Patrice Nadeau | * @}  | 
| 497 | 1 | Patrice Nadeau | */  | 
| 498 | /** @brief Even parity */  | 
||
| 499 | |||
| 500 | #define usart_PARITY_EVEN 'e'  | 
||
| 501 | 65 | Patrice Nadeau | ```  | 
| 502 | 1 | Patrice Nadeau | |
| 503 | ### Atmel AVR  | 
||
| 504 | |||
| 505 | 22 | Patrice Nadeau | Particularités pour les micro-contrôleurs AVR d’Atmel.  | 
| 506 | 1 | Patrice Nadeau | |
| 507 | 22 | Patrice Nadeau | * Progmem : Pour mettre une fonction en Flash au lieu de SRAM.  | 
| 508 | ** Le nom de la fonction est suivie de *_P*.  | 
||
| 509 | * main : Ne revient jamais à un niveau supérieur.  | 
||
| 510 | ** Définir la fonction main avec l’attribut *noreturn*.  | 
||
| 511 | 1 | Patrice Nadeau | ** La boucle sans fin la plus optimisé est le *for (;;)*.  | 
| 512 | 22 | Patrice Nadeau | * Atomic : Opérations ne devant pas être interrompus.  | 
| 513 | |||
| 514 | Particularités pour AVR  | 
||
| 515 | |||
| 516 | 65 | Patrice Nadeau | ``` c  | 
| 517 | 22 | Patrice Nadeau | /**  | 
| 518 | * @brief Progmem function  | 
||
| 519 | 1 | Patrice Nadeau | * @return An unsigned 8 bits integer  | 
| 520 | */  | 
||
| 521 | 22 | Patrice Nadeau | uint_8t PrintString_P()  | 
| 522 | 21 | Patrice Nadeau | |
| 523 | 1 | Patrice Nadeau | /* main function */  | 
| 524 | void main(void) __atribute__((noreturn))  | 
||
| 525 | 40 | Patrice Nadeau |     { | 
| 526 | ...  | 
||
| 527 | /* never return */  | 
||
| 528 |         for (;;) { | 
||
| 529 | }  | 
||
| 530 | }  | 
||
| 531 | |||
| 532 | 1 | Patrice Nadeau | /* atomic operations */  | 
| 533 | 18 | Patrice Nadeau | |
| 534 | 17 | Patrice Nadeau | #ifndef S_SPLINT_S  | 
| 535 | 18 | Patrice Nadeau |     ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { | 
| 536 | /*  | 
||
| 537 | 1 | Patrice Nadeau | * operations that must not be interupted  | 
| 538 | * like loading a 16 bit register with a 8 bit register  | 
||
| 539 | */  | 
||
| 540 | }  | 
||
| 541 | #endif  | 
||
| 542 | 65 | Patrice Nadeau | ```  | 
| 543 | 1 | Patrice Nadeau | |
| 544 | ### Distribution  | 
||
| 545 | |||
| 546 | Les fichiers suivants DOIVENT être inclus dans une distribution en format *tar.gz* :  | 
||
| 547 | |||
| 548 | * ChangeLog  | 
||
| 549 | 18 | Patrice Nadeau | * README  | 
| 550 | * Files.lst  | 
||
| 551 | 1 | Patrice Nadeau | * Makefile  | 
| 552 | * Makefile.mk  | 
||
| 553 | * LICENSE.txt  | 
||
| 554 | * *.c  | 
||
| 555 | * *.h  | 
||
| 556 | * projet.pdf (généré par Doxygen)  | 
||
| 557 | 18 | Patrice Nadeau | |
| 558 | Avec mon makefile :  | 
||
| 559 | |||
| 560 | 1 | Patrice Nadeau | make dist  | 
| 561 | 18 | Patrice Nadeau | |
| 562 | 1 | Patrice Nadeau | ### Modifications  | 
| 563 | |||
| 564 | Un changement à un fichier (source ou en-tête), doit se refléter dans _Git_.  | 
||
| 565 | |||
| 566 | 18 | Patrice Nadeau | Chaque changement est fait avec :  | 
| 567 | 1 | Patrice Nadeau | |
| 568 | git add nom_fichier  | 
||
| 569 | 18 | Patrice Nadeau | git commit  | 
| 570 | |||
| 571 | La ligne DOIT  | 
||
| 572 | |||
| 573 | * être au temps présent  | 
||
| 574 | 17 | Patrice Nadeau | * être en anglais  | 
| 575 | 1 | Patrice Nadeau | * se termine par un point  | 
| 576 | * être dans le format suivant :  | 
||
| 577 | > La partie _section_ est facultative  | 
||
| 578 | |||
| 579 | 18 | Patrice Nadeau | |
| 580 | 1 | Patrice Nadeau | fichier1 (fonction) <section>:  | 
| 581 | 18 | Patrice Nadeau | Ajoute une description au temps présent.  | 
| 582 | Décrire les bogues réglés si il y en avaient.  | 
||
| 583 | 1 | Patrice Nadeau | |
| 584 | |||
| 585 | 17 | Patrice Nadeau | ### Changelog  | 
| 586 | 18 | Patrice Nadeau | |
| 587 | 1 | Patrice Nadeau | La somme de toutes les modification doivent apparaitre dans un fichier « changelog ».  | 
| 588 | > Le standard seras celui GNU : http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs  | 
||
| 589 | |||
| 590 | Ce fichier doit s'appeler **ChangeLog** et DOIT être généré à partir de _Git_ (les doubles espaces ne sont pas une erreur de frappe :  | 
||
| 591 | |||
| 592 | 17 | Patrice Nadeau | git log --no-merges --format="%ad %an <%aE> %n * %B" --date=short > ChangeLog  | 
| 593 | 1 | Patrice Nadeau | |
| 594 | 17 | Patrice Nadeau | ### Validation du code  | 
| 595 | 1 | Patrice Nadeau | |
| 596 | 17 | Patrice Nadeau | Le logiciel _splint_ est utilisé.  | 
| 597 | 1 | Patrice Nadeau | |
| 598 | * Un « typecast » DOIT être utilisé lorsque détecté.  | 
||
| 599 | * L’utilisation du typecast *void* DOIT être utilisé lorsque qu’une fonction retourne un résultat non utilisé.  | 
||
| 600 | |||
| 601 | 18 | Patrice Nadeau | ## Makefile  | 
| 602 | |||
| 603 | 1 | Patrice Nadeau | ## Nagios  | 
| 604 | |||
| 605 | ### Plugins  | 
||
| 606 | |||
| 607 | https://nagios-plugins.org/doc/guidelines.html  | 
||
| 608 | |||
| 609 | 18 | Patrice Nadeau | Un message d'une ligne (< 80 caractères) DOIT être retourné via _STDOUT_ dans le format  | 
| 610 | > *SERVICE STATUS:* texte  | 
||
| 611 | 1 | Patrice Nadeau | |
| 612 | Les codes de retour sont les suivants :  | 
||
| 613 | |||
| 614 | |_. Valeur |_. Service Status |_. Description |  | 
||
| 615 | | 0 | OK | Le service fonctionne |  | 
||
| 616 | | 1 | Warning | Le service fonctionne, problème avec le seuil de la valeur _Warning_ |  | 
||
| 617 | | 2 | Critical | Le service ne fonctionne pas ou problème avec le seuil de la valeur _Critical_ |  | 
||
| 618 | | 3 | Unknow | Arguments non valides ou erreur interne (fork, tcp socket)|  | 
||
| 619 | |||
| 620 | 18 | Patrice Nadeau | Les arguments suivants DOIVENT être fournis :  | 
| 621 | 1 | Patrice Nadeau | |
| 622 | 17 | Patrice Nadeau | * *-H* (*--hostname*) :  | 
| 623 | 1 | Patrice Nadeau | * *-w* (*--warning*) :  | 
| 624 | * *-c* (*--critical*) :  | 
||
| 625 | * *-V* (*--version*) :  | 
||
| 626 | * *-h* (*--help*) :  | 
||
| 627 | |||
| 628 | L'argument _--help_ DOIT aussi appeler l'argument _--version_.  | 
||
| 629 | |||
| 630 | 18 | Patrice Nadeau | En _C_, les fonctions suivantes DOIT être utilisées :  | 
| 631 | 1 | Patrice Nadeau | |
| 632 | 18 | Patrice Nadeau | * _print_revision_ (utils.c)  | 
| 633 | 1 | Patrice Nadeau | * _print_help_  | 
| 634 | * _getopt_long_ (getopt.h)  | 
||
| 635 | 18 | Patrice Nadeau | |
| 636 | ## Puppet  | 
||
| 637 | |||
| 638 | 1 | Patrice Nadeau | ### Généralités  | 
| 639 | |||
| 640 | Inspiré des recommandations disponible au http://docs.puppetlabs.com/guides/style_guide.html.  | 
||
| 641 | |||
| 642 | * Tabulation : 2 espaces  | 
||
| 643 | * Largeur : 80 caractères (« backslah » (\) pour séparer une longue ligne).  | 
||
| 644 | * Commentaires : Style #  | 
||
| 645 | * Guillemets  | 
||
| 646 | * Simple : Pour une « string » sans variables.  | 
||
| 647 | * Double : Pour une « string » avec variables ayant besoin d’être extrapolé.  | 
||
| 648 | 18 | Patrice Nadeau |         * La variable doit être entourée des symboles *<notextile>{</notextile>* et *<notextile>}</notextile>*. | 
| 649 | * Nom des ressources : DOIVENT être entouré du symbole *<notextile> ’ </notextile>*.  | 
||
| 650 | 1 | Patrice Nadeau | * Alignement de => : DOIT être aligné dans un même paragraphe.  | 
| 651 | * Ordre : Si l’attribut _ensure_ doit être inclus, il DOIT être le premier.  | 
||
| 652 | * Lien symbolique : DOIT être déclaré avec *ensure => link*  | 
||
| 653 | |||
| 654 | Ex. :  | 
||
| 655 | 18 | Patrice Nadeau | |
| 656 |     file { '/var/log/syslog': | 
||
| 657 | 1 | Patrice Nadeau | ensure => link,  | 
| 658 | target => '/var/log/messages',  | 
||
| 659 | }  | 
||
| 660 | |||
| 661 | 18 | Patrice Nadeau | * File mode :  | 
| 662 | * 4 chiffres  | 
||
| 663 | * simple guillemet  | 
||
| 664 | 1 | Patrice Nadeau | * Variables  | 
| 665 | 18 | Patrice Nadeau | * lettres  | 
| 666 | * chiffres  | 
||
| 667 | * « underscore »  | 
||
| 668 | |||
| 669 | 1 | Patrice Nadeau | ### Documentation  | 
| 670 | 18 | Patrice Nadeau | |
| 671 | 1 | Patrice Nadeau | http://docs.puppetlabs.com/learning/modules2.html#module-documentation  | 
| 672 | |||
| 673 | Format Rdoc (http://rdoc.rubyforge.org/RDoc/Markup.html) :  | 
||
| 674 | |||
| 675 | * Bloc de commentaires qui commence sur la première ligne du fichier  | 
||
| 676 | 18 | Patrice Nadeau | * Titre avec le symbole *<notextile>=</notextile>*  | 
| 677 | * Séparation avec le symbole *<notextile>-</notextile>*  | 
||
| 678 | 1 | Patrice Nadeau | * Emphase (mot entouré du symbole)  | 
| 679 | * * : gras  | 
||
| 680 | * _ : souligné  | 
||
| 681 | 17 | Patrice Nadeau | * + : Police de caractères pour le code  | 
| 682 | 1 | Patrice Nadeau | * Sections  | 
| 683 | * = Class:  | 
||
| 684 | * == Parameters:  | 
||
| 685 | 40 | Patrice Nadeau | * == Requires:  | 
| 686 | 1 | Patrice Nadeau | * == Sample Usage:  | 
| 687 | 40 | Patrice Nadeau | * Classe  | 
| 688 | * Une classe par fichier « manifest »  | 
||
| 689 | 1 | Patrice Nadeau | |
| 690 | 40 | Patrice Nadeau | ## Script  | 
| 691 | |||
| 692 | ### Bash  | 
||
| 693 | |||
| 694 | 61 | Patrice Nadeau | ``` bash  | 
| 695 | #/bin/bash  | 
||
| 696 | 1 | Patrice Nadeau | |
| 697 | 61 | Patrice Nadeau | function print_revision { | 
| 698 | }  | 
||
| 699 | 17 | Patrice Nadeau | |
| 700 | 61 | Patrice Nadeau | function print_help { | 
| 701 | print_revision  | 
||
| 702 | }  | 
||
| 703 | ```  | 
||
| 704 | 1 | Patrice Nadeau | |
| 705 | 17 | Patrice Nadeau | ### Perl  | 
| 706 | 1 | Patrice Nadeau | |
| 707 | ### PowerShell  | 
||
| 708 | |||
| 709 | Version 4.0. Supporte :  | 
||
| 710 | 41 | Patrice Nadeau | |
| 711 | * Windows 8.1 (natif)  | 
||
| 712 | 1 | Patrice Nadeau | * Windows Server 2012 R2 (natif)  | 
| 713 | * Windows 7 SP1  | 
||
| 714 | * Windows Server 2008 R2 SP1  | 
||
| 715 | * Windows Server 2012  | 
||
| 716 | |||
| 717 | 20 | Patrice Nadeau | #### Fichier  | 
| 718 | |||
| 719 | Le fichier DOIT être composé de la manière suivante :  | 
||
| 720 | |||
| 721 | * L’extension est .ps1  | 
||
| 722 | * Une longue ligne peux être séparée avec un « back tick » (‘).  | 
||
| 723 | |||
| 724 | #### Commentaires  | 
||
| 725 | |||
| 726 | L’aide est accéder par _Get-Help_  | 
||
| 727 | |||
| 728 | |||
| 729 | #REQUIRES -Version 2.0  | 
||
| 730 | <#  | 
||
| 731 | .SYNOPSIS  | 
||
| 732 | A brief description of the function or script.  | 
||
| 733 | This keyword can be used only once in each topic.  | 
||
| 734 | .DESCRIPTION  | 
||
| 735 | A detailed description of the function or script.  | 
||
| 736 | This keyword can be used only once in each topic.  | 
||
| 737 | .NOTES  | 
||
| 738 | File Name  | 
||
| 739 | : xxxx.ps1  | 
||
| 740 | Author  | 
||
| 741 | :  | 
||
| 742 | Prerequisite  | 
||
| 743 | : PowerShell V2 over Vista and upper.  | 
||
| 744 | Copyright 2011 -  | 
||
| 745 | 1 | Patrice Nadeau | .LINK  | 
| 746 | 19 | Patrice Nadeau | Script posted over:  | 
| 747 | http://  | 
||
| 748 | .EXAMPLE  | 
||
| 749 | Example 1  | 
||
| 750 | 1 | Patrice Nadeau | .EXAMPLE  | 
| 751 | 19 | Patrice Nadeau | Example 2  | 
| 752 | #>  | 
||
| 753 | |||
| 754 | ## Vim  | 
||
| 755 | 1 | Patrice Nadeau | |
| 756 | * Entête (en commentaires)  | 
||
| 757 | * Titre  | 
||
| 758 | * Last Change:  | 
||
| 759 | * Maintainer:  | 
||
| 760 | 20 | Patrice Nadeau | * License: This file is placed in the public domain.  | 
| 761 | 19 | Patrice Nadeau | * Autre mots reconnus  | 
| 762 | 1 | Patrice Nadeau | * BUG: (Error:)  | 
| 763 | * TODO:  | 
||
| 764 | * Note:  | 
||
| 765 | * FIXME  | 
||
| 766 | |||
| 767 | ## Références  | 
||
| 768 | |||
| 769 | Références ayant servis à ce document.  | 
||
| 770 | |||
| 771 | [ChangeLog](http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs)  | 
||
| 772 | [GNU deprecated attribute](http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Type-Attributes.html)  |