Commit | Line | Data |
---|---|---|
e9de9629 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 | ||
33 | #include "CECBusDevice.h" | |
eafa9d46 LOK |
34 | #include "../CECProcessor.h" |
35 | #include "../implementations/ANCommandHandler.h" | |
36 | #include "../implementations/CECCommandHandler.h" | |
37 | #include "../implementations/SLCommandHandler.h" | |
11621576 | 38 | #include "../implementations/VLCommandHandler.h" |
eafa9d46 | 39 | #include "../platform/timeutils.h" |
e9de9629 LOK |
40 | |
41 | using namespace CEC; | |
42 | ||
03ae897d | 43 | #define ToString(p) m_processor->ToString(p) |
c4098482 | 44 | |
e9de9629 | 45 | CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) : |
c4098482 | 46 | m_type(CEC_DEVICE_TYPE_RESERVED), |
e9de9629 | 47 | m_iPhysicalAddress(iPhysicalAddress), |
9dc04b07 | 48 | m_iStreamPath(0), |
e9de9629 | 49 | m_iLogicalAddress(iLogicalAddress), |
e55f3f70 | 50 | m_powerStatus(CEC_POWER_STATUS_UNKNOWN), |
e9de9629 | 51 | m_processor(processor), |
c4098482 | 52 | m_vendor(CEC_VENDOR_UNKNOWN), |
4abd6768 | 53 | m_menuState(CEC_MENU_STATE_ACTIVATED), |
8747dd4f | 54 | m_bActiveSource(false), |
d54e8570 | 55 | m_iLastCommandSent(0), |
6a1c0009 | 56 | m_iLastActive(0), |
f8ae3295 | 57 | m_cecVersion(CEC_VERSION_UNKNOWN), |
caaf64d7 LOK |
58 | m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN), |
59 | m_iTransmitTimeout(1000) | |
e9de9629 LOK |
60 | { |
61 | m_handler = new CCECCommandHandler(this); | |
51b2a094 | 62 | |
a3269a0a LOK |
63 | for (unsigned int iPtr = 0; iPtr < 4; iPtr++) |
64 | m_menuLanguage.language[iPtr] = '?'; | |
65 | m_menuLanguage.language[3] = 0; | |
66 | m_menuLanguage.device = iLogicalAddress; | |
1fcf5a3f | 67 | |
c4098482 | 68 | m_strDeviceName = ToString(m_iLogicalAddress); |
e9de9629 LOK |
69 | } |
70 | ||
71 | CCECBusDevice::~CCECBusDevice(void) | |
72 | { | |
6a1c0009 | 73 | m_condition.Broadcast(); |
e9de9629 LOK |
74 | delete m_handler; |
75 | } | |
76 | ||
93729720 | 77 | void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage) |
e9de9629 | 78 | { |
93729720 | 79 | m_processor->AddLog(level, strMessage); |
e9de9629 LOK |
80 | } |
81 | ||
93729720 | 82 | bool CCECBusDevice::HandleCommand(const cec_command &command) |
f8513317 | 83 | { |
81a1e39d | 84 | CLockObject lock(&m_transmitMutex); |
93729720 LOK |
85 | m_iLastActive = GetTimeMs(); |
86 | m_handler->HandleCommand(command); | |
a24c27d3 | 87 | if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) |
8d915412 LOK |
88 | { |
89 | if (m_deviceStatus != CEC_DEVICE_STATUS_PRESENT) | |
90 | { | |
91 | CStdString strLog; | |
92 | strLog.Format("device %s (%x) status changed to present after command %s", GetLogicalAddressName(), (uint8_t)GetLogicalAddress(), ToString(command.opcode)); | |
93 | AddLog(CEC_LOG_DEBUG, strLog); | |
94 | } | |
a24c27d3 | 95 | m_deviceStatus = CEC_DEVICE_STATUS_PRESENT; |
8d915412 | 96 | } |
93729720 LOK |
97 | m_condition.Signal(); |
98 | return true; | |
99 | } | |
100 | ||
93729720 LOK |
101 | bool CCECBusDevice::PowerOn(void) |
102 | { | |
5e5637c6 LOK |
103 | CStdString strLog; |
104 | strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
105 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); | |
00762a71 | 106 | |
5e5637c6 | 107 | cec_command command; |
caaf64d7 | 108 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON, m_iTransmitTimeout); |
5e5637c6 LOK |
109 | if (m_processor->Transmit(command)) |
110 | { | |
9bc8934c LOK |
111 | { |
112 | CLockObject lock(&m_mutex); | |
113 | m_powerStatus = CEC_POWER_STATUS_UNKNOWN; | |
114 | } | |
115 | cec_power_status status = GetPowerStatus(); | |
116 | if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN) | |
117 | { | |
118 | SendKeypress(CEC_USER_CONTROL_CODE_POWER, true); | |
119 | return SendKeyRelease(false); | |
120 | } | |
5e5637c6 | 121 | return true; |
f437e4be LOK |
122 | } |
123 | ||
00762a71 | 124 | return false; |
93729720 LOK |
125 | } |
126 | ||
127 | bool CCECBusDevice::Standby(void) | |
128 | { | |
129 | CStdString strLog; | |
62f5527d | 130 | strLog.Format("<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress); |
93729720 LOK |
131 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); |
132 | ||
133 | cec_command command; | |
caaf64d7 | 134 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY, m_iTransmitTimeout); |
93729720 LOK |
135 | |
136 | return m_processor->Transmit(command); | |
137 | } | |
138 | ||
139 | /** @name Getters */ | |
140 | //@{ | |
d7be392a | 141 | cec_version CCECBusDevice::GetCecVersion(void) |
93729720 | 142 | { |
f294b22f | 143 | CLockObject lock(&m_mutex); |
5e5637c6 LOK |
144 | if (GetStatus() == CEC_DEVICE_STATUS_PRESENT && |
145 | m_cecVersion == CEC_VERSION_UNKNOWN) | |
f294b22f | 146 | RequestCecVersion(); |
f294b22f LOK |
147 | |
148 | return m_cecVersion; | |
149 | } | |
150 | ||
151 | bool CCECBusDevice::RequestCecVersion(void) | |
152 | { | |
153 | bool bReturn(false); | |
81a1e39d | 154 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
93729720 | 155 | { |
81a1e39d LOK |
156 | CStdString strLog; |
157 | strLog.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
158 | AddLog(CEC_LOG_NOTICE, strLog); | |
159 | cec_command command; | |
caaf64d7 | 160 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION, m_iTransmitTimeout); |
81a1e39d LOK |
161 | CLockObject lock(&m_transmitMutex); |
162 | if (m_processor->Transmit(command)) | |
f294b22f | 163 | bReturn = m_condition.Wait(&m_transmitMutex, 1000); |
93729720 | 164 | } |
f294b22f | 165 | return bReturn; |
93729720 LOK |
166 | } |
167 | ||
5e5637c6 LOK |
168 | uint64_t CCECBusDevice::GetLastCommandSent(void) const |
169 | { | |
170 | return GetTimeMs() - m_iLastCommandSent; | |
171 | } | |
172 | ||
62f5527d LOK |
173 | const char* CCECBusDevice::GetLogicalAddressName(void) const |
174 | { | |
c4098482 | 175 | return ToString(m_iLogicalAddress); |
62f5527d LOK |
176 | } |
177 | ||
d7be392a | 178 | cec_menu_language &CCECBusDevice::GetMenuLanguage(void) |
93729720 | 179 | { |
f294b22f | 180 | CLockObject lock(&m_mutex); |
5e5637c6 LOK |
181 | if (GetStatus() == CEC_DEVICE_STATUS_PRESENT && |
182 | !strcmp(m_menuLanguage.language, "???")) | |
f294b22f | 183 | RequestMenuLanguage(); |
5e5637c6 | 184 | |
f294b22f LOK |
185 | return m_menuLanguage; |
186 | } | |
187 | ||
188 | bool CCECBusDevice::RequestMenuLanguage(void) | |
189 | { | |
190 | bool bReturn(false); | |
81a1e39d | 191 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
93729720 | 192 | { |
81a1e39d LOK |
193 | CStdString strLog; |
194 | strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
195 | AddLog(CEC_LOG_NOTICE, strLog); | |
196 | cec_command command; | |
caaf64d7 | 197 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE, m_iTransmitTimeout); |
81a1e39d LOK |
198 | CLockObject lock(&m_transmitMutex); |
199 | if (m_processor->Transmit(command)) | |
f294b22f | 200 | bReturn = m_condition.Wait(&m_transmitMutex, 1000); |
93729720 | 201 | } |
f294b22f | 202 | return bReturn; |
93729720 LOK |
203 | } |
204 | ||
205 | cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const | |
206 | { | |
207 | return m_processor->GetLogicalAddress(); | |
f8513317 LOK |
208 | } |
209 | ||
e9de9629 LOK |
210 | uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const |
211 | { | |
212 | return m_processor->GetPhysicalAddress(); | |
213 | } | |
214 | ||
ed21be2a LOK |
215 | CStdString CCECBusDevice::GetOSDName(void) |
216 | { | |
ed21be2a | 217 | CLockObject lock(&m_mutex); |
5e5637c6 | 218 | if (GetStatus() == CEC_DEVICE_STATUS_PRESENT && |
6583c365 LOK |
219 | m_strDeviceName.Equals(ToString(m_iLogicalAddress)) && |
220 | m_type != CEC_DEVICE_TYPE_TV) | |
5e5637c6 LOK |
221 | RequestOSDName(); |
222 | ||
ed21be2a LOK |
223 | return m_strDeviceName; |
224 | } | |
225 | ||
226 | bool CCECBusDevice::RequestOSDName(void) | |
227 | { | |
228 | bool bReturn(false); | |
229 | if (!MyLogicalAddressContains(m_iLogicalAddress)) | |
230 | { | |
231 | CStdString strLog; | |
232 | strLog.Format("<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
233 | AddLog(CEC_LOG_NOTICE, strLog); | |
234 | cec_command command; | |
caaf64d7 | 235 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_OSD_NAME, m_iTransmitTimeout); |
ed21be2a LOK |
236 | CLockObject lock(&m_transmitMutex); |
237 | if (m_processor->Transmit(command)) | |
238 | bReturn = m_condition.Wait(&m_transmitMutex, 1000); | |
239 | } | |
240 | return bReturn; | |
241 | } | |
242 | ||
16b1e052 LOK |
243 | uint16_t CCECBusDevice::GetPhysicalAddress(bool bRefresh /* = true */) |
244 | { | |
5e5637c6 LOK |
245 | CLockObject lock(&m_mutex); |
246 | if (GetStatus() == CEC_DEVICE_STATUS_PRESENT && | |
247 | (m_iPhysicalAddress == 0xFFFF || bRefresh)) | |
16b1e052 | 248 | { |
5e5637c6 LOK |
249 | if (!RequestPhysicalAddress()) |
250 | AddLog(CEC_LOG_ERROR, "failed to request the physical address"); | |
16b1e052 LOK |
251 | } |
252 | ||
16b1e052 LOK |
253 | return m_iPhysicalAddress; |
254 | } | |
255 | ||
256 | bool CCECBusDevice::RequestPhysicalAddress(void) | |
257 | { | |
258 | bool bReturn(false); | |
259 | if (!MyLogicalAddressContains(m_iLogicalAddress)) | |
260 | { | |
261 | CStdString strLog; | |
262 | strLog.Format("<< requesting physical address of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
263 | AddLog(CEC_LOG_NOTICE, strLog); | |
264 | cec_command command; | |
caaf64d7 | 265 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_PHYSICAL_ADDRESS, m_iTransmitTimeout); |
16b1e052 LOK |
266 | CLockObject lock(&m_transmitMutex); |
267 | if (m_processor->Transmit(command)) | |
268 | bReturn = m_condition.Wait(&m_transmitMutex, 1000); | |
269 | } | |
270 | return bReturn; | |
271 | } | |
272 | ||
d7be392a | 273 | cec_power_status CCECBusDevice::GetPowerStatus(void) |
e9de9629 | 274 | { |
f294b22f | 275 | CLockObject lock(&m_mutex); |
5e5637c6 LOK |
276 | if (GetStatus() == CEC_DEVICE_STATUS_PRESENT && |
277 | m_powerStatus == CEC_POWER_STATUS_UNKNOWN) | |
f294b22f | 278 | RequestPowerStatus(); |
5e5637c6 | 279 | |
f294b22f LOK |
280 | return m_powerStatus; |
281 | } | |
282 | ||
283 | bool CCECBusDevice::RequestPowerStatus(void) | |
284 | { | |
285 | bool bReturn(false); | |
81a1e39d | 286 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
93729720 | 287 | { |
81a1e39d LOK |
288 | CStdString strLog; |
289 | strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
290 | AddLog(CEC_LOG_NOTICE, strLog); | |
291 | cec_command command; | |
caaf64d7 | 292 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS, m_iTransmitTimeout); |
81a1e39d LOK |
293 | CLockObject lock(&m_transmitMutex); |
294 | if (m_processor->Transmit(command)) | |
f294b22f | 295 | bReturn = m_condition.Wait(&m_transmitMutex, 1000); |
93729720 | 296 | } |
f294b22f LOK |
297 | return bReturn; |
298 | } | |
93729720 | 299 | |
f294b22f LOK |
300 | cec_vendor_id CCECBusDevice::GetVendorId(void) |
301 | { | |
81a1e39d | 302 | CLockObject lock(&m_mutex); |
5e5637c6 LOK |
303 | if (GetStatus() == CEC_DEVICE_STATUS_PRESENT && |
304 | m_vendor == CEC_VENDOR_UNKNOWN) | |
f294b22f | 305 | RequestVendorId(); |
5e5637c6 | 306 | |
f294b22f | 307 | return m_vendor; |
e9de9629 LOK |
308 | } |
309 | ||
f294b22f | 310 | bool CCECBusDevice::RequestVendorId(void) |
a3269a0a | 311 | { |
f294b22f | 312 | bool bReturn(false); |
81a1e39d | 313 | if (!MyLogicalAddressContains(m_iLogicalAddress)) |
a3269a0a | 314 | { |
81a1e39d LOK |
315 | CStdString strLog; |
316 | strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); | |
317 | AddLog(CEC_LOG_NOTICE, strLog); | |
318 | cec_command command; | |
caaf64d7 | 319 | cec_command::Format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID, m_iTransmitTimeout); |
81a1e39d | 320 | |
f294b22f | 321 | CLockObject lock(&m_transmitMutex); |
81a1e39d | 322 | if (m_processor->Transmit(command)) |
f294b22f | 323 | bReturn = m_condition.Wait(&m_transmitMutex, 1000); |
a3269a0a | 324 | } |
f294b22f | 325 | return bReturn; |
93729720 LOK |
326 | } |
327 | ||
c4098482 LOK |
328 | const char *CCECBusDevice::GetVendorName(void) |
329 | { | |
f294b22f | 330 | return ToString(GetVendorId()); |
c4098482 LOK |
331 | } |
332 | ||
93729720 LOK |
333 | bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const |
334 | { | |
335 | return m_processor->HasLogicalAddress(address); | |
a3269a0a LOK |
336 | } |
337 | ||
9fd73dd4 LOK |
338 | bool CCECBusDevice::NeedsPoll(void) |
339 | { | |
340 | bool bSendPoll(false); | |
341 | switch (m_iLogicalAddress) | |
342 | { | |
343 | case CECDEVICE_PLAYBACKDEVICE3: | |
344 | if (m_processor->m_busDevices[CECDEVICE_PLAYBACKDEVICE2]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
345 | bSendPoll = true; | |
346 | break; | |
347 | case CECDEVICE_PLAYBACKDEVICE2: | |
348 | if (m_processor->m_busDevices[CECDEVICE_PLAYBACKDEVICE1]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
349 | bSendPoll = true; | |
350 | break; | |
351 | case CECDEVICE_RECORDINGDEVICE3: | |
352 | if (m_processor->m_busDevices[CECDEVICE_RECORDINGDEVICE2]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
353 | bSendPoll = true; | |
354 | break; | |
355 | case CECDEVICE_RECORDINGDEVICE2: | |
356 | if (m_processor->m_busDevices[CECDEVICE_RECORDINGDEVICE1]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
357 | bSendPoll = true; | |
358 | break; | |
359 | case CECDEVICE_TUNER4: | |
360 | if (m_processor->m_busDevices[CECDEVICE_TUNER3]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
361 | bSendPoll = true; | |
362 | break; | |
363 | case CECDEVICE_TUNER3: | |
364 | if (m_processor->m_busDevices[CECDEVICE_TUNER2]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
365 | bSendPoll = true; | |
366 | break; | |
367 | case CECDEVICE_TUNER2: | |
368 | if (m_processor->m_busDevices[CECDEVICE_TUNER1]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
369 | bSendPoll = true; | |
370 | break; | |
371 | case CECDEVICE_AUDIOSYSTEM: | |
372 | case CECDEVICE_PLAYBACKDEVICE1: | |
373 | case CECDEVICE_RECORDINGDEVICE1: | |
374 | case CECDEVICE_TUNER1: | |
375 | case CECDEVICE_TV: | |
376 | bSendPoll = true; | |
377 | break; | |
378 | default: | |
379 | break; | |
380 | } | |
381 | ||
382 | return bSendPoll; | |
383 | } | |
384 | ||
385 | cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */) | |
f8ae3295 | 386 | { |
5e5637c6 | 387 | CLockObject lock(&m_writeMutex); |
9fd73dd4 | 388 | if (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN || bForcePoll) |
f8ae3295 | 389 | { |
95a73fa7 | 390 | lock.Leave(); |
9fd73dd4 LOK |
391 | bool bPollAcked(false); |
392 | if (bForcePoll || NeedsPoll()) | |
393 | bPollAcked = m_processor->PollDevice(m_iLogicalAddress); | |
95a73fa7 LOK |
394 | |
395 | lock.Lock(); | |
396 | m_deviceStatus = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT; | |
f8ae3295 LOK |
397 | } |
398 | ||
399 | return m_deviceStatus; | |
400 | } | |
401 | ||
93729720 LOK |
402 | //@} |
403 | ||
404 | /** @name Setters */ | |
405 | //@{ | |
e55f3f70 | 406 | void CCECBusDevice::SetCecVersion(const cec_version newVersion) |
6a1c0009 | 407 | { |
6a1c0009 LOK |
408 | m_cecVersion = newVersion; |
409 | ||
c686413b | 410 | CStdString strLog; |
c4098482 | 411 | strLog.Format("%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(newVersion)); |
6a1c0009 LOK |
412 | AddLog(CEC_LOG_DEBUG, strLog); |
413 | } | |
414 | ||
93729720 LOK |
415 | void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language) |
416 | { | |
5e5637c6 | 417 | CLockObject lock(&m_writeMutex); |
93729720 LOK |
418 | if (language.device == m_iLogicalAddress) |
419 | { | |
420 | CStdString strLog; | |
62f5527d | 421 | strLog.Format(">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language); |
93729720 LOK |
422 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); |
423 | m_menuLanguage = language; | |
424 | } | |
425 | } | |
426 | ||
15d1a84c LOK |
427 | void CCECBusDevice::SetOSDName(CStdString strName) |
428 | { | |
5e5637c6 | 429 | CLockObject lock(&m_writeMutex); |
15d1a84c LOK |
430 | if (m_strDeviceName != strName) |
431 | { | |
432 | CStdString strLog; | |
433 | strLog.Format(">> %s (%X): osd name set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, strName); | |
434 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); | |
435 | m_strDeviceName = strName; | |
436 | } | |
437 | } | |
438 | ||
28fa6c97 LOK |
439 | void CCECBusDevice::SetMenuState(const cec_menu_state state) |
440 | { | |
5e5637c6 | 441 | CLockObject lock(&m_writeMutex); |
28fa6c97 LOK |
442 | if (m_menuState != state) |
443 | { | |
444 | CStdString strLog; | |
445 | strLog.Format(">> %s (%X): menu state set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_menuState)); | |
446 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); | |
447 | m_menuState = state; | |
448 | } | |
449 | } | |
450 | ||
7856411b LOK |
451 | void CCECBusDevice::SetInactiveDevice(void) |
452 | { | |
5e5637c6 | 453 | CLockObject lock(&m_writeMutex); |
7856411b LOK |
454 | m_bActiveSource = false; |
455 | } | |
456 | ||
457 | void CCECBusDevice::SetActiveDevice(void) | |
458 | { | |
5e5637c6 | 459 | CLockObject lock(&m_writeMutex); |
7856411b LOK |
460 | |
461 | for (int iPtr = 0; iPtr < 16; iPtr++) | |
462 | if (iPtr != m_iLogicalAddress) | |
463 | m_processor->m_busDevices[iPtr]->SetInactiveDevice(); | |
464 | ||
465 | m_bActiveSource = true; | |
466 | m_powerStatus = CEC_POWER_STATUS_ON; | |
467 | } | |
468 | ||
93fff5c1 LOK |
469 | bool CCECBusDevice::TryLogicalAddress(void) |
470 | { | |
471 | CStdString strLog; | |
472 | strLog.Format("trying logical address '%s'", GetLogicalAddressName()); | |
473 | AddLog(CEC_LOG_DEBUG, strLog); | |
474 | ||
475 | m_processor->SetAckMask(0x1 << m_iLogicalAddress); | |
476 | if (!TransmitPoll(m_iLogicalAddress)) | |
477 | { | |
478 | strLog.Format("using logical address '%s'", GetLogicalAddressName()); | |
479 | AddLog(CEC_LOG_NOTICE, strLog); | |
480 | SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC); | |
481 | ||
482 | return true; | |
483 | } | |
484 | ||
485 | strLog.Format("logical address '%s' already taken", GetLogicalAddressName()); | |
486 | AddLog(CEC_LOG_DEBUG, strLog); | |
487 | SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT); | |
488 | return false; | |
489 | } | |
490 | ||
491 | void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) | |
492 | { | |
5e5637c6 | 493 | CLockObject lock(&m_writeMutex); |
93fff5c1 LOK |
494 | switch (newStatus) |
495 | { | |
496 | case CEC_DEVICE_STATUS_UNKNOWN: | |
497 | m_iStreamPath = 0; | |
498 | m_powerStatus = CEC_POWER_STATUS_UNKNOWN; | |
499 | m_vendor = CEC_VENDOR_UNKNOWN; | |
500 | m_menuState = CEC_MENU_STATE_ACTIVATED; | |
501 | m_bActiveSource = false; | |
502 | m_iLastCommandSent = 0; | |
503 | m_iLastActive = 0; | |
504 | m_cecVersion = CEC_VERSION_UNKNOWN; | |
505 | m_deviceStatus = newStatus; | |
506 | break; | |
507 | case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC: | |
508 | m_iStreamPath = 0; | |
509 | m_powerStatus = CEC_POWER_STATUS_ON; | |
510 | m_vendor = CEC_VENDOR_UNKNOWN; | |
511 | m_menuState = CEC_MENU_STATE_ACTIVATED; | |
512 | m_bActiveSource = false; | |
513 | m_iLastCommandSent = 0; | |
514 | m_iLastActive = 0; | |
515 | m_cecVersion = CEC_VERSION_1_3A; | |
516 | m_deviceStatus = newStatus; | |
517 | break; | |
518 | case CEC_DEVICE_STATUS_PRESENT: | |
519 | case CEC_DEVICE_STATUS_NOT_PRESENT: | |
520 | m_deviceStatus = newStatus; | |
521 | break; | |
522 | } | |
523 | } | |
524 | ||
9dc04b07 | 525 | void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress) |
93729720 | 526 | { |
5e5637c6 | 527 | CLockObject lock(&m_writeMutex); |
b8176e3c | 528 | if (iNewAddress > 0 && m_iPhysicalAddress != iNewAddress) |
93729720 LOK |
529 | { |
530 | CStdString strLog; | |
62f5527d | 531 | strLog.Format(">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress); |
93729720 LOK |
532 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); |
533 | ||
534 | m_iPhysicalAddress = iNewAddress; | |
535 | } | |
536 | } | |
537 | ||
9dc04b07 LOK |
538 | void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) |
539 | { | |
5e5637c6 | 540 | CLockObject lock(&m_writeMutex); |
9dc04b07 LOK |
541 | if (iNewAddress > 0) |
542 | { | |
543 | CStdString strLog; | |
68a12fbf | 544 | strLog.Format(">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress == 0 ? m_iStreamPath : iOldAddress, iNewAddress); |
9dc04b07 LOK |
545 | AddLog(CEC_LOG_DEBUG, strLog.c_str()); |
546 | ||
547 | m_iStreamPath = iNewAddress; | |
96274140 LOK |
548 | |
549 | if (iNewAddress > 0) | |
81a1e39d LOK |
550 | { |
551 | lock.Leave(); | |
96274140 | 552 | SetPowerStatus(CEC_POWER_STATUS_ON); |
81a1e39d | 553 | } |
9dc04b07 LOK |
554 | } |
555 | } | |
556 | ||
e55f3f70 LOK |
557 | void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus) |
558 | { | |
5e5637c6 | 559 | CLockObject lock(&m_writeMutex); |
b0271d54 LOK |
560 | if (m_powerStatus != powerStatus) |
561 | { | |
562 | CStdString strLog; | |
c4098482 | 563 | strLog.Format(">> %s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus)); |
b0271d54 LOK |
564 | m_processor->AddLog(CEC_LOG_DEBUG, strLog); |
565 | m_powerStatus = powerStatus; | |
566 | } | |
e55f3f70 LOK |
567 | } |
568 | ||
c4098482 | 569 | void CCECBusDevice::SetVendorId(uint64_t iVendorId) |
e9de9629 | 570 | { |
e9de9629 | 571 | { |
5e5637c6 | 572 | CLockObject lock(&m_writeMutex); |
81a1e39d LOK |
573 | m_vendor = (cec_vendor_id)iVendorId; |
574 | ||
575 | switch (iVendorId) | |
0ab58650 | 576 | { |
81a1e39d LOK |
577 | case CEC_VENDOR_SAMSUNG: |
578 | if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG) | |
579 | { | |
580 | delete m_handler; | |
581 | m_handler = new CANCommandHandler(this); | |
582 | } | |
583 | break; | |
584 | case CEC_VENDOR_LG: | |
585 | if (m_handler->GetVendorId() != CEC_VENDOR_LG) | |
586 | { | |
587 | delete m_handler; | |
588 | m_handler = new CSLCommandHandler(this); | |
589 | } | |
590 | break; | |
591 | case CEC_VENDOR_PANASONIC: | |
592 | if (m_handler->GetVendorId() != CEC_VENDOR_PANASONIC) | |
593 | { | |
594 | delete m_handler; | |
595 | m_handler = new CVLCommandHandler(this); | |
596 | } | |
597 | break; | |
598 | default: | |
599 | if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN) | |
600 | { | |
601 | delete m_handler; | |
602 | m_handler = new CCECCommandHandler(this); | |
603 | } | |
604 | break; | |
0ab58650 | 605 | } |
e9de9629 LOK |
606 | } |
607 | ||
8d915412 LOK |
608 | m_handler->InitHandler(); |
609 | ||
e9de9629 | 610 | CStdString strLog; |
5e5637c6 | 611 | strLog.Format("%s (%X): vendor = %s (%06x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_vendor), m_vendor); |
e9de9629 LOK |
612 | m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str()); |
613 | } | |
93729720 | 614 | //@} |
e9de9629 | 615 | |
93729720 LOK |
616 | /** @name Transmit methods */ |
617 | //@{ | |
618 | bool CCECBusDevice::TransmitActiveSource(void) | |
0f23c85c | 619 | { |
5e5637c6 | 620 | CLockObject lock(&m_writeMutex); |
58c1f6f5 LOK |
621 | if (m_powerStatus != CEC_POWER_STATUS_ON) |
622 | { | |
623 | CStdString strLog; | |
624 | strLog.Format("<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress); | |
625 | AddLog(CEC_LOG_DEBUG, strLog); | |
626 | } | |
627 | else if (m_bActiveSource) | |
8747dd4f LOK |
628 | { |
629 | CStdString strLog; | |
62f5527d | 630 | strLog.Format("<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress); |
8747dd4f | 631 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c | 632 | |
8747dd4f | 633 | cec_command command; |
caaf64d7 | 634 | cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE, m_iTransmitTimeout); |
ab1469a0 LOK |
635 | command.parameters.PushBack((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); |
636 | command.parameters.PushBack((uint8_t) (m_iPhysicalAddress & 0xFF)); | |
0f23c85c | 637 | |
81a1e39d | 638 | lock.Leave(); |
8747dd4f LOK |
639 | return m_processor->Transmit(command); |
640 | } | |
641 | else | |
642 | { | |
643 | CStdString strLog; | |
62f5527d | 644 | strLog.Format("<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress); |
8747dd4f LOK |
645 | AddLog(CEC_LOG_DEBUG, strLog); |
646 | } | |
647 | ||
648 | return false; | |
0f23c85c LOK |
649 | } |
650 | ||
29912296 | 651 | bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) |
0f23c85c | 652 | { |
5e5637c6 | 653 | CLockObject lock(&m_writeMutex); |
d7be392a | 654 | CStdString strLog; |
c4098482 | 655 | strLog.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_cecVersion)); |
d7be392a | 656 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c LOK |
657 | |
658 | cec_command command; | |
caaf64d7 | 659 | cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION, m_iTransmitTimeout); |
ab1469a0 | 660 | command.parameters.PushBack((uint8_t)m_cecVersion); |
0f23c85c | 661 | |
81a1e39d | 662 | lock.Leave(); |
0f23c85c LOK |
663 | return m_processor->Transmit(command); |
664 | } | |
665 | ||
ab27363d | 666 | bool CCECBusDevice::TransmitInactiveSource(void) |
93729720 | 667 | { |
d7be392a | 668 | CStdString strLog; |
ab27363d | 669 | strLog.Format("<< %s (%X) -> broadcast (F): inactive source", GetLogicalAddressName(), m_iLogicalAddress); |
d7be392a | 670 | AddLog(CEC_LOG_NOTICE, strLog); |
93729720 LOK |
671 | |
672 | cec_command command; | |
caaf64d7 | 673 | cec_command::Format(command, m_iLogicalAddress, CECDEVICE_TV, CEC_OPCODE_INACTIVE_SOURCE, m_iTransmitTimeout); |
ab1469a0 LOK |
674 | command.parameters.PushBack((m_iPhysicalAddress >> 8) & 0xFF); |
675 | command.parameters.PushBack(m_iPhysicalAddress & 0xFF); | |
93729720 LOK |
676 | |
677 | return m_processor->Transmit(command); | |
678 | } | |
679 | ||
29912296 | 680 | bool CCECBusDevice::TransmitMenuState(cec_logical_address dest) |
0f23c85c | 681 | { |
d7be392a | 682 | CStdString strLog; |
28fa6c97 | 683 | strLog.Format("<< %s (%X) -> %s (%X): menu state '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_menuState)); |
d7be392a | 684 | AddLog(CEC_LOG_NOTICE, strLog); |
0f23c85c LOK |
685 | |
686 | cec_command command; | |
caaf64d7 | 687 | cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS, m_iTransmitTimeout); |
ab1469a0 | 688 | command.parameters.PushBack((uint8_t)m_menuState); |
0f23c85c LOK |
689 | |
690 | return m_processor->Transmit(command); | |
691 | } | |
692 | ||
29912296 | 693 | bool CCECBusDevice::TransmitOSDName(cec_logical_address dest) |
0f23c85c | 694 | { |
5e5637c6 | 695 | CLockObject lock(&m_writeMutex); |
0f23c85c | 696 | CStdString strLog; |
c4098482 | 697 | strLog.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, m_strDeviceName.c_str()); |
0f23c85c LOK |
698 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
699 | ||
700 | cec_command command; | |
caaf64d7 | 701 | cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME, m_iTransmitTimeout); |
787a3cb8 | 702 | for (unsigned int iPtr = 0; iPtr < m_strDeviceName.length(); iPtr++) |
ab1469a0 | 703 | command.parameters.PushBack(m_strDeviceName.at(iPtr)); |
0f23c85c | 704 | |
81a1e39d | 705 | lock.Leave(); |
0f23c85c LOK |
706 | return m_processor->Transmit(command); |
707 | } | |
708 | ||
38bdb943 LOK |
709 | bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage) |
710 | { | |
5e5637c6 | 711 | CLockObject lock(&m_writeMutex); |
38bdb943 | 712 | CStdString strLog; |
c4098482 | 713 | strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage); |
38bdb943 LOK |
714 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
715 | ||
716 | cec_command command; | |
caaf64d7 | 717 | cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING, m_iTransmitTimeout); |
ab1469a0 | 718 | command.parameters.PushBack((uint8_t)duration); |
38bdb943 LOK |
719 | |
720 | unsigned int iLen = strlen(strMessage); | |
721 | if (iLen > 13) iLen = 13; | |
722 | ||
723 | for (unsigned int iPtr = 0; iPtr < iLen; iPtr++) | |
ab1469a0 | 724 | command.parameters.PushBack(strMessage[iPtr]); |
38bdb943 | 725 | |
81a1e39d | 726 | lock.Leave(); |
38bdb943 LOK |
727 | return m_processor->Transmit(command); |
728 | } | |
729 | ||
29912296 | 730 | bool CCECBusDevice::TransmitPhysicalAddress(void) |
0f23c85c | 731 | { |
5e5637c6 | 732 | CLockObject lock(&m_writeMutex); |
0f23c85c | 733 | CStdString strLog; |
62f5527d | 734 | strLog.Format("<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress); |
0f23c85c LOK |
735 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
736 | ||
737 | cec_command command; | |
caaf64d7 | 738 | cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS, m_iTransmitTimeout); |
ab1469a0 LOK |
739 | command.parameters.PushBack((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF)); |
740 | command.parameters.PushBack((uint8_t) (m_iPhysicalAddress & 0xFF)); | |
741 | command.parameters.PushBack((uint8_t) (m_type)); | |
0f23c85c | 742 | |
81a1e39d | 743 | lock.Leave(); |
0f23c85c LOK |
744 | return m_processor->Transmit(command); |
745 | } | |
746 | ||
93729720 | 747 | bool CCECBusDevice::TransmitPoll(cec_logical_address dest) |
57f45e6c LOK |
748 | { |
749 | bool bReturn(false); | |
93729720 LOK |
750 | if (dest == CECDEVICE_UNKNOWN) |
751 | dest = m_iLogicalAddress; | |
f8513317 | 752 | |
57f45e6c | 753 | CStdString strLog; |
c4098482 | 754 | strLog.Format("<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); |
d7be392a | 755 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
57f45e6c LOK |
756 | |
757 | cec_command command; | |
caaf64d7 | 758 | cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE, m_iTransmitTimeout); |
9b223b29 | 759 | command.retries = 0; |
57f45e6c | 760 | |
1674de37 LOK |
761 | { |
762 | CLockObject lock(&m_transmitMutex); | |
763 | bReturn = m_processor->Transmit(command); | |
764 | } | |
765 | ||
57f45e6c | 766 | AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent"); |
1674de37 LOK |
767 | |
768 | if (bReturn) | |
769 | { | |
5e5637c6 | 770 | CLockObject lock(&m_writeMutex); |
1674de37 LOK |
771 | m_iLastActive = GetTimeMs(); |
772 | } | |
773 | ||
57f45e6c LOK |
774 | return bReturn; |
775 | } | |
93729720 LOK |
776 | |
777 | bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) | |
778 | { | |
5e5637c6 | 779 | CLockObject lock(&m_writeMutex); |
93729720 | 780 | CStdString strLog; |
c4098482 | 781 | strLog.Format("<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus)); |
d7be392a LOK |
782 | AddLog(CEC_LOG_NOTICE, strLog.c_str()); |
783 | ||
93729720 | 784 | cec_command command; |
caaf64d7 | 785 | cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS, m_iTransmitTimeout); |
ab1469a0 | 786 | command.parameters.PushBack((uint8_t) m_powerStatus); |
93729720 | 787 | |
81a1e39d | 788 | lock.Leave(); |
93729720 LOK |
789 | return m_processor->Transmit(command); |
790 | } | |
791 | ||
792 | bool CCECBusDevice::TransmitVendorID(cec_logical_address dest) | |
793 | { | |
5e5637c6 | 794 | CLockObject lock(&m_writeMutex); |
c4098482 LOK |
795 | if (m_vendor == CEC_VENDOR_UNKNOWN) |
796 | { | |
797 | CStdString strLog; | |
798 | strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); | |
799 | AddLog(CEC_LOG_NOTICE, strLog); | |
d7be392a | 800 | |
81a1e39d | 801 | lock.Leave(); |
c4098482 LOK |
802 | m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); |
803 | return false; | |
804 | } | |
805 | else | |
806 | { | |
807 | CStdString strLog; | |
808 | strLog.Format("<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_vendor), (uint64_t)m_vendor); | |
809 | AddLog(CEC_LOG_NOTICE, strLog); | |
810 | ||
811 | cec_command command; | |
caaf64d7 | 812 | cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_DEVICE_VENDOR_ID, m_iTransmitTimeout); |
c4098482 | 813 | |
ab1469a0 LOK |
814 | command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 16) & 0xFF)); |
815 | command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 8) & 0xFF)); | |
816 | command.parameters.PushBack((uint8_t) ((uint64_t)m_vendor & 0xFF)); | |
c4098482 | 817 | |
81a1e39d | 818 | lock.Leave(); |
c4098482 LOK |
819 | return m_processor->Transmit(command); |
820 | } | |
93729720 | 821 | } |
a33794d8 LOK |
822 | |
823 | bool CCECBusDevice::SendKeypress(cec_user_control_code key, bool bWait /* = false */) | |
824 | { | |
5e5637c6 LOK |
825 | CLockObject lock(&m_transmitMutex); |
826 | cec_command command; | |
caaf64d7 | 827 | cec_command::Format(command, m_processor->GetLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_USER_CONTROL_PRESSED, m_iTransmitTimeout); |
5e5637c6 | 828 | command.parameters.PushBack((uint8_t)key); |
a33794d8 | 829 | |
5e5637c6 LOK |
830 | if (bWait) |
831 | { | |
832 | if (m_processor->Transmit(command)) | |
833 | return m_condition.Wait(&m_transmitMutex, 1000); | |
834 | return false; | |
a33794d8 | 835 | } |
5e5637c6 LOK |
836 | |
837 | return m_processor->Transmit(command); | |
a33794d8 LOK |
838 | } |
839 | ||
840 | bool CCECBusDevice::SendKeyRelease(bool bWait /* = false */) | |
841 | { | |
5e5637c6 LOK |
842 | CLockObject lock(&m_transmitMutex); |
843 | cec_command command; | |
caaf64d7 | 844 | cec_command::Format(command, m_processor->GetLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_USER_CONTROL_RELEASE, m_iTransmitTimeout); |
a33794d8 | 845 | |
5e5637c6 LOK |
846 | if (bWait) |
847 | { | |
848 | if (m_processor->Transmit(command)) | |
849 | return m_condition.Wait(&m_transmitMutex, 1000); | |
850 | return false; | |
851 | } | |
852 | else | |
853 | { | |
854 | return m_processor->Transmit(command); | |
a33794d8 LOK |
855 | } |
856 | } | |
93729720 | 857 | //@} |