Trung Nguyen
/
FINAL_PROJECT_4180
asdasdasd
Fork of FINAL_PROJECT_4180 by
lib.cpp
- Committer:
- nyengele
- Date:
- 2016-04-24
- Revision:
- 0:f0e40bf44ffe
- Child:
- 1:0e5e9821d89d
File content as of revision 0:f0e40bf44ffe:
#include "mbed.h" #include "lib.h" int hashcode(const char *data, int size) { int hash = 17; for (int i = 0; i < size; i++) { hash += 31*hash + data[i]; } return hash; } void read_mag_card(Serial *device, char *dest, int *size) { int pos = 0; bool done = false; int markercount = 0; while (!done) { while (!device->readbale()); dest[pos] = device->getc(); if (dest[pos] == '?') markercount++; if (markercount >= 2) done = true; pos++; } *size = pos - 1; }