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