목차

ImodbusRTUmasterInit()

ImodbusRTUmasterInit()는 Master 통신 포트와 보레이트를 설정합니다.

ImodbusRTUmasterInit 명령어 동작 흐름

void ImodbusRTUmasterInit(HardwareSerial& serialPort, long baudrate)
void ImodbusRTUmasterInit(HardwareSerial& serialPort, long baudrate, uint8_t config)

명령어

명령어 인수 반환값 동작
ImodbusRTUmasterInit(serialPort, baudrate) HardwareSerial& serialPort — RS-485에 연결된 Serial
long baudrate — 통신속도
void Master 통신 포트와 보레이트를 설정합니다.

예제

uint16_t data[10];
uint16_t readValue0;
uint16_t readValue1;
 
void setup() {
  ImodbusRTUmasterInit(Serial2, 9600);  // Master 통신 포트와 보레이트를 설정합니다.
}
 
void loop() {
  uint8_t result;
 
  result = ImodbusRTUmaster(Serial2, 1, 0x03, 0, 2, data);  // 하나의 Master 요청을 즉시 실행합니다.
  if (result == IMODBUS_RTU_SUCCESS) {
    readValue0 = data[0];
    readValue1 = data[1];
  }
 
  data[0] = 1234;
  ImodbusRTUmaster(Serial2, 1, 0x06, 10, 1, data);  // 하나의 Master 요청을 즉시 실행합니다.
}

주의사항

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

← 내장 명령어 리스트