Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed wolfSSL
Fork of sd_duplicator by
Diff: main.cpp
- Revision:
- 3:57cbfc7d9b62
- Parent:
- 2:166e98bcd1cc
- Child:
- 4:2bcb836ba0de
--- a/main.cpp Wed Nov 30 20:19:24 2016 +0000
+++ b/main.cpp Tue Dec 06 13:27:55 2016 +0000
@@ -4,57 +4,77 @@
DigitalOut led1(LED1);
DigitalOut led4(LED4);
+
+uint8_t hash[32];
+uint8_t buffer[512];
+SHA256 h;
+
int main()
{
SDBlock original(p5, p6, p7, p22);
- SDBlock duplicate(p11, p12, p13, p21);
const int x = original.disk_initialize();
- const int z = duplicate.disk_initialize();
printf("************\n");
printf("%d\n", x);
+ SDBlock duplicate(p11, p12, p13, p21);
+ const int z = duplicate.disk_initialize();
printf("%d\n", z);
const int y = original.disk_status();
- printf("%d\n", y);
+ printf("original status: %d\n", y);
+ const int t = duplicate.disk_status();
+ printf("duplicate status: %d\n", t);
//s is sector
const uint32_t s = original.disk_sectors();
- printf("secotr size %d\n", s);
- uint8_t buffer[512];
+ printf("sector size %d\n", s);
printf("buffer %d\n", buffer);
- const uint32_t block = 0;
+
+
//start time
- time_t time_start = time(NULL);
- for (int i = 0; i <= s; ++i)
+ //time_t time_start = time(NULL);
+ for (int i = 0; i <= 100; ++i)
{
const int r = original.disk_read(buffer, i, 1);
if (r !=0)
{
printf("%d\n", r);
}
- const int rd2 = duplicate.disk_write(buffer, i, 1);
+ printf("disk read ");
+ /* const int rd2 = duplicate.disk_write(buffer, i, 1);
if (rd2 != 0)
{
printf("%d\n", rd2);
- }
- if(i % 1000 == 0)
+ }*/
+
+ h.update(buffer, 512);
+ printf("digest updated, block %d",i);
+
+ /* if(i % 1000 == 0)
{
- //status update
- double percentage = (i/s) * 100;
+ status update
+ double percentage = (i/s) * 100;
printf("percent copied: %d\n", percentage);
- //time elapsed
+ time elapsed
time_t time_current = time(NULL);
int time_working = time_start - time_current;
double speed = (i * 512) / time_working;
printf("speed (bytes/s): %d\n", speed);
- }
+ } */
}
- printf("finished");
- led1=1;
- led4=1;
+ h.finalize(hash);
+ printf("finished\n");
+ printf("hash: ");
+ for(int i = 0; i < 32; ++i)
+ printf("%02x", hash[i]);
+ printf("\n");
- // printf("%d\n", r);
- //printf("%d\n", buffer);
-
- //printf("%d\n", rd2);
- //const int w =
-}
\ No newline at end of file
+ //when finished do this light pattern
+ while(true)
+ {
+ led1=0;
+ led4=1;
+ wait(.5);
+ led1=1;
+ led4=0;
+ wait(.5);
+ }
+}//end main
