목차

ImodbusRTUmasterAdd()

ImodbusRTUmasterAdd()는 반복 실행할 Master 요청을 등록합니다.

ImodbusRTUmasterAdd 명령어 동작 흐름

bool ImodbusRTUmasterAdd(HardwareSerial& serialPort, uint8_t slaveId, uint8_t functionCode, uint16_t address, uint16_t quantity, uint16_t* data, uint16_t timeoutMs = 100)

명령어

명령어 인수 반환값 동작
ImodbusRTUmasterAdd(serialPort, slaveId, functionCode, address, quantity, data, timeoutMs) HardwareSerial& serialPort — RS-485에 연결된 Serial
uint8_t slaveId — Slave 주소
uint8_t functionCode
uint16_t address
uint16_t quantity
uint16_t* data
uint16_t timeoutMs = 100
bool 반복 실행할 Master 요청을 등록합니다.

예제

void setup() {
  ImodbusRTUmasterInit(Serial2, 9600);  // Master 통신 포트와 보레이트를 설정합니다.
  ImodbusRTUmasterAdd(Serial2, 1, 0x03, 0x00, 1, &D[1]);  // 반복 실행할 Master 요청을 등록합니다.
  ImodbusRTUmasterAdd(Serial2, 1, 0x03, 0x01, 1, &D[2]);  // 반복 실행할 Master 요청을 등록합니다.
}
 
void loop() {
  ImodbusRTUmasterRun();  // 등록 요청 또는 지정한 단일 요청을 실행합니다.
}

주의사항

같은 카테고리의 내장 명령어

← 내장 명령어 리스트