Callum and Adel's changes on 12/02/19
Dependencies: Crypto
Diff: main.cpp
- Revision:
- 15:2f95f2fb68e3
- Parent:
- 14:4e312fb83330
- Child:
- 16:db7ef0a4aa23
diff -r 4e312fb83330 -r 2f95f2fb68e3 main.cpp --- a/main.cpp Tue Mar 05 14:49:13 2019 +0000 +++ b/main.cpp Tue Mar 05 15:48:43 2019 +0000 @@ -134,22 +134,18 @@ uint64_t* nonce = (uint64_t*)((int)sequence + 56); uint8_t hash[32]; uint32_t length64 = 64; - -// MD2::computeHash(hash, (uint8_t*)msg, strlen(msg)); - - Miner.computeHash(hash, sequence, length64); - pc.printf("hash: "); - for(int i = 0; i < 32; ++i) - printf("%02x", hash[i]); - printf("\n"); + uint32_t hashCounter = 0; + Timer timer; //Run the motor synchronisation orState = motorHome(); + // Add callbacks I1.fall(&stateUpdate); I2.fall(&stateUpdate); I3.fall(&stateUpdate); + // Push motor to move currentState = readRotorState(); motorOut((currentState-orState+lead+6)%6); // We push it digitally @@ -162,9 +158,32 @@ // motorOut((intState-orState+lead+6)%6); //+6 to make sure the remainder is positive // } + // Keep the program running indefinitely - while (1); // {} - // pc.printf("Current:%d \t Next:%d \n\r", currentState, (currentState-orState+lead+6)%6);} - + timer.start(); // start timer + while (1) { +// pc.printf("Current:%d \t Next:%d \n\r", currentState, (currentState-orState+lead+6)%6); + Miner.computeHash(hash, sequence, length64); + hashCounter++; + if ((hash[0]==0) && (hash[1]==0)){ + pc.printf("hash: "); + for(int i = 0; i < 32; ++i) + pc.printf("%02x", hash[i]); + pc.printf("\n\r"); + } + + (*nonce)++; + + // Per Second i.e. when greater or equal to 1 + if (timer.read() >= 1){ + pc.printf("HashRate = %02u \n\r",hashCounter); + hashCounter=0; + timer.reset(); + } + } + } + + +