Various tweaks to ATC Flight Sim hardware inputs/outputs.
This commit is contained in:
parent
0f8d8bbf05
commit
8e9f8674a6
4 changed files with 76 additions and 28 deletions
|
@ -136,11 +136,14 @@ bool FGATCInput::open() {
|
|||
init_config();
|
||||
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"Initializing ATC hardware, please wait ..." );
|
||||
"Initializing ATC input hardware, please wait ..." );
|
||||
|
||||
snprintf( analog_in_file, 256, "/proc/atc610x/board%d/analog_in", board );
|
||||
snprintf( radios_file, 256, "/proc/atc610x/board%d/radios", board );
|
||||
snprintf( switches_file, 256, "/proc/atc610x/board%d/switches", board );
|
||||
snprintf( analog_in_file, 256,
|
||||
"/proc/atcflightsim/board%d/analog_in", board );
|
||||
snprintf( radios_file, 256,
|
||||
"/proc/atcflightsim/board%d/radios", board );
|
||||
snprintf( switches_file, 256,
|
||||
"/proc/atcflightsim/board%d/switches", board );
|
||||
|
||||
#if defined( unix ) || defined( __CYGWIN__ )
|
||||
|
||||
|
@ -182,7 +185,7 @@ bool FGATCInput::open() {
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"Done initializing ATC hardware." );
|
||||
"Done initializing ATC input hardware." );
|
||||
|
||||
is_open = true;
|
||||
|
||||
|
@ -859,6 +862,10 @@ bool FGATCInput::close() {
|
|||
|
||||
#if defined( unix ) || defined( __CYGWIN__ )
|
||||
|
||||
if ( !is_open ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
result = ::close( analog_in_fd );
|
||||
|
|
|
@ -118,8 +118,8 @@ bool FGATCMain::open() {
|
|||
// Open the /proc files
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
string lock0_file = "/proc/atc610x/board0/lock";
|
||||
string lock1_file = "/proc/atc610x/board1/lock";
|
||||
string lock0_file = "/proc/atcflightsim/board0/lock";
|
||||
string lock1_file = "/proc/atcflightsim/board1/lock";
|
||||
|
||||
lock0_fd = ::open( lock0_file.c_str(), O_RDWR );
|
||||
if ( lock0_fd == -1 ) {
|
||||
|
@ -171,21 +171,35 @@ bool FGATCMain::open() {
|
|||
|
||||
|
||||
bool FGATCMain::process() {
|
||||
// Lock the hardware, skip if it's not ready yet
|
||||
if ( fgATCMainLock( lock0_fd ) <= 0 ) {
|
||||
return false;
|
||||
// cout << "Main::process()\n";
|
||||
|
||||
bool board0_locked = false;
|
||||
bool board1_locked = false;
|
||||
|
||||
if ( input0 != NULL || output0 != NULL ) {
|
||||
// Lock board0 if we have a configuration for it
|
||||
if ( fgATCMainLock( lock0_fd ) > 0 ) {
|
||||
board0_locked = true;
|
||||
}
|
||||
if ( fgATCMainLock( lock1_fd ) <= 0 ) {
|
||||
// lock0 will be locked here, so release before we return
|
||||
fgATCMainRelease( lock0_fd );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( input1 != NULL || output1 != NULL ) {
|
||||
// Lock board1 if we have a configuration for it
|
||||
if ( fgATCMainLock( lock1_fd ) > 0 ) {
|
||||
board1_locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
// cout << " locks: ";
|
||||
// if ( board0_locked ) { cout << "board0 "; }
|
||||
// if ( board1_locked ) { cout << "board1 "; }
|
||||
// cout << endl;
|
||||
|
||||
// process the ATC inputs
|
||||
if ( input0 != NULL ) {
|
||||
if ( input0 != NULL && board0_locked ) {
|
||||
input0->process();
|
||||
}
|
||||
if ( input1 != NULL ) {
|
||||
if ( input1 != NULL && board1_locked ) {
|
||||
input1->process();
|
||||
}
|
||||
|
||||
|
@ -204,23 +218,42 @@ bool FGATCMain::process() {
|
|||
}
|
||||
|
||||
// process the ATC outputs
|
||||
if ( output0 != NULL ) {
|
||||
if ( output0 != NULL && board0_locked ) {
|
||||
output0->process();
|
||||
}
|
||||
if ( output1 != NULL ) {
|
||||
if ( output1 != NULL && board1_locked ) {
|
||||
output1->process();
|
||||
}
|
||||
|
||||
if ( board0_locked ) {
|
||||
fgATCMainRelease( lock0_fd );
|
||||
}
|
||||
if ( board1_locked ) {
|
||||
fgATCMainRelease( lock1_fd );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool FGATCMain::close() {
|
||||
cout << "FGATCMain::close()" << endl;
|
||||
|
||||
int result;
|
||||
|
||||
if ( input0 != NULL ) {
|
||||
input0->close();
|
||||
}
|
||||
if ( input1 != NULL ) {
|
||||
input1->close();
|
||||
}
|
||||
if ( output0 != NULL ) {
|
||||
output0->close();
|
||||
}
|
||||
if ( output1 != NULL ) {
|
||||
output1->close();
|
||||
}
|
||||
|
||||
result = ::close( lock0_fd );
|
||||
if ( result == -1 ) {
|
||||
SG_LOG( SG_IO, SG_ALERT, "errno = " << errno );
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
{ }
|
||||
|
||||
~FGATCMain() {
|
||||
cout << "FGATCMain destructor" << endl;
|
||||
delete input0;
|
||||
delete input1;
|
||||
delete output0;
|
||||
|
|
|
@ -201,11 +201,14 @@ bool FGATCOutput::open( int lock_fd ) {
|
|||
init_config();
|
||||
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"Initializing ATC hardware, please wait ..." );
|
||||
"Initializing ATC output hardware, please wait ..." );
|
||||
|
||||
snprintf( lamps_file, 256, "/proc/atc610x/board%d/lamps", board );
|
||||
snprintf( radio_display_file, 256, "/proc/atc610x/board%d/radios", board );
|
||||
snprintf( stepper_file, 256, "/proc/atc610x/board%d/steppers", board );
|
||||
snprintf( lamps_file, 256,
|
||||
"/proc/atcflightsim/board%d/lamps", board );
|
||||
snprintf( radio_display_file, 256,
|
||||
"/proc/atcflightsim/board%d/radios", board );
|
||||
snprintf( stepper_file, 256,
|
||||
"/proc/atcflightsim/board%d/steppers", board );
|
||||
|
||||
#if defined( unix ) || defined( __CYGWIN__ )
|
||||
|
||||
|
@ -327,7 +330,7 @@ bool FGATCOutput::open( int lock_fd ) {
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"Done initializing ATC hardware." );
|
||||
"Done initializing ATC output hardware." );
|
||||
|
||||
is_open = true;
|
||||
|
||||
|
@ -402,7 +405,7 @@ static bool navcom1_has_power() {
|
|||
static SGPropertyNode *navcom1_bus_power
|
||||
= fgGetNode( "/systems/electrical/outputs/nav[0]", true );
|
||||
static SGPropertyNode *navcom1_power_btn
|
||||
= fgGetNode( "/instrumentation/comm[0]/inputs/power-btn", true );
|
||||
= fgGetNode( "/instrumentation/nav[0]/power-btn", true );
|
||||
|
||||
return (navcom1_bus_power->getDoubleValue() > 1.0)
|
||||
&& navcom1_power_btn->getBoolValue();
|
||||
|
@ -412,7 +415,7 @@ static bool navcom2_has_power() {
|
|||
static SGPropertyNode *navcom2_bus_power
|
||||
= fgGetNode( "/systems/electrical/outputs/nav[1]", true );
|
||||
static SGPropertyNode *navcom2_power_btn
|
||||
= fgGetNode( "/instrumentation/comm[1]/inputs/power-btn", true );
|
||||
= fgGetNode( "/instrumentation/nav[1]/power-btn", true );
|
||||
|
||||
return (navcom2_bus_power->getDoubleValue() > 1.0)
|
||||
&& navcom2_power_btn->getBoolValue();
|
||||
|
@ -915,6 +918,10 @@ bool FGATCOutput::close() {
|
|||
|
||||
#if defined( unix ) || defined( __CYGWIN__ )
|
||||
|
||||
if ( !is_open ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
result = ::close( lamps_fd );
|
||||
|
|
Loading…
Reference in a new issue