send_task send the mail of people struct to the recieve task

Dependencies:   mbed-rtos mbed

Fork of rtos_queue by mbed official

Files at this revision

API Documentation at this revision

Comitter:
shiyilei
Date:
Mon Oct 27 04:42:31 2014 +0000
Parent:
4:c980920b5e22
Commit message:
send_task send the mail of ; people struct to the recieve task

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib 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
--- a/main.cpp	Tue Jun 04 16:03:43 2013 +0100
+++ b/main.cpp	Mon Oct 27 04:42:31 2014 +0000
@@ -1,41 +1,69 @@
+/**************************************************
+*file:mail_box test
+*Creator:JacobShi
+*Time:2014/10/24
+* Description: send_task send the mail of 
+* people struct to the recieve task
+ **************************************************/
+
 #include "mbed.h"
 #include "rtos.h"
-
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
 typedef struct {
-    float    voltage;   /* AD result of measured voltage */
-    float    current;   /* AD result of measured current */
-    uint32_t counter;   /* A counter value               */
-} message_t;
-
-MemoryPool<message_t, 16> mpool;
-Queue<message_t, 16> queue;
+    char school[5];
+    int num;
+    char career[10];
+}my_inform;
 
-/* Send Thread */
-void send_thread (void const *args) {
-    uint32_t i = 0;
-    while (true) {
-        i++; // fake data update
-        message_t *message = mpool.alloc();
-        message->voltage = (i * 0.1) * 33; 
-        message->current = (i * 0.1) * 11;
-        message->counter = i;
-        queue.put(message);
-        Thread::wait(1000);
+Mail<my_inform,32>taskmail;
+void send_task(void const*args)
+{
+   
+    while(1)
+    {
+        my_inform*my=taskmail.alloc();
+        strcpy(my->school,"ECNU");
+        my->num=0x06;
+        strcpy(my->career,"Student");
+        led1=!led1;
+        taskmail.put(my);
+        Thread::wait(500);
     }
+
 }
 
-int main (void) {
-    Thread thread(send_thread);
-    
-    while (true) {
-        osEvent evt = queue.get();
-        if (evt.status == osEventMessage) {
-            message_t *message = (message_t*)evt.value.p;
-            printf("\nVoltage: %.2f V\n\r"   , message->voltage);
-            printf("Current: %.2f A\n\r"     , message->current);
-            printf("Number of cycles: %u\n\r", message->counter);
-            
-            mpool.free(message);
+void recieve_task(void const *args)
+{
+        osEvent eve;
+        my_inform*my;
+     while(1)
+        {
+                led2=!led2;
+                eve=taskmail.get();
+                if(eve.status==osEventMail)
+                  {
+                    my=(my_inform*)eve.value.p;
+                    printf("school is:%s\r\n", my->school);
+                    printf("number is :%d\r\n",my->num );
+                    printf("career is :%s\r\n",my->career);
+                    taskmail.free(my);
+                }  
+            Thread::wait(200);
         }
+
+}
+
+int main(void)
+{
+    Thread task1(send_task);
+    Thread task2(recieve_task);
+  
+    while(1)
+    {
+       
+
     }
-}
+
+    return 0;
+}
\ No newline at end of file
--- a/mbed-rtos.lib	Tue Jun 04 16:03:43 2013 +0100
+++ b/mbed-rtos.lib	Mon Oct 27 04:42:31 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed-rtos/#e2da1b20a6d5
--- a/mbed.bld	Tue Jun 04 16:03:43 2013 +0100
+++ b/mbed.bld	Mon Oct 27 04:42:31 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file