dcs-bios-arduino-library icon indicating copy to clipboard operation
dcs-bios-arduino-library copied to clipboard

Question: How to check DCS BIOS Connection state (up/down)

Open LeandreArnaud opened this issue 1 year ago • 1 comments

Hello guys ! Thanks you for your work here 👍 I would like to know if there is a way to check if DCS BIOS connection is up or down ? (up = currently live with the plane's data) I need it in one of my script to do something like this:

if (DcsBios::connectionIsUp() {
  // do whatever
} else {
  // whatever else
}

Sorry if it is already in the docs, I didn't find it.

LeandreArnaud avatar Jun 30 '24 21:06 LeandreArnaud

if you are using DCSBIOS_DEFAULT_SERIAL (witch is my case) I found a way to do it :

// when dcs bios is up
if (Serial.available()) {
  // do whatever
}

Does somebody have a solution for those who use DCSBIOS_IRQ_SERIAL ?

LeandreArnaud avatar Jul 05 '24 08:07 LeandreArnaud

I just use something like this

bool isDCSinmission = false; char airCravftname[24];

void onAcftNameChange((char* newValue)) { if(strsmp(newValue,"") isDCSinmission = true; else isDCSinmission = false; strcpy(newValue,airCraftname); } DcsBios::StringBuffer<24> AcftNameBuffer(0x0000, onAcftNameChange);

kbastronomics avatar Aug 02 '24 10:08 kbastronomics

I think this is a good solution. Thanks @kbastronomics :)

LeandreArnaud avatar Aug 03 '24 13:08 LeandreArnaud

for those who want a corrected and simplified version:

bool isDCSinmission = false;

[...]

void onAircraftNameChange(char* newValue) {
  if(strcmp(newValue,""))
    isDCSinmission = true;
  else
    isDCSinmission = false;
}
DcsBios::StringBuffer<24> AcftNameBuffer(0x0000, onAircraftNameChange);

LeandreArnaud avatar Aug 17 '24 22:08 LeandreArnaud