Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
mbed/jsonrpc/RpcPortIn.cpp@78:8cdb8fc7eda8, 2014-06-23 (annotated)
- Committer:
- nyatla
- Date:
- Mon Jun 23 04:45:57 2014 +0000
- Revision:
- 78:8cdb8fc7eda8
- Child:
- 85:416f8bbbdf54
mbed??????rpc???????????
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nyatla | 78:8cdb8fc7eda8 | 1 | #include "RpcHandlerBase.h" |
| nyatla | 78:8cdb8fc7eda8 | 2 | namespace MiMic |
| nyatla | 78:8cdb8fc7eda8 | 3 | { |
| nyatla | 78:8cdb8fc7eda8 | 4 | class PortInHandler :RpcHandlerBase |
| nyatla | 78:8cdb8fc7eda8 | 5 | { |
| nyatla | 78:8cdb8fc7eda8 | 6 | public: |
| nyatla | 78:8cdb8fc7eda8 | 7 | static NyLPC_TBool new1(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) |
| nyatla | 78:8cdb8fc7eda8 | 8 | { |
| nyatla | 78:8cdb8fc7eda8 | 9 | //ud |
| nyatla | 78:8cdb8fc7eda8 | 10 | ModJsonRpc* mod=(ModJsonRpc*)i_param; |
| nyatla | 78:8cdb8fc7eda8 | 11 | unsigned int port; |
| nyatla | 78:8cdb8fc7eda8 | 12 | int mask; |
| nyatla | 78:8cdb8fc7eda8 | 13 | if(getParamUInt(mod,i_rpc,port,0)){ |
| nyatla | 78:8cdb8fc7eda8 | 14 | if(getParamInt(mod,i_rpc,mask,1)){ |
| nyatla | 78:8cdb8fc7eda8 | 15 | addNewObjectBatch(mod,i_rpc->method.id,new ModJsonRpc::RpcObject<PortIn>(new PortIn(portId2PortName(port),mask))); |
| nyatla | 78:8cdb8fc7eda8 | 16 | } |
| nyatla | 78:8cdb8fc7eda8 | 17 | } |
| nyatla | 78:8cdb8fc7eda8 | 18 | return NyLPC_TBool_TRUE; |
| nyatla | 78:8cdb8fc7eda8 | 19 | } |
| nyatla | 78:8cdb8fc7eda8 | 20 | static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param) |
| nyatla | 78:8cdb8fc7eda8 | 21 | { |
| nyatla | 78:8cdb8fc7eda8 | 22 | //d return d |
| nyatla | 78:8cdb8fc7eda8 | 23 | ModJsonRpc* mod=(ModJsonRpc*)i_param; |
| nyatla | 78:8cdb8fc7eda8 | 24 | PortIn* inst=(PortIn*)getObjectBatch(mod,i_rpc); |
| nyatla | 78:8cdb8fc7eda8 | 25 | if(inst!=NULL){ |
| nyatla | 78:8cdb8fc7eda8 | 26 | mod->putResult(i_rpc->method.id,"%d",(int)(inst->read())); |
| nyatla | 78:8cdb8fc7eda8 | 27 | } |
| nyatla | 78:8cdb8fc7eda8 | 28 | return NyLPC_TBool_TRUE; |
| nyatla | 78:8cdb8fc7eda8 | 29 | } |
| nyatla | 78:8cdb8fc7eda8 | 30 | }; |
| nyatla | 78:8cdb8fc7eda8 | 31 | |
| nyatla | 78:8cdb8fc7eda8 | 32 | |
| nyatla | 78:8cdb8fc7eda8 | 33 | |
| nyatla | 78:8cdb8fc7eda8 | 34 | const static struct NyLPC_TJsonRpcMethodDef func_table[]= |
| nyatla | 78:8cdb8fc7eda8 | 35 | { |
| nyatla | 78:8cdb8fc7eda8 | 36 | { "_new1" ,"ud" ,PortInHandler::new1}, |
| nyatla | 78:8cdb8fc7eda8 | 37 | { "read" ,"d" ,PortInHandler::read}, |
| nyatla | 78:8cdb8fc7eda8 | 38 | { NULL ,NULL ,NULL} |
| nyatla | 78:8cdb8fc7eda8 | 39 | }; |
| nyatla | 78:8cdb8fc7eda8 | 40 | |
| nyatla | 78:8cdb8fc7eda8 | 41 | const struct NyLPC_TJsonRpcClassDef MbedJsApi::RPC_MBED_PORT_IN={ |
| nyatla | 78:8cdb8fc7eda8 | 42 | "mbedJS","PortIn",func_table |
| nyatla | 78:8cdb8fc7eda8 | 43 | }; |
| nyatla | 78:8cdb8fc7eda8 | 44 | |
| nyatla | 78:8cdb8fc7eda8 | 45 | |
| nyatla | 78:8cdb8fc7eda8 | 46 | |
| nyatla | 78:8cdb8fc7eda8 | 47 | } |
