I need help to read data from an external device. In the specifications is written that every single fetched value is a 24bit signed integer, but I can't correctly read data from Dart (while I can on Java).
Starting from Java (just because it works), I fetch the data as a byte array, then reading a byte give me the correct value:
byte[] data = call.argument("mydata");
Log.d("CONVERT_DATA_datai", String.valueOf(data[4]));
In this case, the output is -1 and it's correct.
In Dart i've seen that there isn't a byte array type but I should use a List<int> instead, so my code is:
List<int> data = value as List<int>;
print(data[4].toString());
In this case I get the value 255 which is incorrect, I think because I've to convert it to signed 24bit integer.
Other samples are:
-6 in java, 250 in dart (incorrect)
3 in java, 3 in dart (correct)
How can i solve this problem?
Thanks in advance.
There is
Int8Listtype indart:typed_data.And by accessing
Int8List::bufferyou can read any number you want.