Closed sk413025 closed 3 years ago
Did you ever find a solution to this? I am having a similar issue.
The path name may be incorrect, but the overall steps are as follows.
System.IO.Ports
cd C:\dev\KneeBO
dotnet add package System.IO.Ports
dotnet build .
mkdir build
cd build
cmake ..
cmake --build .
cd C:\dev\KneeBO\build\KneeBO
dotnet run
Note that a runtime error will pop up stating that SerialPort cannot be found and therefore cannot be run.
My workaround:
Running dotnet add package System.IO.Ports
again in the build/KneeBO
directory, and then dotnet run
, it will run successfully.
Thank you for releasing this great package, and I look forward to your help with compilation issues. I have been able to run the ROS2Talker and ROS2Listener examples in win10, and now I need to read the serial port, here is a simple example.
Use
dotnet new console
to create a project.Program.cs
namespace KneeBO { class Program{ static void Main(string[] args){ foreach (string portname in SerialPort.GetPortNames()) { Console.WriteLine(portname); } } } }
cmake_minimum_required(VERSION 3.5)
project(kneebo C)
find_package(ament_cmake REQUIRED) find_package(ros2cs_common REQUIRED) find_package(ros2cs_core REQUIRED) find_package(std_msgs REQUIRED) find_package(sensor_msgs REQUIRED) find_package(builtin_interfaces REQUIRED) find_package(dotnet_cmake_module REQUIRED) find_package(rosidl_generator_cs REQUIRED)
set(CSHARP_TARGET_FRAMEWORK "netcoreapp3.1") find_package(DotNETExtra REQUIRED)
set(_assemblies_dep_dlls ${ros2cs_common_ASSEMBLIES_DLL} ${ros2cs_core_ASSEMBLIES_DLL} ${std_msgs_ASSEMBLIES_DLL} ${sensor_msgs_ASSEMBLIES_DLL} ${builtin_interfaces_ASSEMBLIES_DLL} )
add_dotnet_executable(kneebo_talker Program.cs INCLUDE_DLLS ${_assemblies_dep_dlls} )
set_property(TARGET kneebo_talker PROPERTY VS_PACKAGE_REFERENCES "System.IO.Ports_5.0.1" )
ament_package()
mkdir build cd build cmake .. cmake --build . --target INSTALL --config Release
C:\dev\KneeBO\Program.cs(12,41): error CS0103: name 'SerialPort' does not exist in the current content [C:\dev\KneeBO\build\kneebo_talker\kneebo_talker_dotnetcore. csproj] [C:\dev\KneeBO\build\kneebo_talker.vcxproj]