Last change
on this file since 442 was 398, checked in by coas-nagasima, 5 years ago |
mbedTLS版Azure IoT Hub接続サンプルのソースコードを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
710 bytes
|
Line | |
---|
1 | /*
|
---|
2 | * Generate a FCS table for the HDLC FCS (RFC1171).
|
---|
3 | *
|
---|
4 | * Drew D. Perkins at Carnegie Mellon University.
|
---|
5 | *
|
---|
6 | * Code liberally borrowed from Mohsen Banan and D. Hugh Redelmeier.
|
---|
7 | */
|
---|
8 |
|
---|
9 | #include <stdio.h>
|
---|
10 |
|
---|
11 | /* The HDLC polynomail: X**0 + X**5 + X**12 + X**16 (0x8408) */
|
---|
12 |
|
---|
13 | #define Polynomial 0x8408
|
---|
14 |
|
---|
15 | int
|
---|
16 | main (int argc, char *argv[])
|
---|
17 | {
|
---|
18 | unsigned int count, octet;
|
---|
19 | int bit;
|
---|
20 |
|
---|
21 | printf("%s = {\n", argv[1]);
|
---|
22 | for (count = 0; count < 256; count ++) {
|
---|
23 | octet = count;
|
---|
24 | for (bit = 8; bit-- > 0; )
|
---|
25 | octet = (octet & 0x01) ? ((octet >> 1) ^ Polynomial) : (octet >> 1);
|
---|
26 | printf("%c0x%04x,", count % 8 ? ' ' : '\t', octet & 0xffff);
|
---|
27 | if (count % 8 == 7)
|
---|
28 | putchar('\n');
|
---|
29 | }
|
---|
30 | fputs("\t};\n", stdout);
|
---|
31 | return 0;
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.