float->char *, char *->floatをキャストして行います。

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tsumagari
Date:
Sat Feb 11 08:40:42 2017 +0000
Commit message:
float->char *, char *->float????????????

Changed in this revision

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
diff -r 000000000000 -r a5bc99e9290f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 11 08:40:42 2017 +0000
@@ -0,0 +1,21 @@
+#include "mbed.h"
+
+Serial out(p9,p10);
+Serial in(p13,p14);
+
+char number_char[10];
+float number = 0.1234;
+char receive_char[100];
+float number_new;
+
+int main() {
+    *(float*)number_char = number;
+    for(int k = 0; k<10; k++){
+        out.putc(number_char[k]);
+        wait(0.2);
+        if(in.readable()) receive_char[k] = in.getc();
+    }
+    number_new = *(const float*)receive_char;
+    printf("%s\n\r",receive_char);
+    printf("%f",number_new);
+}
diff -r 000000000000 -r a5bc99e9290f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 11 08:40:42 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/176b8275d35d
\ No newline at end of file