Validate Modbus RTU Frames With CRC Sixteen Checksums

Last updated: November 29, 2026

Quick Overview

Implement the CRC-16/MODBUS checksum, a function that appends it to a request payload in the correct byte order, and a validator that rejects corrupted frames read from a serial line.

Schneider Electric
Software Engineering Fundamentals
Software Engineer
Schneider Electric
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Implement the CRC-16/MODBUS checksum, a function that appends it to a request payload in the correct byte order, and a validator that rejects corrupted frames read from a serial line.

Modbus RTU is still how many Schneider meters, drives and Modicon PLCs talk over RS-485, and embedded or gateway engineers are expected to handle the framing details. The interviewer checks bit manipulation, byte order discipline and whether you can test against a known vector.

What the Interviewer Expects
  • Initializes CRC to 0xFFFF and uses the reflected polynomial 0xA001
  • Appends the CRC low byte first
  • Validates by recomputing over all bytes except the last two
  • Uses a known check value to test
  • Mentions a table-driven version for speed on microcontrollers
Key Topics to Cover
CRC
bit manipulation
Modbus RTU
byte order
embedded
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you build a 256-entry lookup table and why is it faster?
  • How does the receiver detect the end of an RTU frame on the wire?
  • What changes for Modbus TCP, which has no CRC?
  • How would you write this in C for a device with 2 KB of RAM?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

CRC-16/MODBUS: width 16, polynomial 0x8005 processed in reflected form (0xA001), initial value 0xFFFF, no final XOR, bytes processed least significant bit first. The two CRC bytes go on the wire low b...

High-Level Design

XOR each byte into the low end of the register, then shift right eight times, XORing the polynomial whenever the bit shifted out was 1. Because the algorithm is reflected, we shift right instead of le...


Submit Your Answer
Markdown supported

Related Questions