Перед проблемой я уже тестировал/отлаживал с помощью оконного приложения и открывал/читал как COM3 или COM5, и все работало отлично, но в качестве платформы ANDROID, которая была установлена на устройстве Android, она возвращала сообщение «SerialPortError: Нет такого файла или каталога, ээээ» = 2", перед инициализацией я обязательно сначала перечислил открытые порты, такие как /dev/ttyS3.
мой androidmanifest.xml
...
мой основной
Communication(String testPort) {
port = SerialPort(testPort);
port.config = SerialPortConfig()
..baudRate = 38400
..stopBits = 1
..parity = SerialPortParity.none
..bits = 8;
}
try {
// Ensure the Communication initialization is async and handle errors properly
communication = await Communication(portName); // Ensure async initialization
// if (communication.port) {
print("Communication initialized with port: ${communication!.port}");
print("Port name: ${communication!.port.name}"); // Output port name (e.g., COM5)
// Try opening the port
try {
bool isOpened = communication!.port.openReadWrite(); // Attempt to open the port for reading and writing
if (isOpened) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Port opened successfully")),
);
print("Port opened successfully.");
} else {
print("Failed to open port.");
_showErrorDialog();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Failed to open port: ${communication!.port.name}")),
);
}
} catch (e) {
print("Error opening port: $e");
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Error opening port: $e")),
);
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ialporterr
Android, flutter, dart, flutter, flutter_libserialport 0.4, ошибка: SerialPortError: нет такого файла или каталога, errn ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Ошибка Flutter: библиотека Dart «dart:ui» недоступна на этой платформе.
Anonymous » » в форуме Android - 0 Ответы
- 37 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Ошибка «нет такого файла или каталога» при чтении CSV-файла в Python [дубликат]
Anonymous » » в форуме Python - 0 Ответы
- 44 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Как решить ошибку (Ошибка ОС: нет такого файла или каталога, errno = 2) Файл чтения в Flutter
Anonymous » » в форуме IOS - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-