![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
version 2.6.5 mode normal en cours(problème de décalage) voir incrément et coefficient codeur
Dependencies: mbed
Fork of Robot_a_cables_v2_6 by
main.cpp@1:4d70e593345f, 2018-02-28 (annotated)
- Committer:
- protongamer
- Date:
- Wed Feb 28 11:34:52 2018 +0000
- Revision:
- 1:4d70e593345f
- Parent:
- 0:1ab5fdb4fa56
- Child:
- 2:1e06fd49ea7b
Console CAN 2.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
LouisReynier | 0:1ab5fdb4fa56 | 1 | #include "mbed.h" |
protongamer | 1:4d70e593345f | 2 | // LR 10/02/18 |
LouisReynier | 0:1ab5fdb4fa56 | 3 | // |
protongamer | 1:4d70e593345f | 4 | // bus CAN generateur de trames |
LouisReynier | 0:1ab5fdb4fa56 | 5 | // |
protongamer | 1:4d70e593345f | 6 | // Emission d'une trame parmi 4 selection à l'aide du pot1 |
protongamer | 1:4d70e593345f | 7 | // eviter les positions intermédaires du pot1 ! |
protongamer | 1:4d70e593345f | 8 | // !! emission sur CAN2 p30Rx p29Tx |
protongamer | 1:4d70e593345f | 9 | // Attention si pas d'ACK faire reset après chaque changement |
protongamer | 1:4d70e593345f | 10 | // J'ai constaté des comportements bizarre dans cette situation |
protongamer | 1:4d70e593345f | 11 | // Des infos sur la liaison série |
protongamer | 1:4d70e593345f | 12 | // La trame est envoyée aussi sur LCD |
protongamer | 1:4d70e593345f | 13 | // |
protongamer | 1:4d70e593345f | 14 | // testé à l'analyseur logique = OK !! |
LouisReynier | 0:1ab5fdb4fa56 | 15 | // |
protongamer | 1:4d70e593345f | 16 | // |
LouisReynier | 0:1ab5fdb4fa56 | 17 | |
protongamer | 1:4d70e593345f | 18 | |
LouisReynier | 0:1ab5fdb4fa56 | 19 | DigitalOut led1(LED1); |
LouisReynier | 0:1ab5fdb4fa56 | 20 | DigitalOut led2(LED2); |
LouisReynier | 0:1ab5fdb4fa56 | 21 | CAN can1(p9, p10,1000000);// on definit pin et debit |
LouisReynier | 0:1ab5fdb4fa56 | 22 | CAN can2(p30, p29, 1000000); |
protongamer | 1:4d70e593345f | 23 | Serial pc(USBTX, USBRX); |
protongamer | 1:4d70e593345f | 24 | //AnalogIn pot_1(p19); // potard pour selection |
protongamer | 1:4d70e593345f | 25 | |
protongamer | 1:4d70e593345f | 26 | |
protongamer | 1:4d70e593345f | 27 | |
protongamer | 1:4d70e593345f | 28 | void send(int id, char octet_emis[], char RouD, char longueur ) |
protongamer | 1:4d70e593345f | 29 | { |
protongamer | 1:4d70e593345f | 30 | int emis_ok = 0 ; |
LouisReynier | 0:1ab5fdb4fa56 | 31 | |
protongamer | 1:4d70e593345f | 32 | if (RouD == 'D') |
protongamer | 1:4d70e593345f | 33 | { emis_ok = can2.write(CANMessage(id, octet_emis, longueur, CANData, CANStandard )) ; |
protongamer | 1:4d70e593345f | 34 | pc.printf("id: %x, %c L = %d, \nData : %x:%x:%x:%x ... \n", id,RouD,longueur,octet_emis[0],octet_emis[1], octet_emis[2], octet_emis[3] ); |
protongamer | 1:4d70e593345f | 35 | }// c'ets la valeur retournée par la fonction write |
protongamer | 1:4d70e593345f | 36 | else |
protongamer | 1:4d70e593345f | 37 | { emis_ok = can2.write(CANMessage(id, octet_emis, longueur, CANRemote, CANStandard )); |
protongamer | 1:4d70e593345f | 38 | pc.printf("id: %x, %c L = %d, \nData : %x:%x:%x:%x ... \n", id,RouD,longueur,octet_emis[0],octet_emis[1], octet_emis[2], octet_emis[3] ); |
protongamer | 1:4d70e593345f | 39 | } |
protongamer | 1:4d70e593345f | 40 | //lcd.locate(0,10); |
protongamer | 1:4d70e593345f | 41 | //lcd.printf("id: %x, %c L = %d, \nData : %x:%x:%x:%x ... \n", id,RouD,longueur,octet_emis[0],octet_emis[1], octet_emis[2], octet_emis[3] ); |
protongamer | 1:4d70e593345f | 42 | if(emis_ok) { |
protongamer | 1:4d70e593345f | 43 | // ici octet emis n'a pas de sens car trame remote ! |
protongamer | 1:4d70e593345f | 44 | pc.printf("j'emets bien !!! \n"); |
LouisReynier | 0:1ab5fdb4fa56 | 45 | } |
LouisReynier | 0:1ab5fdb4fa56 | 46 | led1 = !led1; |
LouisReynier | 0:1ab5fdb4fa56 | 47 | } |
protongamer | 1:4d70e593345f | 48 | |
protongamer | 1:4d70e593345f | 49 | |
protongamer | 1:4d70e593345f | 50 | |
LouisReynier | 0:1ab5fdb4fa56 | 51 | |
LouisReynier | 0:1ab5fdb4fa56 | 52 | int main() { |
protongamer | 1:4d70e593345f | 53 | // int choix = 0 ; |
protongamer | 1:4d70e593345f | 54 | int i = 0 ; |
LouisReynier | 0:1ab5fdb4fa56 | 55 | |
protongamer | 1:4d70e593345f | 56 | char octet_send[9] = "DDDDDDDD"; // valeurs par defaut D=44 |
protongamer | 1:4d70e593345f | 57 | int identif = 0x123 ; // par défaut |
protongamer | 1:4d70e593345f | 58 | char RemoteData = 'D' ; |
protongamer | 1:4d70e593345f | 59 | char length = 2 ; |
protongamer | 1:4d70e593345f | 60 | char c; |
protongamer | 1:4d70e593345f | 61 | uint32_t instruction = 0; |
protongamer | 1:4d70e593345f | 62 | uint8_t state_val = 0; |
protongamer | 1:4d70e593345f | 63 | uint8_t state = 0; |
protongamer | 1:4d70e593345f | 64 | int data_rc; |
protongamer | 1:4d70e593345f | 65 | int data_report[100]; |
protongamer | 1:4d70e593345f | 66 | CANMessage msg; |
protongamer | 1:4d70e593345f | 67 | |
protongamer | 1:4d70e593345f | 68 | pc.printf("CAN CONSOLE \r \n"); |
protongamer | 1:4d70e593345f | 69 | |
protongamer | 1:4d70e593345f | 70 | |
protongamer | 1:4d70e593345f | 71 | |
LouisReynier | 0:1ab5fdb4fa56 | 72 | while(1) { |
protongamer | 1:4d70e593345f | 73 | data_rc = 0; |
protongamer | 1:4d70e593345f | 74 | pc.printf(" Identifier : "); |
protongamer | 1:4d70e593345f | 75 | while(state == 0){ |
protongamer | 1:4d70e593345f | 76 | c = pc.getc(); |
protongamer | 1:4d70e593345f | 77 | switch(c){ |
protongamer | 1:4d70e593345f | 78 | |
protongamer | 1:4d70e593345f | 79 | |
protongamer | 1:4d70e593345f | 80 | |
protongamer | 1:4d70e593345f | 81 | case '0': |
protongamer | 1:4d70e593345f | 82 | pc.printf("0"); |
protongamer | 1:4d70e593345f | 83 | |
protongamer | 1:4d70e593345f | 84 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 85 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 86 | instruction |= 0b0000; |
protongamer | 1:4d70e593345f | 87 | } |
protongamer | 1:4d70e593345f | 88 | |
protongamer | 1:4d70e593345f | 89 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 90 | instruction = 0b0000; |
protongamer | 1:4d70e593345f | 91 | state_val++; |
protongamer | 1:4d70e593345f | 92 | } |
protongamer | 1:4d70e593345f | 93 | |
protongamer | 1:4d70e593345f | 94 | break; |
protongamer | 1:4d70e593345f | 95 | |
protongamer | 1:4d70e593345f | 96 | case '1': |
protongamer | 1:4d70e593345f | 97 | |
protongamer | 1:4d70e593345f | 98 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 99 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 100 | instruction |= 0b0001; |
protongamer | 1:4d70e593345f | 101 | } |
protongamer | 1:4d70e593345f | 102 | |
protongamer | 1:4d70e593345f | 103 | pc.printf("1"); |
protongamer | 1:4d70e593345f | 104 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 105 | instruction = 0b0001; |
protongamer | 1:4d70e593345f | 106 | state_val++; |
protongamer | 1:4d70e593345f | 107 | } |
protongamer | 1:4d70e593345f | 108 | |
protongamer | 1:4d70e593345f | 109 | break; |
protongamer | 1:4d70e593345f | 110 | |
protongamer | 1:4d70e593345f | 111 | case '2': |
protongamer | 1:4d70e593345f | 112 | |
protongamer | 1:4d70e593345f | 113 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 114 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 115 | instruction |= 0b0010; |
protongamer | 1:4d70e593345f | 116 | } |
protongamer | 1:4d70e593345f | 117 | |
protongamer | 1:4d70e593345f | 118 | pc.printf("2"); |
protongamer | 1:4d70e593345f | 119 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 120 | instruction = 0b0010; |
protongamer | 1:4d70e593345f | 121 | state_val++; |
protongamer | 1:4d70e593345f | 122 | } |
protongamer | 1:4d70e593345f | 123 | |
protongamer | 1:4d70e593345f | 124 | break; |
protongamer | 1:4d70e593345f | 125 | |
protongamer | 1:4d70e593345f | 126 | case '3': |
protongamer | 1:4d70e593345f | 127 | pc.printf("3"); |
protongamer | 1:4d70e593345f | 128 | |
protongamer | 1:4d70e593345f | 129 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 130 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 131 | instruction |= 0b0011; |
protongamer | 1:4d70e593345f | 132 | } |
protongamer | 1:4d70e593345f | 133 | |
protongamer | 1:4d70e593345f | 134 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 135 | instruction = 0b0011; |
protongamer | 1:4d70e593345f | 136 | state_val++; |
protongamer | 1:4d70e593345f | 137 | } |
protongamer | 1:4d70e593345f | 138 | |
protongamer | 1:4d70e593345f | 139 | break; |
protongamer | 1:4d70e593345f | 140 | |
protongamer | 1:4d70e593345f | 141 | case '4': |
protongamer | 1:4d70e593345f | 142 | |
protongamer | 1:4d70e593345f | 143 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 144 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 145 | instruction |= 0b0100; |
protongamer | 1:4d70e593345f | 146 | } |
protongamer | 1:4d70e593345f | 147 | |
protongamer | 1:4d70e593345f | 148 | pc.printf("4"); |
protongamer | 1:4d70e593345f | 149 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 150 | instruction = 0b0100; |
protongamer | 1:4d70e593345f | 151 | state_val++; |
protongamer | 1:4d70e593345f | 152 | } |
protongamer | 1:4d70e593345f | 153 | |
protongamer | 1:4d70e593345f | 154 | break; |
protongamer | 1:4d70e593345f | 155 | |
protongamer | 1:4d70e593345f | 156 | case '5': |
protongamer | 1:4d70e593345f | 157 | pc.printf("5"); |
protongamer | 1:4d70e593345f | 158 | |
protongamer | 1:4d70e593345f | 159 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 160 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 161 | instruction |= 0b0101; |
protongamer | 1:4d70e593345f | 162 | } |
protongamer | 1:4d70e593345f | 163 | |
protongamer | 1:4d70e593345f | 164 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 165 | instruction = 0b0101; |
protongamer | 1:4d70e593345f | 166 | state_val++; |
protongamer | 1:4d70e593345f | 167 | } |
protongamer | 1:4d70e593345f | 168 | |
protongamer | 1:4d70e593345f | 169 | break; |
protongamer | 1:4d70e593345f | 170 | |
protongamer | 1:4d70e593345f | 171 | case '6': |
protongamer | 1:4d70e593345f | 172 | pc.printf("6"); |
protongamer | 1:4d70e593345f | 173 | |
protongamer | 1:4d70e593345f | 174 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 175 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 176 | instruction |= 0b0110; |
protongamer | 1:4d70e593345f | 177 | } |
protongamer | 1:4d70e593345f | 178 | |
protongamer | 1:4d70e593345f | 179 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 180 | instruction = 0b0110; |
protongamer | 1:4d70e593345f | 181 | state_val++; |
protongamer | 1:4d70e593345f | 182 | } |
protongamer | 1:4d70e593345f | 183 | |
protongamer | 1:4d70e593345f | 184 | break; |
protongamer | 1:4d70e593345f | 185 | |
protongamer | 1:4d70e593345f | 186 | case '7': |
protongamer | 1:4d70e593345f | 187 | pc.printf("7"); |
protongamer | 1:4d70e593345f | 188 | |
protongamer | 1:4d70e593345f | 189 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 190 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 191 | instruction |= 0b0111; |
protongamer | 1:4d70e593345f | 192 | } |
protongamer | 1:4d70e593345f | 193 | |
protongamer | 1:4d70e593345f | 194 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 195 | instruction = 0b0111; |
protongamer | 1:4d70e593345f | 196 | state_val++; |
protongamer | 1:4d70e593345f | 197 | } |
protongamer | 1:4d70e593345f | 198 | |
protongamer | 1:4d70e593345f | 199 | break; |
protongamer | 1:4d70e593345f | 200 | |
protongamer | 1:4d70e593345f | 201 | case '8': |
protongamer | 1:4d70e593345f | 202 | pc.printf("8"); |
protongamer | 1:4d70e593345f | 203 | |
protongamer | 1:4d70e593345f | 204 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 205 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 206 | instruction |= 0b1000; |
protongamer | 1:4d70e593345f | 207 | } |
protongamer | 1:4d70e593345f | 208 | |
protongamer | 1:4d70e593345f | 209 | |
protongamer | 1:4d70e593345f | 210 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 211 | instruction = 0b1000; |
protongamer | 1:4d70e593345f | 212 | state_val++; |
protongamer | 1:4d70e593345f | 213 | } |
protongamer | 1:4d70e593345f | 214 | |
protongamer | 1:4d70e593345f | 215 | break; |
protongamer | 1:4d70e593345f | 216 | |
protongamer | 1:4d70e593345f | 217 | case '9': |
protongamer | 1:4d70e593345f | 218 | pc.printf("9"); |
protongamer | 1:4d70e593345f | 219 | |
protongamer | 1:4d70e593345f | 220 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 221 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 222 | instruction |= 0b1001; |
protongamer | 1:4d70e593345f | 223 | } |
protongamer | 1:4d70e593345f | 224 | |
protongamer | 1:4d70e593345f | 225 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 226 | instruction = 0b1001; |
protongamer | 1:4d70e593345f | 227 | state_val++; |
protongamer | 1:4d70e593345f | 228 | } |
protongamer | 1:4d70e593345f | 229 | |
protongamer | 1:4d70e593345f | 230 | break; |
protongamer | 1:4d70e593345f | 231 | |
protongamer | 1:4d70e593345f | 232 | case 'a': |
protongamer | 1:4d70e593345f | 233 | pc.printf("a"); |
protongamer | 1:4d70e593345f | 234 | |
protongamer | 1:4d70e593345f | 235 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 236 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 237 | instruction |= 0b1010; |
protongamer | 1:4d70e593345f | 238 | } |
protongamer | 1:4d70e593345f | 239 | |
protongamer | 1:4d70e593345f | 240 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 241 | instruction = 0b1010; |
protongamer | 1:4d70e593345f | 242 | state_val++; |
protongamer | 1:4d70e593345f | 243 | } |
protongamer | 1:4d70e593345f | 244 | |
protongamer | 1:4d70e593345f | 245 | break; |
protongamer | 1:4d70e593345f | 246 | |
protongamer | 1:4d70e593345f | 247 | case 'b': |
protongamer | 1:4d70e593345f | 248 | pc.printf("b"); |
protongamer | 1:4d70e593345f | 249 | |
protongamer | 1:4d70e593345f | 250 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 251 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 252 | instruction |= 0b1011; |
protongamer | 1:4d70e593345f | 253 | } |
protongamer | 1:4d70e593345f | 254 | |
protongamer | 1:4d70e593345f | 255 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 256 | instruction = 0b1011; |
protongamer | 1:4d70e593345f | 257 | state_val++; |
protongamer | 1:4d70e593345f | 258 | } |
protongamer | 1:4d70e593345f | 259 | |
protongamer | 1:4d70e593345f | 260 | break; |
protongamer | 1:4d70e593345f | 261 | |
protongamer | 1:4d70e593345f | 262 | case 'c': |
protongamer | 1:4d70e593345f | 263 | pc.printf("c"); |
protongamer | 1:4d70e593345f | 264 | |
protongamer | 1:4d70e593345f | 265 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 266 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 267 | instruction |= 0b1100; |
protongamer | 1:4d70e593345f | 268 | } |
protongamer | 1:4d70e593345f | 269 | |
protongamer | 1:4d70e593345f | 270 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 271 | instruction = 0b1100; |
protongamer | 1:4d70e593345f | 272 | state_val++; |
protongamer | 1:4d70e593345f | 273 | } |
protongamer | 1:4d70e593345f | 274 | |
protongamer | 1:4d70e593345f | 275 | break; |
protongamer | 1:4d70e593345f | 276 | |
protongamer | 1:4d70e593345f | 277 | case 'd': |
protongamer | 1:4d70e593345f | 278 | pc.printf("d"); |
protongamer | 1:4d70e593345f | 279 | |
protongamer | 1:4d70e593345f | 280 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 281 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 282 | instruction |= 0b1101; |
protongamer | 1:4d70e593345f | 283 | } |
protongamer | 1:4d70e593345f | 284 | |
protongamer | 1:4d70e593345f | 285 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 286 | instruction = 0b1101; |
protongamer | 1:4d70e593345f | 287 | state_val++; |
protongamer | 1:4d70e593345f | 288 | } |
protongamer | 1:4d70e593345f | 289 | |
protongamer | 1:4d70e593345f | 290 | break; |
protongamer | 1:4d70e593345f | 291 | |
protongamer | 1:4d70e593345f | 292 | case 'e': |
protongamer | 1:4d70e593345f | 293 | pc.printf("e"); |
protongamer | 1:4d70e593345f | 294 | |
protongamer | 1:4d70e593345f | 295 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 296 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 297 | instruction |= 0b1110; |
protongamer | 1:4d70e593345f | 298 | } |
protongamer | 1:4d70e593345f | 299 | |
protongamer | 1:4d70e593345f | 300 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 301 | instruction = 0b1110; |
protongamer | 1:4d70e593345f | 302 | state_val++; |
protongamer | 1:4d70e593345f | 303 | } |
protongamer | 1:4d70e593345f | 304 | |
protongamer | 1:4d70e593345f | 305 | break; |
protongamer | 1:4d70e593345f | 306 | |
protongamer | 1:4d70e593345f | 307 | case 'f': |
protongamer | 1:4d70e593345f | 308 | pc.printf("f"); |
protongamer | 1:4d70e593345f | 309 | |
protongamer | 1:4d70e593345f | 310 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 311 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 312 | instruction |= 0b1111; |
protongamer | 1:4d70e593345f | 313 | } |
protongamer | 1:4d70e593345f | 314 | |
protongamer | 1:4d70e593345f | 315 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 316 | instruction = 0b1111; |
protongamer | 1:4d70e593345f | 317 | state_val++; |
protongamer | 1:4d70e593345f | 318 | } |
protongamer | 1:4d70e593345f | 319 | |
protongamer | 1:4d70e593345f | 320 | break; |
protongamer | 1:4d70e593345f | 321 | |
protongamer | 1:4d70e593345f | 322 | case 'A': |
protongamer | 1:4d70e593345f | 323 | pc.printf("a"); |
protongamer | 1:4d70e593345f | 324 | |
protongamer | 1:4d70e593345f | 325 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 326 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 327 | instruction |= 0b1010; |
protongamer | 1:4d70e593345f | 328 | } |
protongamer | 1:4d70e593345f | 329 | |
protongamer | 1:4d70e593345f | 330 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 331 | instruction = 0b1010; |
protongamer | 1:4d70e593345f | 332 | state_val++; |
protongamer | 1:4d70e593345f | 333 | } |
protongamer | 1:4d70e593345f | 334 | |
protongamer | 1:4d70e593345f | 335 | break; |
protongamer | 1:4d70e593345f | 336 | |
protongamer | 1:4d70e593345f | 337 | case 'B': |
protongamer | 1:4d70e593345f | 338 | pc.printf("b"); |
protongamer | 1:4d70e593345f | 339 | |
protongamer | 1:4d70e593345f | 340 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 341 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 342 | instruction |= 0b1011; |
protongamer | 1:4d70e593345f | 343 | } |
protongamer | 1:4d70e593345f | 344 | |
protongamer | 1:4d70e593345f | 345 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 346 | instruction = 0b1011; |
protongamer | 1:4d70e593345f | 347 | state_val++; |
protongamer | 1:4d70e593345f | 348 | } |
protongamer | 1:4d70e593345f | 349 | |
protongamer | 1:4d70e593345f | 350 | break; |
protongamer | 1:4d70e593345f | 351 | |
protongamer | 1:4d70e593345f | 352 | case 'C': |
protongamer | 1:4d70e593345f | 353 | pc.printf("c"); |
protongamer | 1:4d70e593345f | 354 | |
protongamer | 1:4d70e593345f | 355 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 356 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 357 | instruction |= 0b1100; |
protongamer | 1:4d70e593345f | 358 | } |
protongamer | 1:4d70e593345f | 359 | |
protongamer | 1:4d70e593345f | 360 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 361 | instruction = 0b1100; |
protongamer | 1:4d70e593345f | 362 | state_val++; |
protongamer | 1:4d70e593345f | 363 | } |
protongamer | 1:4d70e593345f | 364 | |
protongamer | 1:4d70e593345f | 365 | break; |
protongamer | 1:4d70e593345f | 366 | |
protongamer | 1:4d70e593345f | 367 | case 'D': |
protongamer | 1:4d70e593345f | 368 | pc.printf("d"); |
protongamer | 1:4d70e593345f | 369 | |
protongamer | 1:4d70e593345f | 370 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 371 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 372 | instruction |= 0b1101; |
protongamer | 1:4d70e593345f | 373 | } |
protongamer | 1:4d70e593345f | 374 | |
protongamer | 1:4d70e593345f | 375 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 376 | instruction = 0b1101; |
protongamer | 1:4d70e593345f | 377 | state_val++; |
protongamer | 1:4d70e593345f | 378 | } |
protongamer | 1:4d70e593345f | 379 | |
protongamer | 1:4d70e593345f | 380 | break; |
protongamer | 1:4d70e593345f | 381 | |
protongamer | 1:4d70e593345f | 382 | case 'E': |
protongamer | 1:4d70e593345f | 383 | pc.printf("e"); |
protongamer | 1:4d70e593345f | 384 | |
protongamer | 1:4d70e593345f | 385 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 386 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 387 | instruction |= 0b1110; |
protongamer | 1:4d70e593345f | 388 | } |
protongamer | 1:4d70e593345f | 389 | |
protongamer | 1:4d70e593345f | 390 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 391 | instruction = 0b1110; |
protongamer | 1:4d70e593345f | 392 | state_val++; |
protongamer | 1:4d70e593345f | 393 | } |
protongamer | 1:4d70e593345f | 394 | |
protongamer | 1:4d70e593345f | 395 | break; |
protongamer | 1:4d70e593345f | 396 | |
protongamer | 1:4d70e593345f | 397 | case 'F': |
protongamer | 1:4d70e593345f | 398 | pc.printf("f"); |
protongamer | 1:4d70e593345f | 399 | |
protongamer | 1:4d70e593345f | 400 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 401 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 402 | instruction |= 0b1111; |
protongamer | 1:4d70e593345f | 403 | } |
protongamer | 1:4d70e593345f | 404 | |
protongamer | 1:4d70e593345f | 405 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 406 | instruction = 0b1111; |
protongamer | 1:4d70e593345f | 407 | state_val++; |
protongamer | 1:4d70e593345f | 408 | } |
protongamer | 1:4d70e593345f | 409 | |
protongamer | 1:4d70e593345f | 410 | break; |
protongamer | 1:4d70e593345f | 411 | |
protongamer | 1:4d70e593345f | 412 | case '\r': |
protongamer | 1:4d70e593345f | 413 | pc.printf("\r\nOk\r\n"); |
protongamer | 1:4d70e593345f | 414 | identif = instruction; |
protongamer | 1:4d70e593345f | 415 | state++; |
protongamer | 1:4d70e593345f | 416 | |
protongamer | 1:4d70e593345f | 417 | break; |
protongamer | 1:4d70e593345f | 418 | |
protongamer | 1:4d70e593345f | 419 | } |
protongamer | 1:4d70e593345f | 420 | } |
protongamer | 1:4d70e593345f | 421 | |
protongamer | 1:4d70e593345f | 422 | pc.printf("\r\n Number of octets : "); |
protongamer | 1:4d70e593345f | 423 | |
protongamer | 1:4d70e593345f | 424 | c = pc.getc(); |
protongamer | 1:4d70e593345f | 425 | instruction = 0; |
protongamer | 1:4d70e593345f | 426 | state_val = 0; |
protongamer | 1:4d70e593345f | 427 | |
protongamer | 1:4d70e593345f | 428 | switch(c){ |
protongamer | 1:4d70e593345f | 429 | case '0': |
protongamer | 1:4d70e593345f | 430 | pc.printf("0"); |
protongamer | 1:4d70e593345f | 431 | |
protongamer | 1:4d70e593345f | 432 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 433 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 434 | instruction |= 0b0000; |
protongamer | 1:4d70e593345f | 435 | } |
protongamer | 1:4d70e593345f | 436 | |
protongamer | 1:4d70e593345f | 437 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 438 | instruction = 0b0000; |
protongamer | 1:4d70e593345f | 439 | state_val++; |
protongamer | 1:4d70e593345f | 440 | } |
protongamer | 1:4d70e593345f | 441 | |
protongamer | 1:4d70e593345f | 442 | break; |
protongamer | 1:4d70e593345f | 443 | |
protongamer | 1:4d70e593345f | 444 | case '1': |
protongamer | 1:4d70e593345f | 445 | |
protongamer | 1:4d70e593345f | 446 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 447 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 448 | instruction |= 0b0001; |
protongamer | 1:4d70e593345f | 449 | } |
protongamer | 1:4d70e593345f | 450 | |
protongamer | 1:4d70e593345f | 451 | pc.printf("1"); |
protongamer | 1:4d70e593345f | 452 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 453 | instruction = 0b0001; |
protongamer | 1:4d70e593345f | 454 | state_val++; |
protongamer | 1:4d70e593345f | 455 | } |
protongamer | 1:4d70e593345f | 456 | |
protongamer | 1:4d70e593345f | 457 | break; |
protongamer | 1:4d70e593345f | 458 | |
protongamer | 1:4d70e593345f | 459 | case '2': |
protongamer | 1:4d70e593345f | 460 | |
protongamer | 1:4d70e593345f | 461 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 462 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 463 | instruction |= 0b0010; |
protongamer | 1:4d70e593345f | 464 | } |
protongamer | 1:4d70e593345f | 465 | |
protongamer | 1:4d70e593345f | 466 | pc.printf("2"); |
protongamer | 1:4d70e593345f | 467 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 468 | instruction = 0b0010; |
protongamer | 1:4d70e593345f | 469 | state_val++; |
protongamer | 1:4d70e593345f | 470 | } |
protongamer | 1:4d70e593345f | 471 | |
protongamer | 1:4d70e593345f | 472 | break; |
protongamer | 1:4d70e593345f | 473 | |
protongamer | 1:4d70e593345f | 474 | case '3': |
protongamer | 1:4d70e593345f | 475 | pc.printf("3"); |
protongamer | 1:4d70e593345f | 476 | |
protongamer | 1:4d70e593345f | 477 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 478 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 479 | instruction |= 0b0011; |
protongamer | 1:4d70e593345f | 480 | } |
protongamer | 1:4d70e593345f | 481 | |
protongamer | 1:4d70e593345f | 482 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 483 | instruction = 0b0011; |
protongamer | 1:4d70e593345f | 484 | state_val++; |
protongamer | 1:4d70e593345f | 485 | } |
protongamer | 1:4d70e593345f | 486 | |
protongamer | 1:4d70e593345f | 487 | break; |
protongamer | 1:4d70e593345f | 488 | |
protongamer | 1:4d70e593345f | 489 | case '4': |
protongamer | 1:4d70e593345f | 490 | |
protongamer | 1:4d70e593345f | 491 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 492 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 493 | instruction |= 0b0100; |
protongamer | 1:4d70e593345f | 494 | } |
protongamer | 1:4d70e593345f | 495 | |
protongamer | 1:4d70e593345f | 496 | pc.printf("4"); |
protongamer | 1:4d70e593345f | 497 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 498 | instruction = 0b0100; |
protongamer | 1:4d70e593345f | 499 | state_val++; |
protongamer | 1:4d70e593345f | 500 | } |
protongamer | 1:4d70e593345f | 501 | |
protongamer | 1:4d70e593345f | 502 | break; |
protongamer | 1:4d70e593345f | 503 | |
protongamer | 1:4d70e593345f | 504 | case '5': |
protongamer | 1:4d70e593345f | 505 | pc.printf("5"); |
protongamer | 1:4d70e593345f | 506 | |
protongamer | 1:4d70e593345f | 507 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 508 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 509 | instruction |= 0b0101; |
protongamer | 1:4d70e593345f | 510 | } |
protongamer | 1:4d70e593345f | 511 | |
protongamer | 1:4d70e593345f | 512 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 513 | instruction = 0b0101; |
protongamer | 1:4d70e593345f | 514 | state_val++; |
protongamer | 1:4d70e593345f | 515 | } |
protongamer | 1:4d70e593345f | 516 | |
protongamer | 1:4d70e593345f | 517 | break; |
protongamer | 1:4d70e593345f | 518 | |
protongamer | 1:4d70e593345f | 519 | case '6': |
protongamer | 1:4d70e593345f | 520 | pc.printf("6"); |
protongamer | 1:4d70e593345f | 521 | |
protongamer | 1:4d70e593345f | 522 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 523 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 524 | instruction |= 0b0110; |
protongamer | 1:4d70e593345f | 525 | } |
protongamer | 1:4d70e593345f | 526 | |
protongamer | 1:4d70e593345f | 527 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 528 | instruction = 0b0110; |
protongamer | 1:4d70e593345f | 529 | state_val++; |
protongamer | 1:4d70e593345f | 530 | } |
protongamer | 1:4d70e593345f | 531 | |
protongamer | 1:4d70e593345f | 532 | break; |
protongamer | 1:4d70e593345f | 533 | |
protongamer | 1:4d70e593345f | 534 | case '7': |
protongamer | 1:4d70e593345f | 535 | pc.printf("7"); |
protongamer | 1:4d70e593345f | 536 | |
protongamer | 1:4d70e593345f | 537 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 538 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 539 | instruction |= 0b0111; |
protongamer | 1:4d70e593345f | 540 | } |
protongamer | 1:4d70e593345f | 541 | |
protongamer | 1:4d70e593345f | 542 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 543 | instruction = 0b0111; |
protongamer | 1:4d70e593345f | 544 | state_val++; |
protongamer | 1:4d70e593345f | 545 | } |
protongamer | 1:4d70e593345f | 546 | |
protongamer | 1:4d70e593345f | 547 | break; |
protongamer | 1:4d70e593345f | 548 | |
protongamer | 1:4d70e593345f | 549 | case '8': |
protongamer | 1:4d70e593345f | 550 | pc.printf("8"); |
protongamer | 1:4d70e593345f | 551 | |
protongamer | 1:4d70e593345f | 552 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 553 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 554 | instruction |= 0b1000; |
protongamer | 1:4d70e593345f | 555 | } |
protongamer | 1:4d70e593345f | 556 | |
protongamer | 1:4d70e593345f | 557 | |
protongamer | 1:4d70e593345f | 558 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 559 | instruction = 0b1000; |
protongamer | 1:4d70e593345f | 560 | state_val++; |
protongamer | 1:4d70e593345f | 561 | } |
protongamer | 1:4d70e593345f | 562 | |
protongamer | 1:4d70e593345f | 563 | break; |
protongamer | 1:4d70e593345f | 564 | |
protongamer | 1:4d70e593345f | 565 | case '9': |
protongamer | 1:4d70e593345f | 566 | pc.printf("9"); |
protongamer | 1:4d70e593345f | 567 | |
protongamer | 1:4d70e593345f | 568 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 569 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 570 | instruction |= 0b1001; |
protongamer | 1:4d70e593345f | 571 | } |
protongamer | 1:4d70e593345f | 572 | |
protongamer | 1:4d70e593345f | 573 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 574 | instruction = 0b1001; |
protongamer | 1:4d70e593345f | 575 | state_val++; |
protongamer | 1:4d70e593345f | 576 | } |
protongamer | 1:4d70e593345f | 577 | |
protongamer | 1:4d70e593345f | 578 | break; |
protongamer | 1:4d70e593345f | 579 | |
protongamer | 1:4d70e593345f | 580 | case 'a': |
protongamer | 1:4d70e593345f | 581 | pc.printf("a"); |
protongamer | 1:4d70e593345f | 582 | |
protongamer | 1:4d70e593345f | 583 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 584 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 585 | instruction |= 0b1010; |
protongamer | 1:4d70e593345f | 586 | } |
protongamer | 1:4d70e593345f | 587 | |
protongamer | 1:4d70e593345f | 588 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 589 | instruction = 0b1010; |
protongamer | 1:4d70e593345f | 590 | state_val++; |
protongamer | 1:4d70e593345f | 591 | } |
protongamer | 1:4d70e593345f | 592 | |
protongamer | 1:4d70e593345f | 593 | break; |
protongamer | 1:4d70e593345f | 594 | |
protongamer | 1:4d70e593345f | 595 | case 'b': |
protongamer | 1:4d70e593345f | 596 | pc.printf("b"); |
protongamer | 1:4d70e593345f | 597 | |
protongamer | 1:4d70e593345f | 598 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 599 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 600 | instruction |= 0b1011; |
protongamer | 1:4d70e593345f | 601 | } |
protongamer | 1:4d70e593345f | 602 | |
protongamer | 1:4d70e593345f | 603 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 604 | instruction = 0b1011; |
protongamer | 1:4d70e593345f | 605 | state_val++; |
protongamer | 1:4d70e593345f | 606 | } |
protongamer | 1:4d70e593345f | 607 | |
protongamer | 1:4d70e593345f | 608 | break; |
protongamer | 1:4d70e593345f | 609 | |
protongamer | 1:4d70e593345f | 610 | case 'c': |
protongamer | 1:4d70e593345f | 611 | pc.printf("c"); |
protongamer | 1:4d70e593345f | 612 | |
protongamer | 1:4d70e593345f | 613 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 614 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 615 | instruction |= 0b1100; |
protongamer | 1:4d70e593345f | 616 | } |
protongamer | 1:4d70e593345f | 617 | |
protongamer | 1:4d70e593345f | 618 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 619 | instruction = 0b1100; |
protongamer | 1:4d70e593345f | 620 | state_val++; |
protongamer | 1:4d70e593345f | 621 | } |
protongamer | 1:4d70e593345f | 622 | |
protongamer | 1:4d70e593345f | 623 | break; |
protongamer | 1:4d70e593345f | 624 | |
protongamer | 1:4d70e593345f | 625 | case 'd': |
protongamer | 1:4d70e593345f | 626 | pc.printf("d"); |
protongamer | 1:4d70e593345f | 627 | |
protongamer | 1:4d70e593345f | 628 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 629 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 630 | instruction |= 0b1101; |
protongamer | 1:4d70e593345f | 631 | } |
protongamer | 1:4d70e593345f | 632 | |
protongamer | 1:4d70e593345f | 633 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 634 | instruction = 0b1101; |
protongamer | 1:4d70e593345f | 635 | state_val++; |
protongamer | 1:4d70e593345f | 636 | } |
protongamer | 1:4d70e593345f | 637 | |
protongamer | 1:4d70e593345f | 638 | break; |
protongamer | 1:4d70e593345f | 639 | |
protongamer | 1:4d70e593345f | 640 | case 'e': |
protongamer | 1:4d70e593345f | 641 | pc.printf("e"); |
protongamer | 1:4d70e593345f | 642 | |
protongamer | 1:4d70e593345f | 643 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 644 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 645 | instruction |= 0b1110; |
protongamer | 1:4d70e593345f | 646 | } |
protongamer | 1:4d70e593345f | 647 | |
protongamer | 1:4d70e593345f | 648 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 649 | instruction = 0b1110; |
protongamer | 1:4d70e593345f | 650 | state_val++; |
protongamer | 1:4d70e593345f | 651 | } |
protongamer | 1:4d70e593345f | 652 | |
protongamer | 1:4d70e593345f | 653 | break; |
protongamer | 1:4d70e593345f | 654 | |
protongamer | 1:4d70e593345f | 655 | case 'f': |
protongamer | 1:4d70e593345f | 656 | pc.printf("f"); |
protongamer | 1:4d70e593345f | 657 | |
protongamer | 1:4d70e593345f | 658 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 659 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 660 | instruction |= 0b1111; |
protongamer | 1:4d70e593345f | 661 | } |
protongamer | 1:4d70e593345f | 662 | |
protongamer | 1:4d70e593345f | 663 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 664 | instruction = 0b1111; |
protongamer | 1:4d70e593345f | 665 | state_val++; |
protongamer | 1:4d70e593345f | 666 | } |
protongamer | 1:4d70e593345f | 667 | |
protongamer | 1:4d70e593345f | 668 | break; |
protongamer | 1:4d70e593345f | 669 | |
protongamer | 1:4d70e593345f | 670 | case 'A': |
protongamer | 1:4d70e593345f | 671 | pc.printf("a"); |
protongamer | 1:4d70e593345f | 672 | |
protongamer | 1:4d70e593345f | 673 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 674 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 675 | instruction |= 0b1010; |
protongamer | 1:4d70e593345f | 676 | } |
protongamer | 1:4d70e593345f | 677 | |
protongamer | 1:4d70e593345f | 678 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 679 | instruction = 0b1010; |
protongamer | 1:4d70e593345f | 680 | state_val++; |
protongamer | 1:4d70e593345f | 681 | } |
protongamer | 1:4d70e593345f | 682 | |
protongamer | 1:4d70e593345f | 683 | break; |
protongamer | 1:4d70e593345f | 684 | |
protongamer | 1:4d70e593345f | 685 | case 'B': |
protongamer | 1:4d70e593345f | 686 | pc.printf("b"); |
protongamer | 1:4d70e593345f | 687 | |
protongamer | 1:4d70e593345f | 688 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 689 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 690 | instruction |= 0b1011; |
protongamer | 1:4d70e593345f | 691 | } |
protongamer | 1:4d70e593345f | 692 | |
protongamer | 1:4d70e593345f | 693 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 694 | instruction = 0b1011; |
protongamer | 1:4d70e593345f | 695 | state_val++; |
protongamer | 1:4d70e593345f | 696 | } |
protongamer | 1:4d70e593345f | 697 | |
protongamer | 1:4d70e593345f | 698 | break; |
protongamer | 1:4d70e593345f | 699 | |
protongamer | 1:4d70e593345f | 700 | case 'C': |
protongamer | 1:4d70e593345f | 701 | pc.printf("c"); |
protongamer | 1:4d70e593345f | 702 | |
protongamer | 1:4d70e593345f | 703 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 704 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 705 | instruction |= 0b1100; |
protongamer | 1:4d70e593345f | 706 | } |
protongamer | 1:4d70e593345f | 707 | |
protongamer | 1:4d70e593345f | 708 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 709 | instruction = 0b1100; |
protongamer | 1:4d70e593345f | 710 | state_val++; |
protongamer | 1:4d70e593345f | 711 | } |
protongamer | 1:4d70e593345f | 712 | |
protongamer | 1:4d70e593345f | 713 | break; |
protongamer | 1:4d70e593345f | 714 | |
protongamer | 1:4d70e593345f | 715 | case 'D': |
protongamer | 1:4d70e593345f | 716 | pc.printf("d"); |
protongamer | 1:4d70e593345f | 717 | |
protongamer | 1:4d70e593345f | 718 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 719 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 720 | instruction |= 0b1101; |
protongamer | 1:4d70e593345f | 721 | } |
protongamer | 1:4d70e593345f | 722 | |
protongamer | 1:4d70e593345f | 723 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 724 | instruction = 0b1101; |
protongamer | 1:4d70e593345f | 725 | state_val++; |
protongamer | 1:4d70e593345f | 726 | } |
protongamer | 1:4d70e593345f | 727 | |
protongamer | 1:4d70e593345f | 728 | break; |
protongamer | 1:4d70e593345f | 729 | |
protongamer | 1:4d70e593345f | 730 | case 'E': |
protongamer | 1:4d70e593345f | 731 | pc.printf("e"); |
protongamer | 1:4d70e593345f | 732 | |
protongamer | 1:4d70e593345f | 733 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 734 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 735 | instruction |= 0b1110; |
protongamer | 1:4d70e593345f | 736 | } |
protongamer | 1:4d70e593345f | 737 | |
protongamer | 1:4d70e593345f | 738 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 739 | instruction = 0b1110; |
protongamer | 1:4d70e593345f | 740 | state_val++; |
protongamer | 1:4d70e593345f | 741 | } |
protongamer | 1:4d70e593345f | 742 | |
protongamer | 1:4d70e593345f | 743 | break; |
protongamer | 1:4d70e593345f | 744 | |
protongamer | 1:4d70e593345f | 745 | case 'F': |
protongamer | 1:4d70e593345f | 746 | pc.printf("f"); |
protongamer | 1:4d70e593345f | 747 | |
protongamer | 1:4d70e593345f | 748 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 749 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 750 | instruction |= 0b1111; |
protongamer | 1:4d70e593345f | 751 | } |
protongamer | 1:4d70e593345f | 752 | |
protongamer | 1:4d70e593345f | 753 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 754 | instruction = 0b1111; |
protongamer | 1:4d70e593345f | 755 | state_val++; |
protongamer | 1:4d70e593345f | 756 | } |
protongamer | 1:4d70e593345f | 757 | |
protongamer | 1:4d70e593345f | 758 | break; |
protongamer | 1:4d70e593345f | 759 | |
protongamer | 1:4d70e593345f | 760 | } |
protongamer | 1:4d70e593345f | 761 | |
protongamer | 1:4d70e593345f | 762 | length = instruction; |
protongamer | 1:4d70e593345f | 763 | pc.printf("\r\n"); |
protongamer | 1:4d70e593345f | 764 | if(length > 0){ |
protongamer | 1:4d70e593345f | 765 | pc.printf("Send octets in hexa\r\n"); |
protongamer | 1:4d70e593345f | 766 | i = 0; |
protongamer | 1:4d70e593345f | 767 | pc.printf("\r\n Octet[%d] : ", i); |
protongamer | 1:4d70e593345f | 768 | while(i <= length - 1){ |
protongamer | 1:4d70e593345f | 769 | |
protongamer | 1:4d70e593345f | 770 | |
protongamer | 1:4d70e593345f | 771 | c = pc.getc(); |
protongamer | 1:4d70e593345f | 772 | switch(c){ |
protongamer | 1:4d70e593345f | 773 | case '0': |
protongamer | 1:4d70e593345f | 774 | pc.printf("0"); |
protongamer | 1:4d70e593345f | 775 | |
protongamer | 1:4d70e593345f | 776 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 777 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 778 | instruction |= 0b0000; |
protongamer | 1:4d70e593345f | 779 | } |
protongamer | 1:4d70e593345f | 780 | |
protongamer | 1:4d70e593345f | 781 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 782 | instruction = 0b0000; |
protongamer | 1:4d70e593345f | 783 | state_val++; |
protongamer | 1:4d70e593345f | 784 | } |
protongamer | 1:4d70e593345f | 785 | |
protongamer | 1:4d70e593345f | 786 | break; |
protongamer | 1:4d70e593345f | 787 | |
protongamer | 1:4d70e593345f | 788 | case '1': |
protongamer | 1:4d70e593345f | 789 | |
protongamer | 1:4d70e593345f | 790 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 791 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 792 | instruction |= 0b0001; |
protongamer | 1:4d70e593345f | 793 | } |
protongamer | 1:4d70e593345f | 794 | |
protongamer | 1:4d70e593345f | 795 | pc.printf("1"); |
protongamer | 1:4d70e593345f | 796 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 797 | instruction = 0b0001; |
protongamer | 1:4d70e593345f | 798 | state_val++; |
protongamer | 1:4d70e593345f | 799 | } |
protongamer | 1:4d70e593345f | 800 | |
protongamer | 1:4d70e593345f | 801 | break; |
protongamer | 1:4d70e593345f | 802 | |
protongamer | 1:4d70e593345f | 803 | case '2': |
protongamer | 1:4d70e593345f | 804 | |
protongamer | 1:4d70e593345f | 805 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 806 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 807 | instruction |= 0b0010; |
protongamer | 1:4d70e593345f | 808 | } |
protongamer | 1:4d70e593345f | 809 | |
protongamer | 1:4d70e593345f | 810 | pc.printf("2"); |
protongamer | 1:4d70e593345f | 811 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 812 | instruction = 0b0010; |
protongamer | 1:4d70e593345f | 813 | state_val++; |
protongamer | 1:4d70e593345f | 814 | } |
protongamer | 1:4d70e593345f | 815 | |
protongamer | 1:4d70e593345f | 816 | break; |
protongamer | 1:4d70e593345f | 817 | |
protongamer | 1:4d70e593345f | 818 | case '3': |
protongamer | 1:4d70e593345f | 819 | pc.printf("3"); |
protongamer | 1:4d70e593345f | 820 | |
protongamer | 1:4d70e593345f | 821 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 822 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 823 | instruction |= 0b0011; |
protongamer | 1:4d70e593345f | 824 | } |
protongamer | 1:4d70e593345f | 825 | |
protongamer | 1:4d70e593345f | 826 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 827 | instruction = 0b0011; |
protongamer | 1:4d70e593345f | 828 | state_val++; |
protongamer | 1:4d70e593345f | 829 | } |
protongamer | 1:4d70e593345f | 830 | |
protongamer | 1:4d70e593345f | 831 | break; |
protongamer | 1:4d70e593345f | 832 | |
protongamer | 1:4d70e593345f | 833 | case '4': |
protongamer | 1:4d70e593345f | 834 | |
protongamer | 1:4d70e593345f | 835 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 836 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 837 | instruction |= 0b0100; |
protongamer | 1:4d70e593345f | 838 | } |
protongamer | 1:4d70e593345f | 839 | |
protongamer | 1:4d70e593345f | 840 | pc.printf("4"); |
protongamer | 1:4d70e593345f | 841 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 842 | instruction = 0b0100; |
protongamer | 1:4d70e593345f | 843 | state_val++; |
protongamer | 1:4d70e593345f | 844 | } |
protongamer | 1:4d70e593345f | 845 | |
protongamer | 1:4d70e593345f | 846 | break; |
protongamer | 1:4d70e593345f | 847 | |
protongamer | 1:4d70e593345f | 848 | case '5': |
protongamer | 1:4d70e593345f | 849 | pc.printf("5"); |
protongamer | 1:4d70e593345f | 850 | |
protongamer | 1:4d70e593345f | 851 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 852 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 853 | instruction |= 0b0101; |
protongamer | 1:4d70e593345f | 854 | } |
protongamer | 1:4d70e593345f | 855 | |
protongamer | 1:4d70e593345f | 856 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 857 | instruction = 0b0101; |
protongamer | 1:4d70e593345f | 858 | state_val++; |
protongamer | 1:4d70e593345f | 859 | } |
protongamer | 1:4d70e593345f | 860 | |
protongamer | 1:4d70e593345f | 861 | break; |
protongamer | 1:4d70e593345f | 862 | |
protongamer | 1:4d70e593345f | 863 | case '6': |
protongamer | 1:4d70e593345f | 864 | pc.printf("6"); |
protongamer | 1:4d70e593345f | 865 | |
protongamer | 1:4d70e593345f | 866 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 867 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 868 | instruction |= 0b0110; |
protongamer | 1:4d70e593345f | 869 | } |
protongamer | 1:4d70e593345f | 870 | |
protongamer | 1:4d70e593345f | 871 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 872 | instruction = 0b0110; |
protongamer | 1:4d70e593345f | 873 | state_val++; |
protongamer | 1:4d70e593345f | 874 | } |
protongamer | 1:4d70e593345f | 875 | |
protongamer | 1:4d70e593345f | 876 | break; |
protongamer | 1:4d70e593345f | 877 | |
protongamer | 1:4d70e593345f | 878 | case '7': |
protongamer | 1:4d70e593345f | 879 | pc.printf("7"); |
protongamer | 1:4d70e593345f | 880 | |
protongamer | 1:4d70e593345f | 881 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 882 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 883 | instruction |= 0b0111; |
protongamer | 1:4d70e593345f | 884 | } |
protongamer | 1:4d70e593345f | 885 | |
protongamer | 1:4d70e593345f | 886 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 887 | instruction = 0b0111; |
protongamer | 1:4d70e593345f | 888 | state_val++; |
protongamer | 1:4d70e593345f | 889 | } |
protongamer | 1:4d70e593345f | 890 | |
protongamer | 1:4d70e593345f | 891 | break; |
protongamer | 1:4d70e593345f | 892 | |
protongamer | 1:4d70e593345f | 893 | case '8': |
protongamer | 1:4d70e593345f | 894 | pc.printf("8"); |
protongamer | 1:4d70e593345f | 895 | |
protongamer | 1:4d70e593345f | 896 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 897 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 898 | instruction |= 0b1000; |
protongamer | 1:4d70e593345f | 899 | } |
protongamer | 1:4d70e593345f | 900 | |
protongamer | 1:4d70e593345f | 901 | |
protongamer | 1:4d70e593345f | 902 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 903 | instruction = 0b1000; |
protongamer | 1:4d70e593345f | 904 | state_val++; |
protongamer | 1:4d70e593345f | 905 | } |
protongamer | 1:4d70e593345f | 906 | |
protongamer | 1:4d70e593345f | 907 | break; |
protongamer | 1:4d70e593345f | 908 | |
protongamer | 1:4d70e593345f | 909 | case '9': |
protongamer | 1:4d70e593345f | 910 | pc.printf("9"); |
protongamer | 1:4d70e593345f | 911 | |
protongamer | 1:4d70e593345f | 912 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 913 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 914 | instruction |= 0b1001; |
protongamer | 1:4d70e593345f | 915 | } |
protongamer | 1:4d70e593345f | 916 | |
protongamer | 1:4d70e593345f | 917 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 918 | instruction = 0b1001; |
protongamer | 1:4d70e593345f | 919 | state_val++; |
protongamer | 1:4d70e593345f | 920 | } |
protongamer | 1:4d70e593345f | 921 | |
protongamer | 1:4d70e593345f | 922 | break; |
protongamer | 1:4d70e593345f | 923 | |
protongamer | 1:4d70e593345f | 924 | case 'a': |
protongamer | 1:4d70e593345f | 925 | pc.printf("a"); |
protongamer | 1:4d70e593345f | 926 | |
protongamer | 1:4d70e593345f | 927 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 928 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 929 | instruction |= 0b1010; |
protongamer | 1:4d70e593345f | 930 | } |
protongamer | 1:4d70e593345f | 931 | |
protongamer | 1:4d70e593345f | 932 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 933 | instruction = 0b1010; |
protongamer | 1:4d70e593345f | 934 | state_val++; |
protongamer | 1:4d70e593345f | 935 | } |
protongamer | 1:4d70e593345f | 936 | |
protongamer | 1:4d70e593345f | 937 | break; |
protongamer | 1:4d70e593345f | 938 | |
protongamer | 1:4d70e593345f | 939 | case 'b': |
protongamer | 1:4d70e593345f | 940 | pc.printf("b"); |
protongamer | 1:4d70e593345f | 941 | |
protongamer | 1:4d70e593345f | 942 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 943 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 944 | instruction |= 0b1011; |
protongamer | 1:4d70e593345f | 945 | } |
protongamer | 1:4d70e593345f | 946 | |
protongamer | 1:4d70e593345f | 947 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 948 | instruction = 0b1011; |
protongamer | 1:4d70e593345f | 949 | state_val++; |
protongamer | 1:4d70e593345f | 950 | } |
protongamer | 1:4d70e593345f | 951 | |
protongamer | 1:4d70e593345f | 952 | break; |
protongamer | 1:4d70e593345f | 953 | |
protongamer | 1:4d70e593345f | 954 | case 'c': |
protongamer | 1:4d70e593345f | 955 | pc.printf("c"); |
protongamer | 1:4d70e593345f | 956 | |
protongamer | 1:4d70e593345f | 957 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 958 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 959 | instruction |= 0b1100; |
protongamer | 1:4d70e593345f | 960 | } |
protongamer | 1:4d70e593345f | 961 | |
protongamer | 1:4d70e593345f | 962 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 963 | instruction = 0b1100; |
protongamer | 1:4d70e593345f | 964 | state_val++; |
protongamer | 1:4d70e593345f | 965 | } |
protongamer | 1:4d70e593345f | 966 | |
protongamer | 1:4d70e593345f | 967 | break; |
protongamer | 1:4d70e593345f | 968 | |
protongamer | 1:4d70e593345f | 969 | case 'd': |
protongamer | 1:4d70e593345f | 970 | pc.printf("d"); |
protongamer | 1:4d70e593345f | 971 | |
protongamer | 1:4d70e593345f | 972 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 973 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 974 | instruction |= 0b1101; |
protongamer | 1:4d70e593345f | 975 | } |
protongamer | 1:4d70e593345f | 976 | |
protongamer | 1:4d70e593345f | 977 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 978 | instruction = 0b1101; |
protongamer | 1:4d70e593345f | 979 | state_val++; |
protongamer | 1:4d70e593345f | 980 | } |
protongamer | 1:4d70e593345f | 981 | |
protongamer | 1:4d70e593345f | 982 | break; |
protongamer | 1:4d70e593345f | 983 | |
protongamer | 1:4d70e593345f | 984 | case 'e': |
protongamer | 1:4d70e593345f | 985 | pc.printf("e"); |
protongamer | 1:4d70e593345f | 986 | |
protongamer | 1:4d70e593345f | 987 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 988 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 989 | instruction |= 0b1110; |
protongamer | 1:4d70e593345f | 990 | } |
protongamer | 1:4d70e593345f | 991 | |
protongamer | 1:4d70e593345f | 992 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 993 | instruction = 0b1110; |
protongamer | 1:4d70e593345f | 994 | state_val++; |
protongamer | 1:4d70e593345f | 995 | } |
protongamer | 1:4d70e593345f | 996 | |
protongamer | 1:4d70e593345f | 997 | break; |
protongamer | 1:4d70e593345f | 998 | |
protongamer | 1:4d70e593345f | 999 | case 'f': |
protongamer | 1:4d70e593345f | 1000 | pc.printf("f"); |
protongamer | 1:4d70e593345f | 1001 | |
protongamer | 1:4d70e593345f | 1002 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1003 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1004 | instruction |= 0b1111; |
protongamer | 1:4d70e593345f | 1005 | } |
protongamer | 1:4d70e593345f | 1006 | |
protongamer | 1:4d70e593345f | 1007 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1008 | instruction = 0b1111; |
protongamer | 1:4d70e593345f | 1009 | state_val++; |
protongamer | 1:4d70e593345f | 1010 | } |
protongamer | 1:4d70e593345f | 1011 | |
protongamer | 1:4d70e593345f | 1012 | break; |
protongamer | 1:4d70e593345f | 1013 | |
protongamer | 1:4d70e593345f | 1014 | case 'A': |
protongamer | 1:4d70e593345f | 1015 | pc.printf("a"); |
protongamer | 1:4d70e593345f | 1016 | |
protongamer | 1:4d70e593345f | 1017 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1018 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1019 | instruction |= 0b1010; |
protongamer | 1:4d70e593345f | 1020 | } |
protongamer | 1:4d70e593345f | 1021 | |
protongamer | 1:4d70e593345f | 1022 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1023 | instruction = 0b1010; |
protongamer | 1:4d70e593345f | 1024 | state_val++; |
protongamer | 1:4d70e593345f | 1025 | } |
protongamer | 1:4d70e593345f | 1026 | |
protongamer | 1:4d70e593345f | 1027 | break; |
protongamer | 1:4d70e593345f | 1028 | |
protongamer | 1:4d70e593345f | 1029 | case 'B': |
protongamer | 1:4d70e593345f | 1030 | pc.printf("b"); |
protongamer | 1:4d70e593345f | 1031 | |
protongamer | 1:4d70e593345f | 1032 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1033 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1034 | instruction |= 0b1011; |
protongamer | 1:4d70e593345f | 1035 | } |
protongamer | 1:4d70e593345f | 1036 | |
protongamer | 1:4d70e593345f | 1037 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1038 | instruction = 0b1011; |
protongamer | 1:4d70e593345f | 1039 | state_val++; |
protongamer | 1:4d70e593345f | 1040 | } |
protongamer | 1:4d70e593345f | 1041 | |
protongamer | 1:4d70e593345f | 1042 | break; |
protongamer | 1:4d70e593345f | 1043 | |
protongamer | 1:4d70e593345f | 1044 | case 'C': |
protongamer | 1:4d70e593345f | 1045 | pc.printf("c"); |
protongamer | 1:4d70e593345f | 1046 | |
protongamer | 1:4d70e593345f | 1047 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1048 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1049 | instruction |= 0b1100; |
protongamer | 1:4d70e593345f | 1050 | } |
protongamer | 1:4d70e593345f | 1051 | |
protongamer | 1:4d70e593345f | 1052 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1053 | instruction = 0b1100; |
protongamer | 1:4d70e593345f | 1054 | state_val++; |
protongamer | 1:4d70e593345f | 1055 | } |
protongamer | 1:4d70e593345f | 1056 | |
protongamer | 1:4d70e593345f | 1057 | break; |
protongamer | 1:4d70e593345f | 1058 | |
protongamer | 1:4d70e593345f | 1059 | case 'D': |
protongamer | 1:4d70e593345f | 1060 | pc.printf("d"); |
protongamer | 1:4d70e593345f | 1061 | |
protongamer | 1:4d70e593345f | 1062 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1063 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1064 | instruction |= 0b1101; |
protongamer | 1:4d70e593345f | 1065 | } |
protongamer | 1:4d70e593345f | 1066 | |
protongamer | 1:4d70e593345f | 1067 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1068 | instruction = 0b1101; |
protongamer | 1:4d70e593345f | 1069 | state_val++; |
protongamer | 1:4d70e593345f | 1070 | } |
protongamer | 1:4d70e593345f | 1071 | |
protongamer | 1:4d70e593345f | 1072 | break; |
protongamer | 1:4d70e593345f | 1073 | |
protongamer | 1:4d70e593345f | 1074 | case 'E': |
protongamer | 1:4d70e593345f | 1075 | pc.printf("e"); |
protongamer | 1:4d70e593345f | 1076 | |
protongamer | 1:4d70e593345f | 1077 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1078 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1079 | instruction |= 0b1110; |
protongamer | 1:4d70e593345f | 1080 | } |
protongamer | 1:4d70e593345f | 1081 | |
protongamer | 1:4d70e593345f | 1082 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1083 | instruction = 0b1110; |
protongamer | 1:4d70e593345f | 1084 | state_val++; |
protongamer | 1:4d70e593345f | 1085 | } |
protongamer | 1:4d70e593345f | 1086 | |
protongamer | 1:4d70e593345f | 1087 | break; |
protongamer | 1:4d70e593345f | 1088 | |
protongamer | 1:4d70e593345f | 1089 | case 'F': |
protongamer | 1:4d70e593345f | 1090 | pc.printf("f"); |
protongamer | 1:4d70e593345f | 1091 | |
protongamer | 1:4d70e593345f | 1092 | if(state_val > 0){ |
protongamer | 1:4d70e593345f | 1093 | instruction = instruction << 4; |
protongamer | 1:4d70e593345f | 1094 | instruction |= 0b1111; |
protongamer | 1:4d70e593345f | 1095 | } |
protongamer | 1:4d70e593345f | 1096 | |
protongamer | 1:4d70e593345f | 1097 | if(state_val == 0){ |
protongamer | 1:4d70e593345f | 1098 | instruction = 0b1111; |
protongamer | 1:4d70e593345f | 1099 | state_val++; |
protongamer | 1:4d70e593345f | 1100 | } |
protongamer | 1:4d70e593345f | 1101 | |
protongamer | 1:4d70e593345f | 1102 | break; |
protongamer | 1:4d70e593345f | 1103 | |
protongamer | 1:4d70e593345f | 1104 | case '\r': |
protongamer | 1:4d70e593345f | 1105 | octet_send[i] = instruction; |
protongamer | 1:4d70e593345f | 1106 | instruction = 0; |
protongamer | 1:4d70e593345f | 1107 | state_val = 0; |
protongamer | 1:4d70e593345f | 1108 | i++; |
protongamer | 1:4d70e593345f | 1109 | if(i <= length - 1){ |
protongamer | 1:4d70e593345f | 1110 | pc.printf("\r\n Octet[%d] : ", i);} |
protongamer | 1:4d70e593345f | 1111 | break; |
protongamer | 1:4d70e593345f | 1112 | |
protongamer | 1:4d70e593345f | 1113 | } |
protongamer | 1:4d70e593345f | 1114 | |
protongamer | 1:4d70e593345f | 1115 | |
protongamer | 1:4d70e593345f | 1116 | }//end of while |
protongamer | 1:4d70e593345f | 1117 | } |
protongamer | 1:4d70e593345f | 1118 | pc.printf("Set RTR (1 or 0): "); |
protongamer | 1:4d70e593345f | 1119 | c = pc.getc(); |
protongamer | 1:4d70e593345f | 1120 | if(c == '0'){ |
protongamer | 1:4d70e593345f | 1121 | RemoteData = 'D'; |
protongamer | 1:4d70e593345f | 1122 | } |
protongamer | 1:4d70e593345f | 1123 | if(c == '1'){ |
protongamer | 1:4d70e593345f | 1124 | RemoteData = 'R'; |
protongamer | 1:4d70e593345f | 1125 | } |
protongamer | 1:4d70e593345f | 1126 | pc.printf("%c \r\n",c); |
protongamer | 1:4d70e593345f | 1127 | wait(2); |
protongamer | 1:4d70e593345f | 1128 | |
protongamer | 1:4d70e593345f | 1129 | send(identif, octet_send, RemoteData, length ); |
protongamer | 1:4d70e593345f | 1130 | data_rc = 0; |
protongamer | 1:4d70e593345f | 1131 | for(i = 0; i < 50; i++){ |
protongamer | 1:4d70e593345f | 1132 | pc.printf("Awaiting Data... \r\n"); |
protongamer | 1:4d70e593345f | 1133 | if(can2.read(msg)) { |
protongamer | 1:4d70e593345f | 1134 | pc.printf("Message received: 0x%x \r\n", msg.data[data_rc]); |
protongamer | 1:4d70e593345f | 1135 | data_report[data_rc] = msg.data[data_rc]; |
protongamer | 1:4d70e593345f | 1136 | data_rc++; |
protongamer | 1:4d70e593345f | 1137 | } |
protongamer | 1:4d70e593345f | 1138 | }//end of for |
protongamer | 1:4d70e593345f | 1139 | |
protongamer | 1:4d70e593345f | 1140 | |
protongamer | 1:4d70e593345f | 1141 | for(i = 0; i < data_rc; i++){ |
protongamer | 1:4d70e593345f | 1142 | pc.printf("Data captured %d : 0x%x \r\n", data_rc, data_report[i]); |
protongamer | 1:4d70e593345f | 1143 | |
protongamer | 1:4d70e593345f | 1144 | } |
protongamer | 1:4d70e593345f | 1145 | data_rc = 0; |
protongamer | 1:4d70e593345f | 1146 | i = 0; |
protongamer | 1:4d70e593345f | 1147 | state = 0; |
protongamer | 1:4d70e593345f | 1148 | pc.printf("\r\n"); |
protongamer | 1:4d70e593345f | 1149 | //end of for |
protongamer | 1:4d70e593345f | 1150 | |
protongamer | 1:4d70e593345f | 1151 | }// fin while(1) |
protongamer | 1:4d70e593345f | 1152 | |
protongamer | 1:4d70e593345f | 1153 | } // fin main |
protongamer | 1:4d70e593345f | 1154 | |
protongamer | 1:4d70e593345f | 1155 | /* |
protongamer | 1:4d70e593345f | 1156 | |
LouisReynier | 0:1ab5fdb4fa56 | 1157 | printf("loop()\n"); |
LouisReynier | 0:1ab5fdb4fa56 | 1158 | if(can2.read(msg)) { |
LouisReynier | 0:1ab5fdb4fa56 | 1159 | printf("Message received: %d\n", msg.data[0]); |
LouisReynier | 0:1ab5fdb4fa56 | 1160 | led2 = !led2; |
LouisReynier | 0:1ab5fdb4fa56 | 1161 | } |
LouisReynier | 0:1ab5fdb4fa56 | 1162 | wait(0.2); |
LouisReynier | 0:1ab5fdb4fa56 | 1163 | } |
protongamer | 1:4d70e593345f | 1164 | } */ |
protongamer | 1:4d70e593345f | 1165 | |
protongamer | 1:4d70e593345f | 1166 | //choix= 5*pot_1.read(); |
protongamer | 1:4d70e593345f | 1167 | // lcd.locate(0,0); |
protongamer | 1:4d70e593345f | 1168 | // lcd. printf("Trame %d \n", choix); |
protongamer | 1:4d70e593345f | 1169 | /* switch (choix) |
protongamer | 1:4d70e593345f | 1170 | { // debut sw |
protongamer | 1:4d70e593345f | 1171 | case (0): // Trame qui passe le noeud 15 en Operationnal state |
protongamer | 1:4d70e593345f | 1172 | { identif = 0x00 ; |
protongamer | 1:4d70e593345f | 1173 | octet_send[0] = 0x01 ; |
protongamer | 1:4d70e593345f | 1174 | octet_send[1] = 0x15 ; |
protongamer | 1:4d70e593345f | 1175 | RemoteData = 'D'; |
protongamer | 1:4d70e593345f | 1176 | length = 2 ; |
protongamer | 1:4d70e593345f | 1177 | break ; |
protongamer | 1:4d70e593345f | 1178 | } // fin case 0 |
protongamer | 1:4d70e593345f | 1179 | case (1): // Trame qui passe le noeud 20 en Operationnal state |
protongamer | 1:4d70e593345f | 1180 | { identif = 0x00 ; |
protongamer | 1:4d70e593345f | 1181 | octet_send[0] = 0x01 ; |
protongamer | 1:4d70e593345f | 1182 | octet_send[1] = 0x20 ; |
protongamer | 1:4d70e593345f | 1183 | RemoteData = 'D'; |
protongamer | 1:4d70e593345f | 1184 | length = 2 ; |
protongamer | 1:4d70e593345f | 1185 | break ; |
protongamer | 1:4d70e593345f | 1186 | } // fin case 1 |
protongamer | 1:4d70e593345f | 1187 | case (2): // trame qui ping le noeud 15 |
protongamer | 1:4d70e593345f | 1188 | { identif = 0x715 ; |
protongamer | 1:4d70e593345f | 1189 | for(i=0;i<9;i++) |
protongamer | 1:4d70e593345f | 1190 | { octet_send[i]='D';} // 44 en hexa par defaut |
protongamer | 1:4d70e593345f | 1191 | RemoteData = 'R'; |
protongamer | 1:4d70e593345f | 1192 | length = 0 ; |
protongamer | 1:4d70e593345f | 1193 | break ; |
protongamer | 1:4d70e593345f | 1194 | } // fin case 2 |
protongamer | 1:4d70e593345f | 1195 | case (3): // trame qui ping le noeud 20 |
protongamer | 1:4d70e593345f | 1196 | { identif = 0x720 ; |
protongamer | 1:4d70e593345f | 1197 | for(i=0;i<9;i++) |
protongamer | 1:4d70e593345f | 1198 | { octet_send[i]='D';} // 44 en hexa par defaut |
protongamer | 1:4d70e593345f | 1199 | RemoteData = 'R'; |
protongamer | 1:4d70e593345f | 1200 | length = 0 ; |
protongamer | 1:4d70e593345f | 1201 | break ; |
protongamer | 1:4d70e593345f | 1202 | } // fin case 3 |
protongamer | 1:4d70e593345f | 1203 | |
protongamer | 1:4d70e593345f | 1204 | default : // 4 ou 5 |
protongamer | 1:4d70e593345f | 1205 | { identif = 0x123 ; |
protongamer | 1:4d70e593345f | 1206 | for(i=0;i<9;i++) |
protongamer | 1:4d70e593345f | 1207 | { octet_send[i]='D';} // 44 en hexa par defaut |
protongamer | 1:4d70e593345f | 1208 | RemoteData = 'D'; |
protongamer | 1:4d70e593345f | 1209 | length = 8 ; |
protongamer | 1:4d70e593345f | 1210 | break ; |
protongamer | 1:4d70e593345f | 1211 | } // fin default |
protongamer | 1:4d70e593345f | 1212 | |
protongamer | 1:4d70e593345f | 1213 | } // fin switch |
protongamer | 1:4d70e593345f | 1214 | */ |