mbed RPC

Dependents:   RPC_Serial_OVFZ RPCHTTPServer SerialRPC_rtos_example RPC_HTTP ... more

Fork of mbed-rpc by mbed official

Files at this revision

API Documentation at this revision

Comitter:
emilmont
Date:
Mon Apr 22 17:50:11 2013 +0100
Parent:
0:efe8172b4113
Child:
2:65228c367483
Commit message:
Update license
Add "parse_pins" function removed from the mbed library

Changed in this revision

Arguments.cpp Show annotated file Show diff for this revision Revisions of this file
Arguments.h Show annotated file Show diff for this revision Revisions of this file
RPCFunction.cpp Show annotated file Show diff for this revision Revisions of this file
RPCFunction.h Show annotated file Show diff for this revision Revisions of this file
RPCVariable.h Show annotated file Show diff for this revision Revisions of this file
RpcClasses.h Show annotated file Show diff for this revision Revisions of this file
mbed_rpc.h Show annotated file Show diff for this revision Revisions of this file
parse_pins.cpp Show annotated file Show diff for this revision Revisions of this file
parse_pins.h Show annotated file Show diff for this revision Revisions of this file
rpc.cpp Show annotated file Show diff for this revision Revisions of this file
rpc.h Show annotated file Show diff for this revision Revisions of this file
--- a/Arguments.cpp	Tue Nov 20 17:23:59 2012 +0000
+++ b/Arguments.cpp	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #include "Arguments.h"
 #include "pinmap.h"
@@ -30,24 +24,24 @@
     obj_name = NULL;
     method_name = NULL;
     argc = 0;
-    
+
     // This copy can be removed if we can assume the request string is
     // persistent and writable for the duration of the call
     strcpy(request, rqs);
-    
+
     // Initial '/'
     char* p = request;
     if (*p != '/') return;
     p++;
-    
+
     // Object Name
     p = search_arg(&obj_name, p, '/');
     if (p == NULL) return;
-    
+
     // Method Name
     p = search_arg(&method_name, p, ' ');
     if (p == NULL) return;
-    
+
     // Arguments
     while (true) {
         argv[argc] = NULL;
@@ -55,7 +49,7 @@
         if (argv[argc] != NULL) argc++;
         if (p == NULL) break;
     }
-    
+
     index = -1;
 }
 
--- a/Arguments.h	Tue Nov 20 17:23:59 2012 +0000
+++ b/Arguments.h	Mon Apr 22 17:50:11 2013 +0100
@@ -1,28 +1,23 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #ifndef ARGUMENTS_H
 #define ARGUMENTS_H
 
 #include "platform.h"
+#include "parse_pins.h"
 
 namespace mbed {
 
@@ -32,13 +27,13 @@
 class Arguments {
 public:
     Arguments(const char* rqs);
-    
+
     template<typename Arg>
     Arg   getArg(void);
-    
+
     char *obj_name;
     char *method_name;
-    
+
     int   argc;
     char* argv[RPC_MAX_ARGS];
 
@@ -53,7 +48,7 @@
 class Reply {
 public:
     Reply(char* r);
-    
+
     template<typename Data>
     void putData(Data d);
 
--- a/RPCFunction.cpp	Tue Nov 20 17:23:59 2012 +0000
+++ b/RPCFunction.cpp	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #include "RPCFunction.h"
 
@@ -32,7 +26,7 @@
     _ftr = f;
 }
 
-//Just run the attached function using the string thats in private memory - or just using null values, 
+//Just run the attached function using the string thats in private memory - or just using null values,
 void RPCFunction::run(Arguments* args, Reply* r) {
     (*_ftr)(args, r);
 }
--- a/RPCFunction.h	Tue Nov 20 17:23:59 2012 +0000
+++ b/RPCFunction.h	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #ifndef RPCFUNCTION_RPC
 #define RPCFUNCTION_RPC
@@ -36,14 +30,14 @@
 public:
     /**
      * Constructor
-     * 
+     *
      *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output)
      *@param name The name of this object
      */
     RPCFunction(void (*f)(Arguments*, Reply*), const char* = NULL);
 
-    /** 
-     *run 
+    /**
+     *run
      *
      *Calls the attached function passing the string in but doesn't return the result.
      *@param str The string to be passed into the attached function. This string can consist of any ASCII characters apart from escape codes. The usual limtations on argument content for RPC strings has been removed
--- a/RPCVariable.h	Tue Nov 20 17:23:59 2012 +0000
+++ b/RPCVariable.h	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #ifndef RPCVARIABLE_H_
 #define RPCVARIABLE_H_
@@ -35,8 +29,8 @@
 public:
     /**
      * Constructor
-     * 
-     *@param ptr Pointer to the variable to make accessible over RPC. Any type of 
+     *
+     *@param ptr Pointer to the variable to make accessible over RPC. Any type of
      *variable can be connected
      *@param name The name of that this object will be over RPC
      */
@@ -46,7 +40,7 @@
     }
     /**
      *Read the variable over RPC.
-     * 
+     *
      *@return The value of the variable
      */
     T read() {
@@ -54,13 +48,13 @@
     }
     /**
      *Write a value to the variable over RPC
-     * 
+     *
      *@param The value to be written to the attached variable.
      */
     void write(T value) {
         *_ptr = value;
     }
-    
+
     virtual const struct rpc_method *get_rpc_methods();
     static struct rpc_class *get_rpc_class();
 
--- a/RpcClasses.h	Tue Nov 20 17:23:59 2012 +0000
+++ b/RpcClasses.h	Mon Apr 22 17:50:11 2013 +0100
@@ -1,314 +1,308 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef MBED_CLASSES_H
-#define MBED_CLASSES_H
-
-#include "rpc.h"
-
-namespace mbed {
-
-class RpcDigitalOut : public RPC {
-public:
-    RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
-    
-    void write(int a0) {o.write(a0);}
-    int read(void) {return o.read();}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"write", rpc_method_caller<RpcDigitalOut, int, &RpcDigitalOut::write>},
-            {"read", rpc_method_caller<int, RpcDigitalOut, &RpcDigitalOut::read>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalOut, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"DigitalOut", funcs, NULL};
-        return &c;
-    }
-private:
-    DigitalOut o;
-};
-
-class RpcDigitalIn : public RPC {
-public:
-    RpcDigitalIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
-    
-    int read(void) {return o.read();}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"read", rpc_method_caller<int, RpcDigitalIn, &RpcDigitalIn::read>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalIn, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"DigitalIn", funcs, NULL};
-        return &c;
-    }
-private:
-    DigitalIn o;
-};
-
-class RpcDigitalInOut : public RPC {
-public:
-    RpcDigitalInOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
-    
-    int read(void) {return o.read();}
-    void write(int a0) {o.write(a0);}
-    void input(void) {o.input();}
-    void output(void) {o.output();}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"read", rpc_method_caller<int, RpcDigitalInOut, &RpcDigitalInOut::read>},
-            {"write", rpc_method_caller<RpcDigitalInOut, int, &RpcDigitalInOut::write>},
-            {"input", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::input>},
-            {"output", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::output>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalInOut, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"DigitalInOut", funcs, NULL};
-        return &c;
-    }
-private:
-    DigitalInOut o;
-};
-
-#if DEVICE_ANALOGIN
-class RpcAnalogIn : public RPC {
-public:
-    RpcAnalogIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
-    
-    float read(void) {return o.read();}
-    unsigned short read_u16(void) {return o.read_u16();}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"read", rpc_method_caller<float, RpcAnalogIn, &RpcAnalogIn::read>},
-            {"read_u16", rpc_method_caller<unsigned short, RpcAnalogIn, &RpcAnalogIn::read_u16>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogIn, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"AnalogIn", funcs, NULL};
-        return &c;
-    }
-private:
-    AnalogIn o;
-};
-#endif
-
-#if DEVICE_ANALOGOUT
-class RpcAnalogOut : public RPC {
-public:
-    RpcAnalogOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
-    
-    float read(void) {return o.read();}
-    void write(float a0) {o.write(a0);}
-    void write_u16(unsigned short a0) {o.write_u16(a0);}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"read", rpc_method_caller<float, RpcAnalogOut, &RpcAnalogOut::read>},
-            {"write", rpc_method_caller<RpcAnalogOut, float, &RpcAnalogOut::write>},
-            {"write_u16", rpc_method_caller<RpcAnalogOut, unsigned short, &RpcAnalogOut::write_u16>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogOut, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"AnalogOut", funcs, NULL};
-        return &c;
-    }
-private:
-    AnalogOut o;
-};
-#endif
-
-#if DEVICE_PWMOUT
-class RpcPwmOut : public RPC {
-public:
-    RpcPwmOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
-    
-    float read(void) {return o.read();}
-    void write(float a0) {o.write(a0);}
-    void period(float a0) {o.period(a0);}
-    void period_ms(int a0) {o.period_ms(a0);}
-    void pulsewidth(float a0) {o.pulsewidth(a0);}
-    void pulsewidth_ms(int a0) {o.pulsewidth_ms(a0);}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"read", rpc_method_caller<float, RpcPwmOut, &RpcPwmOut::read>},
-            {"write", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::write>},
-            {"period", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::period>},
-            {"period_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::period_ms>},
-            {"pulsewidth", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::pulsewidth>},
-            {"pulsewidth_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::pulsewidth_ms>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcPwmOut, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"PwmOut", funcs, NULL};
-        return &c;
-    }
-private:
-    PwmOut o;
-};
-#endif
-
-#if DEVICE_SPI
-class RpcSPI : public RPC {
-public:
-    RpcSPI(PinName a0, PinName a1, PinName a2, const char *name=NULL) : RPC(name), o(a0, a1, a2) {}
-    
-    void format(int a0, int a1) {o.format(a0, a1);}
-    void frequency(int a0) {o.frequency(a0);}
-    int write(int a0) {return o.write(a0);}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"format", rpc_method_caller<RpcSPI, int, int, &RpcSPI::format>},
-            {"frequency", rpc_method_caller<RpcSPI, int, &RpcSPI::frequency>},
-            {"write", rpc_method_caller<int, RpcSPI, int, &RpcSPI::write>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, PinName, PinName, const char*, &RPC::construct<RpcSPI, PinName, PinName, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"SPI", funcs, NULL};
-        return &c;
-    }
-private:
-    SPI o;
-};
-#endif
-
-#if DEVICE_SERIAL
-class RpcSerial : public RPC {
-public:
-    RpcSerial(PinName a0, PinName a1, const char *name=NULL) : RPC(name), o(a0, a1) {}
-    
-    void baud(int a0) {o.baud(a0);}
-    int readable(void) {return o.readable();}
-    int writeable(void) {return o.writeable();}
-    int putc(int a0) {return o.putc(a0);}
-    int getc(void) {return o.getc();}
-    int puts(const char * a0) {return o.puts(a0);}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"baud", rpc_method_caller<RpcSerial, int, &RpcSerial::baud>},
-            {"readable", rpc_method_caller<int, RpcSerial, &RpcSerial::readable>},
-            {"writeable", rpc_method_caller<int, RpcSerial, &RpcSerial::writeable>},
-            {"putc", rpc_method_caller<int, RpcSerial, int, &RpcSerial::putc>},
-            {"getc", rpc_method_caller<int, RpcSerial, &RpcSerial::getc>},
-            {"puts", rpc_method_caller<int, RpcSerial, const char *, &RpcSerial::puts>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcSerial, PinName, PinName, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"Serial", funcs, NULL};
-        return &c;
-    }
-private:
-    Serial o;
-};
-#endif
-
-class RpcTimer : public RPC {
-public:
-    RpcTimer(const char *name=NULL) : RPC(name), o() {}
-    
-    void start(void) {o.start();}
-    void stop(void) {o.stop();}
-    void reset(void) {o.reset();}
-    float read(void) {return o.read();}
-    int read_ms(void) {return o.read_ms();}
-    int read_us(void) {return o.read_us();}
-    
-    virtual const struct rpc_method *get_rpc_methods() {
-        static const rpc_method rpc_methods[] = {
-            {"start", rpc_method_caller<RpcTimer, &RpcTimer::start>},
-            {"stop", rpc_method_caller<RpcTimer, &RpcTimer::stop>},
-            {"reset", rpc_method_caller<RpcTimer, &RpcTimer::reset>},
-            {"read", rpc_method_caller<float, RpcTimer, &RpcTimer::read>},
-            {"read_ms", rpc_method_caller<int, RpcTimer, &RpcTimer::read_ms>},
-            {"read_us", rpc_method_caller<int, RpcTimer, &RpcTimer::read_us>},
-            RPC_METHOD_SUPER(RPC)
-        };
-        return rpc_methods;
-    }
-    static struct rpc_class *get_rpc_class() {
-        static const rpc_function funcs[] = {
-            {"new", rpc_function_caller<const char*, const char*, &RPC::construct<RpcTimer, const char*> >},
-            RPC_METHOD_END
-        };
-        static rpc_class c = {"Timer", funcs, NULL};
-        return &c;
-    }
-private:
-    Timer o;
-};
-
-}
-
-#endif
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MBED_CLASSES_H
+#define MBED_CLASSES_H
+
+#include "rpc.h"
+
+namespace mbed {
+
+class RpcDigitalOut : public RPC {
+public:
+    RpcDigitalOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
+
+    void write(int a0) {o.write(a0);}
+    int read(void) {return o.read();}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"write", rpc_method_caller<RpcDigitalOut, int, &RpcDigitalOut::write>},
+            {"read", rpc_method_caller<int, RpcDigitalOut, &RpcDigitalOut::read>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalOut, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"DigitalOut", funcs, NULL};
+        return &c;
+    }
+private:
+    DigitalOut o;
+};
+
+class RpcDigitalIn : public RPC {
+public:
+    RpcDigitalIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
+
+    int read(void) {return o.read();}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"read", rpc_method_caller<int, RpcDigitalIn, &RpcDigitalIn::read>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalIn, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"DigitalIn", funcs, NULL};
+        return &c;
+    }
+private:
+    DigitalIn o;
+};
+
+class RpcDigitalInOut : public RPC {
+public:
+    RpcDigitalInOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
+
+    int read(void) {return o.read();}
+    void write(int a0) {o.write(a0);}
+    void input(void) {o.input();}
+    void output(void) {o.output();}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"read", rpc_method_caller<int, RpcDigitalInOut, &RpcDigitalInOut::read>},
+            {"write", rpc_method_caller<RpcDigitalInOut, int, &RpcDigitalInOut::write>},
+            {"input", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::input>},
+            {"output", rpc_method_caller<RpcDigitalInOut, &RpcDigitalInOut::output>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcDigitalInOut, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"DigitalInOut", funcs, NULL};
+        return &c;
+    }
+private:
+    DigitalInOut o;
+};
+
+#if DEVICE_ANALOGIN
+class RpcAnalogIn : public RPC {
+public:
+    RpcAnalogIn(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
+
+    float read(void) {return o.read();}
+    unsigned short read_u16(void) {return o.read_u16();}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"read", rpc_method_caller<float, RpcAnalogIn, &RpcAnalogIn::read>},
+            {"read_u16", rpc_method_caller<unsigned short, RpcAnalogIn, &RpcAnalogIn::read_u16>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogIn, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"AnalogIn", funcs, NULL};
+        return &c;
+    }
+private:
+    AnalogIn o;
+};
+#endif
+
+#if DEVICE_ANALOGOUT
+class RpcAnalogOut : public RPC {
+public:
+    RpcAnalogOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
+
+    float read(void) {return o.read();}
+    void write(float a0) {o.write(a0);}
+    void write_u16(unsigned short a0) {o.write_u16(a0);}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"read", rpc_method_caller<float, RpcAnalogOut, &RpcAnalogOut::read>},
+            {"write", rpc_method_caller<RpcAnalogOut, float, &RpcAnalogOut::write>},
+            {"write_u16", rpc_method_caller<RpcAnalogOut, unsigned short, &RpcAnalogOut::write_u16>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcAnalogOut, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"AnalogOut", funcs, NULL};
+        return &c;
+    }
+private:
+    AnalogOut o;
+};
+#endif
+
+#if DEVICE_PWMOUT
+class RpcPwmOut : public RPC {
+public:
+    RpcPwmOut(PinName a0, const char *name=NULL) : RPC(name), o(a0) {}
+
+    float read(void) {return o.read();}
+    void write(float a0) {o.write(a0);}
+    void period(float a0) {o.period(a0);}
+    void period_ms(int a0) {o.period_ms(a0);}
+    void pulsewidth(float a0) {o.pulsewidth(a0);}
+    void pulsewidth_ms(int a0) {o.pulsewidth_ms(a0);}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"read", rpc_method_caller<float, RpcPwmOut, &RpcPwmOut::read>},
+            {"write", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::write>},
+            {"period", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::period>},
+            {"period_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::period_ms>},
+            {"pulsewidth", rpc_method_caller<RpcPwmOut, float, &RpcPwmOut::pulsewidth>},
+            {"pulsewidth_ms", rpc_method_caller<RpcPwmOut, int, &RpcPwmOut::pulsewidth_ms>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, const char*, &RPC::construct<RpcPwmOut, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"PwmOut", funcs, NULL};
+        return &c;
+    }
+private:
+    PwmOut o;
+};
+#endif
+
+#if DEVICE_SPI
+class RpcSPI : public RPC {
+public:
+    RpcSPI(PinName a0, PinName a1, PinName a2, const char *name=NULL) : RPC(name), o(a0, a1, a2) {}
+
+    void format(int a0, int a1) {o.format(a0, a1);}
+    void frequency(int a0) {o.frequency(a0);}
+    int write(int a0) {return o.write(a0);}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"format", rpc_method_caller<RpcSPI, int, int, &RpcSPI::format>},
+            {"frequency", rpc_method_caller<RpcSPI, int, &RpcSPI::frequency>},
+            {"write", rpc_method_caller<int, RpcSPI, int, &RpcSPI::write>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, PinName, PinName, const char*, &RPC::construct<RpcSPI, PinName, PinName, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"SPI", funcs, NULL};
+        return &c;
+    }
+private:
+    SPI o;
+};
+#endif
+
+#if DEVICE_SERIAL
+class RpcSerial : public RPC {
+public:
+    RpcSerial(PinName a0, PinName a1, const char *name=NULL) : RPC(name), o(a0, a1) {}
+
+    void baud(int a0) {o.baud(a0);}
+    int readable(void) {return o.readable();}
+    int writeable(void) {return o.writeable();}
+    int putc(int a0) {return o.putc(a0);}
+    int getc(void) {return o.getc();}
+    int puts(const char * a0) {return o.puts(a0);}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"baud", rpc_method_caller<RpcSerial, int, &RpcSerial::baud>},
+            {"readable", rpc_method_caller<int, RpcSerial, &RpcSerial::readable>},
+            {"writeable", rpc_method_caller<int, RpcSerial, &RpcSerial::writeable>},
+            {"putc", rpc_method_caller<int, RpcSerial, int, &RpcSerial::putc>},
+            {"getc", rpc_method_caller<int, RpcSerial, &RpcSerial::getc>},
+            {"puts", rpc_method_caller<int, RpcSerial, const char *, &RpcSerial::puts>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, PinName, PinName, const char*, &RPC::construct<RpcSerial, PinName, PinName, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"Serial", funcs, NULL};
+        return &c;
+    }
+private:
+    Serial o;
+};
+#endif
+
+class RpcTimer : public RPC {
+public:
+    RpcTimer(const char *name=NULL) : RPC(name), o() {}
+
+    void start(void) {o.start();}
+    void stop(void) {o.stop();}
+    void reset(void) {o.reset();}
+    float read(void) {return o.read();}
+    int read_ms(void) {return o.read_ms();}
+    int read_us(void) {return o.read_us();}
+
+    virtual const struct rpc_method *get_rpc_methods() {
+        static const rpc_method rpc_methods[] = {
+            {"start", rpc_method_caller<RpcTimer, &RpcTimer::start>},
+            {"stop", rpc_method_caller<RpcTimer, &RpcTimer::stop>},
+            {"reset", rpc_method_caller<RpcTimer, &RpcTimer::reset>},
+            {"read", rpc_method_caller<float, RpcTimer, &RpcTimer::read>},
+            {"read_ms", rpc_method_caller<int, RpcTimer, &RpcTimer::read_ms>},
+            {"read_us", rpc_method_caller<int, RpcTimer, &RpcTimer::read_us>},
+            RPC_METHOD_SUPER(RPC)
+        };
+        return rpc_methods;
+    }
+    static struct rpc_class *get_rpc_class() {
+        static const rpc_function funcs[] = {
+            {"new", rpc_function_caller<const char*, const char*, &RPC::construct<RpcTimer, const char*> >},
+            RPC_METHOD_END
+        };
+        static rpc_class c = {"Timer", funcs, NULL};
+        return &c;
+    }
+private:
+    Timer o;
+};
+
+}
+
+#endif
--- a/mbed_rpc.h	Tue Nov 20 17:23:59 2012 +0000
+++ b/mbed_rpc.h	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #ifndef MBED_RPC_H
 #define MBED_RPC_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/parse_pins.cpp	Mon Apr 22 17:50:11 2013 +0100
@@ -0,0 +1,80 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "port_api.h"
+
+namespace mbed {
+
+PinName parse_pins(const char *str) {
+#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368)
+    static const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14
+                                , p15, p16, p17, p18, p19, p20, p21, p22, p23
+                                , p24, p25, p26, p27, p28, p29, p30};
+#endif
+
+#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) || defined(TARGET_LPC812)
+    if (str[0] == 'P') {              // Pn_n
+        uint32_t port = str[1] - '0';
+        uint32_t pin  = str[3] - '0'; // Pn_n
+        uint32_t pin2 = str[4] - '0'; // Pn_nn
+        if (pin2 <= 9) {
+            pin = pin * 10 + pin2;
+        }
+        return port_pin((PortName)port, pin);
+
+#elif defined(LTARGET_KL25Z)
+        if (str[0] == 'P' && str[1] == 'T') {   // PTx_n
+            uint32_t port = str[2] - 'A';
+            uint32_t pin  = str[3] - '0'; // PTxn
+            uint32_t pin2 = str[4] - '0'; // PTxnn
+
+            if (pin2 <= 9) {
+                pin = pin * 10 + pin2;
+            }
+            return port_pin((PortName)port, pin);
+#endif
+
+#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368)
+    } else if (str[0] == 'p') {       // pn
+        uint32_t pin  = str[1] - '0'; // pn
+        uint32_t pin2 = str[2] - '0'; // pnn
+        if (pin2 <= 9) {
+            pin = pin * 10 + pin2;
+        }
+        if (pin < 5 || pin > 30) {
+            return NC;
+        }
+        return pin_names[pin - 5];
+#endif
+
+    } else if (str[0] == 'L') {  // LEDn
+        switch (str[3]) {
+            case '1' : return LED1;
+            case '2' : return LED2;
+            case '3' : return LED3;
+            case '4' : return LED4;
+        }
+
+    } else if (str[0] == 'U') {  // USB?X
+        switch (str[3]) {
+            case 'T' : return USBTX;
+            case 'R' : return USBRX;
+        }
+    }
+
+    return NC;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/parse_pins.h	Mon Apr 22 17:50:11 2013 +0100
@@ -0,0 +1,27 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2013 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef MBED_PINMAP_H
+#define MBED_PINMAP_H
+
+#include "PinNames.h"
+
+namespace mbed {
+
+PinName parse_pins(const char *str);
+
+}
+
+#endif
--- a/rpc.cpp	Tue Nov 20 17:23:59 2012 +0000
+++ b/rpc.cpp	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #include "rpc.h"
 
@@ -112,10 +106,10 @@
 
 bool RPC::call(const char *request, char *reply) {
     if (request == NULL) return false;
-    
+
     Arguments args(request);
     Reply r(reply);
-    
+
     /* If there's no name print object and class names to result */
     if (args.obj_name == NULL) {
         for (RPC *p = RPC::_head; p != NULL; p = p->_next) {
@@ -126,20 +120,20 @@
         }
         return true;
     }
-    
+
     /* First try matching an instance */
     RPC *p = lookup(args.obj_name);
     if (p != NULL) {
         /* Get the list of methods we support */
         const rpc_method *cur_method = p->get_rpc_methods();
-        
+
         /* When there's no method print method names to result */
         if (args.method_name == NULL) {
             while (true) {
                 for (; cur_method->name != NULL; cur_method++) {
                     r.putData<const char*>(cur_method->name);
                 }
-                
+
                 /* write_name_arr's args are references, so result and cur_method will have changed */
                 if (cur_method->super != 0) {
                     cur_method = cur_method->super(p);
@@ -148,7 +142,7 @@
                 }
             }
         }
-        
+
         /* Look through the methods for the one whose name matches */
         while (true) {
             for (; cur_method->name != NULL; cur_method++) {
@@ -157,17 +151,17 @@
                     return true;
                 }
             }
-            
+
             if (cur_method->super != 0) {
                 cur_method = cur_method->super(p);
             } else {
                 /* end of methods and no match */
                 return false;
             }
-            
+
         }
     }
-    
+
     /* Then try a class */
     for (const rpc_class *q = _classes; q != NULL; q = q->next) {
         if (strcmp(q->name, args.obj_name) == 0) {
@@ -190,7 +184,7 @@
             }
         }
     }
-    
+
     return false;
 }
 
--- a/rpc.h	Tue Nov 20 17:23:59 2012 +0000
+++ b/rpc.h	Mon Apr 22 17:50:11 2013 +0100
@@ -1,23 +1,17 @@
 /* mbed Microcontroller Library
- * Copyright (c) 2006-2012 ARM Limited
+ * Copyright (c) 2006-2013 ARM Limited
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 #ifndef RPC_H
 #define RPC_H
@@ -44,9 +38,9 @@
  *  The RPC class for most things
  */
 class RPC {
-    
+
 public:
-    
+
     RPC(const char *name = NULL);
 
     virtual ~RPC();
@@ -69,7 +63,7 @@
      * > };
      */
     virtual const struct rpc_method *get_rpc_methods();
-    
+
     static bool call(const char *buf, char *result);
 
     /* Function lookup
@@ -108,35 +102,35 @@
         c->next = _classes;
         _classes = c;
     }
-    
+
     template<class C>
     static const char *construct() {
         RPC *p = new C();
         p->_from_construct = true;
         return p->_name;
     }
-    
+
     template<class C, typename A1>
     static const char *construct(A1 arg1) {
         RPC *p = new C(arg1);
         p->_from_construct = true;
         return p->_name;
     }
-    
+
     template<class C, typename A1, typename A2>
     static const char *construct(A1 arg1, A2 arg2) {
         RPC *p = new C(arg1, arg2);
         p->_from_construct = true;
         return p->_name;
     }
-    
+
     template<class C, typename A1, typename A2, typename A3>
     static const char *construct(A1 arg1, A2 arg2, A3 arg3) {
         RPC *p = new C(arg1, arg2, arg3);
         p->_from_construct = true;
         return p->_name;
     }
-    
+
     template<class C, typename A1, typename A2, typename A3, typename A4>
     static const char *construct(A1 arg1, A2 arg2, A3 arg3, A4 arg4) {
         RPC *p = new C(arg1, arg2, arg3, arg4);
@@ -177,7 +171,7 @@
 template<class T, typename A1, void(T::*member)(A1)>
 void rpc_method_caller(RPC *this_ptr, Arguments *arguments, Reply *result) {
     A1 arg1 = arguments->getArg<A1>();
-    
+
     (static_cast<T*>(this_ptr)->*member)(arg1);
 }
 
@@ -187,7 +181,7 @@
 void rpc_method_caller(RPC *this_ptr, Arguments *arguments, Reply *result) {
     A1 arg1 = arguments->getArg<A1>();
     A2 arg2 = arguments->getArg<A2>();
-    
+
     (static_cast<T*>(this_ptr)->*member)(arg1, arg2);
 }
 
@@ -198,7 +192,7 @@
     A1 arg1 = arguments->getArg<A1>();
     A2 arg2 = arguments->getArg<A2>();
     A3 arg3 = arguments->getArg<A3>();
-    
+
     (static_cast<T*>(this_ptr)->*member)(arg1, arg2, arg3);
 }
 
@@ -215,7 +209,7 @@
 template<typename R, class T, typename A1, R(T::*member)(A1)>
 void rpc_method_caller(RPC *this_ptr, Arguments *arguments, Reply *result) {
     A1 arg1 = arguments->getArg<A1>();
-    
+
     R res = (static_cast<T*>(this_ptr)->*member)(arg1);
     result->putData<R>(res);
 }
@@ -226,7 +220,7 @@
 void rpc_method_caller(RPC *this_ptr, Arguments *arguments, Reply *result) {
     A1 arg1 = arguments->getArg<A1>();
     A2 arg2 = arguments->getArg<A2>();
-    
+
     R res = (static_cast<T*>(this_ptr)->*member)(arg1, arg2);
     result->putData<R>(res);
 }
@@ -238,7 +232,7 @@
     A1 arg1 = arguments->getArg<A1>();
     A2 arg2 = arguments->getArg<A2>();
     A3 arg3 = arguments->getArg<A3>();
-    
+
     R res = (static_cast<T*>(this_ptr)->*member)(arg1, arg2, arg3);
     result->putData<R>(res);
 }
@@ -266,7 +260,7 @@
 void rpc_function_caller(Arguments *arguments, Reply *result) {
     A1 arg1 = arguments->getArg<A1>();
     A2 arg2 = arguments->getArg<A2>();
-    
+
     R res = (*func)(arg1, arg2);
     result->putData<R>(res);
 }
@@ -278,7 +272,7 @@
     A1 arg1 = arguments->getArg<A1>();
     A2 arg2 = arguments->getArg<A2>();
     A3 arg3 = arguments->getArg<A3>();
-    
+
     R res = (*func)(arg1, arg2, arg3);
     result->putData<R>(res);
 }
@@ -291,7 +285,7 @@
     A2 arg2 = arguments->getArg<A2>();
     A3 arg3 = arguments->getArg<A3>();
     A4 arg4 = arguments->getArg<A4>();
-    
+
     R res = (*func)(arg1, arg2, arg3, arg4);
     result->putData<R>(res);
 }