Skip to content

Commit 250083a

Browse files
committed
delta common: print dev details in separate file
refactor only
1 parent 1de5447 commit 250083a

File tree

1 file changed

+56
-52
lines changed

1 file changed

+56
-52
lines changed

src/deltacast_common.cpp

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,61 @@ print_avail_channels(HANDLE BoardHandle)
226226
printf("\n");
227227
}
228228

229+
static void
230+
print_board_info(int i, ULONG DllVersion, bool full)
231+
{
232+
ULONG BoardType = 0U;
233+
ULONG DriverVersion = 0U;
234+
HANDLE BoardHandle = NULL;
235+
ULONG Result = VHD_OpenBoardHandle(i, &BoardHandle, NULL, 0);
236+
if (Result != VHDERR_NOERROR) {
237+
LOG(LOG_LEVEL_ERROR)
238+
<< "[DELTACAST] Unable to open board " << i << ": "
239+
<< delta_get_error_description(Result) << "\n";
240+
return;
241+
}
242+
Result = VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_BOARD_TYPE,
243+
&BoardType);
244+
if (Result != VHDERR_NOERROR) {
245+
LOG(LOG_LEVEL_ERROR)
246+
<< "[DELTACAST] Unable to get board " << i
247+
<< " type: " << delta_get_error_description(Result) << "\n";
248+
return;
249+
}
250+
Result = VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_DRIVER_VERSION,
251+
&DriverVersion);
252+
if (Result != VHDERR_NOERROR) {
253+
LOG(LOG_LEVEL_ERROR)
254+
<< "[DELTACAST] Unable to get board " << i
255+
<< " version: " << delta_get_error_description(Result)
256+
<< "\n";
257+
}
258+
259+
const char *board = delta_get_board_type_name(BoardType);
260+
col() << "\tBoard " << SBOLD(i) << ": " << SBOLD(board)
261+
<< " (driver: " << delta_format_version(DriverVersion, false)
262+
<< ")\n";
263+
if (full) {
264+
print_avail_channels(BoardHandle);
265+
266+
ULONG IsBiDir = 2;
267+
VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_IS_BIDIR,
268+
&IsBiDir);
269+
printf("\t\tbidirectional (switchable) channels: "
270+
"%s\n",
271+
IsBiDir == 2 ? "ERROR"
272+
: IsBiDir == TRUE ? "supported"
273+
: "not supported");
274+
}
275+
if ((DllVersion >> 16U) != (DriverVersion >> 16U)) {
276+
LOG(LOG_LEVEL_WARNING)
277+
<< "[DELTACAST] API and driver version mismatch: "
278+
<< delta_format_version(DllVersion, true) << " vs "
279+
<< delta_format_version(DriverVersion, true) << "\n";
280+
}
281+
VHD_CloseBoardHandle(BoardHandle);
282+
}
283+
229284
void
230285
print_available_delta_boards(bool full)
231286
{
@@ -249,58 +304,7 @@ print_available_delta_boards(bool full)
249304

250305
/* Query DELTA boards information */
251306
for (ULONG i = 0; i < NbBoards; i++) {
252-
ULONG BoardType = 0U;
253-
ULONG DriverVersion = 0U;
254-
HANDLE BoardHandle = NULL;
255-
ULONG Result = VHD_OpenBoardHandle(i, &BoardHandle, NULL, 0);
256-
if (Result != VHDERR_NOERROR) {
257-
LOG(LOG_LEVEL_ERROR)
258-
<< "[DELTACAST] Unable to open board " << i << ": "
259-
<< delta_get_error_description(Result) << "\n";
260-
continue;
261-
}
262-
Result = VHD_GetBoardProperty(
263-
BoardHandle, VHD_CORE_BP_BOARD_TYPE, &BoardType);
264-
if (Result != VHDERR_NOERROR) {
265-
LOG(LOG_LEVEL_ERROR)
266-
<< "[DELTACAST] Unable to get board " << i
267-
<< " type: " << delta_get_error_description(Result)
268-
<< "\n";
269-
continue;
270-
}
271-
Result = VHD_GetBoardProperty(
272-
BoardHandle, VHD_CORE_BP_DRIVER_VERSION, &DriverVersion);
273-
if (Result != VHDERR_NOERROR) {
274-
LOG(LOG_LEVEL_ERROR)
275-
<< "[DELTACAST] Unable to get board " << i
276-
<< " version: "
277-
<< delta_get_error_description(Result) << "\n";
278-
}
279-
280-
const char *board = delta_get_board_type_name(BoardType);
281-
col() << "\tBoard " << SBOLD(i) << ": " << SBOLD(board)
282-
<< " (driver: "
283-
<< delta_format_version(DriverVersion, false) << ")\n";
284-
if (full) {
285-
print_avail_channels(BoardHandle);
286-
287-
ULONG IsBiDir = 2;
288-
VHD_GetBoardProperty(BoardHandle, VHD_CORE_BP_IS_BIDIR,
289-
&IsBiDir);
290-
printf("\t\tbidirectional (switchable) channels: "
291-
"%s\n",
292-
IsBiDir == 2 ? "ERROR"
293-
: IsBiDir == TRUE ? "supported"
294-
: "not supported");
295-
}
296-
if ((DllVersion >> 16U) != (DriverVersion >> 16U)) {
297-
LOG(LOG_LEVEL_WARNING)
298-
<< "[DELTACAST] API and driver version mismatch: "
299-
<< delta_format_version(DllVersion, true) << " vs "
300-
<< delta_format_version(DriverVersion, true)
301-
<< "\n";
302-
}
303-
VHD_CloseBoardHandle(BoardHandle);
307+
print_board_info(i, DllVersion, full);
304308
}
305309
std::cout << "\n";
306310
}

0 commit comments

Comments
 (0)