jcurl / RJCP.DLL.SerialPortStream

SerialPortStream is an independent implementation of System.IO.Ports.SerialPort and SerialStream for better reliability and maintainability. Default branch is 2.x and now has support for Mono with help of a C library.
Microsoft Public License
624 stars 197 forks source link

Using with .NET Core 2.1 on Ubuntu 18.04 #75

Closed FraserElectronics closed 5 years ago

FraserElectronics commented 5 years ago

Using Ubuntu 18.04.1 LTS and .NET Core 2.1

I have compiled the code as described in the readme and have three library files in bin\seriallinux\bin\usr\local\lib.

libnserial.so
libnserial.so.1
libserial.so.1.1

I created a simple .net core console app:

dotnet new console.

I then ran SerialPortStreamCore nuget package:

dotnet add package SerialPortStreamCore --version 2.1.0

This put a package reference into my project file. I then added some simple code into Program.cs

using System;
using RJCP.IO.Ports;

namespace serial
{
  class Program
  {
    string [] ports = SerialPortStream.GetPortNames();
    foreach( var port in ports )
    {
      Console.WriteLine( port );
    }
  }
}

This file builds with no errors but when I run it I get the following output:

Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'libnserial.so.1' or one of its dependancies......

I copied libnserial.so.1 into the project directory and into the bin\Debug directory but still get the error.

Can anyone help me out ?

Andy

jcurl commented 5 years ago

This project does not generate the nuget module you refer to. For that you'll need to contact the author of that module (I can't say how or with what it was compiled). Use the SerialPortStream instead.

With that said, update your LD_LIBRARY_PATH to point to where your library is compiles.