Closed pouryaomidi closed 3 years ago
Could you check the instructions at #7? In short, flutter_serial_port ships the required external library.
Hi @jpnurmi , Thanks for your response. Are you suggesting that on Windows there is no way to use the serialport using purely dart?
@pouryaomidi It's certainly possible to use dart_serial_port
without Flutter, but libserialport.dll
needs to be present. All flutter_serial_port
does is to build and deploy the DLL for you [*], but you can build and deploy the DLL by hand instead.
[*] Simply because Flutter provides a build system to do that, whereas pure Dart packages don't have a way to build native C code.
@jpnurmi, I've already built libserialport using Visual Studio, then added the library in my path, but I still face the same issue mentioned above. Should I mention the libserialport.dll anywhere in the yaml file?
Where is the DLL placed? If I remember correctly, in Windows the DLL can be found "out of the box" if it's in the same directory with the application executable. If that's not possible, you can also define the LIBSERIALPORT_PATH
environment variable to tell dart_serial_port
where to lookup the DLL.
I have tried to put it in dart/bin and next to the example file and both results in failed to load error. I will try the last option you said and send an update.
After creating a system environment variable LIBSERIALPORT_PATH
as it is specified in your code in dylib.dart, I was able to run the code. Thanks for helping!
@jpnurmi, I've already built libserialport using Visual Studio, then added the library in my path, but I still face the same issue mentioned above. Should I mention the libserialport.dll anywhere in the yaml file?
Give me built tutorial of libserialport
Give me built tutorial of libserialport
@blackghost1379, you can get the compiled library "libserialport-0.dll" here: https://packages.msys2.org/package/mingw-w64-x86_64-libserialport?repo=mingw64 Then make changes to the dylib.dart.
Hi, Running the example given on https://pub.dev/packages/dart_serial_port/example gives me the following error:
Invalid argument(s): Failed to load dynamic library (126)
0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:55)
1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:20:12)
2 LibraryLoader.load (package:dart_serial_port/src/dylib.dart:78:58)
3 dylib (package:dart_serial_port/src/dylib.dart:31:67)
4 _SerialPortImpl.availablePorts. (package:dart_serial_port/src/port.dart:230:32)
5 Util.call (package:dart_serial_port/src/util.dart:37:21)
6 _SerialPortImpl.availablePorts (package:dart_serial_port/src/port.dart:230:21)
7 SerialPort.availablePorts (package:dart_serial_port/src/port.dart:82:61)
8 main (file:///D:/Projects/playground/untitled/bin/untitled.dart:14:33)
9 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:283:19)
10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
I am using dart sdk version: 2.12.0-259.8.beta (beta) (Tue Feb 2 15:59:29 2021 +0100) on "windows_x64".
Any tip is appreciated!
Pourya