Skip to content
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

Adding System.IO.Ports support #1921

Merged
merged 18 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile.All
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-all:v1.0
FROM ghcr.io/nanoframework/dev-container-all:v1.1
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile.ESP32
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-esp32:v1.0
FROM ghcr.io/nanoframework/dev-container-esp32:v1.1
1 change: 1 addition & 0 deletions .devcontainer/sources/Dockerfile.All
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog icu-devtools 2>&1 \
&& apt-get install -y \
git \
git-lfs \
curl \
ninja-build \
srecord \
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/sources/Dockerfile.ESP32
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog icu-devtools 2>&1 \
&& apt-get install -y \
git \
git-lfs \
curl \
ninja-build \
srecord \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and push image for all RTOS

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-all
GCR_VERSION: v1.0
GCR_VERSION: v1.1
GCR_FILE: .devcontainer/sources/Dockerfile.All

# Controls when the action will run.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and push ESP32 image

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-esp32
GCR_VERSION: v1.0
GCR_VERSION: v1.1
GCR_FILE: .devcontainer/sources/Dockerfile.ESP32

# Controls when the action will run.
Expand Down
11 changes: 10 additions & 1 deletion .vscode/cmake-variants-DEVCONTAINER.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"API_Windows.Devices.I2c": "ON",
"API_System.Device.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON"
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON"
}
},
"ST_STM32F429I_DISCOVERY": {
Expand Down Expand Up @@ -85,6 +86,7 @@
"API_System.Device.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_Windows.Devices.Adc": "ON",
"API_nanoFramework.Devices.OneWire": "ON",
"API_nanoFramework.Devices.Can": "OFF",
Expand Down Expand Up @@ -126,6 +128,7 @@
"API_System.Device.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_Windows.Devices.Adc": "ON",
"API_nanoFramework.Devices.OneWire": "ON",
"API_nanoFramework.ResourceManager": "ON",
Expand Down Expand Up @@ -172,6 +175,7 @@
"API_System.Device.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_Windows.Devices.Adc": "ON",
"API_Windows.Device.Dac": "ON",
"API_System.Net": "ON",
Expand Down Expand Up @@ -219,6 +223,7 @@
"API_System.Device.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_Windows.Devices.Adc": "ON",
"API_Windows.Device.Dac": "ON",
"API_System.Net": "ON",
Expand Down Expand Up @@ -264,6 +269,7 @@
"API_Windows.Devices.Pwm": "OFF",
"API_Windows.Devices.Wifi": "OFF",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_nanoFramework.ResourceManager": "ON",
"API_nanoFramework.System.Collections": "ON",
"API_System.Net": "ON",
Expand Down Expand Up @@ -305,6 +311,7 @@
"API_System.Device.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_System.Device.Spi": "ON",
"API_Windows.Devices.Spi": "OFF",
"API_Windows.Storage": "ON",
Expand Down Expand Up @@ -346,6 +353,7 @@
"API_Windows.Devices.I2c": "ON",
"API_Windows.Devices.Pwm": "ON",
"API_Windows.Devices.SerialCommunication": "ON",
"API_System.IO.Ports": "ON",
"API_System.Device.Spi": "ON",
"API_Windows.Devices.Spi": "ON",
"API_Windows.Storage": "ON",
Expand Down Expand Up @@ -387,6 +395,7 @@
"API_Windows.Devices.Pwm": "OFF",
"API_Windows.Devices.Adc": "ON",
"API_Windows.Devices.SerialCommunication": "OFF",
"API_System.IO.Ports": "OFF",
"API_nanoFramework.ResourceManager": "OFF",
"API_nanoFramework.System.Collections": "OFF",
"API_nanoFramework.System.Text": "OFF",
Expand Down
1 change: 1 addition & 0 deletions .vscode/cmake-variants.TEMPLATE.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"API_System.Device.I2c": "OFF-default-ON-to-add-this-API",
"API_Windows.Devices.Pwm": "OFF-default-ON-to-add-this-API",
"API_Windows.Devices.SerialCommunication": "OFF-default-ON-to-add-this-API",
"API_System.IO.Ports": "OFF-default-ON-to-add-this-API",
"API_Windows.Devices.Spi": "OFF-default-ON-to-add-this-API",
"API_Hardware.Esp32": "OFF-default-ON-to-add-this-API",
"API_Hardware.Stm32": "OFF-default-ON-to-add-this-API",
Expand Down
7 changes: 7 additions & 0 deletions CMake/Modules/FindNF_NativeAssemblies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ option(API_Windows.Devices.Gpio "option for Windows.Devices.Gpio
option(API_Windows.Devices.I2c "option for Windows.Devices.I2c API")
option(API_Windows.Devices.Pwm "option for Windows.Devices.Pwm API")
option(API_Windows.Devices.SerialCommunication "option for Windows.Devices.SerialCommunication API")
option(API_System.IO.Ports "option for System.IO.Ports API")
option(API_Windows.Devices.Spi "option for Windows.Devices.Spi API")
option(API_System.Device.Spi "option for System.Device.Spi API")
option(API_Windows.Storage "option for Windows.Storage")
Expand Down Expand Up @@ -315,6 +316,12 @@ if(API_Windows.Devices.SerialCommunication)
PerformSettingsForApiEntry("Windows.Devices.SerialCommunication")
endif()

# API_System.IO.Ports
if(API_System.IO.Ports)
##### API name here (doted name)
PerformSettingsForApiEntry("System.IO.Ports")
endif()

# Windows.Devices.Spi
if(API_Windows.Devices.Spi)
##### API name here (doted name)
Expand Down
45 changes: 45 additions & 0 deletions CMake/Modules/FindSystem.IO.Ports.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#

# native code directory
set(BASE_PATH_FOR_THIS_MODULE ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/System.IO.Ports)


# set include directories
list(APPEND System.IO.Ports_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Core)
list(APPEND System.IO.Ports_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Include)
list(APPEND System.IO.Ports_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/HAL/Include)
list(APPEND System.IO.Ports_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/PAL/Include)
list(APPEND System.IO.Ports_INCLUDE_DIRS ${BASE_PATH_FOR_THIS_MODULE})
list(APPEND System.IO.Ports_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/System.IO.Ports)
# TODO remove the following when Windows.Devices.SerialCommunications is removed
list(APPEND System.IO.Ports_INCLUDE_DIRS ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/Windows.Devices.SerialCommunications)

# source files
set(System.IO.Ports_SRCS

sys_io_ser_native.cpp
sys_io_ser_native_System_IO_Ports_SerialPort.cpp
# this will have to be adjusted to the system_device file once Windows.Devices removed
target_windows_devices_serialcommunication_config.cpp
)

foreach(SRC_FILE ${System.IO.Ports_SRCS})
set(System.IO.Ports_SRC_FILE SRC_FILE-NOTFOUND)
find_file(System.IO.Ports_SRC_FILE ${SRC_FILE}
PATHS
${BASE_PATH_FOR_THIS_MODULE}
${TARGET_BASE_LOCATION}
${PROJECT_SOURCE_DIR}/src/System.IO.Ports

CMAKE_FIND_ROOT_PATH_BOTH
)
# message("${SRC_FILE} >> ${System.IO.Ports_SRC_FILE}") # debug helper
list(APPEND System.IO.Ports_SOURCES ${System.IO.Ports_SRC_FILE})
endforeach()

include(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(System.IO.Ports DEFAULT_MSG System.IO.Ports_INCLUDE_DIRS System.IO.Ports_SOURCES)
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ endif()
# and/or manage other APIs that are required

if( API_nanoFramework.Devices.OneWire OR
API_Windows.Devices.SerialCommunication)
API_Windows.Devices.SerialCommunication OR
API_System.IO.Ports)

set(HAL_USE_UART_OPTION TRUE CACHE INTERNAL "HAL OneWire for nanoFramework.Devices.OneWire")

Expand Down Expand Up @@ -644,6 +645,7 @@ if( API_nanoFramework.Devices.OneWire OR
API_System.Device.Gpio OR
API_Windows.Devices.Gpio OR
API_Windows.Devices.SerialCommunication OR
API_System.IO.Ports OR
API_nanoFramework.Devices.Can OR
API_Windows.Storage OR
API_System.IO.FileSystem)
Expand Down
10 changes: 10 additions & 0 deletions CMakeSettings.SAMPLE.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "API_System.IO.Ports",
"value": "True",
"type": "BOOL"
},
{
"name": "API_Windows.Devices.Spi",
"value": "True",
Expand Down Expand Up @@ -493,6 +498,11 @@
"value": "True",
"type": "BOOL"
},
{
"name": "API_System.IO.Ports",
"value": "True",
"type": "BOOL"
},
{
"name": "API_Windows.Devices.Spi",
"value": "True",
Expand Down
8 changes: 8 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
"name": "API_Windows.Devices.SerialCommunication",
"value": "ON"
},
{
"name": "API_System.IO.Ports",
"value": "ON"
},
{
"name": "API_Windows.Devices.Adc",
"value": "ON"
Expand Down Expand Up @@ -411,6 +415,10 @@
"name": "API_Windows.Devices.SerialCommunication:BOOL", //OFF-default-ON-to-add-this-API
"value": "ON"
},
{
"name": "API_System.IO.Ports:BOOL", //OFF-default-ON-to-add-this-API
"value": "ON"
},
{
"name": "API_Windows.Devices.Spi:BOOL", //OFF-default-ON-to-add-this-API
"value": "ON"
Expand Down
Loading