Entry point for USB OTG CAN adapters on Android.
final devices = await CanUsb.listDevices();
final pcan = devices.firstWhere((d) => d.adapterType == CanAdapterType.pcanUsb);
if (!await CanUsb.requestPermission(pcan)) return;
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
deviceEvents
→ Stream<
UsbDeviceEvent> -
Attach, detach and permission events for supported adapters. Broadcast.
no setter
Static Methods
-
backgroundLoggingStatus(
) → Future< BackgroundLoggingStatus> - Whether background logging runs, and its progress.
-
hasPermission(
UsbCanDevice device) → Future< bool> -
Whether the app currently holds USB permission for
device. -
listDevices(
) → Future< List< UsbCanDevice> > - Lists attached adapters found in the device table.
-
logDirectory(
) → Future< String> - Absolute path of the directory that holds background logs.
-
open(
UsbCanDevice device, {CanConfig config = const CanConfig(), bool autoReconnect = false}) → Future< UsbCanBus> -
Opens a CAN bus on
device. -
registerDevice(
{required int vendorId, required int productId, required CanAdapterType type, required String name}) → Future< void> -
Registers any VID/PID as an adapter of
type. Throws CanConfigException for IDs outside 0x0000-0xFFFF or a blank name. -
registerSlcanDevice(
{required int vendorId, required int productId, required String name}) → Future< void> - Registers a clone adapter that speaks SLCAN over USB CDC-ACM, so it appears in listDevices. Registrations last until the app process ends. An existing entry for the same VID/PID is replaced.
-
requestPermission(
UsbCanDevice device) → Future< bool> - Requests USB permission, showing the system dialog if needed. Returns true if granted. Concurrent calls for the same device share one dialog. Throws CanDeviceDisconnectedException if the device is no longer attached.
-
startBackgroundLogging(
UsbCanDevice device, {CanConfig config = const CanConfig(listenOnly: true), List< CanFilter> filters = const [], String? fileName, String notificationTitle = 'CAN logging'}) → Future<String> -
Keeps a bus open in a foreground service and writes a candump
-Llog to app-specific storage (logDirectory). Returns the log file path. -
stopBackgroundLogging(
) → Future< String?> - Stops background logging. Returns the finished log path, or null if logging was not running or no frame was logged. An empty log file is removed instead of kept.