GPS-Tracking-Velo
Dependencies: MODSERIAL SDBlockDevice GPS
Forschungsstand und Theoretische Grundlage
Die Bestandteile der Hardware, die das Projekt gebraucht wird, bestehen aus drei Komponente ein Mikrocontroller Board, eine GPS Antenne und ein SIM Modul. GPS basiert auf Satelliten, die mit codierten Radiosignalen ständig ihre aktuelle Position und genaue Uhrzeit ausstrahlen. Aus den Signallaufzeiten können eine GPS Antenne ihre eigene Position und Geschwindigkeit berechnen. Diese GPS Antenne sollte die Daten der Objektposition aus Satelliten auf dem Board gespeichert werden. Diese Daten wurden noch weiter durch eine SIM Module nach GMS Turm und dann per SMS Nachrichten an Handy gesendet. Möglicherweise können diese Daten auch an Webanwendung nach der Sendung an GMS Turm geschickt werden.
mbed-os-example-fat-filesystem-master/main.cpp@0:ee1ae011cba6, 2019-04-12 (annotated)
- Committer:
- QuangAnhLe
- Date:
- Fri Apr 12 13:45:29 2019 +0000
- Revision:
- 0:ee1ae011cba6
- Child:
- 1:2f617b92078b
este Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
QuangAnhLe | 0:ee1ae011cba6 | 1 | #include "mbed.h" |
QuangAnhLe | 0:ee1ae011cba6 | 2 | #include "FATFileSystem.h" |
QuangAnhLe | 0:ee1ae011cba6 | 3 | //#include "HeapBlockDevice.h" |
QuangAnhLe | 0:ee1ae011cba6 | 4 | #include "SDBlockDevice.h" |
QuangAnhLe | 0:ee1ae011cba6 | 5 | #include <stdio.h> |
QuangAnhLe | 0:ee1ae011cba6 | 6 | #include <errno.h> |
QuangAnhLe | 0:ee1ae011cba6 | 7 | |
QuangAnhLe | 0:ee1ae011cba6 | 8 | //HeapBlockDevice bd(128 * 512, 512); |
QuangAnhLe | 0:ee1ae011cba6 | 9 | //SDBlockDevice bd(PinName mosi, PinName miso, PinName sclk, PinName cs); |
QuangAnhLe | 0:ee1ae011cba6 | 10 | SDBlockDevice bd(D11, D12, D13, D10); |
QuangAnhLe | 0:ee1ae011cba6 | 11 | |
QuangAnhLe | 0:ee1ae011cba6 | 12 | FATFileSystem fs("fs"); |
QuangAnhLe | 0:ee1ae011cba6 | 13 | |
QuangAnhLe | 0:ee1ae011cba6 | 14 | void return_error(int ret_val){ |
QuangAnhLe | 0:ee1ae011cba6 | 15 | if (ret_val) |
QuangAnhLe | 0:ee1ae011cba6 | 16 | printf("Failure. %d\r\n", ret_val); |
QuangAnhLe | 0:ee1ae011cba6 | 17 | else |
QuangAnhLe | 0:ee1ae011cba6 | 18 | printf("done.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 19 | } |
QuangAnhLe | 0:ee1ae011cba6 | 20 | |
QuangAnhLe | 0:ee1ae011cba6 | 21 | void errno_error(void* ret_val){ |
QuangAnhLe | 0:ee1ae011cba6 | 22 | if (ret_val == NULL) |
QuangAnhLe | 0:ee1ae011cba6 | 23 | printf(" Failure. %d \r\n", errno); |
QuangAnhLe | 0:ee1ae011cba6 | 24 | else |
QuangAnhLe | 0:ee1ae011cba6 | 25 | printf(" done.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 26 | } |
QuangAnhLe | 0:ee1ae011cba6 | 27 | |
QuangAnhLe | 0:ee1ae011cba6 | 28 | int main() { |
QuangAnhLe | 0:ee1ae011cba6 | 29 | int error = 0; |
QuangAnhLe | 0:ee1ae011cba6 | 30 | printf("Welcome to the filesystem example.\r\n" |
QuangAnhLe | 0:ee1ae011cba6 | 31 | "Formatting a FAT, RAM-backed filesystem. "); |
QuangAnhLe | 0:ee1ae011cba6 | 32 | error = FATFileSystem::format(&bd); |
QuangAnhLe | 0:ee1ae011cba6 | 33 | return_error(error); |
QuangAnhLe | 0:ee1ae011cba6 | 34 | |
QuangAnhLe | 0:ee1ae011cba6 | 35 | printf("Mounting the filesystem on \"/fs\". "); |
QuangAnhLe | 0:ee1ae011cba6 | 36 | error = fs.mount(&bd); |
QuangAnhLe | 0:ee1ae011cba6 | 37 | return_error(error); |
QuangAnhLe | 0:ee1ae011cba6 | 38 | |
QuangAnhLe | 0:ee1ae011cba6 | 39 | printf("Opening a new file, numbers.txt."); |
QuangAnhLe | 0:ee1ae011cba6 | 40 | FILE* fd = fopen("/fs/numbers.txt", "w"); |
QuangAnhLe | 0:ee1ae011cba6 | 41 | errno_error(fd); |
QuangAnhLe | 0:ee1ae011cba6 | 42 | |
QuangAnhLe | 0:ee1ae011cba6 | 43 | for (int i = 0; i < 15; i++){ |
QuangAnhLe | 0:ee1ae011cba6 | 44 | printf("Writing decimal numbers to a file (%d/20)\r", i); |
QuangAnhLe | 0:ee1ae011cba6 | 45 | fprintf(fd, "%d\r\n", i); |
QuangAnhLe | 0:ee1ae011cba6 | 46 | //fprintf(fd, "%d\r\n", i); |
QuangAnhLe | 0:ee1ae011cba6 | 47 | } |
QuangAnhLe | 0:ee1ae011cba6 | 48 | printf("Writing decimal numbers to a file (20/20) done.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 49 | |
QuangAnhLe | 0:ee1ae011cba6 | 50 | printf("Closing file."); |
QuangAnhLe | 0:ee1ae011cba6 | 51 | fclose(fd); |
QuangAnhLe | 0:ee1ae011cba6 | 52 | printf(" done.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 53 | |
QuangAnhLe | 0:ee1ae011cba6 | 54 | printf("Re-opening file read-only."); |
QuangAnhLe | 0:ee1ae011cba6 | 55 | fd = fopen("/fs/numbers.txt", "r"); |
QuangAnhLe | 0:ee1ae011cba6 | 56 | errno_error(fd); |
QuangAnhLe | 0:ee1ae011cba6 | 57 | |
QuangAnhLe | 0:ee1ae011cba6 | 58 | printf("Dumping file to screen.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 59 | char buff[16] = {0}; |
QuangAnhLe | 0:ee1ae011cba6 | 60 | while (!feof(fd)){ |
QuangAnhLe | 0:ee1ae011cba6 | 61 | int size = fread(&buff[0], 1, 15, fd); |
QuangAnhLe | 0:ee1ae011cba6 | 62 | fwrite(&buff[0], 1, size, stdout); |
QuangAnhLe | 0:ee1ae011cba6 | 63 | } |
QuangAnhLe | 0:ee1ae011cba6 | 64 | printf("EOF.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 65 | |
QuangAnhLe | 0:ee1ae011cba6 | 66 | printf("Closing file."); |
QuangAnhLe | 0:ee1ae011cba6 | 67 | fclose(fd); |
QuangAnhLe | 0:ee1ae011cba6 | 68 | printf(" done.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 69 | |
QuangAnhLe | 0:ee1ae011cba6 | 70 | printf("Opening root directory."); |
QuangAnhLe | 0:ee1ae011cba6 | 71 | DIR* dir = opendir("/fs/"); |
QuangAnhLe | 0:ee1ae011cba6 | 72 | errno_error(fd); |
QuangAnhLe | 0:ee1ae011cba6 | 73 | |
QuangAnhLe | 0:ee1ae011cba6 | 74 | struct dirent* de; |
QuangAnhLe | 0:ee1ae011cba6 | 75 | printf("Printing all filenames:\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 76 | while((de = readdir(dir)) != NULL){ |
QuangAnhLe | 0:ee1ae011cba6 | 77 | printf(" %s\r\n", &(de->d_name)[0]); |
QuangAnhLe | 0:ee1ae011cba6 | 78 | } |
QuangAnhLe | 0:ee1ae011cba6 | 79 | |
QuangAnhLe | 0:ee1ae011cba6 | 80 | printf("Closing root directory. "); |
QuangAnhLe | 0:ee1ae011cba6 | 81 | error = closedir(dir); |
QuangAnhLe | 0:ee1ae011cba6 | 82 | return_error(error); |
QuangAnhLe | 0:ee1ae011cba6 | 83 | printf("Filesystem Demo complete.\r\n"); |
QuangAnhLe | 0:ee1ae011cba6 | 84 | |
QuangAnhLe | 0:ee1ae011cba6 | 85 | while (true) {} |
QuangAnhLe | 0:ee1ae011cba6 | 86 | } |
QuangAnhLe | 0:ee1ae011cba6 | 87 |