Skip to content

DCS‐BIOS in a nutshell

Charlie edited this page Oct 13, 2023 · 15 revisions

Terminology

  • DCS-BIOS Control, a physical cockpit control defined within DCS-BIOS. E.g. Gear Lever GEAR_LEVER.
  • DCS-BIOS Module, all controls pertaining to a DCS aircraft and all defined inside a lua file. E.g. P-51D.lua

Sending

DCS-BIOS exports (sends) cockpit data from Digital Combat Simulator (DCS) over a UDP socket.

  • ushort data, stating the position for a switch, dial, knob
  • string data, can be frequencies 127.000 or other information from a cockpit display e.g. Waypoint : 1

Receiving

DCS-BIOS listens for commands from the user on a TCP socket. Depending on command type the syntax differs.

  • FLAPS_SWITCH INC\n This is a command to increase the position of FLAPS_SWITCH
  • COMPASS_BRIGHTNESS 30000\n Set the position of COMPASS_BRIGHTNESS to 30000.
  • COMPASS_BRIGHTNESS -3000\n Decrease COMPASS_BRIGHTNESS by 3000.
  • and so on, an aircraft has many different controls.

Encoding

ushort data

Data is encoded so that as many controls as possible are included in the same byte.

Therefore each control has :

  • address
  • shift value
  • mask value

so that it can be read from the byte stream in the receiving end.

string data

String data starts with an address and address increases for each character. The data must be converted into a string in the receiving end. It is send in little endian mode. DCS-BIOS sends fixed width strings.

DCS-BIOS Control

This is a cockpit control defined within DCS-BIOS. All controls have some general information but they differ depending on what type of physical control they represent. It can also be a string that is displayed in a cockpit control. The control's unique identifier e.g. FLAPS_SWITCH is used when sending commands to DCS-BIOS but it is not broadcast over the socket to the client. Instead the client must listen for the control's address.

Aircraft Lua Files

Each aircraft (airframe) has a lua file containing definitions of all the DCS-BIOS controls. The contents of the file creates a DCS-BIOS Module. These have been made by someone digging through the DCS aircraft and finding out all the proper arguments for manipulating the cockpit controls. It takes some time to map all these controls.

P_51D:defineToggleSwitch("GEN", 14, 3003, 102, "Right Switch Panel", "Generator")
P_51D:defineToggleSwitch("BAT", 14, 3001, 103, "Right Switch Panel", "Battery")
P_51D:defineToggleSwitch("GUN_HEAT", 14, 3019, 104, "Right Switch Panel", "Gun Heating")
P_51D:defineToggleSwitch("PITOT", 14, 3005, 105, "Right Switch Panel", "Pitot Heating")
P_51D:define3PosTumb("WING_LTS", 14, 3008, 106, "Right Switch Panel", "Wing Position Lights Bright/Off/Dim")
P_51D:define3PosTumb("TAIL_LTS", 14, 3009, 107, "Right Switch Panel", "Tail Position Lights Bright/Off/Dim")
P_51D:define3PosTumb("RED_REC_LT", 14, 3021, 108, "Right Switch Panel", "Red Recognition Light Key/Off/Steady")
P_51D:define3PosTumb("GRN_REC_LT", 14, 3022, 109, "Right Switch Panel", "Green Recognition Light Key/Off/Steady")
P_51D:define3PosTumb("AMBR_REC_LT", 14, 3023, 110, "Right Switch Panel", "Amber Recognition Light Key/Off/Steady")
P_51D:definePushButton("REC_LTS_KEY", 14, 3024, 111, "Right Switch Panel", "Recognition Lights Key")
P_51D:definePushButton("CIRC_PRO_RST", 14, 3025, 112, "Right Switch Panel", "Circuit Protectors Reset")
P_51D:definePotentiometer("RT_FLRES_LT", 14, 3007, 100, { 0, 1 }, "Right Switch Panel", "Right Fluorescent Light")
P_51D:defineToggleSwitch("GUNSIGHT_ON_OFF", 1, 3004, 41, "K14 Gunsight", "Gunsight On/Off")
P_51D:defineToggleSwitch("RET_MASK_LVR", 1, 3006, 39, "K14 Gunsight", "Fixed Reticle Mask Lever")

Aircraft JSON Files

These are auto-generated from the lua files each time a mission starts. They are for communicating with DCS-BIOS.

  • input interfaces, which differs depending of whether it is e.g. a dial or a button
  • output information

This JSON snippet corresponds to the "GEN" (Generator) definition in the above lua snippet.

"GEN": {
                      "category": "Right Switch Panel",
                  "control_type": "selector",
                   "description": "Generator",
                    "identifier": "GEN",
                        "inputs": [ {
                                      "description": "switch to previous or next state",
                                        "interface": "fixed_step"
                                  }, {
                                      "description": "set position",
                                        "interface": "set_state",
                                        "max_value": 1
                                  }, {
                                         "argument": "TOGGLE",
                                      "description": "Toggle switch state",
                                        "interface": "action"
                                  } ],
           "momentary_positions": "none",
                       "outputs": [ {
                                                            "address": 20480,
                                                 "address_identifier": "P_51D_GEN_A",
                                            "address_mask_identifier": "P_51D_GEN_AM",
                                      "address_mask_shift_identifier": "P_51D_GEN",
                                                        "description": "selector position",
                                                               "mask": 1,
                                                          "max_value": 1,
                                                           "shift_by": 0,
                                                             "suffix": "",
                                                               "type": "integer"
                                  } ],
              "physical_variant": "toggle_switch"
       },