-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test querying CAN interface attributes
- Loading branch information
Showing
3 changed files
with
113 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,24 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:linux_can/linux_can.dart'; | ||
|
||
void main() { | ||
runApp(const MyApp()); | ||
} | ||
void main() async { | ||
final can0 = LinuxCan.instance.devices.singleWhere((device) => device.networkInterface.name == 'can0'); | ||
final can1 = LinuxCan.instance.devices.singleWhere((device) => device.networkInterface.name == 'can1'); | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'linux_can Test App', | ||
theme: ThemeData( | ||
primarySwatch: Colors.blue, | ||
), | ||
home: const MyHomePage(title: 'linux_can Test App'), | ||
); | ||
} | ||
} | ||
await Future.delayed(const Duration(seconds: 3)); | ||
|
||
class MyHomePage extends StatefulWidget { | ||
const MyHomePage({super.key, required this.title}); | ||
can0.queryAttributes(); | ||
|
||
final String title; | ||
final can1Attributes = can1.queryAttributes(); | ||
debugPrint('can1 attributes: $can1Attributes'); | ||
|
||
@override | ||
State<MyHomePage> createState() => _MyHomePageState(); | ||
} | ||
debugPrint('can1 hardwareName: ${can1.hardwareName}'); | ||
|
||
debugPrint('can1 xstats: ${can1.xstats}'); | ||
|
||
debugPrint('can1 txqlen: ${can1.txQueueLength}'); | ||
|
||
class _MyHomePageState extends State<MyHomePage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(widget.title), | ||
), | ||
body: Container(), | ||
); | ||
for (var i = 0; i < 50; i++) { | ||
can1.hardwareName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters