Line data Source code
1 : /** 2 : * @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved. 3 : * 4 : * @file calcChecksum.c 5 : * @author Jacob.Garrison 6 : * 7 : * @date Mar 2, 2021 8 : * 9 : */ 10 : 11 : #include "sgUtil.h" 12 : 13 : /* 14 : * Documented in the header file 15 : */ 16 26 : uint8_t calcChecksum(uint8_t *buffer, uint8_t len) 17 : { 18 26 : uint8_t sum = 0x00; 19 : 20 : // Add all bytes excluding checksum 21 939 : for (uint8_t i = 0; i < len - 1; ++i) 22 : { 23 913 : sum += buffer[i]; 24 : } 25 : 26 26 : return sum; 27 : }