From: nyatla
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã
- *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã
- *
- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿
è¦ãããã¾ãã
- *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã
- *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã
- *
- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿
è¦ãããã¾ãã
- *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã
- *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã
- *
- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿
è¦ãããã¾ãã
- *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã
- *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã
- *
- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿
è¦ãããã¾ãã
- *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã
- *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã
- *
- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿
è¦ãããã¾ãã
- *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã
- *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã
- *
- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿
è¦ãããã¾ãã
- * PinNameã®å ´åã¯å¶å¾¡ããPinIDãæå®ãã¾ãã
- * HashMapã®å ´åã¯ä»¥ä¸ã®ã¡ã³ããæå®ã§ãã¾ãã
- *
- *
- * @namespace
- * @name MiMicJS.Error
- * @example
- * throw new MiMicException(MiMicError.NG);
- */
- NS.Error=
- {
- /** æåã示ãã¾ãã
- * @constant
- * @name MiMicJS.Error.OK
- */
- OK:[0x00000000,"OK"],
- /** 詳細æ
å ±ã®ç¡ãã¨ã©ã¼ã§ãã
- * @constant
- * @name MiMicJS.Error.NG
- */
- NG:[0x40000000,"NG"],
- /** Generatorãç¨ããã³ã¼ãã§ãååã®yieldãçµäºãã¦ããªããã¨ã示ãã¾ãã
- * @constant
- * @name MiMicJS.Error.NG_YIELD_NOT_COMPLETED
- */
- NG_YIELD_NOT_COMPLETED:[0x40001001,"The previous function has not been completed."],
- /** é¢æ°ã®å¼ã³åºãé åºãæ£ãããªããã¨ã示ãã¾ãã
- * @constant
- * @name MiMicJS.Error.NG_ILLEGAL_CALL
- */
- NG_ILLEGAL_CALL:[0x40001002,"Illegal procedure call."],
- /** å¼æ°åã®ä¸ä¸è´ãæ¤åºãããã¨ã示ãã¾ãã
- * @constant
- * @name MiMicJS.Error.NG_INVALID_ARG
- */
- NG_INVALID_ARG:[0x40001003,"Invalid arguments."],
- /**
- * ã¨ã©ã¼ã³ã¼ããOKã調ã¹ãã
- * @function
- * @name MiMicJS.Error.isOK
- * @param {Object as [MiMicErrorCode]} v
- * è©ä¾¡ãããªãã¸ã§ã¯ã
- * @return {Boolean}
- * ã¨ã©ã¼ã³ã¼ãã§ãªããã°ãtrueãè¿ãã
- * @example
- * MiMicError.isOK(MiMicError.OK);//true
- */
- isOK:function(v){
- return (0x40000000 & v)==0x00000000;
- }
- };
-
-}());
-
-(function(){
- var NS=MiMicJS;
- /**
- * å¼æ°ã1åã®ãã¿ã¼ã³ã
- * @name MiMicJS.MiMicException:2
- * @function
- * @param {object} e
- * eã®ã¯ã©ã¹ã«ãããåä½ãç°ãªãã
- *
- * bit name discription
- * 30 ErrorBit Error:1,OK:0
- * 29-24 Reserved -
- * 23-16 ModuleID 0x00:unknown
0x39:MiMic
0xF0-0xFF: user define
Other:Reserved
- * 15-8 ClassID 0x00:unknown
- * 7-0 ErrorID
- *
- * @example
- * throw new MiMicException(MiMicError.NG);
- * throw new MiMicException("Error");
- * try{
- * throw new MiMicException("Error");
- * }catch(e){
- * throw new MiMicException(e);
- * }
- */
- /**
- * MiMic javascript APIãçæããä¾å¤ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿ã§ãããé¢æ°ãã¨ã«MiMicExceptionã使ã£ãtry-catchãå°å
¥ãããã¨ã«ãããä¾å¤çºçæã«ã¹ã¿ãã¯ãã¬ã¼ã¹ã¡ãã»ã¼ã¸ãå¾ããã¨ãåºæ¥ãã
- * ã¹ã¿ãã¯ãã¬ã¼ã¹ã¯æ¹è¡ã§é£çµãããæååã§ãããmessageããããã£ã«æ ¼ç´ããããalerté¢æ°ã§è¡¨ç¤ºãããã¨ã§ãå¹ççãªãããã¯ãå¯è½ã§ããã
- * å¼æ°ã®éãã«ãããæ°ç¨®é¡ã®å¼ã³åºãæ¹ãããã
- * @constructor
- * @name MiMicJS.MiMicException
- * @param ...
- * 詳細ã¯ãMiMicException:nãåç
§ã
- */
- NS.MiMicException=function MiMicException(/*...*/)
- {
- var pfx;
- if(typeof arguments.callee.caller=="function"){
- if(arguments.callee.caller.name.toString().length>0){
- pfx="function '"+arguments.callee.caller.name+'.';
- }else{
- var s=arguments.callee.caller.toString();
- pfx="closure '"+s.substring(0,s.indexOf("{"))+"...'";
- }
- }else{
- pfx="root document";
- }
- var sfx="";
- switch(arguments.length){
- case 0:
- //ã¨ããããexceptiion
- this.code=NS.Error.NG[0];
- this.message=pfx+" code(0x"+this.code.toString(16)+")"+NS.Error.NG[1];
- return;
- case 1:
- var v=arguments[0];
- if(v instanceof NS.MiMicException){
- //exceptionç¶æ¿
- this.code=v.code;
- sfx=" \nfrom "+v.message;
- }else if(typeof v=="object" && v.length==2){
- //Errorã³ã¼ããã¼ãã«
- this.code=v[0];
- sfx=v[1];
- }else{
- //æååããªãã¸ã§ã¯ã
- this.code=NS.Error.NG[0];
- sfx=NS.Error.NG[1]+" "+(((typeof v)!='undefined')?v.toString():"v==undefined");
- }
- this.message=pfx+" code(0x"+this.code.toString(16)+")"+sfx;
- return;
- default:
- break;
- }
- throw new NS.MiMicException("Invalid MiMicException argument.");
- }
-
- NS.MiMicException.prototype=
- {
-
- /**
- * MiMicErrorCodeå½¢å¼ã®ã¨ã©ã¼ã³ã¼ããä¿æããã
- * @field {object as MiMicErrorCode}
- * @name MiMicJS.MiMicException#code
- */
- code:null,
- /**
- * ã¨ã©ã¼ã¡ãã»ã¼ã¸ãä¿æããããã®å¤ã¯ãæ¹è¡åºåãã®ã³ã¼ã«ã¹ã¿ãã¯ã§ããã
- * @field {string}
- * @name MiMicJS.MiMicException#message
- */
- message:"",
- /**
- * messageãã£ã¼ã«ããalertã§è¡¨ç¤ºããã
- * @name MiMicJS.MiMicException#alert
- * @function
- * @example
- * try{
- * throw new MiMicException();
- * }catch(e){
- * e.alert();
- * }
- */
- alert:function(){
- alert(this.message);
- },
- /**
- * toStringãä¸æ¸ãããããªãã¸ã§ã¯ããæåååããã
- * æååã¯ä¾å¤ã®ã³ã¼ã«ã¹ã¿ãã¯ã§ããããããã¯ã§å½¹ç«ã¤ã
- * @function
- * @name MiMicJS.MiMicException#toString
- * @return {string}
- * ç¾å¨ã®ãªãã¸ã§ã¯ãã®ç¶æ
ï¼ä¾å¤ã®ã³ã¼ã«ã¹ã¿ãã¯ï¼
- * @example
- * try{
- * throw new MiMicException();
- * }catch(e){
- * alert(e.toString());
- * }
- */
- toString:function()
- {
- return "MiMicException:"+this.message;
- }
- }
-}());
-
-(function(){
- /**@private */
- var NS=MiMicJS;
- /**
- * MiMicRPCã®ã¯ã©ã¤ã¢ã³ãã¯ã©ã¹ã§ãã
- * éä¿¡APIãæä¾ãã¾ãã
- * @name MiMicJS.Rpc
- * @constructor
- * @param {HashMap} i_event
- * éåæã¤ãã³ããã³ãã©ã®é£æ³é
åã§ããç»é²ã§ããã¡ã³ãã¯ä»¥ä¸ã®éãã§ãã
- *
- *
- */
- NS.Rpc=function Rpc(i_event)
- {
- this._event=(i_event)?i_event:null;
- }
- NS.Rpc.prototype=
- {
- _event:null,
- /**
- * @private
- * Websocketã¤ã³ã¹ã¿ã³ã¹ã§ãã
- */
- _ws:null,
- /**
- * @private
- * [READ ONLY]
- * RPCã®å¹³åRTT[ms]ã§ãã
- * @name MiMicJs.Rpc#RTT
- */
- rtt:0,
- /** ã¡ã½ããIDã«ã¦ã³ã¿ãsendJsonãå®è¡ããæ¯ã«ã¤ã³ã¯ãªã¡ã³ãããã¾ãã*/
- _method_id:0,
- /**
- * RPCã³ãã¯ã·ã§ã³ãéãã¾ãã
- * é¢æ°ãçµäºããã¨onOpenã¤ãã³ããã³ã¼ã«ããã¯ãã¾ãã
- * @name MiMicJS.Rpc#open
- * @function
- * @param i_url
- * ws://ããå§ã¾ãWebsocketãµã¼ãã¹URLãæå®ãã¾ãã
- */
- open:function open(i_url)
- {
- var _t=this;
- if(this._ws){
- throw new MiMicException();
- }
-
- var q=new Array();
- var ev=this._event;
- var ws=new WebSocket(i_url);
- ws.onopen = function(){
- if(ev.onOpen){ev.onOpen();}
- }
- ws.onclose = function(){
- if(ev.onClose){ev.onClose();}
- };
- ws.error = function(){
- _t.shutdown();
- if(ev.onClose){ev.onError();}
- };
- var rx="";
- var rxst=0;
- var _t=this;
- ws.onmessage = function (e)
- {
- //ã¹ããªã¼ã ããJSONãæ½åºã"ã®ã¨ã¹ã±ã¼ãã«ã¯å¯¾å¿ããªãã
- for(var i=0;i
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
é åã®å ´åã¯æ¬¡ã®é çªã§ãã©ã¡ã¼ã¿ãæå®ãã¾ãã - *
{pin,value}- * - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - * - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.DigitalOut} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var pin=new mbedJS.DigitalOut(mcu,mbedJS.PinName.P0_22,{ - * onNew:function(){ - * pin.read(); - * }, - * onWrite:function(){ - * mcu.close(); - * }, - * onRead:function(v){ - * pin.write((v+1)%2); - * }}); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var pin=new mbedJS.DigitalOut(mcu,{pin:mbedJS.PinName.P0_22,value:0},g); - * yield pin.waitForNew(); - * var v=yield pin.read(); - * yield pin.write((v+1)%2); - * v=yield pin.read(); - * yield pin.write((v+1)%2); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * } - * }(); - * g.next(); - */ -var CLASS=function DigitalOut(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - function rcb(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - //ãã©ã¡ã¿çæ - var pr; - if(MI.isHashArray(i_params)){ - pr=[i_params.pin,i_params.value]; - }else if(MI.isArray(i_params)){ - pr=[i_params[0],null]; - }else{ - pr=[i_params,null]; - } - MI.assertInt(pr[0]); - if(pr[1]){ - MI.assertInt(pr[1]); - _t._mcu.rpc(_t.RPC_NS+":_new2",pr[0]+","+pr[1],rcb); - }else{ - _t._mcu.rpc(_t.RPC_NS+":_new1",pr[0],rcb); - } - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:DigitalOut", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new DigitalOut()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.DigitalOut#waitForNew - * @function - */ - waitForNew:function DigitalOut_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã³ã«å¤ãåºåãã¾ãã - * é¢æ°ã®å®äºæã«onWriteã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.DigitalOut#write - * @function - * @param {int} i_value - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - write:function DigitalOut_write(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onWrite); - MI._assertYield.call(_t); - _t._lc=CLASS.write; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":write",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã³ããå¤ãèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.DigitalOut#read - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯ãã³ã®å¤ãè¿ãã¾ãã - */ - read:function DigitalOut_read() - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onRead); - MI._assertYield.call(_t); - _t._lc=CLASS.read; - return _t._mcu.rpc(_t.RPC_NS+":read",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.DigitalOut#dispose - * @function - */ - dispose:function DigitalOut_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } - -} -NS.DigitalOut=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.I2C.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.I2C.js deleted file mode 100644 index 37c0cfb..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.I2C.js +++ /dev/null @@ -1,401 +0,0 @@ -/** - * @fileOverview I2Cã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * I2Cã¯ã©ã¹ã§ãã - * mbed::I2Cã¨åçã®æ©è½ãæã¡ã¾ãã - * @constructor - * @name mbedJS.I2C - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {[PinName,PinName]} i_params - * i2Cãã¹ãæ§æãããã³IDãæå®ãã¾ããsda,sclã®é çªã§ãã - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.I2C} - * @example //Callback - * var st=0; - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var i2c=new mbedJS.I2C(mcu,[mbedJS.PinName.p28,mbedJS.PinName.p27],{ - * onNew:function(){ - * i2c.frequency(100000); - * }, - * onFrequency:function() - * { - * i2c.start(); - * }, - * onStart:function(){ - * st=0; - * i2c.write(1); - * }, - * onWrite:function(v){ - * if(st==0){ - * i2c.write(0,[1,2,3],false); - * st++; - * }else{ - * i2c.read(1); - * st=0; - * } - * }, - * onRead:function(v){ - * if(st==0){ - * i2c.read(1,2,false); - * st++; - * }else{ - * i2c.stop(); - * } - * }, - * onStop:function(){ - * mcu.close(); - * } - * }); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var v; - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var i2c=new mbedJS.I2C(mcu,[mbedJS.PinName.p28,mbedJS.PinName.p27],g); - * yield i2c.waitForNew(); - * yield i2c.frequency(100000); - * yield i2c.start(); - * yield i2c.write(1); - * yield i2c.write(0,[1,2,3],false); - * yield i2c.read(1); - * yield i2c.read(1,2,false); - * yield i2c.stop(); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * alert(e); - * throw e; - * } - * }(); - * g.next(); - */ -var CLASS=function I2C(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params[0]+","+i_params[1], - function (j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:I2C", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new I2C()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.I2C#waitForNew - * @function - */ - waitForNew:function I2C_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * Hzåä½ã§ãã¹ã®é度ãæå®ãã¾ãã - * é¢æ°ã®å®äºæã«onFrequencyã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.I2C#frequency - * @function - * @param {int} i_hz - * Hzåä½ã®ãã¹é度ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - frequency:function I2C_frequency(i_hz) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onFrequency); - MI._assertYield.call(_t); - _t._lc=CLASS.frequency; - MI.assertInt(i_hz); - return _t._mcu.rpc(_t.RPC_NS+":frequency",_t._oid+","+i_hz, - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * å¼æ°ã3åã®å ´å - * @name mbedJS.I2C#read:1 - * @function - * @param {int} address - * 8ãããã®I2CSlaveã¢ãã¬ã¹ã§ãã - * @param {int} length - * èªã¿åºããã¼ã¿ã®é·ãã§ãã256æªæºã®å¤ãæå®ãã¦ãã ããã - * @param {boolean} repeated - * Repeated start, true - do not send stop at end - * Optionalã§ããçç¥æã¯falseã§ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @return {HashMap} - * {ret:int,data:[byte]} - * Generatorã®å ´åã¯æ»ãå¤ãªãã¸ã§ã¯ããè¿ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.I2CSlave} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var i2c=new mbedJS.I2CSlave(mcu,[mbedJS.PinName.p28,mbedJS.PinName.p27],{ - * onNew:function(){ - * i2c.frequency(100000); - * }, - * onFrequency:function() - * { - * i2c.address(1); - * }, - * onAddress:function() - * { - * i2c.receive(); - * }, - * onReceive:function(){ - * st=0; - * i2c.write(1); - * }, - * onWrite:function(v){ - * if(st==0){ - * i2c.write([1,2,3]); - * st++; - * }else{ - * i2c.read(); - * st=0; - * } - * }, - * onRead:function(v){ - * if(st==0){ - * i2c.read(2,false); - * st++; - * }else{ - * log("[PASS]onRead:"+v.ret+":"+v.data); - * i2c.stop(); - * } - * }, - * onStop:function(){ - * mcu.close(); - * } - * }); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var v; - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var i2c=new mbedJS.I2CSlave(mcu,[mbedJS.PinName.p28,mbedJS.PinName.p27],g); - * yield i2c.waitForNew(); - * yield i2c.frequency(100000); - * yield i2c.address(1); - * v=yield i2c.receive(); - * v=yield i2c.write(1); - * v=yield i2c.write([1,2,3]); - * v=yield i2c.read(); - * v=yield i2c.read(2,false); - * log("[PASS]onRead:"+v.ret+":"+v.data); - * yield i2c.stop(); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * alert(e); - * throw e; - * } - * }(); - * g.next(); - * return; - */ -var CLASS=function I2CSlave(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params[0]+","+i_params[1], - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -/** - * mbedJS.Serial#receiveã®æ»ãå¤ã®ç¨®é¡ã§ãã - * NoData,ReadAddressed,WriteGeneral,WriteAddressedãããã¾ãã - * @name mbedJS.I2CSlave#RxStatus - */ -CLASS.RxStatus={ - NoData:0,ReadAddressed:1,WriteGeneral:2,WriteAddressed:3 -} -CLASS.prototype={ - /** @private */ - RPC_NS:"mbedJS:I2CSlave", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new I2CSlave()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.I2CSlave#waitForNew - * @function - */ - waitForNew:function I2CSlave_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * I2CSlaveã®ã¢ãã¬ã¹ãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onAddressã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.I2CSlave#address - * @function - * @param {int} i_value - * 8ãããã®ã¢ãã¬ã¹å¤ã§ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - address:function I2CSlave_address(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onAddress); - MI._assertYield.call(_t); - _t._lc=CLASS.write; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":address",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * Hzåä½ã§ãã¹ã®é度ãæå®ãã¾ãã - * é¢æ°ã®å®äºæã«onFrequencyã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.I2CSlave#frequency - * @function - * @param {int} i_hz - * Hzåä½ã®ãã¹é度ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - frequency:function I2CSlave_frequency(i_hz) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onFrequency); - MI._assertYield.call(_t); - _t._lc=CLASS.frequency; - MI.assertInt(i_hz); - return _t._mcu.rpc(_t.RPC_NS+":frequency",_t._oid+","+i_hz, - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * å¼æ°ã2åã®å ´å - * @name mbedJS.I2CSlave#read:1 - * @function - * @param {int} length - * èªã¿åºããã¼ã¿ã®é·ãã§ãã256æªæºã®å¤ãæå®ãã¦ãã ããã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @return {HashMap} - * {ret:int,data:[byte]} - * Generatorã®å ´åã¯æ»ãå¤ãªãã¸ã§ã¯ããè¿ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®æ»ãå¤ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- * @return {mbedJS.Mcu} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * mcu.getInfo(); - * }, - * onGetInfo:function(v){ - * log("[PASS]onGetInfo:"+v.version+","+v.platform+","+v.mcu.name+","+v.mcu.eth+","+v.memory.free); - * var pin=new mbedJS.DigitalIn(mcu,mbedJS.PinName.P0_22,{ - * onNew:function(){ - * mcu.disposeObject(pin._oid); - * }}); - * }, - * onDisposeObject:function(v){ - * mcu.close(); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * } - * }(); - * g.next(); - */ -var CLASS=function Mcu(i_url,i_handler) -{ - var _t=this; - _t._lc=CLASS; - _t._has_error=false; - if(MI.isGenerator(i_handler)){_t._gen=i_handler;} - else if(i_handler){_t._event=i_handler} - - _t._rpc=new MI.Rpc({ - onOpen:function _Mcu_onOpen(){ - if(_t._event.onNew){_t._event.onNew();} - if(_t._gen){_t._gen.next(_t);} - _t.lc=null; - }, - onClose:function _Mcu_onClose(){ - if(_t._lc==CLASS.close){ - if(_t._event.onClose){_t._event.onClose();} - }else{ - if(_t._event.onError){_t._event.onError();} - } - if(_t._gen){ - _t._gen.next(_t); - } - _t.lc=null; - }, - onError:function _Mcu_onError() - { - _t._has_error=true; - if(_t._event.onError){_t._event.onError();} - if(_t._gen && _t._lc){ - _t._gen.throw(new MI.MiMicException()); - } - //@todo MCUã«ã¶ãä¸ãã£ã¦ãå ¨ã¦ã®yieldã«å¯¾ãã¦ãExceptionã®çºçè¦è«ï¼ - } - }); - //MCUã¸æ¥ç¶ - this._rpc.open('ws://'+i_url+'/rpc/'); -} -CLASS.prototype= -{ - RPC_NS:"mbedJS:Mcu", - _lc:null, - _rpc:null, - _gen:null, - _event:{}, - _has_error:false, - /** - * ã¨ã©ã¼ç¶æ ã§ããããè¿ãã¾ãã - * Generatorã¢ã¼ãã®å ´åã«ãå®æå®è¡ãã¦ã¤ã³ã¹ã¿ã³ã¹ã®ç¶æ ããã§ãã¯ã§ãã¾ãã - * falseã®å ´åãä¸ä½ã®ãªãã¸ã§ã¯ãã§yieldããã¯ãçºçãã¦ããå ´åãããã¾ãã - * @name mbedJS.Mcu#hasError - * @function - * @return {boolean} - * true - ã¤ã³ã¹ã¿ã³ã¹ã¯ã¨ã©ã¼ç¶æ ã§åæ¢ä¸ã§ãã使ç¨ã§ãã¾ããã - * false - ã¤ã³ã¹ã¿ã³ã¹ã¯åä½ä¸ã§ãã使ç¨å¯è½ã§ãã - */ - hasError:function(){ - return _t._has_error; - }, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new Mcu()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.Mcu#waitForNew - * @function - */ - waitForNew:function MCU_waitForNew(){ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }, - /** - * RPCãåæãã¾ããé¢æ°ã®å®äºæã«onCloseã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Mcu#close - * @function - */ - close:function MCU_close(){ - MI._assertYield.call(this); - this._lc=CLASS.close; - this._rpc.close(); - }, - /** - * ã³ã¼ã«ããã¯é¢æ°ãå ¨ã¦ãã£ã³ã»ã«ãã¦ãMcuã¨ã®æ¥ç¶ãã·ã£ãããã¦ã³ãã¾ãã - * ãã®é¢æ°ã¯å³åº§ã«å®äºãã¾ãã - * @name mbedJS.Mcu#shutdown - * @function - */ - shutdown:function MCU_shutdown(){ - this._rpc.shutdown(); - }, - /** - * RPCã¡ã½ãããå®è¡ãã¾ãã - * @name mbedJS.Mcu#rpc - * @function - * @param {string} m - * ã¡ã½ããåã§ãã - * @param {string} p - * ãã©ã¡ã¼ã¿é¨ã®æååã§ããJSONãªãã¸ã§ã¯ãã®é åãè¨è¿°ãã¾ãã - * é åã®è¦ç´ ã¯ããªããã£ãåã§ããå¿ è¦ãããã¾ãã - * @param {function(json)} c - * RPCãå®äºããã¨ãã«å¼ã³åºãã³ã¼ã«ããã¯é¢æ°ã§ãã - *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.Memory} - * @example //Callback - * var s=0; - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var mem=new mbedJS.Memory(mcu,{ - * onNew:function(){ - * s=0; - * mem.write(0x20080000,1); - * }, - * onWrite:function(){ - * log("[PASS]onWrite:"+s); - * switch(s){ - * case 0: - * mem.read(0x20080000,1); - * break; - * case 1: - * mem.read(0x20080001,1); - * break; - * case 2: - * mem.read(0x20080000,8); - * break; - * } - * }, - * onRead:function(v){ - * log("[PASS]onRead:"+s); - * switch(s){ - * case 0: - * mem.write(0x20080001,[2]); - * break; - * case 1: - * mem.write(0x20080004,[10,20,30]); - * break; - * case 2: - * mem.write32(0x20080000,0xff); - * s=-1; - * } - * s++; - * }, - * onWrite32:function(){ - * log("[PASS]onWrite32:"+s); - * switch(s){ - * case 0: - * mem.read32(0x20080000); - * break; - * case 1: - * mem.read32(0x20080004,4); - * break; - * case 2: - * mem.read32(0x20080000,16); - * break; - * } - * }, - * onRead32:function(v){ - * log("[PASS]onRead32:"+s); - * switch(s){ - * case 0: - * mem.write32(0x20080004,[2]); - * break; - * case 1: - * mem.write32(0x20080004,[10,20,30]); - * break; - * case 2: - * mcu.close(); - * } - * s++; - * } - * }); - * }, - * onClose:function(){ - * log("[PASS]onClose"); - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var v; - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var mem=new mbedJS.Memory(mcu,g); - * yield mem.waitForNew(); - * yield mem.write(0x20080000,1); - * log("[PASS]onWrite:"); - * v=yield mem.read(0x20080000,1); - * log("[PASS]onRead:"+v); - * v=yield mem.read(0x20080001,1); - * log("[PASS]onRead:"+v); - * v=yield mem.read(0x20080000,8); - * log("[PASS]onRead:"+v); - * yield mem.write(0x20080001,[2]); - * log("[PASS]onWrite:"); - * yield mem.write(0x20080004,[10,20,30]); - * log("[PASS]onWrite:"); - * yield mem.write32(0x20080000,0xff); - * log("[PASS]onWrite32:"); - * v=yield mem.read32(0x20080000); - * log("[PASS]onRead32:"+v); - * v=yield mem.read32(0x20080004,4); - * log("[PASS]onRead32:"+v); - * v=yield mem.read32(0x20080000,16); - * log("[PASS]onRead32:"+v); - * yield mem.write32(0x20080004,[2]); - * log("[PASS]onWrite32:"); - * yield mem.write32(0x20080004,[10,20,30]); - * log("[PASS]onWrite32:"); - * mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * alert(e); - * throw e; - * } - * }(); - * g.next(); - */ -var CLASS=function Memory(i_mcu,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - _t._mcu.rpc(_t.RPC_NS+":init","", - function(j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"MiMic:Memory", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new Memory()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.Memory#waitForNew - * @function - */ - waitForNew:function Memory_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 1ãã¤ãåä½ã§ã¡ã¢ãªããèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Memory#read - * @function - * @param {int} i_addr - * ã¡ã¢ãªã¢ãã¬ã¹ - * @param {int} i_size - * (Optional) èªåºããµã¤ãºã§ããçç¥æã¯1ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int[]} - * Generatorã¢ã¼ãã®æã¯ã¡ã¢ãªå¤ãæ ¼ç´ããé åãè¿ãã¾ãã - */ - read:function Memory_read(i_addr,i_size) - { - //read(i_addr) - //read(i_addr,i_len) - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onRead); - MI._assertYield.call(_t); - _t._lc=CLASS.read; - var a=[i_addr,(MI._getBaseArgsLen(arguments)==1)?i_size:1]; - MI.assertInt(a); - return _t._mcu.rpc(_t.RPC_NS+":read",a[0]+","+a[1], - function (j) - { - var v=MI.bstr2byteArray(j.result[0]); - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 1ãã¤ããã¡ã¢ãªã¸æ¸ãè¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onWriteã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Memory#write - * @function - * @param {int} i_addr - * æ¸ãè¾¼ã¿å ã®ã¡ã¢ãªã¢ãã¬ã¹ãæå®ãã¾ãã - * @param {int|int[]} i_v - * æ¸ãè¾¼ãbyteé åãã¾ãã¯æ°å¤ãæå®ãã¾ãã - * æ°å¤ã®å ´åã¯1ãã¤ããæ¸ãè¾¼ã¿ã¾ããæ大é·ãã¯200byteãããã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - write:function Memory_write(i_addr,i_v) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onWrite); - MI._assertYield.call(_t); - _t._lc=CLASS.write; - MI.assertInt(i_addr); - MI.assertInt(i_v); - return _t._mcu.rpc(_t.RPC_NS+":write",i_addr+",\""+MI.byteArray2bstr(i_v)+"\"", - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 4ãã¤ãåä½ã§ã¡ã¢ãªããèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onRead32ã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Memory#read32 - * @function - * @param {int} i_addr - * ã¡ã¢ãªã¢ãã¬ã¹ - * @param {int} i_size - * (Optional) èªåºããµã¤ãºã§ããçç¥æã¯4ã§ãã4ã®åæ°ãæå®ãã¦ãã ããã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int[]} - * Generatorã¢ã¼ãã®æã¯ã¡ã¢ãªå¤ãæ ¼ç´ããé åãè¿ãã¾ãã - */ - read32:function Memory_read32(i_addr,i_size) - { - //read(i_addr) - //read(i_addr,i_len) - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onRead32); - MI._assertYield.call(_t); - _t._lc=CLASS.read32; - - var a=[i_addr,(MI._getBaseArgsLen(arguments)==1)?4:i_size]; - if(a[1]%4!=0){ - throw new MI.MiMicException(MI.Error.NG_INVALID_ARG); - } - MI.assertInt(a); - return _t._mcu.rpc(_t.RPC_NS+":read",a[0]+","+a[1], - function (j) - { - var v=MI.bstr2uintArray(j.result[0]); - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 32bit unsigned intãã¡ã¢ãªã¸æ¸ãè¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onWrite32ã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Memory#write32 - * @function - * @param {int} i_addr - * æ¸ãè¾¼ã¿å ã®ã¡ã¢ãªã¢ãã¬ã¹ãæå®ãã¾ãã - * @param {int|int[]} i_v - * æ¸ãè¾¼ãbyteé åãã¾ãã¯æ°å¤ãæå®ãã¾ãã - * æ°å¤ã®å ´åã¯1ãã¤ããæ¸ãè¾¼ã¿ã¾ããæ大é·ãã¯200byteãããã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - write32:function Memory_write32(i_addr,i_v) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onWrite32); - MI._assertYield.call(_t); - _t._lc=CLASS.write32; - MI.assertInt(i_addr); - MI.assertInt(i_v); - return _t._mcu.rpc(_t.RPC_NS+":write",i_addr+",\""+MI.uintArray2bstr(i_v)+"\"", - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - } -} -NS.Memory=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.PortIn.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.PortIn.js deleted file mode 100644 index 3bfcbd1..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.PortIn.js +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @fileOverview PortInã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * PortInã¯ã©ã¹ã§ãã - * mbed::PortInã¨åçã®æ©è½ãæã¡ã¾ãã - * @name mbedJS.PortIn - * @constructor - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {HashMap|Array} i_params - *- * HashNapã®å ´åã¯ä»¥ä¸ã®ã¡ã³ããæå®ã§ãã¾ãã - *
é åã®å ´åã¯æ¬¡ã®é çªã§ãã©ã¡ã¼ã¿ãæå®ãã¾ãã - *
{port,mask}- * - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.PortIn} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var pin=new mbedJS.PortIn(mcu,[mbedJS.PortName.Port0,0xffffffff],{ - * onNew:function(){ - * log("[PASS]onNew"); - * pin.read(); - * }, - * onRead:function(v) - * { - * log("[PASS]read:"+v); - * mcu.close(); - * }}); - * }, - * onClose:function(){ - * log("[PASS]onClose"); - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var port=new mbedJS.PortIn(mcu,[mbedJS.PortName.Port0,0xffffffff],g); - * yield port.waitForNew(); - * var v=yield port.read(); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * } - * }(); - * g.next(); - */ -var CLASS=function PortIn(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - //å¼æ°ã®æ£è¦å - var pr; - if(MI.isHashArray(i_params)){ - pr=[i_params.port,i_params.mask]; - }else if(MI.isArray(i_params)){ - pr=i_params; - } - MI.assertInt(pr); - _t._mcu.rpc(_t.RPC_NS+":_new1",pr[0]+","+pr[1], - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:PortIn", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new PortIn()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.PortIn#waitForNew - * @function - */ - waitForNew:function PortIn_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã³ããå¤ãèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PortIn#read - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯ãã¼ãã®å¤ãè¿ãã¾ãã - */ - read:function PortIn_read() - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onRead); - MI._assertYield.call(_t); - _t._lc=CLASS.read; - return _t._mcu.rpc(_t.RPC_NS+":read",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.PortIn#dispose - * @function - */ - dispose:function PortIn_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } -} -NS.PortIn=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.PortOut.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.PortOut.js deleted file mode 100644 index ce40749..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.PortOut.js +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @fileOverview PortOutã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * PortOutã¯ã©ã¹ã§ãã - * mbed::PortOutã¨åçã®æ©è½ãæã¡ã¾ãã - * @name mbedJS.PortOut - * @constructor - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {HashMap|Array} i_params - *- * HashNapã®å ´åã¯ä»¥ä¸ã®ã¡ã³ããæå®ã§ãã¾ãã - *
é åã®å ´åã¯æ¬¡ã®é çªã§ãã©ã¡ã¼ã¿ãæå®ãã¾ãã - *
{port,mask}- * - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *
- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.PortOut} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var pin=new mbedJS.PortOut(mcu,[mbedJS.PortName.Port0,0xffffffff],{ - * onNew:function(){ - * pin.write(1234); - * }, - * onWrite:function() - * { - * pin.read(); - * }, - * onRead:function(v) - * { - * mcu.close(); - * }}); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var port=new mbedJS.PortOut(mcu,{port:mbedJS.PortName.Port0,mask:0xffffffff},g); - * yield port.waitForNew(); - * yield port.write(5678); - * var v=yield port.read(); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * } - * }(); - * g.next(); - */ -var CLASS=function PortOut(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - //å¼æ°ã®æ£è¦å - var pr; - if(MI.isHashArray(i_params)){ - pr=[i_params.port,i_params.mask]; - }else if(MI.isArray(i_params)){ - pr=i_params; - } - MI.assertInt(pr); - _t._mcu.rpc(_t.RPC_NS+":_new1",pr[0]+","+pr[1], - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:PortOut", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new PortOut()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.PortOut#waitForNew - * @function - */ - waitForNew:function DigitalOut_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã¼ãã¸å¤ãåºåãã¾ãã - * é¢æ°ã®å®äºæã«onWriteã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PortOut#write - * @function - * @param {int} i_value - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - write:function PortOut_write(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onWrite); - MI._assertYield.call(_t); - _t._lc=CLASS.write; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":write",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã¼ãããå¤ãèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PortOut#read - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯ãã¼ãã®å¤ãè¿ãã¾ãã - */ - read:function PortOut_read() - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onRead); - MI._assertYield.call(_t); - _t._lc=CLASS.read; - return _t._mcu.rpc(_t.RPC_NS+":read",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.PortOut#dispose - * @function - */ - dispose:function PortOut_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } -} -NS.PortOut=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.PwmOut.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.PwmOut.js deleted file mode 100644 index 053ec2c..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.PwmOut.js +++ /dev/null @@ -1,420 +0,0 @@ -/** - * @fileOverview PwmOutã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * PwmOutã¯ã©ã¹ã§ãã - * mbed::PwmOutã¨åçã®æ©è½ãæã¡ã¾ãã - * @name mbedJS.PwmOut - * @constructor - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {PinName} i_params - * ãã³IDãæå®ãã¾ãã - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.PwmOut} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var pin=new mbedJS.PwmOut(mcu,mbedJS.PinName.p21,{ - * onNew:function(){ - * pin.write(0.33); - * }, - * onWrite:function() - * { - * pin.read(); - * }, - * onRead:function(v) - * { - * pin.period(1.0); - * }, - * onPeriod:function(){ - * pin.period_ms(1); - * }, - * onPeriod_ms:function(){ - * pin.period_us(10); - * }, - * onPeriod_us:function(){ - * pin.pulsewidth(3); - * }, - * onPulsewidth:function(){ - * pin.pulsewidth_ms(30); - * }, - * onPulsewidth_ms:function(){ - * pin.pulsewidth_us(40); - * }, - * onPulsewidth_us:function(){ - * mcu.close(); - * } - * }); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var pin=new mbedJS.PwmOut(mcu,mbedJS.PinName.p21,g); - * yield pin.waitForNew(); - * yield pin.write(0.33); - * var v=yield pin.read(); - * yield pin.period(1.0); - * yield pin.period_ms(1); - * yield pin.period_us(10); - * yield pin.pulsewidth(3); - * yield pin.pulsewidth_ms(30); - * yield pin.pulsewidth_us(40); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * }}(); - * g.next(); - */ -var CLASS=function PwmOut(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params, - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:PwmOut", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new PwmOut()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.PwmOut#waitForNew - * @function - */ - waitForNew:function PwmOut_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã³ã«å¤ãåºåãã¾ãã - * é¢æ°ã®å®äºæã«onWriteã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#write - * @function - * @param {float} i_value - * [0,1]ã®å¤ãæå®ãã¾ãã - * @return {int|none} - *Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã
- *Generatorã¢ã¼ãã®æã¯æ»ãå¤ã¯ããã¾ããã
- */ - write:function PwmOut_write(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onWrite); - MI._assertYield.call(_t); - _t._lc=CLASS.write; - MI.assertNumber(i_value); - return _t._mcu.rpc(_t.RPC_NS+":write_fx",_t._oid+","+Math.round(i_value*10000), - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã³ããå¤ãèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#read - * @function - * @returnã{int|float} - *Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã
- *Generatorã¢ã¼ãã®æã¯ãã³ã®å¤ãè¿ãã¾ãã
- */ - read:function PwmOut_read() - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onRead); - MI._assertYield.call(_t); - _t._lc=CLASS.read; - return _t._mcu.rpc(_t.RPC_NS+":read_fx",_t._oid, - function (j) - { - var v=j.result[0]/10000; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * PWMã®å¨æãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onPeriodã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#period - * @function - * @param {float} i_value - * ç§åä½ã®å¨æãè¨å®ãã¾ãã - * @return {int|none} - *Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã
- *Generatorã¢ã¼ãã®æã¯æ»ãå¤ã¯ããã¾ããã
- */ - period:function PwmOut_period(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onPeriod); - MI._assertYield.call(_t); - _t._lc=CLASS.period; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":period_fx",_t._oid+","+Math.round(i_value*10000), - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * PWMã®å¨æãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onPeriod_msã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#period_ms - * @function - * @param {int} i_value - * msåä½ã®å¨æãè¨å®ãã¾ãã - * @return {int|none} - *Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã
- *Generatorã¢ã¼ãã®æã¯æ»ãå¤ã¯ããã¾ããã
- */ - period_ms:function PwmOut_period_ms(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onPeriod_ms); - MI._assertYield.call(_t); - _t._lc=CLASS.period_ms; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":period_ms",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * PWMã®å¨æãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onPeriod_usã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#period_us - * @function - * @param {int} i_value - * æ´æ°å¤ãæå®ãã¾ãã - * @return {int|none} - *Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã
- *Generatorã¢ã¼ãã®æã¯æ»ãå¤ã¯ããã¾ããã
- */ - period_us:function PwmOut_period_us(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onPeriod_us); - MI._assertYield.call(_t); - _t._lc=CLASS.period_us; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":period_us",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * PWMã®å¨æãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onPeriodã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#pulsewidth - * @function - * @param {float} i_value - * ç§åä½ã®å¨æãè¨å®ãã¾ãã - * @return {int|none} - *Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã
- *Generatorã¢ã¼ãã®æã¯æ»ãå¤ã¯ããã¾ããã
- */ - pulsewidth:function PwmOut_pulsewidth(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onPulsewidth); - MI._assertYield.call(_t); - _t._lc=CLASS.pulsewidth; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":pulsewidth_fx",_t._oid+","+Math.round(i_value*10000), - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * PWMã®å¨æãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onPulsewidth_msã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#pulsewidth_ms - * @function - * @param {int} i_value - * msåä½ã®å¨æãè¨å®ãã¾ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - pulsewidth_ms:function PwmOut_pulsewidth_ms(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onPulsewidth_ms); - MI._assertYield.call(_t); - _t._lc=CLASS.pulsewidth_ms; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":pulsewidth_ms",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * PWMã®å¨æãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onPulsewidth_usã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.PwmOut#pulsewidth_us - * @function - * @param {int} i_value - * æ´æ°å¤ãæå®ãã¾ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - pulsewidth_us:function PwmOut_pulsewidth_us(i_value) - { - try{ - var _t=this; - var cb=MI._getCb(arguments,_t._event.onPulsewidth_us); - MI._assertYield.call(_t); - _t._lc=CLASS.pulsewidth_us; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":pulsewidth_us",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.PwmOut#dispose - * @function - */ - dispose:function PwmOut_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } -} -NS.PwmOut=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.SPI.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.SPI.js deleted file mode 100644 index aa453db..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.SPI.js +++ /dev/null @@ -1,239 +0,0 @@ -/** - * @fileOverview SPIã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * SPIã¯ã©ã¹ã§ãã - * mbed::SPIã¨åçã®æ©è½ãæã¡ã¾ãã - * @name mbedJS.SPI - * @constructor - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {[PinName,PinName,PinName]} i_params - * SPIãæ§æãã3ã¤ã®PinNameãæ ¼ç´ããé åã§ããmosi,miso,sclkã®é çªã§ãã - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.SPI} - * @exampleã//Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var pin=new mbedJS.SPI(mcu,[mbedJS.PinName.p5,mbedJS.PinName.p6,mbedJS.PinName.p7],{ - * onNew:function(){ - * pin.frequency(1000000); - * }, - * onFrequency:function() - * { - * pin.format(8,3); - * }, - * onFormat:function() - * { - * pin.write(39); - * }, - * onWrite:function(v){ - * mcu.close(); - * }}); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * } - * }); - * @exampleã//Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var pin=new mbedJS.SPI(mcu,[mbedJS.PinName.p5,mbedJS.PinName.p6,mbedJS.PinName.p7],g); - * yield pin.waitForNew(); - * yield pin.frequency(1000000); - * yield pin.format(8,3); - * v=yield pin.write(39); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * } - * }(); - * g.next(); - */ -var CLASS=function SPI(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params[0]+","+i_params[1]+","+i_params[2]+","+NS.PinName.NC, - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:SPI", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new SPI()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.SPI#waitForNew - * @function - */ - waitForNew:function SPI_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * SPI Slaveã«å¤ãæ¸ãè¾¼ã¿ãæ»ãå¤ãè¿ãã¾ãã - * é¢æ°ã®å®äºæã«onWriteã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPI#write - * @function - * @param {int} i_value - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - write:function SPI_write(i_value) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onWrite); - _t._lc=CLASS.write; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":write",_t._oid+","+i_value, - function(j){ - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * frequencyã«å¤ãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onFrequencyã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPI#frequency - * @function - * @param {int} i_value - * frequencyã«è¨å®ããå¤ã§ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - frequency:function SPI_frequency(i_value) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onFrequency); - _t._lc=CLASS.frequency; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":frequency",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * formatã«å¤ãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onFormatã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPI#format - * @function - * @param {int} i_bits - * @param {int} i_mode - * çç¥å¯è½ã§ããçç¥æã¯0ã«ãªãã¾ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - format:function SPI_format(i_bits,i_mode) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onFormat); - _t._lc=CLASS.format; - var mode=i_mode?i_mode:0; - MI.assertInt([i_bits,mode]); - return _t._mcu.rpc(_t.RPC_NS+":format",_t._oid+","+i_bits+","+mode, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.SPI#dispose - * @function - */ - dispose:function SPI_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } -} -NS.SPI=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.SPISlave.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.SPISlave.js deleted file mode 100644 index e4e2088..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.SPISlave.js +++ /dev/null @@ -1,314 +0,0 @@ -/** - * @fileOverview SPISlaveã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * SPISlaveã¯ã©ã¹ã§ãã - * mbed::SPISlaveã¨åçã®æ©è½ãæã¡ã¾ãã - * @name mbedJS.SPISlave - * @constructor - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {[PinName,PinName,PinName]} i_params - * SPIãæ§æãã4ã¤ã®PinNameãæ ¼ç´ããé åã§ãã - * mosi, miso, sclkã®é çªã§è¨å®ãã¾ãã - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.SPI} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var pin=new mbedJS.SPISlave(mcu,[mbedJS.PinName.p5,mbedJS.PinName.p6,mbedJS.PinName.p7,mbedJS.PinName.p8],{ - * onNew:function(){ - * pin.frequency(1000000); - * }, - * onFrequency:function() - * { - * pin.format(8,3); - * }, - * onFormat:function() - * { - * pin.read(); - * }, - * onRead:function(v){ - * pin.receive(); - * }, - * onReceive:function(v) - * { - * pin.reply(1); - * }, - * onReply:function(){ - * mcu.close(); - * } - * }); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var pin=new mbedJS.SPISlave(mcu,[mbedJS.PinName.p5,mbedJS.PinName.p6,mbedJS.PinName.p7,mbedJS.PinName.p8],g); - * yield pin.waitForNew(); - * yield pin.frequency(1000000); - * yield pin.format(8,3); - * var v=yield pin.read(); - * v=yield pin.receive(); - * yield pin.reply(1); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * } - * }(); - * g.next(); - */ -var CLASS=function SPISlave(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - _t._mcu=i_mcu; - _t._lc=CLASS; - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params[0]+","+i_params[1]+","+i_params[2]+","+i_params[3], - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -CLASS.prototype= -{ - /** @private */ - RPC_NS:"mbedJS:SPISlave", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new SPISlave()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.SPISlave#waitForNew - * @function - */ - waitForNew:function SPISlave_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - - /** - * frequencyã«å¤ãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onFrequencyã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPISlave#frequency - * @function - * @param {int} i_value - * - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - frequency:function SPISlave_frequency(i_value) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onFrequency); - _t._lc=CLASS.frequency; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":frequency",_t._oid+","+i_value, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * formatã«å¤ãè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onFormatã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPISlave#format - * @function - * @param {int} i_bits - * @param {int} i_mode - * çç¥å¯è½ã§ããçç¥æã¯0ã«ãªãã¾ãã - * @return {int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - format:function SPISlave_format(i_bits,i_mode) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onFormat); - _t._lc=CLASS.format; - var mode=i_mode?i_mode:0; - MI.assertInt([i_bits,mode]); - return _t._mcu.rpc(_t.RPC_NS+":format",_t._oid+","+i_bits+","+mode, - function(j){ - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 転éã¡ã¢ãªããå¤ãèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPISlave#read - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯ãã³ã®å¤ãè¿ãã¾ãã - */ - read:function SPISlave_read() - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onRead); - _t._lc=CLASS.read; - return _t._mcu.rpc(_t.RPC_NS+":read",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã¼ã¿ãå°çãã¦ããããè¿ãã¾ãã - * é¢æ°ã®å®äºæã«onReadã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPISlave#receive - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯ãã³ã®å¤ãè¿ãã¾ãã - */ - receive:function SPISlave_receive() - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onReceive); - _t._lc=CLASS.receive; - return _t._mcu.rpc(_t.RPC_NS+":receive",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 転éãããã¡ã«æ¬¡ã«éä¿¡ããã¡ãã»ã¼ã¸ãã»ãããã¾ãã - * é¢æ°ã®å®äºæã«onReplyã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.SPISlave#reply - * @function - * @param {int} i_value - * 次ã«éã8bitã®å¤ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - reply:function SPISlave_reply(i_value) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onReply); - _t._lc=CLASS.reply; - MI.assertInt(i_value); - return _t._mcu.rpc(_t.RPC_NS+":reply",_t._oid+","+i_value, - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - }); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.SPISlave#dispose - * @function - */ - dispose:function SPISlave_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } -} -NS.SPISlave=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.Serial.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.Serial.js deleted file mode 100644 index 40e2fe6..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.Serial.js +++ /dev/null @@ -1,502 +0,0 @@ -/** - * @fileOverview AnalogInã¯ã©ã¹ãå®ç¾©ãã¾ãã - */ -(function(){ -var NS=mbedJS; -var MI=MiMicJS; - -/** - * Serialã¯ã©ã¹ã§ãã - * mbed::Serialã¨åçã®æ©è½ãæã¡ã¾ãã - * @constructor - * @name mbedJS.Serial - * @param {mbedJS.Mcu} i_mcu - * ã¤ã³ã¹ã¿ã³ã¹ããã¤ã³ãããMCUãªãã¸ã§ã¯ãã§ãã - * @param {[PinName,PinName]} i_params - * UARTãæ§æããï¼æ¬ã®ãã³ãæå®ãã¾ããtx,rxã®é ã§è¨å®ãã¾ãã - * @param {HashMap|Generator|function} i_handler - * éåæã¤ãã³ããã³ãã©ã®é£æ³é åãGeneratorãã³ã¼ã«ããã¯é¢æ°ã®ä½ãããæå®ãã¾ãã - *- * éåæã¤ãã³ããã³ãã©ã®å ´åãé¢æ°ã¯ã¤ãã³ããã³ãã©ã§çµæãéç¥ãã¾ãã - *
- * Generatorãæå®ããå ´åãã³ã¼ã«ããã¯é¢æ°ã®å¼æ°ã¯yiledã®æ»ãå¤ã¨ãã¦åå¾ã§ãã¾ãã - *
- *- * ã³ã¼ã«ããã¯é¢æ°ãæå®ããå ´åãRPCãå®äºããã¨ãã«å¼ã³åºããã¾ããã¡ã³ãé¢æ°ã®ã¤ãã³ããã³ãã©ã¯åå¥ã«è¨å®ããå¿ è¦ãããã¾ãã - *
- * @return {mbedJS.Serial} - * @example //Callback - * var mcu=new mbedJS.Mcu("192.168.128.39", - * { - * onNew:function(){ - * var uart=new mbedJS.Serial(mcu,[mbedJS.PinName.p9,mbedJS.PinName.p10],{ - * onNew:function(){ - * uart.baud(115200); - * }, - * onBaud:function() - * { - * uart.send_break(); - * }, - * onSend_break:function(){ - * uart.format(8,uart.Parity.None,1); - * }, - * onFormat:function(){ - * uart.readable(); - * }, - * onReadable:function(v){ - * uart.writeable(); - * }, - * onWriteable:function(v){ - * uart.putc(32); - * }, - * onPutc:function(v){ - * uart.getc(); - * }, - * onGetc:function(v){ - * uart.puts("1234"); - * }, - * onPuts:function(v){ - * uart.gets(5); - * }, - * onGets:function(v){ - * mcu.close(); - * } - * }); - * }, - * onClose:function(){ - * }, - * onError:function(){ - * alert("Error"); - * } - * }); - * @example //Generator - * var g=function*(){ - * try{ - * var v; - * var mcu=new mbedJS.Mcu("192.168.128.39",g); - * yield mcu.waitForNew(); - * var uart=new mbedJS.Serial(mcu,[mbedJS.PinName.p9,mbedJS.PinName.p10],g); - * yield uart.waitForNew(); - * yield uart.baud(115200); - * yield uart.send_break(); - * yield uart.format(8,uart.Parity.None,1); - * v=yield uart.readable(); - * v=yield uart.writeable(); - * v=yield uart.putc(32); - * v=yield uart.getc(); - * v=yield uart.puts("1234"); - * v=yield uart.gets(5); - * yield mcu.close(); - * }catch(e){ - * mcu.shutdown(); - * alert(e); - * throw e; - * } - * }(); - * g.next(); - */ -var CLASS=function Serial(i_mcu,i_params,i_handler) -{ - try{ - var _t=this; - var cb; - _t._mcu=i_mcu; - _t._lc=CLASS; - //ãã³ãã©ã®åæå - var cb=MI._initHandler.call(_t,i_handler); - MI.assertInt(i_params); - _t._mcu.rpc(_t.RPC_NS+":_new1",i_params[0]+","+i_params[1], - function(j) - { - _t._oid=j.result[0]; - if(cb){cb();} - if(_t._gen){_t._gen.next(_t);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } -} -/** - * mbedJS.Serial#formaté¢æ°ã«æå®ããå¤ã®ç¨®é¡ã§ãã - * None,Odd,Even,Forced1,Forced0ãããã¾ãã - * @name mbedJS.Serial#Parity - * @field - */ -CLASS.Parity={ - None:0,Odd:1,Even:2,Forced1:3,Forced0:4 -} -CLASS.prototype={ - /** @private */ - RPC_NS:"mbedJS:Serial", - /** @private æå¾ã«ã³ã¼ã«ããAPIã§ãã*/ - _lc:null, - /** @private Generatorã¢ã¼ãã®å ´åã«Generatorãªãã¸ã§ã¯ããä¿æãã¾ãã*/ - _gen:null, - /** @private ã³ã¼ã«ããã¯é¢æ°ã®é£æ³é åã§ããè¦ç´ ã¯ã³ã³ã¹ãã©ã¯ã¿ãåç §ãã¦ãã ããã*/ - _event:{}, - /** @private ãªã¢ã¼ãã¤ã³ã¹ã¿ã³ã¹ã®ãªãã¸ã§ã¯ãIDã§ãã*/ - _oid:null, - /** - * Generatorã¢ã¼ãã®ã¨ãã«ä½¿ç¨ããé¢æ°ã§ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦new AnalogIn()ã®å®äºãå¾ ã¡ã¾ãã - * @name mbedJS.Serial#waitForNew - * @function - */ - waitForNew:function Serial_waitForNew() - { - try{ - if(this._lc!=CLASS){throw new MI.MiMicException(MI.Error.NG_ILLEGAL_CALL);} - this._lc=CLASS.waitForNew; - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã©ã¼ããããè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onFormatã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#format - * @function - * @param {int} i_bits - * ãããæ°ã§ããçç¥æã¯8ã§ãã - * @param {int} i_parity - * ããªãã£ã®å¤ã§ããçç¥æã¯mbedJS.Serial#Parity.Noneã§ãã - * @param {int} i_stop_bits - * ã¹ããããããã®å¤ã§ããçç¥æã¯1ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - format:function Serial_format(i_bits,i_parity,i_stop_bits) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onFormat); - _t._lc=CLASS.format; - var p=[MI.isUndefined(i_bits,8),MI.isUndefined(i_parity,CLASS.Parity.None),MI.isUndefined(i_stop_bits,1)]; - MI.assertInt(p); - return _t._mcu.rpc(_t.RPC_NS+":format",_t._oid+","+p[0]+","+p[1]+","+p[2], - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * èªåºãå¯è½ããè¿ãã¾ãã - * é¢æ°ã®å®äºæã«onReadableã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#readable - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{boolean} - * Generatorã¢ã¼ãã®æã¯ç¶æ å¤ã®çå½å¤ãè¿ãã¾ãã - */ - readable:function Serial_readable() - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onReadable); - _t._lc=CLASS.readable; - return _t._mcu.rpc(_t.RPC_NS+":readable",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * æ¸ãè¾¼ã¿å¯è½ããè¿ãã¾ãã - * é¢æ°ã®å®äºæã«onWriteableã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#writeable - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{boolean} - * Generatorã¢ã¼ãã®æã¯ç¶æ å¤ã®çå½å¤ãè¿ãã¾ãã - */ - writeable:function Serial_writeable() - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onWriteable); - _t._lc=CLASS.writeable; - return _t._mcu.rpc(_t.RPC_NS+":writeable",_t._oid, - function (j) - { - var v=j.result[0]?true:false; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã¬ã¼ã¯ä¿¡å·ãéä¿¡ãã¾ãã - * é¢æ°ã®å®äºæã«onSend_breakã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#send_break - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - send_break:function Serial_send_break() - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onSend_break); - _t._lc=CLASS.send_break; - return _t._mcu.rpc(_t.RPC_NS+":send_break",_t._oid, - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 1ãã¤ãã®å¤ãåºåãã¾ãã - * é¢æ°ã®å®äºæã«onPutcã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#putc - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯è¬ã®å¤ãè¿ãã¾ãã - */ - putc:function Serial_putc(i_c) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onPutc); - _t._lc=CLASS.putc; - MI.assertInt(i_c); - return _t._mcu.rpc(_t.RPC_NS+":putc",_t._oid+","+i_c, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * æååãåºåãã¾ãã - * é¢æ°ã®å®äºæã«onPutsã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#puts - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯è¬ã®å¤ãè¿ãã¾ãã - */ - puts:function Serial_puts(i_s) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onPuts); - _t._lc=CLASS.puts; - return _t._mcu.rpc(_t.RPC_NS+":puts",_t._oid+",\""+i_s+"\"", - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * 1ãã¤ããèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onGetcã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#getc - * @function - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{int} - * Generatorã¢ã¼ãã®æã¯åä¿¡ããæ°å¤ãè¿ãã¾ãã - */ - getc:function Serial_getc() - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onGetc); - _t._lc=CLASS.getc; - return _t._mcu.rpc(_t.RPC_NS+":getc",_t._oid, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * æååãèªã¿è¾¼ã¿ã¾ãã - * é¢æ°ã®å®äºæã«onGetsã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#gets - * @function - * @param {int} i_len - * åä¿¡ã¡ã¢ãªã®ãµã¤ãºãæå®ãã¾ãã256æªæºãæå®ãã¦ãã ããã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - * @returnã{string} - * Generatorã¢ã¼ãã®æã¯åä¿¡ããæååãè¿ãã¾ãã - */ - gets:function Serial_gets(i_len) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onGets); - _t._lc=CLASS.gets; - MI.assertInt(i_len); - return _t._mcu.rpc(_t.RPC_NS+":gets",_t._oid+","+i_len, - function (j) - { - var v=j.result[0]; - if(cb){cb(v);} - if(_t._gen){_t._gen.next(v);} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * ãã¼ã¬ã¤ããè¨å®ãã¾ãã - * é¢æ°ã®å®äºæã«onBaudã¤ãã³ããçºçãã¾ãã - * Generatorã¢ã¼ãã®æã¯ãyieldã¨ä½µç¨ãã¦å®äºãå¾ æ©ã§ãã¾ãã - * @name mbedJS.Serial#baud - * @function - * @param {int} i_baudrate - * ãã¼ã¬ã¤ãã®å¤ã§ãã - * @returnã{int} - * Callbackã¢ã¼ãã®æã¯RPCã¡ã½ããã®ã¤ã³ãã¯ã¹ãè¿ãã¾ãã - */ - baud:function Serial_baud(i_baudrate) - { - try{ - var _t=this; - MI._assertYield.call(_t); - var cb=MI._getCb(arguments,_t._event.onBaud); - _t._lc=CLASS.baud; - MI.assertInt(i_baudrate); - return _t._mcu.rpc(_t.RPC_NS+":baud",_t._oid+","+i_baudrate, - function (j) - { - if(cb){cb();} - if(_t._gen){_t._gen.next();} - _t._lc=null; - } - ); - }catch(e){ - throw new MI.MiMicException(e); - } - }, - /** - * MCUã«çæããã¦ãããªãã¸ã§ã¯ããç ´æ£ãã¾ãã - * @name mbedJS.Serial#dispose - * @function - */ - dispose:function Serial_dispose() - { - return this._mcu._dispose.apply(this,arguments); - } -} -NS.Serial=CLASS; -}()); \ No newline at end of file diff --git a/misc/mbedJS/mbddJS.API/mbedJS/mbed.types.js b/misc/mbedJS/mbddJS.API/mbedJS/mbed.types.js deleted file mode 100644 index 74f06b8..0000000 --- a/misc/mbedJS/mbddJS.API/mbedJS/mbed.types.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @fileOverview mbedSDKã®å®æ°ãå®ç¾©ãã¾ãã - */ - -/** - * mbedJSãã¼ã ã¹ãã¼ã¹ - * @namespace - */ -var mbedJS={}; -(function(){ -var NS=mbedJS; -/** - * mbedSDKã®ãã³èå¥åã§ããã©ã¤ãã©ãªã®ãã³åã¨ä¸è´ãã¾ãã次ã®ãã³åã使ç¨ã§ãã¾ãã - *