Jump to content

Recommended Posts

Posted (edited)

Hi All,

 

I have just started a project to build a switch box for DCS.

 

After purchasing the Arduino Mega, I am able to upload a script using port 3 such as the "Blink" script and works fine.

 

I have also connected a button that can be held to on then released to off and uploaded a script to use that button to turn on and off the light on the Mega board (same as used in the "Blink script". This shows that I can communicate with the Mega.

 

After Downloading the DSC Bios software. I get the following warning when I try to connect the mega to DCS BIOS using connect-serial-port.cdm;

 

WARNING: Couldn't compute FAST_CWD pointer. Please report this problem to

the public mailing list cygwin@cygwin.com

 

This warning starts with;

5 [main] socat 13340 find_fast_cwd:

 

Yet the value in this line change.

 

Dcs-beta is running at the time I try to connect(not on pause) and the mega is plugged in.

 

I have trying changing ports, changing baud rates and even taken out the tcp line in the BIOCong.lau (as I found some of these fixes online) to no avail.

 

I am running windows 10 v 1903 and have looked everywhere online and on youtube for the fix to again, no avail.

 

Unfortunately, This sort of thing is not my area of expertise but trying very hard to learn quickly.

 

Any detailed help would be greatly appreciated.

Edited by Mark McCosker
Posted (edited)

Thanks Hans,

 

 

/*

Tell DCS-BIOS to use a serial connection and use interrupt-driven

communication. The main program will be interrupted to prioritize

processing incoming data.

 

This should work on any Arduino that has an ATMega328 controller

(Uno, Pro Mini, many others).

*/

#define DCSBIOS_IRQ_SERIAL

 

#include "DcsBios.h"

 

/* paste code snippets from the reference documentation here */

 

DcsBios::Switch2Pos lightsTestSw("LIGHTS_TEST_SW", 22);

 

void setup() {

DcsBios::setup();

}

 

void loop() {

DcsBios::loop();

}

 

Just using this as a start.

Edited by Mark McCosker
Posted

Hi Smill,

 

As I stated in the first message, this ones works fine;

 

/*

Blink

 

Turns an LED on for one second, then off for one second, repeatedly.

 

Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO

it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to

the correct LED pin independent of which board is used.

If you want to know what pin the on-board LED is connected to on your Arduino

model, check the Technical Specs of your board at:

https://www.arduino.cc/en/Main/Products

 

modified 8 May 2014

by Scott Fitzgerald

modified 2 Sep 2016

by Arturo Guadalupi

modified 8 Sep 2016

by Colby Newman

 

This example code is in the public domain.

 

http://www.arduino.cc/en/Tutorial/Blink

*/

 

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin LED_BUILTIN as an output.

pinMode(LED_BUILTIN, OUTPUT);

}

 

// the loop function runs over and over again forever

void loop() {

digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

}

 

Which means that I can communicate to the board. The issue is that the board will not communicate to the computer.

Posted

Alright. First off all your sketch works, I just tested communication on my machine running your code

/*
Tell DCS-BIOS to use a serial connection and use interrupt-driven
communication. The main program will be interrupted to prioritize
processing incoming data.

This should work on any Arduino that has an ATMega328 controller
(Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"

/* paste code snippets from the reference documentation here */

DcsBios::Switch2Pos lightsTestSw("LIGHTS_TEST_SW", 22);

void setup() {
DcsBios::setup();
}

void loop() {
DcsBios::loop();
}

I only have the A-10C and it doesn't looks like it's for that airframe which means I can't test functionality of the switch.

 

What aircraft is the code for by the way? In it's 'raw' state DCS-BIOS is specific to one airframe, which means that if you load the code on the Arduino for the F-14B then nothing happens in the A-10C. However the communication should still work as I'll illustrate below.

 

I am a little puzzled as to why you get

5 [main] socat 13340 find_fast_cwd
as mine says 1 [main]. But unfortunately I am unable to tell you what that means simply because I don't know.

 

Anyway please check that you OB saved games folder/DCS.openbeta/script looks at least like this;

qz9AfCr.png

 

You may have other stuff in there. I do but removed it for the purpose of this picture.

 

Also check if you get the waterfall of text when DCS is running;

 

If you do then you have communications from DCS to the connect-serial-port program :thumbup:

 

If you do not get the waterfall of text then your export.lua may be missing this line;

dofile(lfs.writedir()..[[scriptsDCS-BIOSBIOS.lua]])

 

Next without DCS running or DCS paused you try and flip the switch to get a result similar to this;

 

 

If you do get the text lines changing when you flip the switch then the communication between the Arduino and connect-serial-port program is working :thumbup:

 

If you do not get similar result then check your wiring on your switch. If it is has three pins for a two position switch then you may have used the incorrect ones. A multimeter set for Ohms can quickly rule this out.

 

Also confirm that you are using GND and pin22 similar to this

uno1.jpg

 

All the used pins are being pulled high in DCS-BIOS. You ground the pin to trigger the input.

 

One way to check communication from DCS via onnect-serial-port program to the Arduino is to modify your code to include Pin13 as an LED e.g.

 

DcsBios::LED masterCaution(0x1012, 0x0800, 13); // NOTE THIS IS FOR THE A-10C!!

 

This won't work for you as it looks like your code is not for the A-10C, however you get the idea as to use the onboard LED to check communication from DCS via connect-serial-port program to the Arduino. You just need to find the code string for your particular airframe.

 

With regard to the Baud rate I heard this recently also in another post. I am pretty sure you can't change the Baud rate for the Arduino using DCS-BIOS. It's default set to 250000, but granted I can be mistaken.

 

I haven't modified my BIOSConfig.lua file so don't think you need to either. I normally start connect-serial-port program prior to starting DCS but I don't think that should matter at all.

 

Cheers

Hans

Posted

Hi Hans,

 

Thanks,

 

I am using the F-18.

 

Script file looks like

 

attachment.php?attachmentid=214590&stc=1&d=1564577172

 

I dont get the waterfall which is what I am trying to do. I get the error message

 

attachment.php?attachmentid=214591&stc=1&d=1564577402

 

I am using the Mega Board and not the uno, yet I can get the led program to work (using the led on the board) the issue is that the connect-serial-port program will not work.

Script.PNG.7297ba5f43e98943b2789e51f5e053dd.PNG

240676339_comerror.PNG.4474f7250c628c62ab0cf6d55cc8217e.PNG

Posted

Hi Mark

Some other question:

Is DCS running (unpaused) when you start the connect-serial-port?

When you push the button, which command do you see on the serial monitor (on the arduino app / tools)

Posted

 

I dont get the waterfall which is what I am trying to do. I get the error message

 

I am using the Mega Board and not the uno, yet I can get the led program to work (using the led on the board) the issue is that the connect-serial-port program will not work.

Don't worry about the error code when starting connect-serial-port program. It does that and doesn't mean anything for this issue. Mine does it too.

 

Can you attach your Export.lua file for us?

 

Cheers

Hans

Posted

Hi Hans, sure;

 

local dcsSr=require('lfs');dofile(dcsSr.writedir()..[[scripts\DCS-SimpleRadioStandalone.lua]])

 

local Tacviewlfs=require('lfs');dofile(Tacviewlfs.writedir()..'Scripts/TacviewGameExport.lua')

 

dofile(lfs.writedir()..[[scripts\DCS-BIOS\BIOS.lua]])

Posted (edited)

With regard to serial-to-com-port error I found this on 476th vFG Discord channel;

 

I found the issue described here: https://github.com/dcs-bios/dcs-bios/issues/108

At the bottom there, there's a link to a fork which contains a new version of SOCAT (https://github.com/PrestaMath/dcs-bios). I just downloaded the SOCAT folder from there and replaced the folder in my original installation of DCS BIOS.

 

I just tried that fix and it seem do have done the trick. I rename my original Socat folder to _Socat and then unpacked this folder where the original Socat folder was;

https://drive.google.com/file/d/1Qw1FnZcXTwMHHwW0xc4Jv1kmLF8MEuCz/view?usp=sharing

 

Left everything else the way it was and now the error message is gone.

 

Credit for the fix goes to PrestaMath.

 

Cheers

Hans

Edited by Hansolo
Posted

Hi Hans (and Presta)

 

Little closer now as the error has gone yet the waterfall does not flow and just get a cursor after the countdown.

 

Text does appear when I press the button;

 

attachment.php?attachmentid=214596&stc=1&d=1564583061

 

And the button does not work in the cockpit.

697604095_Connectionofbutton.PNG.6815966c745a0b335c81d9d815703283.PNG

Posted

Ok Guys,

 

I would just like to say thanks to Hans, Presta, Muts and smill for your comments and help.

 

This issue has now been worked out as I looked in the DCS logs and found an issue where some of the dcs bios such as the Lib, doc, Bios.lau and Biosconfig files for the f-18 were located.

 

In short they were located in the dcs/scripts/dcs-bios/scripts/dcs-bios

 

After looking at the log I noticed that dcs was looking in;

user/savedgames/dcs/script

 

I them moved all the files from dcs/scripts/dcs-bios/scripts/dcs-bios and placed them in

user/savedgames/dcs/script

 

The waterflow is now flowing and my button works in the F-18 cockpit.

 

Again a great big thank you to all that helped.

Posted

Glad you got it sorted, I was going to pitch in last night with a "have you read the manual?" but thought that was a bit rude.

 

However, for anyone else having trouble getting dcs-bios working there is an incredibly easy to follow set of instructions on the main dcs-bios page here

 

https://github.com/dcs-bios/dcs-bios/blob/master/Scripts/DCS-BIOS/doc/userguide.adoc

 

Step 1.3 and 1.4 specifically mention putting the scripts in your savegame folder.

Intel i7 13700K @ 5.3 GHz / ASUS TUF Gaming Z490-Plus / 64 Gb G.Skill DDR4-3600 / RTX 4090 / 2TB Kingston KC3000 NVME / Win 10 x64 Pro / Pimax Crystal / WINWING F/A-18 HOTAS

A-10C, AJS-37, AV-8B, F-4E, F-5E, F-14, F-15E, F-16, F/A-18C, F-86F, FC3, Christen Eagle 2, FW190D-9, Mosquito, P-47D, P-51D, Spitfire, AH-64D, KA-50, UH-1H

Combined Arms, WWII Asset Pack, China Assets Pack, Super Carrier, Falklands Assets

Nevada, Normandy, Persian Gulf, The Channel, Syria, Mariana Islands, South Atlantic, Sinai, Kola, Afghanistan

Posted

Congrats, now it gets fun.

 

BlackLibrary spent much time helping me through PM's and it was a great feeling for me to finally see an edit I did show up in control reference html. A few more weeks and I can get building again. Best of luck with your pit.

  • 2 weeks later...
Posted

Hi Guys,

 

Next issue.

 

Keypad Script.

 

The current DCS-Bios Script is;

 

DcsBios::Switch2Pos ampcdPb01("AMPCD_PB_01", Pin);

 

Given that I am using a 3x4 matrix key pad, is there a script that can be used in place of this?

 

I have looked at some of the other threads and watched the clip on how the matrix works and can understand that.

 

The keypad I an using is;

 

https://www.jaycar.com.au/12-key-numeric-keypad/p/SP0770

 

and have the pinout in ports 2-8 in the Arduino mega boards.

 

Any help will be great appreciated.

 

Regards

Mark

Posted

Thanks Hans,

 

Do I place the script for this matrix within;

 

/*

Tell DCS-BIOS to use a serial connection and use interrupt-driven

communication. The main program will be interrupted to prioritize

processing incoming data.

 

This should work on any Arduino that has an ATMega328 controller

(Uno, Pro Mini, many others).

*/

#define DCSBIOS_IRQ_SERIAL

 

#include "DcsBios.h"

 

/* paste code snippets from the reference documentation here */

DcsBios::Switch2Pos fcsResetBtn("FCS_RESET_BTN", A1);

DcsBios::Switch2Pos lGenSw("L_GEN_SW", 24);

DcsBios::Switch3Pos batterySw("BATTERY_SW",26, 28);

DcsBios::RotaryEncoder radaltHeight("RADALT_HEIGHT", "-3200", "+3200", A1, A3);

 

 

void setup() {

DcsBios::setup();

}

 

void loop() {

DcsBios::loop();

}

 

Or can I enter the script below my current script?

Posted

Thanks again Hans,

 

You have done it again and all works fine.

 

Thanks so much.

 

For others, my script is here;

 

/*

Tell DCS-BIOS to use a serial connection and use interrupt-driven

communication. The main program will be interrupted to prioritize

processing incoming data.

 

This should work on any Arduino that has an ATMega328 controller

(Uno, Pro Mini, many others).

*/

#define DCSBIOS_IRQ_SERIAL

#define TXENABLE_PIN 2

#include <Keypad.h>

 

#include "DcsBios.h"

 

/* paste code snippets from the reference documentation here */

DcsBios::Switch2Pos fcsResetBtn("FCS_RESET_BTN", A1);

DcsBios::Switch2Pos lGenSw("L_GEN_SW", 24);

DcsBios::Switch3Pos batterySw("BATTERY_SW",26, 28);

DcsBios::RotaryEncoder radaltHeight("RADALT_HEIGHT", "-3200", "+3200", A1, A3);

const byte ROWS = 4; //four rows

const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {

{'1','2','3'},

{'4','5','6'},

{'7','8','9'},

{'*','0','#'},

};

byte rowPins[ROWS] = {3, 8, 7, 5}; //connect to the row pinouts of the keypad

byte colPins[COLS] = {4, 2, 6}; //connect to the column pinouts of the keypad

 

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

 

 

void setup() {

DcsBios::setup();

keypad.addEventListener(keypadEvent); // Add an event listener.

keypad.setHoldTime(100); // Default is 1000mS

keypad.setDebounceTime(50); // Default is 50mS

}

 

void loop() {

DcsBios::loop();

char key = keypad.getKey();

}

void keypadEvent(KeypadEvent KEY){

switch (keypad.getState()) { // gives PRESSED, HOLD or RELEASED

case PRESSED:

switch(KEY) {

// UFC

case '1': sendDcsBiosMessage("UFC_1", "1"); break;

case '2': sendDcsBiosMessage("UFC_2", "1"); break;

case '3': sendDcsBiosMessage("UFC_3", "1"); break;

case '4': sendDcsBiosMessage("UFC_4", "1"); break;

case '5': sendDcsBiosMessage("UFC_5", "1"); break;

 

case '6': sendDcsBiosMessage("UFC_6", "1"); break;

case '7': sendDcsBiosMessage("UFC_7", "1"); break;

case '8': sendDcsBiosMessage("UFC_8", "1"); break;

case '9': sendDcsBiosMessage("UFC_9", "1"); break;

case '0': sendDcsBiosMessage("UFC_0", "1"); break;

case '*': sendDcsBiosMessage("UFC_CLR", "1"); break;

case '#': sendDcsBiosMessage("UFC_ENT", "1"); break;

 

 

}}

switch (keypad.getState()){ // gives PRESSED, HOLD or RELEASED

case RELEASED: // LMFD

switch(KEY) { // Released OSBs or Neutral Rockers signal is sent

case '1': sendDcsBiosMessage("UFC_1", "0"); break;

case '2': sendDcsBiosMessage("UFC_2", "0"); break;

case '3': sendDcsBiosMessage("UFC_3", "0"); break;

case '4': sendDcsBiosMessage("UFC_4", "0"); break;

case '5': sendDcsBiosMessage("UFC_5", "0"); break;

 

case '6': sendDcsBiosMessage("UFC_6", "0"); break;

case '7': sendDcsBiosMessage("UFC_7", "0"); break;

case '8': sendDcsBiosMessage("UFC_8", "0"); break;

case '9': sendDcsBiosMessage("UFC_9", "0"); break;

case '0': sendDcsBiosMessage("UFC_0", "0"); break;

case '*': sendDcsBiosMessage("UFC_CLR", "0"); break;

case '#': sendDcsBiosMessage("UFC_ENT", "0"); break;

 

}}

}

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...