n_s88_octets(0),
thread(*this)
{
+ QueuedCommand cmd;
+ cmd.command[0] = READ_POWER_STATE;
+ cmd.length = 1;
+ push_command(cmd);
}
ArduControl::~ArduControl()
void ArduControl::set_power(bool p)
{
- if(p==power.pending)
- return;
-
- power.pending = p;
- ++power.serial;
-
- QueuedCommand cmd(POWER);
- cmd.tag.serial = power.serial;
- cmd.command[0] = (p ? POWER_ON : POWER_OFF);
- cmd.length = 1;
- push_command(cmd);
+ if(power.set(p))
+ {
+ QueuedCommand cmd(POWER);
+ cmd.tag.serial = power.serial;
+ cmd.command[0] = (p ? POWER_ON : POWER_OFF);
+ cmd.length = 1;
+ push_command(cmd);
+ }
}
void ArduControl::halt(bool)
else if(tag && !repeat_count)
control.push_completed_tag(tag);
}
+ else if(type==POWER_STATE && rlength==2)
+ {
+ control.power.set(reply[1]);
+
+ Tag ptag;
+ ptag.type = Tag::GENERAL;
+ ptag.command = POWER;
+ ptag.serial = control.power.serial;
+ control.push_completed_tag(ptag);
+ }
else if(type==S88_DATA && rlength>2)
{
unsigned offset = static_cast<unsigned char>(reply[1]);
{
POWER_ON = 0x01,
POWER_OFF = 0x02,
+ READ_POWER_STATE = 0x03,
READ_TRACK_CURRENT = 0x08,
SET_OVERCURRENT_LIMIT = 0x09,
READ_INPUT_VOLTAGE = 0x0A,
OVERCURRENT = 0xA0,
TRACK_CURRENT = 0xC0,
INPUT_VOLTAGE = 0xC1,
+ POWER_STATE = 0xC2,
S88_DATA = 0xD0
};