Comments (2)
That is the purpose of the split
method.
https://github.com/google/crclib.dart/blob/main/lib/src/primitive.dart#L105
After calling that, you can finalize the returned sink.
from crclib.dart.
Thanks! @postmasters I think that should work. It would be helpful if FinalSink
could be exposed and just the type for ParametricCrcSink<dynamic>
but in theory, based on what you said, the below should work. I do manage to get it to work when the bytes being sent over BLE are small enough that there's only 1 chunk from C to Dart. But I have not been able to get it working for multiple chunks and going from Dart to C. The C side isn't able to compute a proper CRC based on the value I calculate on the Dart side. I'm pretty sure the polynomials and all variables match even though the other code is C, and I've tried multiple types from the catalog.dart
file but still no luck. I'll assume it's some weird mismatch and this issue can be closed.
Another interesting note is that the code here works both Dart to C and C to Dart: https://github.com/kaisellgren/CRC32/blob/master/lib/crc32.dart
Crc32IsoHdlc crc32 = Crc32IsoHdlc();
CrcValueCollector outputSink = CrcValueCollector();
if (currentChunk == 0) {
final crcSink = crc32.startChunkedConversion(outputSink);
crcSink.add(totalSegments);
crcSink.close();
} else {
final updatedSink = crcSink.split(outputSink);
updatedSink.add(totalSegments);
updatedSink.close();
}
...
class CrcValueCollector implements Sink<CrcValue> {
CrcValue? crcValue;
int get crcValueInt {
final bigIntVal = crcValue!.toBigInt();
return bigIntVal.toInt();
}
@override
void add(CrcValue data) {
crcValue = data;
}
@override
void close() {
print('CRC Calculation Completed: ${crcValue.toString()}');
}
}
from crclib.dart.
Related Issues (11)
- Automatically extract parameters from `reveng` catalog HOT 1
- Does the lib support for CRC_16 [ISO3309]? HOT 3
- Null Safety support HOT 9
- calculated CRC16 ARC HOT 6
- package:crclib/catalog.dart not found HOT 3
- Web Support HOT 1
- Does this package have Python crc_hqx function equivalent? HOT 10
- BadState with null safety version HOT 2
- Dart CI workflow failed because of no VM image
- Replace usage of tuple with records
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crclib.dart.