Skip to content

Commit

Permalink
Add improved connect-serial-port.cmd script (ask for COM port, add de…
Browse files Browse the repository at this point in the history
…lay before sending data)

The new version of the connect-serial-port.cmd script brings two changes:
1) By default, it will ask for a COM port number to connect to
2) It will wait a few seconds between configuring the port and starting
   socat to avoid an issue where some Mega 2560 boards would get stuck
   in the bootloader and never start the main program
  • Loading branch information
jboecker committed Jun 16, 2017
1 parent a85c2d8 commit d33fcc9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
31 changes: 17 additions & 14 deletions Scripts/DCS-BIOS/doc/userguide.adoc
Expand Up @@ -327,27 +327,32 @@ When it disappears the upload is complete.

==== Step 6: Test your new panel

DCS-BIOS comes with a script that automatically connects a serial port to DCS.
DCS-BIOS comes with a script that connects a serial port to DCS.
This serial port is the means by which your PC and your Arduino Board communicate.
To initiated this connection you need specify the COM Port to use.
To initiate this connection you need specify the COM Port to use.
You will use the same COM Port that the Arduino IDE used to program your board.
To begin...

* Double-click `connect-serial-port.cmd` which is in the DCS-BIOS folder you previously downloaded.
A console window should pop up. Type in the number of the COM port that your Arduino board is connected to and press Return.
Leave the console window open.

*You can now start DCS and try your new panel in action!*


If you don't want to type in the COM port number every time you run the script, you can edit the script
(or a copy of it) so it always uses the same port:

* Start Notepad++.
Open the`connect-serial-port.cmd` file which is in the DCS-BIOS folder you previously downloaded.
With the file on the screen the second line will read as:
Open the `connect-serial-port.cmd` file which is in the DCS-BIOS folder you previously downloaded.
Near the top of the file, you will see a line that says `set COMPORT=ASK`. Replace `ASK` with the number of the COM port you wish this script to use.
For example, to use COM5, the line should look like this:
----
set COMPORT=5
----
* Replace the number 5 with the COM port number that your Arduino board is connected to.

* Save the file and close Notepad++.

* Double-click `connect-serial-port.cmd`.
A console window should pop up.
Leave it open.

*You can now start DCS and try your new panel in action!*
WARNING: If you make a copy of the script, you need to place it in the same folder as the original. Otherwise it will not find the `socat` executable.

==== Summary
You can make any panel you like using this template file.
Expand All @@ -362,12 +367,10 @@ You can make any panel you like using this template file.

* Begin using your switches and LED's in your DCS aircraft.

*It can't get much easier then that.*

==== What this Guide *IS NOT*
If your intent is to include displays and/or analog gauges with your panels you will need to have additional programming knowledge.
There are displays in the aircraft that could incorporate LCD displays, LED displays or OLED displays.
In addition there are analog Gauges in the cockpit that could be built using stepper motors, servos's or even air core motors.
In addition there are analog Gauges in the cockpit that could be built using stepper motors, servos or even air core motors.
With such a wide choice of components available, it really is beyond the scope of this particular document to provide instruction on every possible solution.


Expand Down
27 changes: 23 additions & 4 deletions connect-serial-port.cmd
@@ -1,11 +1,30 @@
REM Specify the number of the COM port your Arduino is connected to:
@echo off
REM Specify the COM port number to connect to in the following line.
REM If set to the default value of ASK, the script will ask you to type it in each time.
set COMPORT=ASK

set COMPORT=5
REM Set PROTOCOL to "TCP" if UDP does not work for you. When using TCP,
REM you have to start the script after you have started the mission and the simulation
REM has been unpaused, otherwise the connection will fail ("Connection refused").
set PROTOCOL=UDP

set VERBOSE=-v
set MODE_OUTPUT_REDIR=CON
if "%1" == "/Q" (
set VERBOSE=
set MODE_OUTPUT_REDIR=NUL
shift
)

if not "%1" == "" set COMPORT=%1
if "%COMPORT%" == "ASK" set /p COMPORT=Enter a COM Port Number:

set /A TTYNUM=%COMPORT%-1
mode COM%COMPORT% BAUD=250000 PARITY=N DATA=8 STOP=1 TO=off DTR=on
socat\socat -v UDP4-RECV:5010,ip-add-membership=239.255.50.10:127.0.0.1,reuseaddr!!udp-sendto:localhost:7778 /dev/ttyS%TTYNUM%
if "%MODE_OUTPUT_REDIR%" == "NUL" echo Connecting to COM port %COMPORT%
mode COM%COMPORT% BAUD=250000 PARITY=N DATA=8 STOP=1 TO=off DTR=off > %MODE_OUTPUT_REDIR%
timeout 2
if "%PROTOCOL%" == "UDP" socat\socat %VERBOSE% UDP4-RECV:5010,ip-add-membership=239.255.50.10:0.0.0.0,reuseaddr!!udp-sendto:localhost:7778 /dev/ttyS%TTYNUM%
if "%PROTOCOL%" == "TCP" socat\socat %VERBOSE% TCP4-CONNECT:127.0.0.1:7778 /dev/ttyS%TTYNUM%


pause
5 changes: 5 additions & 0 deletions multiple-com-ports.cmd
@@ -0,0 +1,5 @@
@echo off
REM The COMPORTS variable should be set to a space-separated list of COM port numbers:
set COMPORTS=4 3

for %%i in (%COMPORTS%) do start /b cmd /c connect-serial-port.cmd /Q %%i

0 comments on commit d33fcc9

Please sign in to comment.