readCard method
Reads card data from the MSR605X device.
The timeout
parameter specifies the maximum time to wait for a card swipe in milliseconds.
Returns a TrackData object containing the data from the card.
Throws an exception if the read operation fails or times out.
Implementation
Future<TrackData> readCard({int timeout = 3000}) async {
try {
return await MSRXPlatform.instance.readCard(timeout: timeout);
} on PlatformException catch (e) {
if (e.code == 'TIMEOUT') {
throw TimeoutException("No card detected within $timeout ms");
}
throw Exception("Failed to read card: ${e.message}");
}
}