imc_def

Last updated:

0 purchases

imc_def Image
imc_def Images
Add to Cart

Description:

imc def

imc_def #

A dart package for IMC messages manipulation.
Getting Started #
This package is both a generator and an IMC messages manipulation
package.
The IMC definition is found here.
Using the package #
To use you need to import into your pubspec.yaml such as:

In case to use the package with the bundle generated IMC

dependencies:
imc_def: ^x.x.x
copied to clipboard
Don't forget to flutter pub get.

In case you want to use the source to generate your own code
add your settings to your project's pubspec.yaml file or create
a file in your root project folder named imc_def.yaml with your settings.

imc_def:
imc: <path_to_imc_file_definitions>
githash: <git repo owner>@<git hash reduced> # please add this info (example for LSTS would be 'lsts@f19a343')
# package: imc # optional, will create in src inside the folder(s)
copied to clipboard
After adding your settings, run the package with
flutter pub run imc_def:imc_generator
copied to clipboard
In your code just import:
import 'package:imc_def/imc_def.dart' as imc;
copied to clipboard
or if generating:
import 'package:<project_name>/src/<package/>imc_def.dart' as imc;
copied to clipboard
An example of use is the following:
...
var hbMsgB = imc.HeartbeatBuilder()
..src = 0x16
..dst = 0x17;
var dstEnt = 0;
Timer.periodic(Duration(milliseconds: 300), (Timer t) {
var msg = (hbMsgB
..timestamp = DateTime.now()
..dstEnt = dstEnt++ & 0xFF)
.build();
var dataB = imc.messagesIdsSerializers[msg.msgId]?.call().serialize(msg);
var bytes =
dataB?.buffer.asUint8List(dataB.offsetInBytes, dataB.lengthInBytes);
if (dataB != null && bytes != null) {
var bs = socket.send(bytes, InternetAddress("0.0.0.0"), 4444);
print(
"Bytes sent $bs | ${dataB.offsetInBytes}, ${dataB.lengthInBytes}");
}
});
...
copied to clipboard
To use alternative sync numbers also do:
...
imc.alternativeSyncNumbers = [0x0102];
...
var hbMsgB = imc.HeartbeatBuilder()
..src = 0x16
..dst = 0x17;
var dstEnt = 0;
Timer.periodic(Duration(milliseconds: 300), (Timer t) {
var msg = (hbMsgB
..timestamp = DateTime.now()
..dstEnt = dstEnt++ & 0xFF)
.build();
var dataB = imc.messagesIdsSerializers[msg.msgId]?.call().serialize(msg, 0x0102);
var bytes =
dataB?.buffer.asUint8List(dataB.offsetInBytes, dataB.lengthInBytes);
if (dataB != null && bytes != null) {
var bs = socket.send(bytes, InternetAddress("0.0.0.0"), 4444);
print(
"Bytes sent $bs | ${dataB.offsetInBytes}, ${dataB.lengthInBytes}");
}
});
...
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.