Serial number identifier program for Mbed

Dependencies:   MODSERIAL mbed

Fork of serial_number_identifier by Adhithya Rajasekaran

Files at this revision

API Documentation at this revision

Comitter:
adhithyan15
Date:
Mon Apr 20 11:11:28 2015 +0000
Commit message:
Initial build

Changed in this revision

MODSERIAL.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MODSERIAL.lib	Mon Apr 20 11:11:28 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/AjK/code/MODSERIAL/#ae0408ebdd68
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 20 11:11:28 2015 +0000
@@ -0,0 +1,42 @@
+// This program is a modification of the program get_serial_number
+// by Dan Minear
+#include "mbed.h"
+#include <string>
+#include <sstream>
+#include <algorithm>
+#include "MODSERIAL.h"
+#define IAP_LOCATION 0x1FFF1FF1
+
+typedef void (*IAP)(unsigned long [], unsigned long[] );
+IAP iap_entry = (IAP) IAP_LOCATION;
+
+MODSERIAL pc(USBTX,USBRX);
+
+string get_serial_number(){
+   unsigned long command[5] = {0,0,0,0,0};
+    unsigned long result[5] = {0,0,0,0,0};
+    command[0] = 58;  // read device serial number
+    iap_entry(command, result);
+    string output;
+    stringstream out;
+    if (result[0] == 0) {
+        for(int i = 1; i < 5; i++) {
+            out << result[i];
+        }
+    } else {
+        printf("Status error!\r\n");
+    }
+    output = out.str();     
+    return output;
+
+}
+
+int main() {
+    string serial = get_serial_number();
+    while(1){
+      if(pc.readable()){
+        pc.printf(serial.c_str());
+        break;
+      }   
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 20 11:11:28 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/433970e64889
\ No newline at end of file