-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Feature: component hosted (#2305)
The hosted component allows Sming's host emulator to run parts of the commands on an actual microcontroller. The communication is done via [simplePRC](https://simplerpc.readthedocs.io) and the microcontroller has to be flashed with a special application. Overview -------- Sming's host emulator allows easier debugging and development of embedded applications. This component named "Hosted" extends the host emulator and facilitates testing functionality that only a real microcontroller can provide as for example digital I/O operations or SPI operations. For example in order to run the Basic_Blink application under the host emulator and run the actual blinking of a LED on a microcontroller we can compile the application using the following directives:: ``` make SMING_ARCH=Host ENABLE_HOSTED=tcp HOSTED_SERVER_IP=192.168.4.1 ``` `SMING_ARCH=Host` instructs the build system to build the application for the Host architecture. `ENABLE_HOSTED=tcp` instructs the host emulator to communication with the real microcontroller using TCP `HOSTED_SERVER_IP=192.168.4.1` instructs the host emulator to connect to IP `192.168.4.1`. In the sub-directory ``samples`` inside this component you will find the sample applications that will turn your microcontroller into a remote RCP server. The compilation and flashing for ESP32, for example, can be done using the following commands: ``` cd samples/tcp make SMING_ARCH=Esp32 WIFI_SSID=YourSSID WIFI_PWD=YourPassword make flash ``` If you replace ``SMING_ARCH=Esp32`` with ``SMING_ARCH=Esp8266`` then the hosted application will be compiled and flashed on a ESP8266 microcontroller. Make sure to replace the values of WIFI_SSID and WIFI_PWD with the actual name and password for the Access Point (AP).
- Loading branch information
Showing
47 changed files
with
1,547 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/SmingHub/Sming | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
* | ||
* emu.h | ||
* | ||
****/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Executing this function will run once the main emulator loop. | ||
*/ | ||
void host_main_loop(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* hostlib.h | ||
* | ||
* Copyright 2019 mikee47 <mike@sillyhouse.net> | ||
* | ||
* This file is part of the Sming Framework Project | ||
* | ||
* This library is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, version 3 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with SHEM. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
****/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void host_init(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* init.cpp - Sming Host Emulator startup code | ||
* | ||
* Copyright 2019 mikee47 <mike@sillyhouse.net> | ||
* | ||
* This file is part of the Sming Framework Project | ||
* | ||
* This library is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, version 3 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with SHEM. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
****/ | ||
|
||
#include "include/hostlib/init.h" | ||
|
||
extern void init(); | ||
|
||
void host_init() | ||
{ | ||
init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "SPI.h" | ||
|
||
bool SPIClass::begin() | ||
{ | ||
return false; | ||
} | ||
|
||
void SPIClass::transfer(uint8_t* buffer, size_t numberBytes) | ||
{ | ||
} | ||
|
||
void SPIClass::prepare(SPISettings& settings) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
COMPONENT_SRCDIRS := $(COMPONENT_PATH)/src | ||
COMPONENT_DEPENDS := Hosted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/SmingHub/Sming | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
* | ||
* Digital.cpp | ||
* | ||
* @author 2021 Slavey Karadzhov <slav@attachix.com> | ||
* | ||
* | ||
****/ | ||
|
||
#include <Digital.h> | ||
#include <Hosted/Client.h> | ||
|
||
extern Hosted::Client* hostedClient; | ||
|
||
void pinMode(uint16_t pin, uint8_t mode) | ||
{ | ||
hostedClient->send(__func__, pin, mode); | ||
} | ||
|
||
void digitalWrite(uint16_t pin, uint8_t val) | ||
{ | ||
hostedClient->send(__func__, pin, val); | ||
} | ||
|
||
uint8_t digitalRead(uint16_t pin) | ||
{ | ||
hostedClient->send(__func__, pin); | ||
return hostedClient->wait<uint8_t>(); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
HostEd | ||
====== | ||
|
||
.. highlight:: bash | ||
|
||
The hosted component allows Sming's host emulator to run parts of the commands on an actual microcontroller. | ||
The communication is done via `simplePRC <https://simplerpc.readthedocs.io/>`_ and the microcontroller has to be flashed with a special application. | ||
|
||
Overview | ||
-------- | ||
Sming's host emulator allows easier debugging and development of embedded applications. This component named "HostEd" extends the host emulator | ||
and facilitates testing functionality that only a real microcontroller can provide as for example digital I/O operations or SPI operations. | ||
|
||
For example in order to run the Basic_Blink application under the host emulator and run the actual blinking of a LED on a microcontroller | ||
we can compile the application using the following directives:: | ||
|
||
make SMING_ARCH=Host ENABLE_HOSTED=tcp HOSTED_SERVER_IP=192.168.4.1 | ||
|
||
`SMING_ARCH=Host` instructs the build system to build the application for the Host architecture. | ||
`ENABLE_HOSTED=tcp` instructs the host emulator to communication with the real microcontroller using TCP | ||
`HOSTED_SERVER_IP=192.168.4.1` instructs the host emulator to connect to IP `192.168.4.1`. | ||
|
||
We need to compile and flash also a special application on the desired microcontroller. | ||
This application will act as an RPC Server and will execute the commands from the host emulator on the microcontroller. | ||
|
||
In the sub-directory ``samples`` inside this directory you will find the sample applications that will turn your microcontroller into | ||
RCP server. | ||
|
||
The compilation and flashing for ESP32, for example, can be done using the following commands:: | ||
|
||
cd samples/tcp | ||
make SMING_ARCH=Esp32 WIFI_SSID=YourSSID WIFI_PWD=YourPassword | ||
make flash | ||
|
||
If you replace ``SMING_ARCH=Esp32`` with ``SMING_ARCH=Esp8266`` then the hosted application will be compiled and flashed on a ESP8266 microcontroller. | ||
Make sure to replace the values of WIFI_SSID and WIFI_PWD with the actual name and password for the Access Point (AP). | ||
|
||
Communication | ||
------------- | ||
At the moment the communication between an application running on the Host and the RCP server running on a microcontroller | ||
can be done using TCP or serial interface. | ||
The ``transport`` classes are located under ``include/Hosted/Transport``. | ||
|
||
Configuration | ||
------------- | ||
.. envvar:: ENABLE_HOSTED | ||
|
||
Default: empty (disabled) | ||
|
||
Enables the hosted component. Valid values for the moment are: | ||
- tcp - for communication over TCP network. | ||
- serial - for communication over serial interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
COMPONENT_SRCDIRS := $(COMPONENT_PATH)/src | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) $(COMPONENT_PATH)/include | ||
COMPONENT_DEPENDS := simpleRPC | ||
|
||
# Architecture of the device where the hosted service will be flashed | ||
HOSTED_ARCH ?= Esp8266 | ||
|
||
COMPONENT_RELINK_VARS += ENABLE_HOSTED | ||
COMPONENT_VARS := ENABLE_HOSTED | ||
|
||
ENABLE_HOSTED ?= | ||
|
||
ifneq ($(ENABLE_HOSTED),) | ||
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/init/$(ENABLE_HOSTED) | ||
EXTRA_LDFLAGS := -Wl,-wrap,host_init | ||
endif | ||
|
||
COMPONENT_VARS += HOSTED_SERVER_IP | ||
|
||
COMPONENT_CFLAGS = -DHOSTED_SERVER_IP=$(HOSTED_SERVER_IP) | ||
COMPONENT_CXXFLAGS := $(COMPONENT_CFLAGS) |
Oops, something went wrong.