AdkHardware.h
Go to the documentation of this file.
00001 #ifndef _ADK_HARDWARE_H_
00002 #define _ADK_HARDWARE_H_
00003 
00004 #include "AndroidAccessory/AndroidAccessory.h"
00005 #include <WProgram.h>
00006 
00007 #define __DEBUG__ 
00008 
00009 class AdkHardware{
00010 public:
00011     AdkHardware(): acc("Willow Garage", "ROSSerialADK",
00012                             "ROS ADK Bridge",  "1.0", "http://www.android.com",
00013                             "0000000012345678"),index(-1) 
00014 {
00015     }
00016     void init(){
00017         acc.powerOn();
00018         index=0;
00019         len=0;
00020         Serial.begin(115200);
00021     }
00022     
00023     void write(uint8_t* data, int out_len){
00024         if (acc.isConnected()) acc.write(data, out_len);
00025        
00026        #ifdef __DEBUG__
00027         Serial.print("ADK : ");
00028         for(int i=0; i< out_len; i++) Serial.print(data[i]);
00029         Serial.println("");
00030         #endif
00031         
00032     }
00033     
00034     int read(){
00035         int ret =-1;
00036         if (index< len){
00037            ret = input_buff[index];
00038            ++index;
00039 
00040         }
00041         else{
00042             if (acc.isConnected()) len = acc.read(input_buff, 100, 1);
00043             index = 0;
00044             if (len>0){
00045                 #ifdef __DEBUG__
00046                 Serial.print("\nCell :");
00047                 #endif
00048                 ret = input_buff[index];
00049                 index++;
00050             }
00051             
00052         }
00053         #ifdef __DEBUG__
00054         if (ret!=-1) Serial.print((char) ret);
00055         #endif 
00056         return ret;
00057     }
00058     
00059     unsigned long time(){return millis();};
00060 private:
00061     AndroidAccessory acc;
00062     uint8_t input_buff[100];
00063     int index;
00064     int len;
00065 };
00066 
00067 #endif


rosserial_adk_demo
Author(s): Adam Stambler
autogenerated on Mon Dec 2 2013 12:02:02