cwIo.cpp : Add 'enableFl' to each IO sub-system.

This commit is contained in:
kevin 2024-03-07 11:44:48 -05:00
parent 72701c79af
commit 77695db9ad

View File

@ -503,6 +503,7 @@ namespace cw
const object_t* port_array = nullptr; const object_t* port_array = nullptr;
unsigned pollPeriodMs = 50; unsigned pollPeriodMs = 50;
unsigned recvBufByteN = 512; unsigned recvBufByteN = 512;
bool enableFl = false;
// get the serial port list node // get the serial port list node
if((cfg = c->find("serial")) == nullptr) if((cfg = c->find("serial")) == nullptr)
@ -512,7 +513,8 @@ namespace cw
} }
// the serial header values // the serial header values
if((rc = cfg->getv("pollPeriodMs", pollPeriodMs, if((rc = cfg->getv("enableFl",enableFl,
"pollPeriodMs", pollPeriodMs,
"recvBufByteN", recvBufByteN, "recvBufByteN", recvBufByteN,
"array", port_array)) != kOkRC ) "array", port_array)) != kOkRC )
{ {
@ -521,6 +523,13 @@ namespace cw
} }
p->serialN = port_array->child_count(); p->serialN = port_array->child_count();
if( enableFl==false || p->serialN == 0 )
{
cwLogInfo("Serial port sub-system disabled.");
goto errLabel;
}
p->serialA = mem::allocZ<serialPort_t>(p->serialN); p->serialA = mem::allocZ<serialPort_t>(p->serialN);
@ -634,6 +643,7 @@ namespace cw
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
const object_t* cfg = nullptr; const object_t* cfg = nullptr;
bool enableFl = false;
// get the MIDI port cfg // get the MIDI port cfg
if((cfg = c->find("midi")) == nullptr) if((cfg = c->find("midi")) == nullptr)
@ -642,14 +652,19 @@ namespace cw
return kOkRC; return kOkRC;
} }
if((rc = cfg->getv("asyncFl", p->midiAsyncFl )) != kOkRC ) if((rc = cfg->getv( "enableFl", enableFl,
"asyncFl", p->midiAsyncFl )) != kOkRC )
{ {
rc = cwLogError(kSyntaxErrorRC,"MIDI configuration parse failed."); rc = cwLogError(kSyntaxErrorRC,"MIDI configuration parse failed.");
} }
if( !enableFl )
cwLogInfo("MIDI device system disabled.");
else
{
if((rc = create(p->midiH, _midiCallback, p, cfg)) != kOkRC ) if((rc = create(p->midiH, _midiCallback, p, cfg)) != kOkRC )
return rc; return rc;
}
return rc; return rc;
} }
@ -762,6 +777,7 @@ namespace cw
unsigned maxSocketCnt = 10; unsigned maxSocketCnt = 10;
unsigned recvBufByteCnt = 4096; unsigned recvBufByteCnt = 4096;
const object_t* socketL = nullptr; const object_t* socketL = nullptr;
bool enableFl = false;
// get the socket configuration node // get the socket configuration node
if((node = cfg->find("socket")) == nullptr ) if((node = cfg->find("socket")) == nullptr )
@ -772,6 +788,7 @@ namespace cw
// get the required socket arguments // get the required socket arguments
if(( rc = node->getv( if(( rc = node->getv(
"enableFl", enableFl,
"maxSocketCnt", maxSocketCnt, "maxSocketCnt", maxSocketCnt,
"recvBufByteCnt", recvBufByteCnt, "recvBufByteCnt", recvBufByteCnt,
"threadTimeOutMs", p->sockThreadTimeOutMs, "threadTimeOutMs", p->sockThreadTimeOutMs,
@ -786,6 +803,13 @@ namespace cw
// create the socket control array // create the socket control array
p->sockN = socketL->child_count(); p->sockN = socketL->child_count();
if( enableFl == false || p->sockN == 0 )
{
cwLogInfo("Socket system disabled.");
goto errLabel;
}
p->sockA = mem::allocZ<socket_t>(p->sockN); p->sockA = mem::allocZ<socket_t>(p->sockN);
// create the socket manager // create the socket manager
@ -2023,8 +2047,27 @@ namespace cw
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
audio::device::driver_t* audioDrv = nullptr; audio::device::driver_t* audioDrv = nullptr;
const object_t* cfg; const object_t* cfg = nullptr;
bool enableFl = false;
// get the audio port node
if((cfg = c->find("audio")) == nullptr )
{
cwLogWarning("No 'audio' configuration node.");
goto errLabel;
}
if((rc = cfg->getv("enableFl",enableFl)) != kOkRC )
{
rc = cwLogError(rc,"Error reading top level audio cfg.");
goto errLabel;
}
if( !enableFl )
{
cwLogInfo("Audio sub-system disabled.");
goto errLabel;
}
// initialize the audio device interface // initialize the audio device interface
if((rc = audio::device::create(p->audioH)) != kOkRC ) if((rc = audio::device::create(p->audioH)) != kOkRC )
@ -2047,14 +2090,6 @@ namespace cw
goto errLabel; goto errLabel;
} }
// get the audio port node
if((cfg = c->find("audio")) == nullptr )
{
cwLogWarning("No 'audio' configuration node.");
}
else
{
// create the audio device sub-system - audio device files must be created // create the audio device sub-system - audio device files must be created
// before they can be referenced in _audioParseConfig(). // before they can be referenced in _audioParseConfig().
if((rc = _audioCreateDeviceFiles(p,cfg,audioDrv)) != kOkRC ) if((rc = _audioCreateDeviceFiles(p,cfg,audioDrv)) != kOkRC )
@ -2079,7 +2114,6 @@ namespace cw
} }
audio::device::report( p->audioH ); audio::device::report( p->audioH );
}
errLabel: errLabel:
return rc; return rc;
@ -2113,6 +2147,7 @@ namespace cw
const char* uiCfgLabel = "ui"; const char* uiCfgLabel = "ui";
ui::ws::args_t args = {}; ui::ws::args_t args = {};
const object_t* ui_cfg = nullptr; const object_t* ui_cfg = nullptr;
bool enableFl = false;
// Duplicate the application id map // Duplicate the application id map
if( mapN > 0 ) if( mapN > 0 )
@ -2131,12 +2166,19 @@ namespace cw
if((ui_cfg = c->find(uiCfgLabel)) != nullptr ) if((ui_cfg = c->find(uiCfgLabel)) != nullptr )
{ {
if((rc = ui_cfg->getv("asyncFl",p->uiAsyncFl)) != kOkRC ) if((rc = ui_cfg->getv("enableFl",enableFl,
"asyncFl",p->uiAsyncFl)) != kOkRC )
{ {
rc = cwLogError(rc,"UI configuration parse failed."); rc = cwLogError(rc,"UI configuration parse failed.");
goto errLabel; goto errLabel;
} }
if( !enableFl )
{
cwLogInfo("UI sub-system disabled.");
goto errLabel;
}
// parse the ui // parse the ui
if((rc = ui::ws::parseArgs( *c, args, uiCfgLabel )) == kOkRC ) if((rc = ui::ws::parseArgs( *c, args, uiCfgLabel )) == kOkRC )
{ {