Skip to content

Commit b08a34e

Browse files
authored
Add crc module
1 parent ad8f870 commit b08a34e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/Berry.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,28 @@ Tasmota Function|Parameters and details
10751075
:---|:---
10761076
uuid4<a class="cmnd" id="uuid_uuid4"></a>|`uuid.uuid4() -> string`<br>Generates a uuid4 random id as string.
10771077

1078+
1079+
### `crc` module
1080+
1081+
The `crc` module allows to compute crc32/16/8 from bytes() arrays.
1082+
1083+
``` ruby
1084+
> import crc
1085+
> crc.crc32(0xFFFFFFFF, bytes("AABBCC"))
1086+
-1091314015
1087+
> crc.crc16(0xFFFF, bytes("AABBCC"))
1088+
20980
1089+
> crc.crc8(0xFF, bytes("AABBCC"))
1090+
139
1091+
```
1092+
1093+
Tasmota Function|Parameters and details
1094+
:---|:---
1095+
crc32<a class="cmnd" id="crc_crc32"></a>|`crc.crc32(crc:int, payload:bytes) -> int`<br>Compute crc32 from an initial value and a bytes() buffer
1096+
crc16<a class="cmnd" id="crc_crc16"></a>|`crc.crc32(crc:int, payload:bytes) -> int`<br>Compute crc32 from an initial value and a bytes() buffer
1097+
crc8<a class="cmnd" id="crc_crc8"></a>|`crc.crc32(crc:int, payload:bytes) -> int`<br>Compute crc32 from an initial value and a bytes() buffer
1098+
1099+
10781100
## Compiling Berry
10791101

10801102
Berry is included if the following is defined in `user_config_override.h`:

0 commit comments

Comments
 (0)