protected void SendSerialCommand(byte label, byte[] data)
{
if (data.Length > 600)
throw new ArgumentOutOfRangeException("Max data size is 600 bytes");
lock (lockObject)
{
sendCounter++;
// log.Info("Sending packet {0} to DMX", sendCounter);
try
{
var header = new byte[] { 0x7E, label, (byte)(data.Length & 0xFF), (byte)(data.Length >> 8) };
var footer = new byte[] { 0xE7 };
serialPort.Write(header, 0, header.Length);
if (data.Length > 0)
serialPort.Write(data, 0, data.Length);
serialPort.Write(footer, 0, footer.Length);
}
catch (Exception ex)
{
log.Info("SendSerialCommand exception: " + ex.Message);
// Ignore
}
}
}