To build a HART Universal Command 3 (Read Dynamic Variables and Loop Current) Long Frame, you need the 5-byte unique address of your Endress+Hauser CM82. Below is the precise C function to construct the command string, along with an example byte output. ## 1. C Function to Build Command 3 Long Frame This function sets the long frame start delimiter to 0x82, inserts the 5-byte device address, specifies Command 3 (0x03), assigns a data length of zero (0x00), and computes the mandatory XOR checksum (LRC). #include #include // Calculates the mandatory Longitudinal Redundancy Check (LRC)uint8_t calculate_lrc(const uint8_t *frame, size_t start_idx, size_t end_idx) { uint8_t lrc = 0; for (size_t i = start_idx; i < end_idx; i++) { lrc ^= frame[i]; } return lrc; } /** * Builds a HART Command 3 Long Frame. * @param buf Destination buffer (must be at least 14 bytes). * @param long_addr Pointer to the 5-byte CM82 unique address array. * @return Total number of bytes written to the buffer. */size_t build_cmd3_long_frame(uint8_t *buf, const uint8_t *long_addr) { size_t idx = 0; // 1. Preamble (CM82 requires minimum 5 bytes of 0xFF) for (int i = 0; i < 5; i++) { buf[idx++] = 0xFF; } // Checksum calculation must start directly after the preamble bytes size_t checksum_start = idx; // 2. Start Delimiter (0x82 = Master-to-Slave, Long Frame) buf[idx++] = 0x82; // 3. Address Field (5-byte Unique Device ID) memcpy(&buf[idx], long_addr, 5); idx += 5; // 4. Command Byte (0x03 = Read Dynamic Variables and Loop Current) buf[idx++] = 0x03; // 5. Data Byte Count (0x00 = No data bytes sent in request) buf[idx++] = 0x00; size_t checksum_end = idx; // 6. Checksum (LRC) buf[idx++] = calculate_lrc(buf, checksum_start, checksum_end); return idx; } ## 2. Example Raw Byte String Output Assuming your CM82 has an example 5-byte unique address of 11 9C 02 AB CD, the resulting 14-byte serial stream layout looks exactly like this: | Byte Index | Hex Value | Description | |---|---|---| | 0 - 4 | FF FF FF FF FF | Preamble (Synchronization) | | 5 | 82 | Start Delimiter (Long Frame Master-to-Slave) | | 6 | 11 | Manufacturer ID (Endress+Hauser) | | 7 | 9C | Expanded Device Type | | 8 - 10 | 02 AB CD | Device Identification Number | | 11 | 03 | HART Command 3 | | 12 | 00 | Data Byte Count (0 bytes) | | 13 | 3B | Checksum / LRC (82 ^ 11 ^ 9C ^ 02 ^ AB ^ CD ^ 03 ^ 00) | Raw Byte Array String: \xFF\xFF\xFF\xFF\xFF\x82\x11\x9C\x02\xAB\xCD\x03\x00\x3B ------------------------------ Would you like the C parsing code to extract the Loop Current and IEEE-754 floating-point process variables from the slave response frame, or do you need help setting up the UART serial port settings for the transmission?