Comments (11)
Yes, it indicates an error but the last error is not set so it slips through. There was a reason to add that check so I'm sceptic to blindly change it. However, clamping the -2 length to 0 length would give and empty list, to make it a no-op.
from flutter_libserialport.
Yes, it indicates an error but the last error is not set so it slips through. There was a reason to add that check so I'm sceptic to blindly change it. However, clamping the -2 length to 0 length would give and empty list, to make it a no-op.
So do you consider this a bug that needs resolving? I'm asking this because initially, we viewed this as our own bad implementation, can we provide any extra data that helps you move forward with this bug or offer a workaround?
from flutter_libserialport.
Do you have any code snippet to show? Where does the error come from? Does it show any stacktrace?
from flutter_libserialport.
I cloned this repo and modified example/main.dart
like this:
void initPorts() {
setState(() => availablePorts = SerialPort.availablePorts);
final serial = SerialPort('COM1');
if (serial.openReadWrite()) {
final reader = SerialPortReader(serial);
reader.stream.listen((event) {
print(event);
});
serial.write(Uint8List.fromList([1, 2, 3, 4]));
}
}
Stacktrace is null. But i have attached a screenshot:
from flutter_libserialport.
@jpnurmi
Any comment/progress on this? we are facing the same issue here. would appreciate it if you help us navigate through the issue.
from flutter_libserialport.
I'm not sure why the library returns an error without providing the last error. Nevertheless, a sanity check like this could help. Are you able to test it for me? I don't have a suitable environment...
diff --git a/lib/src/util.dart b/lib/src/util.dart
index 2ca44c5..b0e2ddf 100644
--- a/lib/src/util.dart
+++ b/lib/src/util.dart
@@ -44,7 +44,7 @@ class Util {
static Uint8List read(int bytes, UtilFunc<ffi.Uint8> readFunc) {
final ptr = ffi.calloc<ffi.Uint8>(bytes);
final len = call(() => readFunc(ptr));
- final res = Uint8List.fromList(ptr.asTypedList(len));
+ final res = Uint8List.fromList(ptr.asTypedList(len.clamp(0, len)));
ffi.calloc.free(ptr);
return res;
}
from flutter_libserialport.
The problem is with len
being -2
. I tried debugging but it seems -2
comes from serialport.dll
.
final len = call(() => readFunc(ptr));
from flutter_libserialport.
@jpnurmi @AriaShishegaran any progress on this one? I started getting this error after switching to SerialPortReader
. Before, I was calling port.read(...)
myself and had no such issue. The advantage of the reader is that it provides a convenient stream.
from flutter_libserialport.
@ricardoboss we are about to release on pub dev the 0.4.0.
Could check the issue against this release as available?
from flutter_libserialport.
Sure, I can't say when I have time to test this though
from flutter_libserialport.
Sure, I can't say when I have time to test this though
No problem ;)
from flutter_libserialport.
Related Issues (20)
- Support for Gradle 8.3.0: Define namespace HOT 2
- Problème lecture et écriture
- android support HOT 5
- Windwos Incomplete writing HOT 1
- read not working on Windows HOT 4
- Cant open port on MacOS HOT 2
- Cant open port on Windows
- Failed to load dynamic library 'libserialport.so' HOT 3
- Android: Namespace not specified
- SerialPortError: Input/output error, errno = 5
- Multiple instances of serial port reader in call stack
- Android support
- It does not send hex numbers 11 and 13 HOT 1
- IOS problem HOT 1
- How to set the baud rate ? HOT 3
- How to read serial data HOT 2
- No running
- Can't read buffer that was not empty before opening serial port (Windows) HOT 3
- How to configure baudrate and port HOT 2
- Can't run android app HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_libserialport.