-
-
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
Conversation
TODO: - [ ] get id for a remote RPC function(class method) - [x] fix the documentation - [x] add to the tcp sample also an example of creating own access point and connecting to it. - [ ] fix copyright headers
TODO: - [x] move the parser to be part of the rcp component. - [x] add parser test case.
Sming/Arch/Host/app.mk
Outdated
@@ -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 comment
The 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 comment
The 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 malloc_count
Component uses these a lot so a good reference.
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.
Function wrappers are more reliable - the malloc_count Component uses these a lot so a good reference.
Ok, thanks for pointing this out. The host_init
weak function is replaced with wrapper.
e7d5de6
to
3ae47cd
Compare
3ae47cd
to
b51536a
Compare
class SPIClass : public SPIBase | ||
{ | ||
public: | ||
bool begin() override | ||
{ | ||
return false; | ||
} | ||
bool begin() override; | ||
|
||
void end() override | ||
{ | ||
} | ||
|
||
using SPIBase::beginTransaction; | ||
using SPIBase::transfer; | ||
void transfer(uint8_t* buffer, size_t numberBytes) override | ||
{ | ||
} | ||
void transfer(uint8_t* buffer, size_t numberBytes) override; | ||
|
||
protected: | ||
void prepare(SPISettings& settings) override | ||
{ | ||
} | ||
void prepare(SPISettings& settings) override; | ||
}; | ||
|
||
/** @brief Global instance of SPI class */ |
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.
Sming/Components/Hosted/include/Hosted/Transport/TcpServerTransport.h
Outdated
Show resolved
Hide resolved
Sming/Components/Hosted/include/Hosted/Transport/TcpServerTransport.h
Outdated
Show resolved
Hide resolved
Sming/Components/Hosted/include/Hosted/Transport/TcpServerTransport.h
Outdated
Show resolved
Hide resolved
Sming/Components/Hosted/include/Hosted/Transport/BaseTransport.h
Outdated
Show resolved
Hide resolved
Sming/Arch/Host/app.mk
Outdated
@@ -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 comment
The 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 malloc_count
Component uses these a lot so a good reference.
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).
The hosted component allows Sming's host emulator to run parts of the commands on an actual microcontroller.
The communication is done via simplePRC 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::
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 TCPHOSTED_SERVER_IP=192.168.4.1
instructs the host emulator to connect to IP192.168.4.1
.In the sub-directory
samples
inside this component you will find the sample applications that will turn your microcontroller intoa remote RCP server.
The compilation and flashing for ESP32, for example, can be done using the following commands:
If you replace
SMING_ARCH=Esp32
withSMING_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).