Android, Flutter, Dart, Flutter, flutter_libserialport 0.4, Fehler: SerialPortError: Keine solche Datei oder kein solcheAndroid

Forum für diejenigen, die für Android programmieren
Guest
 Android, Flutter, Dart, Flutter, flutter_libserialport 0.4, Fehler: SerialPortError: Keine solche Datei oder kein solche

Post by Guest »

Vor dem Problem habe ich bereits mit einer Windows-Anwendung getestet/debuggt und wie COM3 oder COM5 geöffnet/gelesen und es hat perfekt funktioniert, aber als ANDROID-Plattform, die auf einem Android-Gerät installiert war, wurde „SerialPortError: Keine solche Datei oder kein solches Verzeichnis, Fehlernummer“ zurückgegeben = 2", vor der Initialisierung habe ich sicherlich zuerst die offenen Ports aufgelistet, z. B. /dev/ttyS3.
meine androidmanifest.xml

Code: Select all
















...
meine Hauptseite

Code: Select all

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")),
);
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post