This repository has been archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
HauppaugeDev.cpp
709 lines (623 loc) · 19.7 KB
/
HauppaugeDev.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
/* -*- Mode: c++ -*-
*
* Copyright (C) John Poet 2018
*
* This file is part of HauppaugeUSB.
*
* HauppaugeUSB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HauppaugeUSB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HauppaugeUSB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <thread>
#include <math.h>
#include "registryif.h"
#include "audio_CX2081x.h"
#include "device_EDID.h"
#include "hauppauge2_EDID.h"
//Common/Rx/audio_CS8416.h
#include "audio_CS8416.h"
#include "HauppaugeDev.h"
#include "FlipInterlacedFields.h"
#include "Logger.h"
using namespace std;
HauppaugeDev::HauppaugeDev(const Parameters & params)
: m_fd(-1)
, m_rxDev(nullptr)
, m_encDev(nullptr)
, m_fx2(nullptr)
, m_params(params)
, m_video_initialized(-1)
, m_err(false)
{
configure();
}
HauppaugeDev::~HauppaugeDev(void)
{
Close();
}
void HauppaugeDev::configure(void)
{
#if 0
switch (m_params.audio_rate)
{
case HAPI_AUDIO_SAMPLE_RATE_FOLLOW_INPUT:
m_params.audioSamplerate = -1;
break;
case HAPI_AUDIO_SAMPLE_RATE_NONE:
m_params.audioSamplerate = 0;
break;
case HAPI_AUDIO_SAMPLE_RATE_32_KHZ:
m_params.audioSamplerate = 32000;
break;
case HAPI_AUDIO_SAMPLE_RATE_44_1_KHZ:
m_params.audioSamplerate = 44100;
break;
case HAPI_AUDIO_SAMPLE_RATE_48_KHZ:
m_params.audioSamplerate = 48000;
break;
case HAPI_AUDIO_SAMPLE_RATE_96_KHZ:
m_params.audioSamplerate = 96000;
break;
case HAPI_AUDIO_SAMPLE_RATE_192_KHZ:
m_params.audioSamplerate = 192000;
break;
case HAPI_AUDIO_SAMPLE_RATE_16_KHZ:
m_params.audioSamplerate = 16000;
break;
}
#endif
RegistryAccess::writeDword("VideoCapSource", m_params.videoInput);
// RegistryAccess::writeDword("RateControl", m_params.videoRateControl); // Ignored
RegistryAccess::writeDword("VideoRateControl", m_params.videoRateControl);
RegistryAccess::writeDword("VideoTSBitrate", m_params.tsBitrate);
RegistryAccess::writeDword("VideoOutputBitrate", m_params.videoBitrate);
RegistryAccess::writeDword("VBRMin", m_params.videoVBRMin);
RegistryAccess::writeDword("VBRMax", m_params.videoVBRMax);
RegistryAccess::writeDword("VideoProfile", m_params.videoProfile);
RegistryAccess::writeDword("Profile", m_params.videoProfile);
#if 0
RegistryAccess::writeDword("VideoCodecOutputFormat", 4);
RegistryAccess::writeDword("Level", m_params.videoH264Level);
RegistryAccess::writeDword("VideoLatency", m_params.videoLatency);
RegistryAccess::writeDword("Latency", m_params.videoLatency);
#endif
RegistryAccess::writeDword("VideoLevel", m_params.videoH264Level);
RegistryAccess::writeDword("AudioCapSource", m_params.audioInput);
// RegistryAccess::writeDword("AudioCapSPDIFInput", 3); // Default = 0
RegistryAccess::writeDword("AudioCodecOutputFormat", m_params.audioCodec);
// RegistryAccess::writeDword("AudioCapMode", 5);
RegistryAccess::writeDword("AudioOutputSamplingRate",
m_params.audioSamplerate);
RegistryAccess::writeDword("AudioCapSampleRate", m_params.audioSamplerate);
RegistryAccess::writeDword("AudioOutputBitrate", m_params.audioBitrate);
// AudioOutputMode
// -
}
bool HauppaugeDev::set_digital_audio(bool optical)
{
try
{
// init CS8416 optical receiver if detected
audio_CS8416 audio_CS8416(*m_fx2);
if (optical)
audio_CS8416.reset(audio_CS8416::AudioInput::OPTICAL);
else
audio_CS8416.reset(audio_CS8416::AudioInput::HDMI);
INFOLOG << "CS8416 initialized.";
}
catch (std::runtime_error &e)
{
WARNLOG << "This device does not have a CS8416. "
<< "AC3 not available.";
return false;
}
return true;
}
bool HauppaugeDev::set_audio_format(encoderAudioInFormat_t audioFormat)
{
bool spdif = (m_params.audioInput == HAPI_AUDIO_CAPTURE_SOURCE_SPDIF);
if (spdif)
{
if (set_digital_audio(true))
{
m_fx2->setPortStateBits(FX2_PORT_E, 0x10, 0x00);
DEBUGLOG << "Audio Input: S/PDIF";
}
else
{
WARNLOG << "Can't initialize CS8416 part. "
"S/PDIF input is not available";
spdif = false;
}
}
if (!spdif)
{
switch (m_params.audioInput)
{
case HAPI_AUDIO_CAPTURE_SOURCE_HDMI:
{
if (set_digital_audio(false))
{
// Device has a CS8416 chip
if (audioFormat == ENCAIF_AC3)
{
m_fx2->setPortStateBits(FX2_PORT_E, 0x10, 0x00);
INFOLOG << "'SPDIF' from HDMI via 8416";
}
else
{
m_fx2->setPortStateBits(FX2_PORT_E, 0x00, 0x00);
INFOLOG << "I2S audio from ADV7842";
}
}
else
{
// Older device without CS8416
m_fx2->setPortStateBits(FX2_PORT_E, 0, 0x18);
INFOLOG << "I2S audio from ADV7842";
}
INFOLOG << "Audio Input: HDMI";
break;
}
case HAPI_AUDIO_CAPTURE_SOURCE_LR:
default:
{
if (m_params.audioBoost)
{
// Set audio input via RCA with audio boost
m_fx2->setPortStateBits(FX2_PORT_E, 0x18, 0);
INFOLOG << "Audio Input: RCA with boost";
}
else
{
// Set audio input via RCA
m_fx2->setPortStateBits(FX2_PORT_E, 0x08, 0x10);
INFOLOG << "Audio Input: RCA";
}
break;
}
}
}
INFOLOG << "Audio codec: "
<< (audioFormat == ENCAIF_AC3 ? "AC3" : "AUTO");
return true;
}
bool HauppaugeDev::set_input_format(encoderSource_t source,
unsigned width, unsigned height,
bool interlaced, float vFreq,
float aspectRatio, float audioSampleRate)
{
INFOLOG << "Input width: " << width
<< " height: " << height
<< " interlaced: " << interlaced
<< " vFreq: " << vFreq
<< " audio SR: " << audioSampleRate;
encoderAudioInFormat_t audioFormat =
(m_params.audioCodec == HAPI_AUDIO_CODEC_AC3 ? ENCAIF_AC3
: ENCAIF_AUTO);
set_audio_format(audioFormat);
if (m_params.videoCodingMode >= HAPI_CODING_MODE_FIELD &&
m_params.videoCodingMode <= HAPI_CODING_MODE_PAFF)
{
string desc;
switch (m_params.videoCodingMode)
{
case HAPI_CODING_MODE_FRAME:
desc = "Frame";
break;
case HAPI_CODING_MODE_FIELD:
desc = "Field";
break;
case HAPI_CODING_MODE_MBAFF:
desc = "MBAFF";
break;
case HAPI_CODING_MODE_PAFF:
desc = "PAFF";
break;
default:
desc = "Unknown";
}
if (interlaced)
{
INFOLOG << "Setting video coding mode to " << desc;
RegistryAccess::writeDword("VideoCodingMode", m_params.videoCodingMode);
}
else
INFOLOG << "Progressive video, "
<< "ignoring requested video coding mode " << desc;
}
else
DEBUGLOG << "Progressive video";
if (interlaced && m_params.flipFields)
FlipHDMIFields();
if(!m_encDev->setInputFormat(source, audioFormat,
width, height, interlaced,
vFreq, aspectRatio, audioSampleRate))
{
CRITLOG << "Cannot set video mode";
return false;
}
return true;
}
bool HauppaugeDev::valid_resolution(int width, int height)
{
if (width == 0 || height == 0)
return false;
if (width != 1920 && width != 1280 && width != 720)
return false;
if (height != 1080 && height != 720 && height != 480 && height != 576)
return false;
return true;
}
bool HauppaugeDev::init_cvbs(void)
{
if (m_video_initialized != HAPI_VIDEO_CAPTURE_SOURCE_CVBS)
{
m_rxDev->setInput(RXI_CVBS);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
m_rxDev->showInfo();
m_encDev->showInfo();
}
int idx;
for (idx = 0; idx < MAX_RETRY; ++idx)
{
if (m_rxDev->hasInputSignal())
break;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (idx == MAX_RETRY)
{
m_errmsg = "No input signal.";
CRITLOG << m_errmsg;
return false;
}
receiverOutputParams_t vp;
for (idx = 0; idx < MAX_RETRY; ++idx)
{
// getOutputParams can return garbage
if (m_rxDev->getOutputParams(&vp) &&
valid_resolution(vp.width, vp.height))
break;
INFOLOG << "Invalid Output Params, retrying.";
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (idx == MAX_RETRY)
{
m_errmsg = "Cannot determine video mode.";
CRITLOG << m_errmsg;
return false;
}
float aspectRatio = vp.aspectRatio;
#if 0
if (enforceAR != 0)
aspectRatio = enforceAR;
#endif
if (!set_input_format(ENCS_CVBS, vp.width, vp.height, vp.interlaced,
vp.vFreq, aspectRatio, 0))
return false;
m_rxDev->setOutputBusMode(RXOBM_656_10);
INFOLOG << "Composite video input initialized.";
m_video_initialized = HAPI_VIDEO_CAPTURE_SOURCE_CVBS;
return true;
}
bool HauppaugeDev::init_component(void)
{
if (m_video_initialized != HAPI_VIDEO_CAPTURE_SOURCE_COMPONENT)
{
m_rxDev->setInput(RXI_COMP);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
m_rxDev->showInfo();
m_encDev->showInfo();
}
int idx;
for (idx = 0; idx < MAX_RETRY; ++idx)
{
if (m_rxDev->hasInputSignal())
break;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (idx == MAX_RETRY)
{
m_errmsg = "No input signal.";
CRITLOG << m_errmsg;
return false;
}
receiverOutputParams_t vp;
for (idx = 0; idx < MAX_RETRY; ++idx)
{
// getOutputParams can return garbage
if (m_rxDev->getOutputParams(&vp) &&
valid_resolution(vp.width, vp.height))
break;
INFOLOG << "Invalid Output Params (" << vp.width << "x" << vp.height
<< "), retrying.";
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (idx == MAX_RETRY)
{
m_errmsg = "Cannot determine video mode.";
CRITLOG << m_errmsg;
return false;
}
float aspectRatio = vp.aspectRatio;
#if 0
if (enforceAR != 0)
aspectRatio = enforceAR;
#endif
if (!set_input_format(ENCS_COMP, vp.width, vp.height, vp.interlaced,
vp.vFreq, aspectRatio, 0))
return false;
if(((vp.height == 480) && (roundf(vp.vFreq) == 60) && vp.interlaced) ||
((vp.height == 576) && (roundf(vp.vFreq) == 50) && vp.interlaced))
m_rxDev->setOutputBusMode(RXOBM_656_10_DC);
else
m_rxDev->setOutputBusMode(RXOBM_422_10x2);
audio_CX2081x audio_CX2081x(*m_fx2);
audio_CX2081x.init();
INFOLOG << "Component video input initialized.";
m_video_initialized = HAPI_VIDEO_CAPTURE_SOURCE_COMPONENT;
return true;
}
bool HauppaugeDev::init_sdi(void)
{
m_errmsg = "SDI not supported.";
CRITLOG << m_errmsg;
return false;
}
bool HauppaugeDev::init_hdmi(void)
{
if (m_video_initialized != HAPI_VIDEO_CAPTURE_SOURCE_HDMI)
{
m_rxDev->setInput(RXI_HDMI);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
m_rxDev->showInfo();
m_encDev->showInfo();
}
int idx;
for (idx = 0; idx < MAX_RETRY; ++idx)
{
if (m_rxDev->hasInputSignal())
break;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (idx == MAX_RETRY)
{
m_errmsg = "No input signal.";
CRITLOG << m_errmsg;
return false;
}
receiverAudioParams_t ap;
ap.sampleRate = 0; // default
m_rxDev->getAudioParams(&ap);
int vic = m_rxDev->getHDMIFormat();
if (vic <= 0 || !m_encDev->setHDMIFormat(vic, ap.sampleRate))
{
receiverHDMIParams_t vp;
for (idx = 0; idx < MAX_RETRY; ++idx)
{
// getHDMIParams can return garbage
if (m_rxDev->getHDMIParams(&vp) &&
valid_resolution(vp.width, vp.height))
break;
INFOLOG << "Invalid Output Params, retrying.";
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
if (idx == MAX_RETRY)
{
m_errmsg = "Cannot determine video mode.";
CRITLOG << m_errmsg;
return false;
}
if (!set_input_format(ENCS_HDMI, vp.width, vp.height,
vp.interlaced, vp.vFreq,
16.0f/9, ap.sampleRate))
return false;
// there should not be any such modes in DMT... Or maybe
// bad InfoFrame?
m_rxDev->setOutputBusMode(RXOBM_422_10x2);
}
else
{
switch (vic)
{ // TODO: will be moved into device_t class soon
case 6:
case 7:
case 21:
case 22:
m_rxDev->setOutputBusMode(RXOBM_656_10_DC);
break;
default:
m_rxDev->setOutputBusMode(RXOBM_422_10x2);
}
}
#if 0
if (enforceAR != 0)
m_encDev->setHDMIAR(enforceAR);
#endif
INFOLOG << "HDMI video input initialized.";
m_video_initialized = HAPI_VIDEO_CAPTURE_SOURCE_HDMI;
return true;
}
bool HauppaugeDev::open_file(const string & file_name)
{
if (file_name == "stdout")
m_fd = 1;
else
m_fd = open(file_name.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (m_fd < 0)
{
m_errmsg = "Failed to open '" + file_name + "' :" + strerror(errno);
ERRORLOG << m_errmsg;
return false;
}
INFOLOG << "Output to '" << file_name << "'";
return true;
}
void HauppaugeDev::log_ports(void)
{
DEBUGLOG << hex
<< "\nPORT_A: [0x" << m_fx2->getPortDir(FX2_PORT_A)
<< "] 0x" << m_fx2->getPortState(FX2_PORT_A) << "\n\t"
<< "PORT_B: [0x" << m_fx2->getPortDir(FX2_PORT_B) << "] "
<< "0x" << m_fx2->getPortState(FX2_PORT_B) << "\n\t"
<< "PORT_C: [0x" << m_fx2->getPortDir(FX2_PORT_C) << "] "
<< "0x" << m_fx2->getPortState(FX2_PORT_C) << "\n\t"
<< "PORT_D: [0x" << m_fx2->getPortDir(FX2_PORT_D) << "] "
<< "0x" << m_fx2->getPortState(FX2_PORT_D) << "\n\t"
<< "PORT_E: [0x" << m_fx2->getPortDir(FX2_PORT_E) << "] "
<< "0x" << m_fx2->getPortState(FX2_PORT_E) << "\n\t"
<< "CTL_PORTS: [0x" << m_fx2->getPortDir(FX2_CTL_PORTS)
<< "] 0x" << m_fx2->getPortState(FX2_CTL_PORTS)
<< dec;
}
bool HauppaugeDev::Open(USBWrapper_t & usbio, bool ac3,
DataTransfer::callback_t * cb)
{
INFOLOG << "Opening Hauppauge USB device.";
if (m_params.verbose)
{
string desc;
usbio.USBDevDesc(desc);
DEBUGLOG << desc;
}
m_fx2 = new FX2Device_t(usbio);
int idx =0;
for ( ; !m_fx2->isUSBHighSpeed() && idx < MAX_RETRY; ++idx)
{
m_fx2->stopCPU();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
m_fx2->loadFirmware();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
m_fx2->startCPU();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
INFOLOG << "FX2 ready after " << idx << " tries.";
log_ports();
// reset CS5340, it will be set back by m_encDev->init()
m_fx2->setPortStateBits(FX2_CTL_PORTS, 0, 0x10);
m_encDev = new encoderDev_DXT_t(*m_fx2);
if (!m_encDev->init())
{
m_errmsg = "Encoder init failed.";
CRITLOG << m_errmsg;
return false;
}
DEBUGLOG << hex
<< "\nPORT_A: 0x" << m_fx2->getPortState(FX2_PORT_A)
<< "\nPORT_E: 0x" << m_fx2->getPortState(FX2_PORT_E)
<< dec;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
INFOLOG << "encDev ready";
m_rxDev = new receiver_ADV7842_t(*m_fx2);
if (ac3)
{
#if 1
m_rxDev->setEDID(edidHDPVR2_1080p6050_ac3_fix_rgb,
sizeof(edidHDPVR2_1080p6050_ac3_fix_rgb),
edidHDPVR2_1080p6050_ac3_fix_rgbSpaLoc);
INFOLOG << "Using 1080p6050 w/AC3 EDID.";
#else
m_rxDev->setEDID(edidHDPVR2_1080p6050_atmos,
sizeof(edidHDPVR2_1080p6050_ac3_fix_rgb),
edidHDPVR2_1080p6050_atmos_SPAloc);
INFOLOG << "Using 1080p6050 w/Atmos EDID.";
#endif
}
else
{
#if 0
// Original EDID
m_rxDev->setEDID(EDID_default, sizeof(EDID_default), EDID_default_SPAloc);
INFOLOG << "Using 1080p6050 stereo EDID.";
#else
// Updated EDID from Hauppauge
m_rxDev->setEDID(edidHDPVR2_1080p6050_pcm_fix_rgb,
sizeof(edidHDPVR2_1080p6050_pcm_fix_rgb),
edidHDPVR2_1080p6050_pcm_fix_rgbSpaLoc);
INFOLOG << "Using 1080p6050 stereo RGB EDID.";
#endif
}
m_rxDev->init();
INFOLOG << "rxDev ready";
if (!m_params.output.empty())
{
if (!open_file(m_params.output))
return false;
m_encDev->setOutputFD(m_fd);
}
if (cb)
m_encDev->setWriteCallback(*cb);
// audio_CX2081x _audio_CX2081x(*m_fx2);
INFOLOG << "Hauppauge USB device ready.";
return true;
}
void HauppaugeDev::Close(void)
{
if (m_rxDev)
{
delete m_rxDev;
m_rxDev = nullptr;
}
if (m_encDev)
{
delete m_encDev;
m_encDev = nullptr;
}
if (m_fx2)
{
delete m_fx2;
m_fx2 = nullptr;
}
}
bool HauppaugeDev::StartEncoding(void)
{
switch (m_params.videoInput)
{
case HAPI_VIDEO_CAPTURE_SOURCE_CVBS:
if (!init_cvbs())
return false;
break;
case HAPI_VIDEO_CAPTURE_SOURCE_COMPONENT:
if (!init_component())
return false;
break;
case HAPI_VIDEO_CAPTURE_SOURCE_SDI:
if (!init_sdi())
return false;
break;
case HAPI_VIDEO_CAPTURE_SOURCE_HDMI:
default:
if (!init_hdmi())
return false;
break;
}
if(!m_encDev->startCapture())
{
m_errmsg = "Encoder start capture failed.";
ERRORLOG << m_errmsg;
return false;
}
log_ports();
return true;
}
bool HauppaugeDev::StopEncoding(void)
{
if(!m_encDev->stopCapture())
{
m_errmsg = "Encoder stop capture failed.";
WARNLOG << m_errmsg;
return false;
}
log_ports();
return true;
}