Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
crc16.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

unsigned short crcsum (const unsigned char *message, unsigned long length, unsigned short crc)
 
int crcverify (const unsigned char *message, unsigned long length)
 
void crcappend (unsigned char *message, unsigned long length)
 

Function Documentation

◆ crcappend()

void crcappend ( unsigned char *  message,
unsigned long  length 
)
77{
78 unsigned long crc;
79
80 crc = crcsum(message, length, CRC_INIT);
81 message[length] = (unsigned char)(crc & 0xff);
82 message[length+1] = (unsigned char)((crc >> 8) & 0xff);
83}
#define CRC_INIT
Definition crc16.c:44
unsigned short crcsum(const unsigned char *message, unsigned long length, unsigned short crc)
Definition crc16.c:49
double length(std::vector< SurfacePoint > &path)
Definition exact_geodesic.cpp:1682

References CRC_INIT, and crcsum().

Referenced by jtagmkII_send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crcsum()

unsigned short crcsum ( const unsigned char *  message,
unsigned long  length,
unsigned short  crc 
)
51{
52 unsigned long i;
53
54 for(i = 0; i < length; i++)
55 {
56 CRC(crc, message[i]);
57 }
58 return crc;
59}
#define CRC(crcval, newchar)
Definition crc16.c:45

References CRC.

Referenced by crcappend(), and crcverify().

+ Here is the caller graph for this function:

◆ crcverify()

int crcverify ( const unsigned char *  message,
unsigned long  length 
)
63{
64 /*
65 * Returns true if the last two bytes in a message is the crc of the
66 * preceding bytes.
67 */
68 unsigned short expected;
69
70 expected = crcsum(message, length - 2, CRC_INIT);
71 return (expected & 0xff) == message[length - 2] &&
72 ((expected >> 8) & 0xff) == message[length - 1];
73}

References CRC_INIT, and crcsum().

Referenced by jtagmkII_recv_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: