5a96a696b1
- 펌웨어(program), C# 대시보드(TestProgram), 시뮬레이터(Simulator), 프로토콜/문서(Protocol, doc) 전체를 단일 저장소로 통합 - program 폴더의 별도 git 저장소를 제거하고 통합 저장소에 흡수 - 빌드 산출물(program/build, bin/obj, *.o/.elf/.bin/.hex 등) .gitignore 처리 - 사내 Synology NAS Git 원격 연결 예정 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
20 lines
608 B
C#
20 lines
608 B
C#
namespace ErvProtocol
|
|
{
|
|
// CRC-16/MODBUS (poly 0xA001 reflected, init 0xFFFF)
|
|
// PC_ERV_Protocol.md 1장 - CMD~PAYLOAD 구간, 결과 리틀엔디안
|
|
public static class Crc16
|
|
{
|
|
public static ushort Modbus(byte[] data, int start, int length)
|
|
{
|
|
ushort crc = 0xFFFF;
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
crc ^= data[start + i];
|
|
for (int b = 0; b < 8; b++)
|
|
crc = (crc & 0x0001) != 0 ? (ushort)((crc >> 1) ^ 0xA001) : (ushort)(crc >> 1);
|
|
}
|
|
return crc;
|
|
}
|
|
}
|
|
}
|