-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06e96d0
commit 26ca1a6
Showing
5 changed files
with
90 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
import "dart:convert"; | ||
|
||
import 'package:osc/osc.dart'; | ||
import "dart:typed_data"; | ||
import "package:subsystems/subsystems.dart"; | ||
import "package:burt_network/logging.dart"; | ||
|
||
const port = "COM11"; | ||
const port = "/dev/ttyACM0"; | ||
|
||
// void printXYZ(List<int> data) { | ||
// data = data.sublist(20); | ||
// String message = utf8.decode(data, allowMalformed: true); | ||
// logger.info("Received: $data"); | ||
// print("Message: ${message}"); | ||
// try { | ||
// final message = OSCMessage.fromBytes(data); | ||
// print (message); | ||
// } catch (error) { | ||
// print("Invalid message. Got error: $error"); | ||
// } | ||
// } | ||
|
||
// void main() async { | ||
// final device = SerialDevice( | ||
// portName: port, | ||
// readInterval: const Duration(milliseconds: 500), | ||
// ); | ||
// device.open(); | ||
// device.stream.listen(printXYZ); | ||
// // device.write(Uint8List.fromList([1, 2, 3])); | ||
// } | ||
|
||
void main() async { | ||
final device = SerialDevice( | ||
portName: port, | ||
readInterval: const Duration(milliseconds: 100), | ||
); | ||
device.open(); | ||
device.stream.listen((data) => logger.info("Received: $data")); | ||
device.write(Uint8List.fromList([1, 2, 3])); | ||
void main() { | ||
reader = ImuReader(stdin); | ||
reader.init(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import "dart:convert"; | ||
|
||
import 'package:osc/osc.dart'; | ||
import "dart:typed_data"; | ||
import "package:subsystems/subsystems.dart"; | ||
import "package:burt_network/logging.dart"; | ||
|
||
const port = "/dev/ttyACM0"; | ||
|
||
class ImuReader { | ||
final String port; | ||
|
||
ImuReader(this.port); | ||
|
||
void printXYZ(List <int> data){ | ||
|
||
data = data.sublist(20); | ||
String message = utf8.decode(data, allowMalformed: true); | ||
|
||
logger.info("Received: $data"); | ||
|
||
print("Message: ${message}"); | ||
|
||
try { | ||
|
||
final message = OSCMessage.fromBytes(data); | ||
print (message); | ||
|
||
} catch (error) { | ||
|
||
print("Invalid message. Got error: $error"); | ||
|
||
} | ||
} | ||
|
||
void init() { | ||
final Stream<List<int>> inputStream; | ||
ImuReader(this.inputStream); | ||
|
||
void intit() { | ||
inputStream.listen(printXYZ); | ||
} | ||
} | ||
void dispose() { | ||
ImuReader.dispose(); | ||
logger.info("ImuReader disposed"); | ||
|
||
} | ||
} |
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
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