-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: component hosted #2305
Changes from 23 commits
304c805
7334e0b
60a6960
b0bd00a
3fe8f77
5aa9226
27633cb
711ddc3
48abae7
4093b3f
9658b9e
c17a553
6ce358f
c4755f3
49013b8
9d56171
b9115e5
a465ba1
e0a2128
b51536a
d67b771
be59a41
cbb1f81
583b640
563f25a
54882dc
24ec69e
369c483
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,11 @@ LDFLAGS += \ | |
# Executable | ||
TARGET_OUT_0 := $(FW_BASE)/$(APP_NAME)$(TOOL_EXT) | ||
|
||
# Hosted Settings | ||
ifneq ($(ENABLE_HOSTED),) | ||
COMPONENTS_AR := $(USER_LIBDIR)/$(CLIB_PREFIX)Hosted-$(CMP_Hosted_LIBHASH).a $(USER_LIBDIR)/$(CLIB_PREFIX)Hosted-Lib-$(CMP_Hosted-Lib_LIBHASH).a $(COMPONENTS_AR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mikee47 Is it possible with the existing build system for a component to put its library at the front of the list of compiled libraries? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably the only way. I'm guessing the reason for this is to get the linkage with weak functions working properly? Note that weak functions won't work at all in Windows! Function wrappers are more reliable - the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for pointing this out. The |
||
endif | ||
|
||
# Target definitions | ||
|
||
.PHONY: application | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
COMPONENT_SRCDIRS := $(COMPONENT_PATH)/src | ||
COMPONENT_DEPENDS := Hosted |
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 <[email protected]> | ||
* | ||
* | ||
****/ | ||
|
||
#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>(); | ||
} |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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_VARS := ENABLE_HOSTED | ||
|
||
ENABLE_HOSTED ?= | ||
|
||
ifneq ($(ENABLE_HOSTED),) | ||
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/init/$(ENABLE_HOSTED) | ||
endif | ||
|
||
COMPONENT_VARS += HOSTED_SERVER_IP | ||
|
||
COMPONENT_CFLAGS = -DHOSTED_SERVER_IP=$(HOSTED_SERVER_IP) | ||
COMPONENT_CXXFLAGS := $(COMPONENT_CFLAGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've added
SPI.cpp
but not made any changes to the code. Revert SPI.cpp and SPI.h.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have split them into header and implementation to make it easier for the hosted component to replace the
real
implementation with its own implementation. I would prefer to leave it as it is and add the SPI hosted implementation in a separate PR if that is ok for you.