cec_opcode opcode;
cec_datapacket parameters;
int8_t opcode_set;
- int32_t ack_timeout;
+ int32_t transmit_timeout;
#ifdef __cplusplus
static void format(cec_command &command, cec_logical_address initiator, cec_logical_address destination, cec_opcode opcode)
{
command.clear();
- command.initiator = initiator;
- command.destination = destination;
- command.opcode = opcode;
- command.opcode_set = 1;
- command.ack_timeout = 1000;
+ command.initiator = initiator;
+ command.destination = destination;
+ command.opcode = opcode;
+ command.opcode_set = 1;
}
void push_back(uint8_t data)
void clear(void)
{
- initiator = CECDEVICE_UNKNOWN;
- destination = CECDEVICE_UNKNOWN;
- ack = 0;
- eom = 0;
- opcode_set = 0;
- opcode = CEC_OPCODE_FEATURE_ABORT;
- ack_timeout = 1000;
+ initiator = CECDEVICE_UNKNOWN;
+ destination = CECDEVICE_UNKNOWN;
+ ack = 0;
+ eom = 0;
+ opcode_set = 0;
+ opcode = CEC_OPCODE_FEATURE_ABORT;
+ transmit_timeout = 1000;
parameters.clear();
};
#endif
}
}
- if (data.ack_timeout > 0)
+ if (data.transmit_timeout > 0)
{
- bool bError(false);
- if ((bReturn = WaitForAck(&bError, output->size(), data.ack_timeout)) == false)
+ if ((bReturn = WaitForTransmitSucceeded(output->size(), data.transmit_timeout)) == false)
m_controller->AddLog(CEC_LOG_ERROR, "did not receive ack");
}
else
- {
bReturn = true;
- }
}
return bReturn;
Transmit(command);
}
-bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout /* = 1000 */)
+bool CCECProcessor::WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout /* = 1000 */)
{
- bool bTransmitSucceeded = false;
+ bool bError(false);
+ bool bTransmitSucceeded(false);
uint8_t iPacketsLeft(iLength / 4);
- *bError = false;
int64_t iNow = GetTimeMs();
int64_t iTargetTime = iNow + (uint64_t) iTimeout;
- while (!bTransmitSucceeded && !*bError && (iTimeout == 0 || iNow < iTargetTime))
+ while (!bTransmitSucceeded && !bError && (iTimeout == 0 || iNow < iTargetTime))
{
CCECAdapterMessage msg;
continue;
}
- *bError = msg.is_error();
+ bError = msg.is_error();
m_controller->AddLog(msg.is_error() ? CEC_LOG_WARNING : CEC_LOG_DEBUG, msg.ToString());
switch(msg.message())
break;
case MSGCODE_TRANSMIT_SUCCEEDED:
bTransmitSucceeded = (iPacketsLeft == 0);
- *bError = !bTransmitSucceeded;
+ bError = !bTransmitSucceeded;
break;
default:
CStdString strLog;
strLog.Format("received unexpected reply '%1x' instead of ack", msg.message());
m_controller->AddLog(CEC_LOG_WARNING, strLog);
- *bError = true;
+ bError = true;
break;
}
iNow = GetTimeMs();
}
- return bTransmitSucceeded && !*bError;
+ return bTransmitSucceeded && !bError;
}
bool CCECProcessor::ParseMessage(const CCECAdapterMessage &msg)
private:
void LogOutput(const cec_command &data);
- bool WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout = 1000);
+ bool WaitForTransmitSucceeded(uint8_t iLength, uint32_t iTimeout = 1000);
bool ParseMessage(const CCECAdapterMessage &msg);
void ParseCommand(cec_command &command);
cec_command command;
cec_command::format(command, GetMyLogicalAddress(), GetLogicalAddress(), CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
- command.ack_timeout = 0;
m_processor->Transmit(command);
}
}
"Available commands:" << endl <<
endl <<
"tx {bytes} transfer bytes over the CEC line." << endl <<
- "txn {bytes} transfer bytes and don't wait for an ACK reply." << endl <<
+ "txn {bytes} transfer bytes but don't wait for transmission ACK." << endl <<
"[tx 40 00 FF 11 22 33] sends bytes 0x40 0x00 0xFF 0x11 0x22 0x33" << endl <<
endl <<
"on {address} power on the device with the given logical address." << endl <<
bytes.push_back(ivalue);
if (command == "txn")
- bytes.ack_timeout = 0;
+ bytes.transmit_timeout = 0;
parser->Transmit(bytes);
}