Commit | Line | Data |
---|---|---|
abbca718 LOK |
1 | /* |
2 | * This file is part of the libCEC(R) library. | |
3 | * | |
4 | * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. | |
5 | * libCEC(R) is an original work, containing original code. | |
6 | * | |
7 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
8 | * | |
9 | * This program is dual-licensed; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | * | |
23 | * | |
24 | * Alternatively, you can license this library under a commercial license, | |
25 | * please contact Pulse-Eight Licensing for more information. | |
26 | * | |
27 | * For more information contact: | |
28 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
29 | * http://www.pulse-eight.com/ | |
30 | * http://www.pulse-eight.net/ | |
31 | */ | |
32 | ||
2abe74eb | 33 | #include "CECProcessor.h" |
abbca718 | 34 | |
2abe74eb | 35 | #include "AdapterCommunication.h" |
eafa9d46 | 36 | #include "devices/CECBusDevice.h" |
2abe74eb | 37 | #include "LibCEC.h" |
abbca718 | 38 | #include "util/StdString.h" |
b9187cc6 | 39 | #include "platform/timeutils.h" |
abbca718 LOK |
40 | |
41 | using namespace CEC; | |
42 | using namespace std; | |
43 | ||
2b4d8297 | 44 | CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm, const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) : |
b9eea66d | 45 | m_iLogicalAddress(CECDEVICE_UNKNOWN), |
2abe74eb LOK |
46 | m_strDeviceName(strDeviceName), |
47 | m_communication(serComm), | |
8b7e5ff6 LOK |
48 | m_controller(controller), |
49 | m_bMonitor(false) | |
abbca718 | 50 | { |
7ea0d558 | 51 | for (int iPtr = 0; iPtr < 16; iPtr++) |
09c10b66 | 52 | m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, iPtr == iLogicalAddress ? iPhysicalAddress : 0); |
abbca718 LOK |
53 | } |
54 | ||
2abe74eb | 55 | CCECProcessor::~CCECProcessor(void) |
abbca718 | 56 | { |
8b0ee2cc | 57 | m_startCondition.Broadcast(); |
2abe74eb LOK |
58 | StopThread(); |
59 | m_communication = NULL; | |
60 | m_controller = NULL; | |
d1998c7b LOK |
61 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) |
62 | delete m_busDevices[iPtr]; | |
abbca718 LOK |
63 | } |
64 | ||
2abe74eb | 65 | bool CCECProcessor::Start(void) |
abbca718 | 66 | { |
8b0ee2cc | 67 | CLockObject lock(&m_mutex); |
2abe74eb | 68 | if (!m_communication || !m_communication->IsOpen()) |
13fd6a66 LOK |
69 | { |
70 | m_controller->AddLog(CEC_LOG_ERROR, "connection is closed"); | |
a8f0bd18 | 71 | return false; |
13fd6a66 | 72 | } |
abbca718 | 73 | |
a8f0bd18 | 74 | if (!SetLogicalAddress(m_iLogicalAddress)) |
abbca718 | 75 | { |
2abe74eb | 76 | m_controller->AddLog(CEC_LOG_ERROR, "could not set the logical address"); |
a8f0bd18 | 77 | return false; |
abbca718 LOK |
78 | } |
79 | ||
60fa4578 | 80 | if (CreateThread()) |
8b0ee2cc LOK |
81 | { |
82 | if (!m_startCondition.Wait(&m_mutex)) | |
83 | { | |
84 | m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread"); | |
85 | return false; | |
86 | } | |
a8f0bd18 | 87 | return true; |
8b0ee2cc | 88 | } |
a8f0bd18 | 89 | else |
2abe74eb | 90 | m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread"); |
abbca718 | 91 | |
a8f0bd18 | 92 | return false; |
abbca718 LOK |
93 | } |
94 | ||
2abe74eb | 95 | void *CCECProcessor::Process(void) |
f99bc831 | 96 | { |
8b0ee2cc LOK |
97 | { |
98 | CLockObject lock(&m_mutex); | |
99 | m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); | |
100 | m_startCondition.Signal(); | |
101 | } | |
abbca718 | 102 | |
271e7778 LOK |
103 | cec_command command; |
104 | CCECAdapterMessage msg; | |
105 | CCECAdapterMessagePtr msgPtr; | |
9dee1670 | 106 | |
b9eea66d LOK |
107 | m_communication->SetAckMask(0x1 << (uint8_t)m_iLogicalAddress); |
108 | ||
13fd6a66 | 109 | while (!IsStopped()) |
abbca718 | 110 | { |
60fa4578 | 111 | bool bParseFrame(false); |
9dee1670 | 112 | command.clear(); |
76321de4 LOK |
113 | msg.clear(); |
114 | ||
60fa4578 LOK |
115 | { |
116 | CLockObject lock(&m_mutex); | |
271e7778 LOK |
117 | if (m_frameBuffer.Pop(msgPtr)) |
118 | bParseFrame = ParseMessage(msgPtr); | |
119 | else if (m_communication->IsOpen() && m_communication->Read(msg, 50)) | |
120 | { | |
121 | msgPtr = CCECAdapterMessagePtr(new CCECAdapterMessage(msg)); | |
122 | bParseFrame = ParseMessage(msgPtr); | |
123 | } | |
76321de4 | 124 | |
78e8010a | 125 | bParseFrame &= !IsStopped(); |
76321de4 | 126 | if (bParseFrame) |
9dee1670 | 127 | command = m_currentframe; |
60fa4578 LOK |
128 | } |
129 | ||
13fd6a66 | 130 | if (bParseFrame) |
9dee1670 | 131 | ParseCommand(command); |
abbca718 | 132 | |
13fd6a66 LOK |
133 | m_controller->CheckKeypressTimeout(); |
134 | ||
0ab58650 LOK |
135 | for (unsigned int iDevicePtr = 0; iDevicePtr < 16; iDevicePtr++) |
136 | m_busDevices[iDevicePtr]->PollVendorId(); | |
137 | ||
13fd6a66 | 138 | if (!IsStopped()) |
d5bffd3c | 139 | Sleep(5); |
abbca718 LOK |
140 | } |
141 | ||
60fa4578 | 142 | return NULL; |
abbca718 LOK |
143 | } |
144 | ||
2abe74eb | 145 | bool CCECProcessor::SetActiveView(void) |
abbca718 | 146 | { |
60fa4578 | 147 | if (!IsRunning()) |
f99bc831 LOK |
148 | return false; |
149 | ||
0f23c85c | 150 | return m_busDevices[m_iLogicalAddress]->BroadcastActiveView(); |
abbca718 LOK |
151 | } |
152 | ||
2abe74eb | 153 | bool CCECProcessor::SetInactiveView(void) |
abbca718 | 154 | { |
60fa4578 | 155 | if (!IsRunning()) |
f99bc831 LOK |
156 | return false; |
157 | ||
0f23c85c | 158 | return m_busDevices[m_iLogicalAddress]->BroadcastInactiveView(); |
abbca718 LOK |
159 | } |
160 | ||
9dee1670 | 161 | void CCECProcessor::LogOutput(const cec_command &data) |
abbca718 | 162 | { |
1d3ca3de LOK |
163 | CStdString strTx; |
164 | strTx.Format("<< %02x:%02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination, (uint8_t)data.opcode); | |
9dee1670 | 165 | |
06a1f7ce | 166 | for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++) |
1d3ca3de LOK |
167 | strTx.AppendFormat(":%02x", data.parameters[iPtr]); |
168 | m_controller->AddLog(CEC_LOG_TRAFFIC, strTx.c_str()); | |
9dee1670 | 169 | } |
2abe74eb | 170 | |
2abe74eb | 171 | bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress) |
abbca718 | 172 | { |
06775107 LOK |
173 | if (m_iLogicalAddress != iLogicalAddress) |
174 | { | |
175 | CStdString strLog; | |
176 | strLog.Format("<< setting logical address to %1x", iLogicalAddress); | |
177 | m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str()); | |
178 | ||
179 | m_iLogicalAddress = iLogicalAddress; | |
180 | return m_communication && m_communication->SetAckMask(0x1 << (uint8_t)m_iLogicalAddress); | |
181 | } | |
2abe74eb | 182 | |
06775107 | 183 | return true; |
abbca718 | 184 | } |
825ddb96 | 185 | |
2492216a LOK |
186 | bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) |
187 | { | |
0f23c85c LOK |
188 | m_busDevices[m_iLogicalAddress]->SetPhysicalAddress(iPhysicalAddress); |
189 | return m_busDevices[m_iLogicalAddress]->BroadcastActiveView(); | |
1969b140 LOK |
190 | } |
191 | ||
8b7e5ff6 LOK |
192 | bool CCECProcessor::SwitchMonitoring(bool bEnable) |
193 | { | |
194 | CStdString strLog; | |
195 | strLog.Format("== %s monitoring mode ==", bEnable ? "enabling" : "disabling"); | |
196 | m_controller->AddLog(CEC_LOG_NOTICE, strLog.c_str()); | |
197 | ||
198 | m_bMonitor = bEnable; | |
199 | if (bEnable) | |
200 | return m_communication && m_communication->SetAckMask(0); | |
201 | else | |
202 | return m_communication && m_communication->SetAckMask(0x1 << (uint8_t)m_iLogicalAddress); | |
203 | } | |
204 | ||
6a1c0009 LOK |
205 | cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress) |
206 | { | |
207 | return m_busDevices[iAddress]->GetCecVersion(); | |
208 | } | |
209 | ||
a3269a0a LOK |
210 | bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language) |
211 | { | |
212 | *language = m_busDevices[iAddress]->GetMenuLanguage(); | |
213 | return (strcmp(language->language, "???")); | |
214 | } | |
215 | ||
8d84e2c0 | 216 | bool CCECProcessor::Transmit(const cec_command &data) |
825ddb96 | 217 | { |
7ea0d558 | 218 | bool bReturn(false); |
13929cff LOK |
219 | LogOutput(data); |
220 | ||
5a1e87c8 | 221 | CCECAdapterMessagePtr output(new CCECAdapterMessage(data)); |
13929cff | 222 | |
2abe74eb | 223 | CLockObject lock(&m_mutex); |
eb35e4ca LOK |
224 | { |
225 | CLockObject msgLock(&output->mutex); | |
226 | if (!m_communication || !m_communication->Write(output)) | |
227 | return bReturn; | |
228 | else | |
0e31a62c | 229 | { |
eb35e4ca | 230 | output->condition.Wait(&output->mutex); |
0e31a62c LOK |
231 | if (output->state != ADAPTER_MESSAGE_STATE_SENT) |
232 | { | |
233 | m_controller->AddLog(CEC_LOG_ERROR, "command was not sent"); | |
234 | return bReturn; | |
235 | } | |
236 | } | |
2abe74eb | 237 | |
cd505625 LOK |
238 | if (data.ack_timeout > 0) |
239 | { | |
240 | bool bError(false); | |
241 | if ((bReturn = WaitForAck(&bError, output->size(), data.ack_timeout)) == false) | |
242 | m_controller->AddLog(CEC_LOG_ERROR, "did not receive ack"); | |
243 | } | |
244 | else | |
245 | { | |
246 | bReturn = true; | |
247 | } | |
2abe74eb LOK |
248 | } |
249 | ||
7ea0d558 | 250 | return bReturn; |
825ddb96 | 251 | } |
abbca718 | 252 | |
2abe74eb | 253 | void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason /* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */) |
abbca718 | 254 | { |
9dee1670 LOK |
255 | m_controller->AddLog(CEC_LOG_DEBUG, "<< transmitting abort message"); |
256 | ||
06a1f7ce LOK |
257 | cec_command command; |
258 | cec_command::format(command, m_iLogicalAddress, address, CEC_OPCODE_FEATURE_ABORT); | |
9dee1670 LOK |
259 | command.parameters.push_back((uint8_t)opcode); |
260 | command.parameters.push_back((uint8_t)reason); | |
261 | ||
262 | Transmit(command); | |
abbca718 LOK |
263 | } |
264 | ||
7ea0d558 | 265 | bool CCECProcessor::WaitForAck(bool *bError, uint8_t iLength, uint32_t iTimeout /* = 1000 */) |
abbca718 | 266 | { |
7ea0d558 LOK |
267 | bool bTransmitSucceeded = false; |
268 | uint8_t iPacketsLeft(iLength / 4); | |
050df0f9 | 269 | *bError = false; |
abbca718 LOK |
270 | |
271 | int64_t iNow = GetTimeMs(); | |
25701fa6 | 272 | int64_t iTargetTime = iNow + (uint64_t) iTimeout; |
abbca718 | 273 | |
78e8010a | 274 | while (!bTransmitSucceeded && !*bError && (iTimeout == 0 || iNow < iTargetTime)) |
abbca718 | 275 | { |
220537f2 | 276 | CCECAdapterMessage msg; |
25701fa6 | 277 | |
06a1f7ce | 278 | if (!m_communication->Read(msg, iTimeout > 0 ? (int32_t)(iTargetTime - iNow) : 1000)) |
abbca718 | 279 | { |
abbca718 | 280 | iNow = GetTimeMs(); |
5d38b0b6 LOK |
281 | continue; |
282 | } | |
283 | ||
7ea0d558 LOK |
284 | switch(msg.message()) |
285 | { | |
286 | case MSGCODE_TIMEOUT_ERROR: | |
287 | case MSGCODE_HIGH_ERROR: | |
288 | case MSGCODE_LOW_ERROR: | |
289 | { | |
290 | CStdString logStr; | |
291 | if (msg.message() == MSGCODE_TIMEOUT_ERROR) | |
292 | logStr = "MSGCODE_TIMEOUT"; | |
293 | else if (msg.message() == MSGCODE_HIGH_ERROR) | |
294 | logStr = "MSGCODE_HIGH_ERROR"; | |
295 | else | |
296 | logStr = "MSGCODE_LOW_ERROR"; | |
297 | ||
298 | int iLine = (msg.size() >= 3) ? (msg[1] << 8) | (msg[2]) : 0; | |
299 | uint32_t iTime = (msg.size() >= 7) ? (msg[3] << 24) | (msg[4] << 16) | (msg[5] << 8) | (msg[6]) : 0; | |
300 | logStr.AppendFormat(" line:%i", iLine); | |
301 | logStr.AppendFormat(" time:%u", iTime); | |
302 | m_controller->AddLog(CEC_LOG_WARNING, logStr.c_str()); | |
303 | *bError = true; | |
304 | } | |
305 | break; | |
306 | case MSGCODE_COMMAND_ACCEPTED: | |
307 | m_controller->AddLog(CEC_LOG_DEBUG, "MSGCODE_COMMAND_ACCEPTED"); | |
308 | iPacketsLeft--; | |
309 | break; | |
310 | case MSGCODE_TRANSMIT_SUCCEEDED: | |
311 | m_controller->AddLog(CEC_LOG_DEBUG, "MSGCODE_TRANSMIT_SUCCEEDED"); | |
312 | bTransmitSucceeded = (iPacketsLeft == 0); | |
313 | *bError = !bTransmitSucceeded; | |
314 | break; | |
315 | case MSGCODE_RECEIVE_FAILED: | |
316 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_RECEIVE_FAILED"); | |
317 | *bError = true; | |
318 | break; | |
319 | case MSGCODE_COMMAND_REJECTED: | |
320 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_COMMAND_REJECTED"); | |
321 | *bError = true; | |
322 | break; | |
323 | case MSGCODE_TRANSMIT_FAILED_LINE: | |
324 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_LINE"); | |
325 | *bError = true; | |
326 | break; | |
327 | case MSGCODE_TRANSMIT_FAILED_ACK: | |
328 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_ACK"); | |
329 | *bError = true; | |
330 | break; | |
331 | case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA: | |
332 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA"); | |
333 | *bError = true; | |
334 | break; | |
335 | case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE: | |
336 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE"); | |
337 | *bError = true; | |
338 | break; | |
339 | default: | |
271e7778 LOK |
340 | CCECAdapterMessagePtr msgPtr = CCECAdapterMessagePtr(new CCECAdapterMessage(msg)); |
341 | m_frameBuffer.Push(msgPtr); | |
7ea0d558 LOK |
342 | break; |
343 | } | |
344 | ||
5d38b0b6 | 345 | iNow = GetTimeMs(); |
abbca718 LOK |
346 | } |
347 | ||
78e8010a | 348 | return bTransmitSucceeded && !*bError; |
abbca718 LOK |
349 | } |
350 | ||
271e7778 | 351 | bool CCECProcessor::ParseMessage(CCECAdapterMessagePtr msg) |
abbca718 | 352 | { |
7ea0d558 | 353 | bool bEom = false; |
60fa4578 | 354 | |
271e7778 | 355 | if (msg->empty()) |
7ea0d558 | 356 | return bEom; |
abbca718 LOK |
357 | |
358 | CStdString logStr; | |
abbca718 | 359 | |
271e7778 | 360 | switch(msg->message()) |
abbca718 LOK |
361 | { |
362 | case MSGCODE_NOTHING: | |
2abe74eb | 363 | m_controller->AddLog(CEC_LOG_DEBUG, "MSGCODE_NOTHING"); |
abbca718 LOK |
364 | break; |
365 | case MSGCODE_TIMEOUT_ERROR: | |
366 | case MSGCODE_HIGH_ERROR: | |
367 | case MSGCODE_LOW_ERROR: | |
368 | { | |
271e7778 | 369 | if (msg->message() == MSGCODE_TIMEOUT_ERROR) |
abbca718 | 370 | logStr = "MSGCODE_TIMEOUT"; |
271e7778 | 371 | else if (msg->message() == MSGCODE_HIGH_ERROR) |
abbca718 LOK |
372 | logStr = "MSGCODE_HIGH_ERROR"; |
373 | else | |
374 | logStr = "MSGCODE_LOW_ERROR"; | |
375 | ||
271e7778 LOK |
376 | int iLine = (msg->size() >= 3) ? (msg->at(1) << 8) | (msg->at(2)) : 0; |
377 | uint32_t iTime = (msg->size() >= 7) ? (msg->at(3) << 24) | (msg->at(4) << 16) | (msg->at(5) << 8) | (msg->at(6)) : 0; | |
abbca718 LOK |
378 | logStr.AppendFormat(" line:%i", iLine); |
379 | logStr.AppendFormat(" time:%u", iTime); | |
2abe74eb | 380 | m_controller->AddLog(CEC_LOG_WARNING, logStr.c_str()); |
abbca718 LOK |
381 | } |
382 | break; | |
383 | case MSGCODE_FRAME_START: | |
384 | { | |
7ea0d558 LOK |
385 | logStr = "MSGCODE_FRAME_START"; |
386 | m_currentframe.clear(); | |
271e7778 | 387 | if (msg->size() >= 2) |
abbca718 | 388 | { |
271e7778 LOK |
389 | logStr.AppendFormat(" initiator:%u destination:%u ack:%s %s", msg->initiator(), msg->destination(), msg->ack() ? "high" : "low", msg->eom() ? "eom" : ""); |
390 | m_currentframe.initiator = msg->initiator(); | |
391 | m_currentframe.destination = msg->destination(); | |
392 | m_currentframe.ack = msg->ack(); | |
393 | m_currentframe.eom = msg->eom(); | |
abbca718 | 394 | } |
7ea0d558 | 395 | m_controller->AddLog(CEC_LOG_DEBUG, logStr.c_str()); |
abbca718 LOK |
396 | } |
397 | break; | |
398 | case MSGCODE_FRAME_DATA: | |
399 | { | |
7ea0d558 | 400 | logStr = "MSGCODE_FRAME_DATA"; |
271e7778 | 401 | if (msg->size() >= 2) |
78e8010a | 402 | { |
271e7778 | 403 | uint8_t iData = msg->at(1); |
7ea0d558 LOK |
404 | logStr.AppendFormat(" %02x", iData); |
405 | m_currentframe.push_back(iData); | |
271e7778 | 406 | m_currentframe.eom = msg->eom(); |
abbca718 | 407 | } |
7ea0d558 | 408 | m_controller->AddLog(CEC_LOG_DEBUG, logStr.c_str()); |
78e8010a | 409 | |
271e7778 | 410 | bEom = msg->eom(); |
abbca718 | 411 | } |
78e8010a LOK |
412 | break; |
413 | case MSGCODE_COMMAND_ACCEPTED: | |
414 | m_controller->AddLog(CEC_LOG_DEBUG, "MSGCODE_COMMAND_ACCEPTED"); | |
415 | break; | |
416 | case MSGCODE_TRANSMIT_SUCCEEDED: | |
417 | m_controller->AddLog(CEC_LOG_DEBUG, "MSGCODE_TRANSMIT_SUCCEEDED"); | |
78e8010a LOK |
418 | break; |
419 | case MSGCODE_RECEIVE_FAILED: | |
420 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_RECEIVE_FAILED"); | |
78e8010a LOK |
421 | break; |
422 | case MSGCODE_COMMAND_REJECTED: | |
423 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_COMMAND_REJECTED"); | |
78e8010a LOK |
424 | break; |
425 | case MSGCODE_TRANSMIT_FAILED_LINE: | |
426 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_LINE"); | |
78e8010a LOK |
427 | break; |
428 | case MSGCODE_TRANSMIT_FAILED_ACK: | |
429 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_ACK"); | |
78e8010a LOK |
430 | break; |
431 | case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA: | |
432 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA"); | |
78e8010a LOK |
433 | break; |
434 | case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE: | |
435 | m_controller->AddLog(CEC_LOG_WARNING, "MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE"); | |
abbca718 LOK |
436 | break; |
437 | default: | |
438 | break; | |
439 | } | |
7ea0d558 LOK |
440 | |
441 | return bEom; | |
abbca718 LOK |
442 | } |
443 | ||
e9de9629 | 444 | void CCECProcessor::ParseCommand(cec_command &command) |
abbca718 | 445 | { |
e9de9629 | 446 | CStdString dataStr; |
1d3ca3de | 447 | dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode); |
e9de9629 LOK |
448 | for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) |
449 | dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]); | |
1d3ca3de | 450 | m_controller->AddLog(CEC_LOG_TRAFFIC, dataStr.c_str()); |
dc113aca | 451 | |
e9de9629 LOK |
452 | if (!m_bMonitor) |
453 | m_busDevices[(uint8_t)command.initiator]->HandleCommand(command); | |
dc113aca LOK |
454 | } |
455 | ||
0f23c85c LOK |
456 | uint16_t CCECProcessor::GetPhysicalAddress(void) const |
457 | { | |
458 | return m_busDevices[m_iLogicalAddress]->GetPhysicalAddress(); | |
459 | } | |
460 | ||
e9de9629 | 461 | void CCECProcessor::SetCurrentButton(cec_user_control_code iButtonCode) |
dc113aca | 462 | { |
e9de9629 | 463 | m_controller->SetCurrentButton(iButtonCode); |
dc113aca LOK |
464 | } |
465 | ||
e9de9629 | 466 | void CCECProcessor::AddCommand(const cec_command &command) |
dc113aca | 467 | { |
e9de9629 | 468 | m_controller->AddCommand(command); |
dc113aca LOK |
469 | } |
470 | ||
e9de9629 | 471 | void CCECProcessor::AddKey(void) |
dc113aca | 472 | { |
e9de9629 | 473 | m_controller->AddKey(); |
abbca718 | 474 | } |
acec5f48 | 475 | |
e9de9629 | 476 | void CCECProcessor::AddLog(cec_log_level level, const CStdString &strMessage) |
acec5f48 | 477 | { |
e9de9629 | 478 | m_controller->AddLog(level, strMessage); |
acec5f48 | 479 | } |