ofstream g_logOutput;
bool g_bShortLog(false);
CStdString g_strPort;
-int8_t g_iHDMIPort(-1);
+uint8_t g_iHDMIPort(CEC_DEFAULT_HDMI_PORT);
+cec_logical_address g_iBaseDevice((cec_logical_address)CEC_DEFAULT_BASE_DEVICE);
cec_device_type_list g_typeList;
bool g_bSingleCommand(false);
" -l --list-devices List all devices on this system" << endl <<
" -t --type {p|r|t|a} The device type to use. More than one is possible." << endl <<
" -p --port {int} The HDMI port to use as active source." << endl <<
+ " -b --base {int} The logical address of the device to with this " << endl <<
+ " adapter is connected." << endl <<
" -f --log-file {file} Writes all libCEC log message to a file" << endl <<
" -sf --short-log-file {file} Writes all libCEC log message without timestamps" << endl <<
" and log levels to a file." << endl <<
int iDev = atoi(strDev);
if (iDev >= 0 && iDev < 15)
{
- cec_osd_name name = parser->GetOSDName((cec_logical_address)iDev);
+ cec_osd_name name = parser->GetDeviceOSDName((cec_logical_address)iDev);
cout << "OSD name of device " << iDev << " is '" << name.name << "'" << endl;
}
return true;
{
cout << "listing active devices:" << endl;
cec_logical_addresses addresses = parser->GetActiveDevices();
- for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
+ for (uint8_t iPtr = 0; iPtr <= 11; iPtr++)
if (addresses[iPtr])
cout << "logical address " << (int)iPtr << endl;
return true;
{
if (addresses[iPtr])
{
- uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr);
- cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
- cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
- cec_osd_name osdName = parser->GetOSDName((cec_logical_address)iPtr);
+ uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr);
+ bool bActive = parser->IsActiveSource((cec_logical_address)iPtr);
+ uint16_t iPhysicalAddress = parser->GetDevicePhysicalAddress((cec_logical_address)iPtr);
+ cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr);
+ cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr);
+ cec_osd_name osdName = parser->GetDeviceOSDName((cec_logical_address)iPtr);
+ CStdString strAddr;
+ strAddr.Format("%04x", iPhysicalAddress);
cec_menu_language lang;
lang.device = CECDEVICE_UNKNOWN;
parser->GetDeviceMenuLanguage((cec_logical_address)iPtr, &lang);
cout << "device #" << (int)iPtr << ": " << parser->ToString((cec_logical_address)iPtr) << endl;
- cout << "vendor: " << parser->ToString((cec_vendor_id)iVendorId) << endl;
- cout << "osd string: " << osdName.name << endl;
- cout << "CEC version: " << parser->ToString(iCecVersion) << endl;
- cout << "power status: " << parser->ToString(power) << endl;
+ cout << "address: " << strAddr.c_str() << endl;
+ cout << "active source: " << (bActive ? "yes" : "no") << endl;
+ cout << "vendor: " << parser->ToString((cec_vendor_id)iVendorId) << endl;
+ cout << "osd string: " << osdName.name << endl;
+ cout << "CEC version: " << parser->ToString(iCecVersion) << endl;
+ cout << "power status: " << parser->ToString(power) << endl;
if ((uint8_t)lang.device == iPtr)
- cout << "language: " << lang.language << endl;
+ cout << "language: " << lang.language << endl;
cout << endl;
}
}
{
bool bReturn(true);
int iArgPtr = 1;
- while (iArgPtr < argc)
+ while (iArgPtr < argc && bReturn)
{
if (argc >= iArgPtr + 1)
{
{
ListDevices(parser);
UnloadLibCec(parser);
+ parser = NULL;
}
bReturn = false;
}
ShowHelpCommandLine(argv[0]);
return 0;
}
+ else if (!strcmp(argv[iArgPtr], "-b") ||
+ !strcmp(argv[iArgPtr], "--base"))
+ {
+ if (argc >= iArgPtr + 2)
+ {
+ g_iBaseDevice = (cec_logical_address)atoi(argv[iArgPtr + 1]);
+ cout << "using base device '" << (int)g_iBaseDevice << "'" << endl;
+ ++iArgPtr;
+ }
+ ++iArgPtr;
+ }
else if (!strcmp(argv[iArgPtr], "-p") ||
!strcmp(argv[iArgPtr], "--port"))
{
if (argc >= iArgPtr + 2)
{
g_iHDMIPort = (int8_t)atoi(argv[iArgPtr + 1]);
- cout << "using HDMI port '" << g_iHDMIPort << "'" << endl;
+ cout << "using HDMI port '" << (int)g_iHDMIPort << "'" << endl;
++iArgPtr;
}
++iArgPtr;
}
}
- if (g_iHDMIPort > 0)
- {
- parser->SetHDMIPort((cec_logical_address)CEC_DEFAULT_BASE_DEVICE, (uint8_t)g_iHDMIPort);
- FlushLog(parser);
- }
-
- cout << "scanning the CEC bus..." << endl;
+ parser->SetHDMIPort(g_iBaseDevice, g_iHDMIPort);
+ cout << "opening a connection to the CEC adapter..." << endl;
if (!parser->Open(g_strPort.c_str()))
{
if (!g_bSingleCommand)
{
+ FlushLog(parser);
cout << "cec device opened" << endl;
parser->PowerOnDevices(CECDEVICE_TV);