sendBit()

描述

將引數以位元設定至 ModbusMasterNode 類別中的私有陣列 writeData 中,並自動堆疊資料,和 beginTransmission 與無參數的 writeMultipleCoils 搭配使用。
writeData 是使用 Write 功能碼的 Modbus 封包內容。

語法


node1.sendBit(value)

參數

node1ModbusMasterNode 物件。

value:填入 writeData 陣列的布林值,即欲傳送的 Modbus 封包內容。

範例

#include <Modbus86.h>

ModbusMaster bus1;
ModbusMasterNode node1;

uint8_t result;

void setup()
{
	while(!Serial);
	bus1.begin(MODBUS_RTU, Serial1);
	node1.attach(16, bus1); 

	node1.beginTransmission(5);
	node1.sendBit(true);
	node1.sendBit(false);
	result = node1.writeMultipleCoils();

	if (result != MODBUS_SUCCESS) {
		Serial.print("ErrorCode: ");
		Serial.println(result);
	}
}

void loop()
{
}


See Also

beginTransmission()
writeMultipleCoils()


函式庫參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.