Program to control an accelerometer, motors and a rangefinder using the ScmRTOS ported to mbed. (Work in progress and buggy)

Dependencies:   mbed

Revision:
0:9b057566f9ee
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hexacopter/Command_handler.h	Mon Nov 01 20:39:01 2010 +0000
@@ -0,0 +1,91 @@
+#pragma once
+#ifndef COMMAND_HANDLER_H
+#define COMMAND_HANDLER_H
+#include <messages.h>
+#include <processes.h>
+
+//DigitalOut led2(LED2); 
+extern BusOut leds;
+template<> OS_PROCESS void Command_handler::Exec() //serial stream handling process
+{
+    //led2 = 0;
+    char RX_Command[100] = "";
+    RX_Command[99] = '\0';
+   
+    for(;;)
+    {       
+       
+       //RX_channel.pop(temp);
+       for(byte i = 0; i<100; i++)
+       {            
+            RX_channel.pop(RX_Command[i]);
+            leds = 0x4;
+            if(i == 99)
+                {
+                    RX_Command[i] = '\0';                    
+                }
+            //pc.putc(RX_Command[i]);
+            if(RX_Command[i] == '\0')  //keep popping chars until a delimiter is found
+               break;
+       }
+      //led2 = !led2; 
+      TX_channel.write(RX_Command, strlen(RX_Command)+1); //output the command for debugging
+      TX_channel.push('\n');
+      //char temp = 0;
+      //TX_channel.pop(temp);
+      //OUT->putc(temp);
+      //OUT->printf(RX_Command);
+      
+        if (strstr(RX_Command,"SER:") != NULL) //check for Serv: in the command - this will indicate that the command is destined for the servo process
+            {
+               SER_channel.write(RX_Command, strlen(RX_Command)+1);
+               //Servo_Command_Event.Signal();                
+             }
+            
+        else if (strstr(RX_Command,"PIN") != NULL) //check for PING in the command - this will indicate that the command is destined for the PING process
+            {
+
+               PING_MESSAGE = 0;
+               PING_MESSAGE.send();
+             }    
+        
+        else if (strstr(RX_Command,"PIC") != NULL) //check for PING in the command - this will indicate that the command is destined for the PING process
+        {
+
+           PING_MESSAGE = 1;
+           PING_MESSAGE.send();
+         }    
+        
+        else if (strstr(RX_Command, "MOT:") != NULL) //check to see if incoming motor control command
+        {
+            MOT_channel.write(RX_Command, strlen(RX_Command)+1);
+            
+        }
+        else if (strstr(RX_Command, "MO2:") != NULL) //this command will deal with both motors
+        {
+            MOT_channel.write(RX_Command, strlen(RX_Command)+1);
+            
+        }
+        
+        else if (strstr(RX_Command, "ACR") != NULL) //check to see if incoming motor control command
+        { //OS::message<byte> ACCELEROMETER_MESSAGE; //if message is a zero, then return acceleration once, if a 1 then continually return acceleration data         
+                         
+                ACCELEROMETER_MESSAGE = 1;
+                ACCELEROMETER_MESSAGE.send(); //send the message
+            
+        }        
+        else if (strstr(RX_Command, "ACC") != NULL) //check to see if incoming motor control command
+        { //OS::message<byte> ACCELEROMETER_Message; //if message is a zero, then return acceleration once, if a 1 then continually return acceleration data         
+                         
+                ACCELEROMETER_MESSAGE = 0;
+                ACCELEROMETER_MESSAGE.send(); //send the message
+            
+        }
+        leds = 0x4;
+    }
+    
+}  
+
+
+#endif
+