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.
Dependencies: mbed-rpc mbed-rtos mbed
Fork of Blinking_RPC by
RPCBlink.cpp
00001 /* 00002 Serial communication between NXP LPC1768 and a PC (Linux), with RPC librairie and a python script 00003 */ 00004 00005 00006 #include"mbed.h" 00007 00008 #include "mbed_rpc.h" 00009 #include <RPCVariable.h> 00010 #include "rtos.h" 00011 00012 //------------------------init variable----------------------------------------- 00013 //------------------------------------------------------------------------------ 00014 Serial pc(USBTX, USBRX); //serial comm with USB 00015 00016 DigitalOut Led1(LED1); //Led1 will be use for this example 00017 00018 int Blink = 0; //init Blink to 0 00019 RPCVariable<int> rpc_Blink(&Blink, "Blink_RPC"); //RPCVariable<'FORMAT'> NAME(&'VARIABLE',"ALIAS") 00020 00021 Thread Serial_thrd; //we will need a thread for serial comm update 00022 00023 //------------------------------------------------------------------------------ 00024 void comm_serie() 00025 { 00026 //The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so don't add to base class 00027 00028 // receive commands, and send back the responses 00029 char buf[256], outbuf[256]; 00030 00031 while(1) { 00032 pc.gets(buf, 256); 00033 //Call the static call method on the RPC class 00034 RPC::call(buf, outbuf); 00035 pc.printf("%s\n", outbuf); 00036 } 00037 } 00038 00039 00040 00041 int main() 00042 { 00043 Serial_thrd.start(comm_serie); //start the serial comm 00044 00045 while(1) 00046 { 00047 if(Blink == 0) //if Blink_RPC is 0, then Led1 no blinking 00048 { 00049 Led1 = 1; 00050 00051 } 00052 else if(Blink ==1) //if BLink_RPC is 1 , then Led1 is blinking 00053 { 00054 Led1 = 1; 00055 wait(0.2); 00056 Led1=0; 00057 wait(0.2); 00058 } 00059 } 00060 } 00061
Generated on Sat Jul 16 2022 01:57:01 by
1.7.2
