Apollo3zehn / FluentModbus

Lightweight and fast client and server implementation of the Modbus protocol (TCP/RTU).
MIT License
189 stars 71 forks source link

Error running .NET Core on Raspberry Pi #62

Closed ciramconsulting closed 2 years ago

ciramconsulting commented 2 years ago

Hi, we created a sample app for reading modbus using TCP for Solar Inverter. On Windows it works 100% not on Raspberry Pi . Generated error: "A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/home/pi/Ciram/'. Failed to run as a self-contained app. If this should be a framework-dependent app, add the /home/pi/Ciram/ModbusApp.runtimeconfig.json file specifying the appropriate framework."

ModbusApp.runtimeconfig.json contains:

{ "runtimeOptions": { "tfm": "netcoreapp3.1", "framework": { "name": "Microsoft.NETCore.App", "version": "3.1.0" } } }

Other App's that we create with the same code, but without FluentModbus works on the Raspberry Pi.

This is what we used for all our products for windows and Raspberry Pi

Exe netcoreapp3.1 ModbusApp.Program -> this is new now.

image

ciramconsulting commented 2 years ago

If we add a full depency file (same issue)

{ "runtimeTarget": { "name": ".NETCoreApp,Version=v3.1", "signature": "" }, "compilationOptions": {}, "targets": { ".NETCoreApp,Version=v3.1": { "ModbusApp/1.0.0": { "dependencies": { "ConsoleTables": "2.4.2", "FluentModbus": "3.2.1", "Newtonsoft.Json": "13.0.1" }, "runtime": { "ModbusApp.dll": {} } }, "ConsoleTables/2.4.2": { "dependencies": { "System.Reflection.TypeExtensions": "4.3.0" }, "runtime": { "lib/netcoreapp3.1/ConsoleTables.dll": { "assemblyVersion": "2.0.0.0", "fileVersion": "2.4.2.0" } } }, "FluentModbus/3.2.1": { "dependencies": { "Microsoft.Extensions.Logging.Abstractions": "3.0.0", "System.IO.Ports": "4.6.0", "System.Runtime.CompilerServices.Unsafe": "4.7.1" }, "runtime": { "lib/netstandard2.1/FluentModbus.dll": { "assemblyVersion": "3.0.0.0", "fileVersion": "3.2.1.0" } } }, "Microsoft.Extensions.Logging.Abstractions/3.0.0": { "runtime": { "lib/netstandard2.0/Microsoft.Extensions.Logging.Abstractions.dll": { "assemblyVersion": "3.0.0.0", "fileVersion": "3.0.19.46305" } } }, "Microsoft.NETCore.Platforms/3.0.0": {}, "Microsoft.NETCore.Targets/1.1.0": {}, "Microsoft.Win32.Registry/4.6.0": { "dependencies": { "System.Security.AccessControl": "4.6.0", "System.Security.Principal.Windows": "4.6.0" } }, "Newtonsoft.Json/13.0.1": { "runtime": { "lib/netstandard2.0/Newtonsoft.Json.dll": { "assemblyVersion": "13.0.0.0", "fileVersion": "13.0.1.25517" } } }, "runtime.linux-arm.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "runtimeTargets": { "runtimes/linux-arm/native/System.IO.Ports.Native.so": { "rid": "linux-arm", "assetType": "native", "fileVersion": "0.0.0.0" } } }, "runtime.linux-arm64.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "runtimeTargets": { "runtimes/linux-arm64/native/System.IO.Ports.Native.so": { "rid": "linux-arm64", "assetType": "native", "fileVersion": "0.0.0.0" } } }, "runtime.linux-x64.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "runtimeTargets": { "runtimes/linux-x64/native/System.IO.Ports.Native.so": { "rid": "linux-x64", "assetType": "native", "fileVersion": "0.0.0.0" } } }, "runtime.native.System.IO.Ports/4.6.0": { "dependencies": { "runtime.linux-arm.runtime.native.System.IO.Ports": "4.6.0-rc2.19462.14", "runtime.linux-arm64.runtime.native.System.IO.Ports": "4.6.0-rc2.19462.14", "runtime.linux-x64.runtime.native.System.IO.Ports": "4.6.0-rc2.19462.14", "runtime.osx-x64.runtime.native.System.IO.Ports": "4.6.0-rc2.19462.14" } }, "runtime.osx-x64.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "runtimeTargets": { "runtimes/osx-x64/native/System.IO.Ports.Native.dylib": { "rid": "osx-x64", "assetType": "native", "fileVersion": "0.0.0.0" } } }, "System.IO/4.3.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "Microsoft.NETCore.Targets": "1.1.0", "System.Runtime": "4.3.0", "System.Text.Encoding": "4.3.0", "System.Threading.Tasks": "4.3.0" } }, "System.IO.Ports/4.6.0": { "dependencies": { "Microsoft.Win32.Registry": "4.6.0", "runtime.native.System.IO.Ports": "4.6.0" }, "runtime": { "lib/netstandard2.0/System.IO.Ports.dll": { "assemblyVersion": "4.0.2.0", "fileVersion": "4.700.19.46214" } }, "runtimeTargets": { "runtimes/linux/lib/netstandard2.0/System.IO.Ports.dll": { "rid": "linux", "assetType": "runtime", "assemblyVersion": "4.0.2.0", "fileVersion": "4.700.19.46214" }, "runtimes/osx/lib/netstandard2.0/System.IO.Ports.dll": { "rid": "osx", "assetType": "runtime", "assemblyVersion": "4.0.2.0", "fileVersion": "4.700.19.46214" }, "runtimes/win/lib/netstandard2.0/System.IO.Ports.dll": { "rid": "win", "assetType": "runtime", "assemblyVersion": "4.0.2.0", "fileVersion": "4.700.19.46214" } } }, "System.Reflection/4.3.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "Microsoft.NETCore.Targets": "1.1.0", "System.IO": "4.3.0", "System.Reflection.Primitives": "4.3.0", "System.Runtime": "4.3.0" } }, "System.Reflection.Primitives/4.3.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "Microsoft.NETCore.Targets": "1.1.0", "System.Runtime": "4.3.0" } }, "System.Reflection.TypeExtensions/4.3.0": { "dependencies": { "System.Reflection": "4.3.0", "System.Runtime": "4.3.0" } }, "System.Runtime/4.3.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "Microsoft.NETCore.Targets": "1.1.0" } }, "System.Runtime.CompilerServices.Unsafe/4.7.1": { "runtime": { "lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.dll": { "assemblyVersion": "4.0.6.0", "fileVersion": "4.700.20.12001" } } }, "System.Security.AccessControl/4.6.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "System.Security.Principal.Windows": "4.6.0" } }, "System.Security.Principal.Windows/4.6.0": {}, "System.Text.Encoding/4.3.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "Microsoft.NETCore.Targets": "1.1.0", "System.Runtime": "4.3.0" } }, "System.Threading.Tasks/4.3.0": { "dependencies": { "Microsoft.NETCore.Platforms": "3.0.0", "Microsoft.NETCore.Targets": "1.1.0", "System.Runtime": "4.3.0" } } } }, "libraries": { "ModbusApp/1.0.0": { "type": "project", "serviceable": false, "sha512": "" }, "ConsoleTables/2.4.2": { "type": "package", "serviceable": true, "sha512": "sha512-0SRFOWYCgFQ0RfAMof2DsGEJHI2YKquCA4X26kKyuG+MG+/2R3NRgRVEqXDMU7eVP69MGDzb1eg4i3/APlIfQg==", "path": "consoletables/2.4.2", "hashPath": "consoletables.2.4.2.nupkg.sha512" }, "FluentModbus/3.2.1": { "type": "package", "serviceable": true, "sha512": "sha512-urZgz9bDV+SFz8jSQEWWxYVH3oR8m5GhHL2FiXaj3ddYH08P8YMssQurovJMvqrVS3sGWIzZ1kkz3l1erGFIeQ==", "path": "fluentmodbus/3.2.1", "hashPath": "fluentmodbus.3.2.1.nupkg.sha512" }, "Microsoft.Extensions.Logging.Abstractions/3.0.0": { "type": "package", "serviceable": true, "sha512": "sha512-+PsosTYZn+omucI0ff9eywo9QcPLwcbIWf7dz7ZLM1zGR8gVZXJ3wo6+tkuIedUNW5iWENlVJPEvrGjiVeoNNQ==", "path": "microsoft.extensions.logging.abstractions/3.0.0", "hashPath": "microsoft.extensions.logging.abstractions.3.0.0.nupkg.sha512" }, "Microsoft.NETCore.Platforms/3.0.0": { "type": "package", "serviceable": true, "sha512": "sha512-TsETIgVJb/AKoYfSP+iCxkuly5d3inZjTdx/ItZLk2CxY85v8083OBS3uai84kK3/baLnS5/b5XGs6zR7SuuHQ==", "path": "microsoft.netcore.platforms/3.0.0", "hashPath": "microsoft.netcore.platforms.3.0.0.nupkg.sha512" }, "Microsoft.NETCore.Targets/1.1.0": { "type": "package", "serviceable": true, "sha512": "sha512-aOZA3BWfz9RXjpzt0sRJJMjAscAUm3Hoa4UWAfceV9UTYxgwZ1lZt5nO2myFf+/jetYQo4uTP7zS8sJY67BBxg==", "path": "microsoft.netcore.targets/1.1.0", "hashPath": "microsoft.netcore.targets.1.1.0.nupkg.sha512" }, "Microsoft.Win32.Registry/4.6.0": { "type": "package", "serviceable": true, "sha512": "sha512-Xuqo5Lf5h1eUAbT8sJwNSEgusyEcQQQcza1R8dxJ6q/1vLSU1SG/WxtgiCPAth14dz/IjBXCxWT/+6E9glX33w==", "path": "microsoft.win32.registry/4.6.0", "hashPath": "microsoft.win32.registry.4.6.0.nupkg.sha512" }, "Newtonsoft.Json/13.0.1": { "type": "package", "serviceable": true, "sha512": "sha512-ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==", "path": "newtonsoft.json/13.0.1", "hashPath": "newtonsoft.json.13.0.1.nupkg.sha512" }, "runtime.linux-arm.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "type": "package", "serviceable": true, "sha512": "sha512-iPSWmmEhl0TNIVKHEOvgYEwpXoL7+KRxINcP9ni8JmfdeYPDVzTZXK/d0/1BxlLZIqXC3uMKjFhXFSFLxVlLAg==", "path": "runtime.linux-arm.runtime.native.system.io.ports/4.6.0-rc2.19462.14", "hashPath": "runtime.linux-arm.runtime.native.system.io.ports.4.6.0-rc2.19462.14.nupkg.sha512" }, "runtime.linux-arm64.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "type": "package", "serviceable": true, "sha512": "sha512-Ii8t2RrqsHoBwnvpN8CwQYiukabVJnBYHE6ee/Yl+jKRpkbavlnA9pktxLQARsL1YJ4AKrNT/pAdQCuxTKECBA==", "path": "runtime.linux-arm64.runtime.native.system.io.ports/4.6.0-rc2.19462.14", "hashPath": "runtime.linux-arm64.runtime.native.system.io.ports.4.6.0-rc2.19462.14.nupkg.sha512" }, "runtime.linux-x64.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "type": "package", "serviceable": true, "sha512": "sha512-zc0JugELjZ3MCPzYAroQyuTiChrw8lVUQlMc0bKolAsjpWcCECaLOLd9NRms1sfI52r4ILPvKFlqJwelc88Qhw==", "path": "runtime.linux-x64.runtime.native.system.io.ports/4.6.0-rc2.19462.14", "hashPath": "runtime.linux-x64.runtime.native.system.io.ports.4.6.0-rc2.19462.14.nupkg.sha512" }, "runtime.native.System.IO.Ports/4.6.0": { "type": "package", "serviceable": true, "sha512": "sha512-rbYF/0jSnO+Q6hY1/e/MGXG2MLMj7Enth1Euma85w/r1R+1u/kuEFYNc5bkqG8mpdY3EbVpGn5RTuRU0kVQ6rw==", "path": "runtime.native.system.io.ports/4.6.0", "hashPath": "runtime.native.system.io.ports.4.6.0.nupkg.sha512" }, "runtime.osx-x64.runtime.native.System.IO.Ports/4.6.0-rc2.19462.14": { "type": "package", "serviceable": true, "sha512": "sha512-t2+r1sZd8zeBh7omYsd1ZnwxVZ8POBR1JmvcwUXK82R+XWtf2/RMFZenJFfuy1ii507hB79JvNCFj7ZF0+WhCQ==", "path": "runtime.osx-x64.runtime.native.system.io.ports/4.6.0-rc2.19462.14", "hashPath": "runtime.osx-x64.runtime.native.system.io.ports.4.6.0-rc2.19462.14.nupkg.sha512" }, "System.IO/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-3qjaHvxQPDpSOYICjUoTsmoq5u6QJAFRUITgeT/4gqkF1bajbSmb1kwSxEA8AHlofqgcKJcM8udgieRNhaJ5Cg==", "path": "system.io/4.3.0", "hashPath": "system.io.4.3.0.nupkg.sha512" }, "System.IO.Ports/4.6.0": { "type": "package", "serviceable": true, "sha512": "sha512-9mh48ySrW31fi8JZdcXSKKSrtCH/ZgRkpOMYWwmN//KtCFGIgsyjxpft2wRKlGW/YHG70SG6Xsr/TCLf53fQOA==", "path": "system.io.ports/4.6.0", "hashPath": "system.io.ports.4.6.0.nupkg.sha512" }, "System.Reflection/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-KMiAFoW7MfJGa9nDFNcfu+FpEdiHpWgTcS2HdMpDvt9saK3y/G4GwprPyzqjFH9NTaGPQeWNHU+iDlDILj96aQ==", "path": "system.reflection/4.3.0", "hashPath": "system.reflection.4.3.0.nupkg.sha512" }, "System.Reflection.Primitives/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-5RXItQz5As4xN2/YUDxdpsEkMhvw3e6aNveFXUn4Hl/udNTCNhnKp8lT9fnc3MhvGKh1baak5CovpuQUXHAlIA==", "path": "system.reflection.primitives/4.3.0", "hashPath": "system.reflection.primitives.4.3.0.nupkg.sha512" }, "System.Reflection.TypeExtensions/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-7u6ulLcZbyxB5Gq0nMkQttcdBTx57ibzw+4IOXEfR+sXYQoHvjW5LTLyNr8O22UIMrqYbchJQJnos4eooYzYJA==", "path": "system.reflection.typeextensions/4.3.0", "hashPath": "system.reflection.typeextensions.4.3.0.nupkg.sha512" }, "System.Runtime/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-JufQi0vPQ0xGnAczR13AUFglDyVYt4Kqnz1AZaiKZ5+GICq0/1MH/mO/eAJHt/mHW1zjKBJd7kV26SrxddAhiw==", "path": "system.runtime/4.3.0", "hashPath": "system.runtime.4.3.0.nupkg.sha512" }, "System.Runtime.CompilerServices.Unsafe/4.7.1": { "type": "package", "serviceable": true, "sha512": "sha512-zOHkQmzPCn5zm/BH+cxC1XbUS3P4Yoi3xzW7eRgVpDR2tPGSzyMZ17Ig1iRkfJuY0nhxkQQde8pgePNiA7z7TQ==", "path": "system.runtime.compilerservices.unsafe/4.7.1", "hashPath": "system.runtime.compilerservices.unsafe.4.7.1.nupkg.sha512" }, "System.Security.AccessControl/4.6.0": { "type": "package", "serviceable": true, "sha512": "sha512-gmlk6khICtVhiUnVBBtlsH0H/5QFDqhTZgtpp3AX14wWE6OIE+BX95NLD+X4AolXnIy/oXpNNmXYnsNfW1KuDQ==", "path": "system.security.accesscontrol/4.6.0", "hashPath": "system.security.accesscontrol.4.6.0.nupkg.sha512" }, "System.Security.Principal.Windows/4.6.0": { "type": "package", "serviceable": true, "sha512": "sha512-Mdukseovp0YIGaz16FMH6nbfgZkrCFOJbtXQptv0aeBO9h775Ilb9+TDwLVTKikoW7y7CY7lpoXl9zmZ5G3ndA==", "path": "system.security.principal.windows/4.6.0", "hashPath": "system.security.principal.windows.4.6.0.nupkg.sha512" }, "System.Text.Encoding/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-BiIg+KWaSDOITze6jGQynxg64naAPtqGHBwDrLaCtixsa5bKiR8dpPOHA7ge3C0JJQizJE+sfkz1wV+BAKAYZw==", "path": "system.text.encoding/4.3.0", "hashPath": "system.text.encoding.4.3.0.nupkg.sha512" }, "System.Threading.Tasks/4.3.0": { "type": "package", "serviceable": true, "sha512": "sha512-LbSxKEdOUhVe8BezB/9uOGGppt+nZf6e1VFyw6v3DN6lqitm0OSn2uXMOdtP0M3W4iMcqcivm2J6UgqiwwnXiA==", "path": "system.threading.tasks/4.3.0", "hashPath": "system.threading.tasks.4.3.0.nupkg.sha512" } } }

ciramconsulting commented 2 years ago

Fixed! You need to run dotnet ModbusApp.dll !!!! not ModbusApp.exe

Apollo3zehn commented 2 years ago

Good to know, thanks for your feedback!