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
- Committer:
- Thom_cass
- Date:
- 2017-07-30
- Revision:
- 0:fcc2576568f1
File content as of revision 0:fcc2576568f1:
/*
Serial communication between NXP LPC1768 and a PC (Linux), with RPC librairie and a python script
*/
#include"mbed.h"
#include "mbed_rpc.h"
#include <RPCVariable.h>
#include "rtos.h"
//------------------------init variable-----------------------------------------
//------------------------------------------------------------------------------
Serial pc(USBTX, USBRX); //serial comm with USB
DigitalOut Led1(LED1); //Led1 will be use for this example
int Blink = 0; //init Blink to 0
RPCVariable<int> rpc_Blink(&Blink, "Blink_RPC"); //RPCVariable<'FORMAT'> NAME(&'VARIABLE',"ALIAS")
Thread Serial_thrd; //we will need a thread for serial comm update
//------------------------------------------------------------------------------
void comm_serie()
{
//The mbed RPC classes are now wrapped to create an RPC enabled version - see RpcClasses.h so don't add to base class
// receive commands, and send back the responses
char buf[256], outbuf[256];
while(1) {
pc.gets(buf, 256);
//Call the static call method on the RPC class
RPC::call(buf, outbuf);
pc.printf("%s\n", outbuf);
}
}
int main()
{
Serial_thrd.start(comm_serie); //start the serial comm
while(1)
{
if(Blink == 0) //if Blink_RPC is 0, then Led1 no blinking
{
Led1 = 1;
}
else if(Blink ==1) //if BLink_RPC is 1 , then Led1 is blinking
{
Led1 = 1;
wait(0.2);
Led1=0;
wait(0.2);
}
}
}
