1. 02 (0x02) read coil input
Use this function code to read the state of 1 to 2000 input coils from the remote address. The state of each coil can only be 0 or 1, and the number of read coils is specified by the master station when reading.
2. Send message format
The more detailed format is as follows:
start character + slave station address + function code + high start address + low start address + high number of coils + low number of coils + LRC + end character, a total of 17 bytes, of which LRC is excluded when calculating Start character, end character.
3. Return message format
The more detailed format is as follows:
start character + slave station address + function code + byte count + low byte of coil status + ... + high byte of coil status + LRC + end character, a total of 2N+11 bytes, N is to be read The number of bytes occupied by all coil states (8 coils occupy one byte).
4. Case
Slave address: 1
Start address: 0
Number of coils: 10
Suppose you want to read 10 coil status values with slave address 1 and start address 0,