Allows Arduino to be used on SIOC
I adapted the PMDGDataEventServer to allow Arduino users to get to PMDG NGX data and events. In some cases data is needed from FSX (through FSUIPC or FS2Connect) and PMDG. This is not possible unless one uses an Arduino Duo with 2 serial ports (2 USB connections) and program the Arduino to connect to PMDGDataEventServer and e.g. FS2Connect.
In such an environment I would recommend the use of SIOC (IOCP server) as this can make very flexible setup and scripting.
I assume that the reader of this is already familiar with SIOC.
SIOC deals with ‘Variables’. Variables can be set and read from a variety of sources.
- Open Cockpit Hardware,
- FSIO Hardware (as discribed on this site),
- FSX through FSUIPC
- PMDG DataEventServer
My Arduino2SIOC program adds an other possibility to this list.
Through the Arduino2SIOC server Arduino users can communicate variable data with SIOC over a serial (Arduino standard) port.
The Arduino2SIOC program allows to connect 6 Arduino’s .
At the other end the programm connects to SIOC (IOCPserver) over TCP/IP.
This means that the computer running the Arduino2SIOC server can be on any computer in your network.
Programming your Arduino
The communication between Arduino and Arduino2SIOC server is extremly simple.
To send a value to a SIOC variable:
char line; ... ... int Variable = 123; int Value = 654; sprintf(lijn,"%d=%d", Variable, Value); Serial.println(line);
‘Variable’ is the SIOC variable you want to set ‘Value’ to.
Ofcause your SIOC script will know how to handle variable 123.
Receiving values from SIOC
If you want SIOC to send you Variable values (when they change) you need to register the Variables. The program lines to do that are simple again
char line; … … string line = "Reg:100:101:102:104:104:"; Serial.println(line); …
The above code snipped will the variables 100-104 will be registered with SIO. At the same time the Arduino2SIOC server will register wich port the data requested.
When one of these variables in SIOC changes, SIOC will send them to Arduino2SIOC server and the server will send the value to the right Arduino/port in the format:
Your arduino program wil get that message over the serial port. It’s your task as an Arduino programmer to deal with it. A simple example program structure you can find here.
Note the the Arduino2SIOC server can only remember ONE port per variable. In the event 2 Arduino’s request the same variable only one wins.
Starting the program.
This is how the program looks like when started:
It follows the same logic as the PMDGDataEventServer on this site.
6 Comm ports can be selected using L1,L3,L3,R2,R2 and R3.
In the picture COM11 is active. Needles to say that opening port 6 (R3) failed as COM11 was already assinged.
SIOC/IOCPserver IP adress can be set to a different value than ‘localhost’. If you want to run the program on an other computer in your network you need to set the IP adress to the computer running SIOC. You do this by typing the IP adress in the lower input line. Then press L4.
Same for the port. I doubt you will have to change it, but you can (using R4).
SIOC Auto Connect can be set and unset. When set the program will try to connect to SIOC right after start. (every 20 seconds). When the connection would break, the program will try to reconnect every 20 seconds.
Manual connect/disconnect from SIOC
L6. R6 Speak for themselves. You would set program starts hidden once everything is set. When hidden, an Icon will appear on the taskbar. Double click and the program will reopen.
L7 will open a logging screen where the messages between Ardiuno and the program, and between the program and SIOC are logged.
Input line. (testing the program)
The input line allows you to test the connection with SIOC.
Everything you enter in the input line will regarded as comming from Port 99, but handled the same way as if it were send from a connected comm port.
So if you enter 100=60: this will set SIOC variable 100 to 60.
If you enter: “Reg:13: and [Send] this will register variable 13 within SIOC.
What good does that do?
Well, if you open the log ( L7) you will see that SIOC will send you the value of Var 013 if that var changes value.
Use IOCP console to test it, no need for FSX to run, just SIOC and Arduino2SIOC server.
You do not need a SIOC script for this test.
- Start SIOC and open IOCP console
- In IOCP Console: enter 1 for Var 013 (or any other Var###)
- Start Arduino2SIOC server.
- Open the log window ( L 7 )
- Connect to SIOC.
- In the input line you enter Reg:13
- Press [Send]. ( The text you put in is handled by the program as input from Comm 99)
You should see the communication between the progam and SIOC:
Arn:Inicio message but also Arn:Vivo messages and the value of the requested variable if not 0. In this case you entered 1.
The program knows that Port 99 requested the value of Var013, so that is why you see To Port:99: 13=1.
Change Var013 to something else, and see how SIOC sends this new value to the program and the program sends it to Port 99. (Nothing is actualy send as port 99 physicaly does not exist)
Now enter 13=123 [Send]
Observe how the program sends a message to SIOC to change var 013 to 123. And now observer how SIOC then sends the new value of Var013 to the program.
If you want to use this program, please register yourself at my FSIO Forum. There you will find a download link within the first topic of Arduino2SIOC server
You can contact me here.