An arduino library to communicate using the Dallas one-wire protocol, where the Arduino takes the role of a slave.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
531 B

#include "Arduino.h"
#include "SerialChannel.h"
short SerialChannel::nextId = 0;
SerialChannel::SerialChannel()
{
}
void SerialChannel::init(const char* name)
{
id = nextId++;
Serial.write((short)0);
Serial.write(id);
Serial.write(strlen(name));
Serial.write(name);
}
void SerialChannel::write(byte* data, short byteCount)
{
Serial.write(byteCount);
Serial.write(id);
Serial.write(data, byteCount);
}
void SerialChannel::write(const char* text)
{
Serial.write((byte*)text, strlen(text));
}