I'm in the process of converting the Universal Powerline Bus (UPB) functionality from an old controller to a Raspberry Pi 2 Right now, I'm in a learning mode in order to fully understand the protocol. I'm using a simple .Net serial port utility to submit various commands to the PIM and review the PIM responses.
What now befuddles me is the Device State Report 0x86, The protocol document indicates that there can be up to 17 retrieved state information values. I've determined that Arg1 is the level of brightness. This value ranges from 00 (off) to 64 (full bright) for a UPB dimmable switch.The question is what do the other 16 retrieved state information variables represent? I can't find any detailed information what these variable represent. It's possible I may have overlooked that information somewhere.
So, submitting 0710018DFF302C to the PIM means report state command (0x30) for UBP dimmable switch unit 141
The PIM will respond with 08001FFD8600E5 where the 00 means that the switch is turned off. A value of 64 in that position will mean the switch is at full bright.
I've included the basic utility that I use to do my testing. If you wish, you can change the hard coded values to do some experimenting.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UPBRaspberry
{
using System;
using System.IO.Ports;
class PortDataReceived
{
static byte[] cr = { 0x0D };
static byte[] ctlt = { 0x14 };
static byte[] ctlw = { 0x17 };
public static void Main()
{
SerialPort mySerialPort = new SerialPort("COM4");
mySerialPort.BaudRate = 4800;
mySerialPort.Parity = Parity.None;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits = 8;
mySerialPort.Handshake = Handshake.None;
mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
mySerialPort.ReadTimeout = -1;
mySerialPort.WriteTimeout = -1;
mySerialPort.RtsEnable = false;
mySerialPort.DtrEnable = true;
if (!mySerialPort.IsOpen)
{
mySerialPort.Open();
}
// Place in message mode
mySerialPort.Write(ctlw, 0, ctlw.Length);
mySerialPort.Write("70028E"); // Put the PIM in Message Mode. This variable must NOT be changed
mySerialPort.Write(cr, 0, cr.Length);
mySerialPort.Write(ctlt, 0, ctlt.Length);
mySerialPort.Write("0710018DFF302C"); // Report State Command (0x30)for unit 141
mySerialPort.Write(cr, 0, cr.Length);
Console.ReadKey();
mySerialPort.Close();
}
private static void DataReceivedHandler(
object sender,
SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
Console.Write("{0:x}", indata);
}
}
}
What now befuddles me is the Device State Report 0x86, The protocol document indicates that there can be up to 17 retrieved state information values. I've determined that Arg1 is the level of brightness. This value ranges from 00 (off) to 64 (full bright) for a UPB dimmable switch.The question is what do the other 16 retrieved state information variables represent? I can't find any detailed information what these variable represent. It's possible I may have overlooked that information somewhere.
So, submitting 0710018DFF302C to the PIM means report state command (0x30) for UBP dimmable switch unit 141
The PIM will respond with 08001FFD8600E5 where the 00 means that the switch is turned off. A value of 64 in that position will mean the switch is at full bright.
I've included the basic utility that I use to do my testing. If you wish, you can change the hard coded values to do some experimenting.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UPBRaspberry
{
using System;
using System.IO.Ports;
class PortDataReceived
{
static byte[] cr = { 0x0D };
static byte[] ctlt = { 0x14 };
static byte[] ctlw = { 0x17 };
public static void Main()
{
SerialPort mySerialPort = new SerialPort("COM4");
mySerialPort.BaudRate = 4800;
mySerialPort.Parity = Parity.None;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits = 8;
mySerialPort.Handshake = Handshake.None;
mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
mySerialPort.ReadTimeout = -1;
mySerialPort.WriteTimeout = -1;
mySerialPort.RtsEnable = false;
mySerialPort.DtrEnable = true;
if (!mySerialPort.IsOpen)
{
mySerialPort.Open();
}
// Place in message mode
mySerialPort.Write(ctlw, 0, ctlw.Length);
mySerialPort.Write("70028E"); // Put the PIM in Message Mode. This variable must NOT be changed
mySerialPort.Write(cr, 0, cr.Length);
mySerialPort.Write(ctlt, 0, ctlt.Length);
mySerialPort.Write("0710018DFF302C"); // Report State Command (0x30)for unit 141
mySerialPort.Write(cr, 0, cr.Length);
Console.ReadKey();
mySerialPort.Close();
}
private static void DataReceivedHandler(
object sender,
SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
Console.Write("{0:x}", indata);
}
}
}