This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NyLPC_cJsonRpcFunction_Memory.c Source File

NyLPC_cJsonRpcFunction_Memory.c

00001 #include "NyLPC_net.h"
00002 
00003 ///**
00004 // * 1バイトをメモリに書き込む
00005 // */
00006 //static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00007 //{
00008 //  //ubb
00009 //  NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00010 //  NyLPC_TUInt8* addr;
00011 //  NyLPC_TUInt8 v,mask;
00012 //  if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,((NyLPC_TUInt32*)&addr))){
00013 //      if(NyLPC_TJsonRpcParserResult_getByte(i_rpc,1,((NyLPC_TUInt8*)&v))){
00014 //          if(NyLPC_TJsonRpcParserResult_getByte(i_rpc,2,((NyLPC_TUInt8*)&mask))){
00015 //              *addr=((*addr)&(~mask))|((*addr)|mask);
00016 //              return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"");
00017 //          }
00018 //      }
00019 //  }
00020 //  NyLPC_cModJsonRpc_putError(mod,i_rpc->method.id,NyLPC_TJsonRpcErrorCode_INVALID_PARAMS);
00021 //  return NyLPC_TBool_FALSE;
00022 //}
00023 ///**
00024 // * 1バイトをメモリから読み込む
00025 // */
00026 //static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00027 //{
00028 //  //u
00029 //  NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00030 //  NyLPC_TUInt8* addr;
00031 //  if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,((NyLPC_TUInt32*)&addr))){
00032 //      return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"%u",(int)(*addr));
00033 //  }
00034 //  NyLPC_cModJsonRpc_putError(mod,i_rpc->method.id,NyLPC_TJsonRpcErrorCode_INVALID_PARAMS);
00035 //  return NyLPC_TBool_FALSE;
00036 //}
00037 //
00038 ///**
00039 // * write32
00040 // */
00041 //static NyLPC_TBool write32(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00042 //{
00043 //  //uuu
00044 //  NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00045 //  NyLPC_TUInt32* addr;
00046 //  NyLPC_TUInt32 v,mask;
00047 //  if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,((NyLPC_TUInt32*)&addr))){
00048 //      if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,1,((NyLPC_TUInt32*)&v))){
00049 //          if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,2,((NyLPC_TUInt32*)&mask))){
00050 //              *addr=((*addr)&(~mask))|((*addr)|mask);
00051 //              return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"");
00052 //          }
00053 //      }
00054 //  }
00055 //  NyLPC_cModJsonRpc_putError(mod,i_rpc->method.id,NyLPC_TJsonRpcErrorCode_INVALID_PARAMS);
00056 //  return NyLPC_TBool_FALSE;
00057 //}
00058 ///**
00059 // * read32
00060 // */
00061 //static NyLPC_TBool read32(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00062 //{
00063 //  //u
00064 //  NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00065 //  NyLPC_TUInt32* addr;
00066 //  NyLPC_TUInt32 v;
00067 //  if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,((NyLPC_TUInt32*)&addr))){
00068 //      v=(*addr);
00069 //      return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"%u",v);
00070 //  }
00071 //  NyLPC_cModJsonRpc_putError(mod,i_rpc->method.id,NyLPC_TJsonRpcErrorCode_INVALID_PARAMS);
00072 //  return NyLPC_TBool_FALSE;
00073 //}
00074 /**
00075  * 準備(特にやることない)
00076  */
00077 static NyLPC_TBool init(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00078 {
00079     //uB
00080     NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00081     return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"");
00082 }
00083 
00084 /**
00085  * メモリブロックを書き込む
00086  */
00087 static NyLPC_TBool write(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00088 {
00089     //uB
00090     NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00091     NyLPC_TUInt8* addr;
00092     const NyLPC_TUInt8* v;
00093     NyLPC_TUInt8 l;
00094     if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,((NyLPC_TUInt32*)&addr))){
00095         if(NyLPC_TJsonRpcParserResult_getByteArray(i_rpc,1,&v,&l)){
00096             memcpy(addr,v,l);
00097             return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"");
00098         }
00099     }
00100     NyLPC_cModJsonRpc_putError(mod,i_rpc->method.id,NyLPC_TJsonRpcErrorCode_INVALID_PARAMS);
00101     return NyLPC_TBool_FALSE;
00102 }
00103 /**
00104  * メモリブロックを読み込む
00105  */
00106 static NyLPC_TBool read(const union NyLPC_TJsonRpcParserResult* i_rpc,void* i_param)
00107 {
00108     //uu
00109     NyLPC_TcModJsonRpc_t* mod=(NyLPC_TcModJsonRpc_t*)i_param;
00110     NyLPC_TUInt8* addr;
00111     NyLPC_TUInt32 l;
00112     if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,0,((NyLPC_TUInt32*)&addr))){
00113         if(NyLPC_TJsonRpcParserResult_getUInt32(i_rpc,1,((NyLPC_TUInt32*)&l))){
00114             return NyLPC_cModJsonRpc_putResult(mod,i_rpc->method.id,"\"%.*B\"",(int)l,addr);
00115         }
00116     }
00117     NyLPC_cModJsonRpc_putError(mod,i_rpc->method.id,NyLPC_TJsonRpcErrorCode_INVALID_PARAMS);
00118     return NyLPC_TBool_FALSE;
00119 }
00120 
00121 
00122 
00123 const static struct NyLPC_TJsonRpcMethodDef func_table[]=
00124 {
00125     { "init"    ,""     ,init},
00126     { "write"   ,"uB"   ,write},
00127     { "read"    ,"uu"   ,read},
00128     { NULL      ,NULL   ,NULL}
00129 };
00130 
00131 const struct NyLPC_TJsonRpcClassDef NyLPC_cJsonRpcFunction_Memory={
00132     "MiMic","Memory",func_table
00133 };
00134