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