Jump to content

Recommended Posts

Posted

LEDs are done via the indicatorTables in siocConfig.

Rotaries(not encoders) are done with the SimpleRotary Function.

I'll post about this in a little while.

/Oakes

 

I tryed to make a Led(lamp_EnginesStartValve) functioning as it is

in the game...

from this post

http://forums.eagle.ru/showpost.php?p=766849&postcount=17

(thanks my friend)

I saw that lamp_EnginesStartValve = 163

 

So at the Sioc Config menu I added

Var 0011, name L_EngStartValv, Link IOCARD_OUT, Output 1

First i wonder where to wire the Led(with resistance 470 Ohm)

Accordinng to Master Card manual the J2 Connector's pins are the outputs from 11 to 48 with pin #1 the +5Vcc and the pin #2 GND.

So how will be the wiring?

The one of the Led pins will go to the #11 and the other to #2 ???

Do i have to connect the #1 to +5V ??

Also in the

C:\Program Files\Eagle Dynamics\Ka-50\Config\Export\SIOCConfig\siocconfig.lua

Second what code line do i have to add?

thanks in advance

stelios

Posted

So i added these code lines

warningIndicators =

{

[v11] = {0,163}

}

gIndicatorTables = {warningIndicators}

 

in the siocconfig.lua file...

but how will be the wiring ?

#2 and #11 for the led? and that is all?

it will work when it will flash from the game ?

thanks

stelios

Posted

no you should take by exemple, for SIOCCOnfig.lua

 

EnginesIndicators =

{

[0011] = {0,163}

}

gIndicatorTables = {EnginesIndicators}

 

 

for SIOC :

 

if you connect like : The one of the Led pins will go to the #11

 

you should have :

 

Var 0011, name L_EngStartValv, Link IOCARD_OUT, Output 11

Posted

I wish I was into the programming right now, which is sad to say I am not. Right now I am still into building the pit itself. I'm following this thread though because eventually I will be doing the wiring and panel building, so will have to work on the backend code to finish this - however I will be using the EPIC board on my pit.

 

The EPIC board uses something called the 'EPICenter' programming interface, which uses EPL files to interface with the simulation. It's a lot like C++ in programming.

 

My main concern is that there isn't a whole lot of interest in EPIC programming for BS and a lot of people here are using the LUA route with alternate boards which causes me some concern since it looks like I'll be the only one using the EPIC USB boards.

Posted
My main concern is that there isn't a whole lot of interest in EPIC programming for BS and a lot of people here are using the LUA route with alternate boards which causes me some concern since it looks like I'll be the only one using the EPIC USB boards.

 

The LUA route is required as it's the only way to get data out of Black Shark. What you will have to do is communicate between LUA and the EPIC software/system. The LUA portions of all these solutions will have plenty of nuggets for you to pull from when you get there.

  • 2 weeks later...
Posted

Im picking up bits and pieces but Im pretty lost. I dont know enough about programming to link up and share multiple files and data between each other. I got the basic talker/listener thing going but cant seem to figure out how to extract that data into another program/s. Plus sounds like everyone using different languages which is making it even harder. Some using, VB, VC#, VC++.

Intel i7 990X, 6GB DDR3, Nvidia GTX 470 x2 SLI, Win 7 x64

http://picasaweb.google.com/sweinhart

Posted
You don't really need to understand the protocol, just the API that the various languages use. All the low level stuff is abstracted away by the API.

 

The data sending Lua code has already been posted and in any case is included in your Lua files in the DCS:BS directory. The other end, it's a relatively simple matter of listening on the socket and reading in the data. My example using C# .Net:

 

private void readSocket() {
           StreamReader reader;
           String data;
           TcpListener listener = new TcpListener(IPAddress.Any, 8080);
           listener.Start();
           Socket sock = listener.AcceptSocket();
           NetworkStream serverstream = new NetworkStream(sock);
           reader = new StreamReader(serverstream);

           while (true) {
               Console.WriteLine("receiving from server...");
               data = reader.ReadLine();
               Console.WriteLine(data);
           }
       }

 

So I tried running the script just as you have it here and I just get a blank screen. Earlier I was playing with the code a little and changed the local host to an IP address and I would get the message receiving from host but that was it. Then when I left the sim I would just get that message constantly scrolling down. The error log said it connected but did not receive any errors. No data ever wrote to the screen. I played with it some more and cant even get it to do that anymore. Now Im getting error log msg "attempt to index global 'socket' (a nil value)

 

Help pls?

 

The error log says

Intel i7 990X, 6GB DDR3, Nvidia GTX 470 x2 SLI, Win 7 x64

http://picasaweb.google.com/sweinhart

  • 2 weeks later...
Posted

Oakes,

 

I have today carried out all the steps to connect my iocards to BS using SIOC, the switch worked first time so your instructions are perfect, very many thanks.

 

Encoders and 7 segment LEDs next :-)

 

Peter.

  • 4 months later...
Posted

Sorry if i ask stupid thinks , but i just maybe start make cockpit in black shark but i have couple thinks what i dont understand im very happy if some one want help.

 

1. what cards i need is opencockpit master card and usb expansion enough.

2 if cards are ok what i need PROGRAM to get buttons and leds and other stuf to work?

3.i can use cnc machine and i think to make radio switch and other like that i have there 5 pin example and one ground and when i switch own made rotary i example get push button 1 in card next is 2 and etc can i use that in black shark or i need do that via one button function and some scripts or some calculate where that rotary is? i hope u guys understand what i try tell.

4. black shark has many 3 way switch how i can use them correct in game when i click that button go example lamp switch 10%/30%/100%/off

can i use this my own button when example pin 1 and ground is off pin2 and ground is 10% so i can jump directly axample 10% to 100% or i need some script or something what calculate my button and black shark that is nessassery click in that device?

Thanks if someone can help me.

Posted

1. what cards i need is opencockpit master card and usb expansion enough.

Yes, for input and outputs (i.e switches, rotaries, encoders, pushbuttons and LEDS etc). For 7-seg displays, servos, steppers you need other cards

2 if cards are ok what i need PROGRAM to get buttons and leds and other stuf to work?

Please see this thread, starts at post 53 (Stelios and me) http://forums.eagle.ru/showthread.php?t=45071&page=6

 

 

3.i can use cnc machine and i think to make radio switch and other like that i have there 5 pin example and one ground and when i switch own made rotary i example get push button 1 in card next is 2 and etc can i use that in black shark or i need do that via one button function and some scripts or some calculate where that rotary is? i hope u guys understand what i try tell.

No, rotaries can be connected directly to the OC mastercard, connect each pin to an input (+ gnd of course) => for a 5 position rotary this means that you will have 5 sioc variables. One of these five variables will then be 1 and the rest will be 0 depending on the position of you rotary => as you rotate the rotary the following will happen [var1,var2,var3,var4,var5] => [10000], [01000],[00100],[00010] and [00001]

 

Have a look at variables 0590 to 0594 in this file (the code for the Datalink ID) (0510 will be 1,2,3 or 4 depending on the setting of the Datalink ID rotary - this value is then sent to Export.lua)

 

 

http://code.google.com/p/dcsbsexport/source/browse/trunk/SIOC/dcs.txt

 

 

4. black shark has many 3 way switch how i can use them correct in game when i click that button go example lamp switch 10%/30%/100%/off

can i use this my own button when example pin 1 and ground is off pin2 and ground is 10% so i can jump directly axample 10% to 100% or i need some script or something what calculate my button and black shark that is nessassery click in that device?

3,4,5 etc way switches functions the same a a rotary, i.e. each position of the switch means that a SIOC variable is set to 1 and the rest to 0. For a 3 position switch => [var1,var2,var3] => [100], [010],[001].

 

See variables 0506,0507 and 0510 for tips (0510 will be 1,2 or 3 depending on the setting of the burst length switch - this value is then sent to Export.lua)

 

Since we have direct connection to DCS via LUA we can set any switch/rotary to any position we want at any time (without actually having to go through all position).

 

This is the flow we use:

Physical switch/rotary is moved => determine position of physical switch/rotary (with SIOC) => send to Export.lua via TCP => look up correct parameters for the corresponding virtual switch/rotary => set the virtual switch/rotary to the correct position.

 

 

Thanks if someone can help me.

 

 

/Oakes

Posted (edited)

ok big thanks oakes.

 

this post what u make clearly this bs input thinks so i can made my home cockpit.

Edited by Nasty
Posted

I need some help with lua

 

Hello all the pits fanatics !

 

In my attempts to expand my touchpal profile abilities, I am interested in reading arguments values from the panels other than MainPanel.

But I feel a little on my own with that piece of export.lua editing.

 

As my knowledge of this langage is just the rookie level I think I need some help.

 

I made the export.lua script included in the joined zip file

 

the purpose is neither to drive a pit, nor touchpal for the time.

 

It is just made to validate recursive processing to gain infos to debug to \TEMP\Export.log

and if found, errors to error.log (would be best if nothing in that one...)

 

I made a table of all other tables to read Arguments values from other elements that are not inside Mainpanel.

 

I don't know why the update_element() action in the script on line 295 triggers an error :

Lua::Config::call error LuaExportAfterNextFrame:./Config/Export/Export.lua:295: attempt to call method 'update_arguments' (a nil value)

 

I would be very happy if someone could look at this script to tell me about errors or no go if any...

you can event test the script :

>>but first backup your one ! <<

then by unzipping, and renamming it with just export.lua as name, and then copy and replace your one at \config\export.

launch BS,

then at a moment stop it (escape and exit)

then look at error.log and export.log.

 

My objective is to have outputs from BS to LEDs in real pit or signal on touchpal for elements not in mainpanel.lua

 

I never saw anyone publishing about that ... so I have doubts about this ability... but hope is hope...

 

( Oakes ? any idea ? )

export.luaHellfrog.TestDebugAllPanel.zip

Posted

Hi Hellfrog

 

line 295: lDevice:update_arguments()

 

I assume that this line doesn't fail for every device? (especially not for the MainPanel device)

 

If so, I guess that the particular device referenced in lDevice at the time doesn't contain the update_arguments() function hence the error.

 

You can test for this with the type command:

 

if type(lDevice.update_arguments)~=nil then
   lDevice:update_arguments() 
End

I think this should work, haven't tested it.

 

You can try this little example here: http://www.lua.org/cgi-bin/demo

Just paste this into the box and click run.

apa = {a=12, b=20, c = function (self) self.a=self.a-2 end}
io.write(apa.a)
print ""
apa:c()
io.write(apa.a)
print ""
apa.c(apa) -- same as apa:c()
io.write(apa.a)
print ""
io.write(type(apa.a))
print ""
io.write(type(apa.c))
print ""
io.write(type(apa.d)) -- this function doesn't exist, will return nil

Otherwise you can use some form of error catching, but I haven't looked into how LUA implements this.

 

 

/Oakes

Posted

OK

thank you for your kind and quick reply.

 

Without more info from DCS team we just have to loop around all panels and add an error interception in the script in case it has no updateargument ability, that is your answer ?

Posted (edited)

You can parse out (all?) the available functions for most devices by doing this, so you can see if one of a given name exists before you try to call it:

 

                    ...
                   local d = GetDevice(devID);
                   local funcscan = getmetatable(d).__index;
                   for k,v in pairs(funcscan)
                   do
                     socket.try(c:send(k.."="..type(v).."\n"));
                   end
                   ...

 

(Here I was sending the results back to a program of all the available function names, before deciding whether to call any of them).

 

Here for example is the response from the Abris (device 9):

 

1(get_active_route=function)

1(get_current_route_segment_info=function)

1(get_mode=function)

1(print_to_console=function)

1(get_edited_route=function)

1(performClickableAction=function)

1(get_sns_mode=function)

1(get_current_route=function)

1(replace_last_console_line=function)

1(SetCommand=function)

 

Note the format used by the program receiving the output is as follows, but LUA is only actually sending the data that is between the brackets: socketnum(keyname=datatypevalue)

 

Here is mainpanel (device 0):

 

1(get_argument_value=function)

1(performClickableAction=function)

1(update_arguments=function)

1(set_argument_value=function)

1(SetCommand=function)

 

So you can 'safely' check for the presence of this before calling it, and by interrogating LUA state live (which is good because what you're looking up are bindings to C/C++ functions in LUA custom structs, which aren't exposed well otherwise in any LUA source or table navigation - as far as I could tell anyway).

 

This 'metatable' that's being queried is a kind of lookup populated by ED, and may not list internal or blocked functions at their choosing, so that's why I question whether it will actually list all functions or not.. in reality, it lists those which we may be allowed to make use of.

 

I did do this in a loop one time, scanning devices 0 through 255. Note that the device ID appears to be an unsigned byte, so if you try to get device 256 it wraps around to 0 and you get mainpanel again as the response. So it can be quite quick to zip through all the available devices today in a loop up to this value and find out which ones have active functions that can be called, and whether they include a specific one you're interested in.

Edited by topdog

[ i7 2600k 4.6GHz :: 16GB Mushkin Blackline LV :: EVGA GTX 1080ti 11GB ]

[ TM Warthog / Saitek Rudder :: Oculus Rift :: Obutto cockpit :: Acer HN274H 27" 120Hz :: 3D Vision Ready ]

Posted

I also had this by the way as part of the same test code I was using.

 

It's referring a modified version of the Serialization.lua script that just wrote its recursive output to a string instead of to the io library (since I'm too novice to know how to redirect the io to a string buffer in LUA), so that I could then call many of the functions dynamically and get some interesting output back again:-

 

                    ...
                   local d = GetDevice(devID);
                   local result = d[funcname](d);
                   if type(result) == "table" then
                     socket.try(c:send(serializestr(funcname, result).."\n"))
                   else
                       socket.try(c:send(result.."\n"));
                   end
                   ...

 

DevID is number of the device, and funcname is a string for the function I want to call.

 

Results of me calling get_active_route on Abris for Instant Action yielded this lovely response :D

 

1(get_active_route = {})

1(get_active_route["date"] = {})

1(get_active_route["date"]["year"] = 2009)

1(get_active_route["date"]["day"] = 1)

1(get_active_route["date"]["month"] = 6)

1(get_active_route["segments"] = {})

1(get_active_route["segments"][1] = {})

1(get_active_route["segments"][1]["preset_true_speed"] = 55.555555555556)

1(get_active_route["segments"][1]["estimated_remaining_fuel"] = 1191.6917252816)

1(get_active_route["segments"][1]["route_waypoint_type"] = 0)

1(get_active_route["segments"][1]["preset_time_over_target"] = 32400.1)

1(get_active_route["segments"][1]["preset_magnetic_variation"] = 0)

1(get_active_route["segments"][1]["preset_flight_level"] = 1147)

1(get_active_route["segments"][1]["preset_fuel_consumption"] = 786)

1(get_active_route["segments"][1]["preset_flight_time_on_segment"] = 0)

1(get_active_route["segments"][1]["preset_vertical_speed"] = 0)

1(get_active_route["segments"][1]["preset_remaining_fuel"] = 1192)

1(get_active_route["segments"][1]["preset_wind_speed"] = 4.7204999923706)

1(get_active_route["segments"][1]["end"] = {})

1(get_active_route["segments"][1]["end"]["position"] = {})

1(get_active_route["segments"][1]["end"]["position"]["longitude"] = 41.061232259035)

1(get_active_route["segments"][1]["end"]["position"]["latitude"] = 43.978903277824)

1(get_active_route["segments"][1]["end"]["sub_type"] = 1)

1(get_active_route["segments"][1]["end"]["callsign"] = "1")

1(get_active_route["segments"][1]["preset_ground_speed"] = 55.555555555556)

1(get_active_route["segments"][1]["preset_atmospheric_temperature"] = 20.681182861328)

1(get_active_route["segments"][1]["preset_wind_direction"] = 230.00000097659)

1(get_active_route["segments"][1]["preset_flight_method"] = 0)

1(get_active_route["segments"][2] = {})

1(get_active_route["segments"][2]["preset_true_speed"] = 83.333333333333)

1(get_active_route["segments"][2]["estimated_remaining_fuel"] = 1185.1098426434)

1(get_active_route["segments"][2]["route_waypoint_type"] = 0)

1(get_active_route["segments"][2]["preset_time_over_target"] = 32420.665299857)

1(get_active_route["segments"][2]["preset_magnetic_variation"] = 0)

1(get_active_route["segments"][2]["preset_flight_level"] = 1179)

1(get_active_route["segments"][2]["preset_fuel_consumption"] = 786)

1(get_active_route["segments"][2]["preset_flight_time_on_segment"] = 20.565299857411)

1(get_active_route["segments"][2]["preset_vertical_speed"] = 1.5560191303735)

1(get_active_route["segments"][2]["preset_remaining_fuel"] = 1187.5099095311)

1(get_active_route["segments"][2]["preset_wind_speed"] = 4.7684998512268)

1(get_active_route["segments"][2]["end"] = {})

1(get_active_route["segments"][2]["end"]["position"] = {})

1(get_active_route["segments"][2]["end"]["position"]["longitude"] = 41.041511731076)

1(get_active_route["segments"][2]["end"]["position"]["latitude"] = 43.985800999341)

1(get_active_route["segments"][2]["end"]["sub_type"] = 1)

1(get_active_route["segments"][2]["end"]["callsign"] = "2")

1(get_active_route["segments"][2]["preset_ground_speed"] = 85.586684701586)

1(get_active_route["segments"][2]["preset_atmospheric_temperature"] = 20.472473144531)

1(get_active_route["segments"][2]["preset_wind_direction"] = 230.00000097659)

1(get_active_route["segments"][2]["preset_flight_method"] = 0)

1(get_active_route["segments"][3] = {})

1(get_active_route["segments"][3]["preset_true_speed"] = 83.333333333333)

1(get_active_route["segments"][3]["estimated_remaining_fuel"] = 1158.9093911764)

1(get_active_route["segments"][3]["route_waypoint_type"] = 0)

1(get_active_route["segments"][3]["preset_time_over_target"] = 32497.403069806)

1(get_active_route["segments"][3]["preset_magnetic_variation"] = 0)

1(get_active_route["segments"][3]["preset_flight_level"] = 1090)

1(get_active_route["segments"][3]["preset_fuel_consumption"] = 786)

1(get_active_route["segments"][3]["preset_flight_time_on_segment"] = 76.737769948373)

1(get_active_route["segments"][3]["preset_vertical_speed"] = -1.1597939327645)

1(get_active_route["segments"][3]["preset_remaining_fuel"] = 1170.7554964257)

1(get_active_route["segments"][3]["preset_wind_speed"] = 4.6350002288818)

1(get_active_route["segments"][3]["end"] = {})

1(get_active_route["segments"][3]["end"]["position"] = {})

1(get_active_route["segments"][3]["end"]["position"]["longitude"] = 40.961973972663)

1(get_active_route["segments"][3]["end"]["position"]["latitude"] = 44.001567544889)

1(get_active_route["segments"][3]["end"]["sub_type"] = 1)

1(get_active_route["segments"][3]["end"]["callsign"] = "3")

1(get_active_route["segments"][3]["preset_ground_speed"] = 86.245045873601)

1(get_active_route["segments"][3]["preset_atmospheric_temperature"] = 21.052947998047)

1(get_active_route["segments"][3]["preset_wind_direction"] = 230.00000097659)

1(get_active_route["segments"][3]["preset_flight_method"] = 0)

1(get_active_route["segments"][4] = {})

1(get_active_route["segments"][4]["preset_true_speed"] = 83.333333333333)

1(get_active_route["segments"][4]["estimated_remaining_fuel"] = 1090.5744569938)

1(get_active_route["segments"][4]["route_waypoint_type"] = 0)

1(get_active_route["segments"][4]["preset_time_over_target"] = 32710.438049256)

1(get_active_route["segments"][4]["preset_magnetic_variation"] = 0)

1(get_active_route["segments"][4]["preset_flight_level"] = 1039)

1(get_active_route["segments"][4]["preset_fuel_consumption"] = 786)

1(get_active_route["segments"][4]["preset_flight_time_on_segment"] = 213.03497945059)

1(get_active_route["segments"][4]["preset_vertical_speed"] = -0.23939730522906)

1(get_active_route["segments"][4]["preset_remaining_fuel"] = 1124.2428592457)

1(get_active_route["segments"][4]["preset_wind_speed"] = 4.5584998130798)

1(get_active_route["segments"][4]["end"] = {})

1(get_active_route["segments"][4]["end"]["position"] = {})

1(get_active_route["segments"][4]["end"]["position"]["longitude"] = 41.154358653949)

1(get_active_route["segments"][4]["end"]["position"]["latitude"] = 43.932465415053)

1(get_active_route["segments"][4]["end"]["sub_type"] = 1)

1(get_active_route["segments"][4]["end"]["callsign"] = "4")

1(get_active_route["segments"][4]["preset_ground_speed"] = 81.026376685351)

1(get_active_route["segments"][4]["preset_atmospheric_temperature"] = 21.385559082031)

1(get_active_route["segments"][4]["preset_wind_direction"] = 230.00000097659)

1(get_active_route["segments"][4]["preset_flight_method"] = 0)

1(get_active_route["segments"][5] = {})

1(get_active_route["segments"][5]["preset_true_speed"] = 83.333333333333)

1(get_active_route["segments"][5]["estimated_remaining_fuel"] = 1080.1984110338)

1(get_active_route["segments"][5]["route_waypoint_type"] = 0)

1(get_active_route["segments"][5]["preset_time_over_target"] = 32743.588094516)

1(get_active_route["segments"][5]["preset_magnetic_variation"] = 0)

1(get_active_route["segments"][5]["preset_flight_level"] = 947.09564208984)

1(get_active_route["segments"][5]["preset_fuel_consumption"] = 786)

1(get_active_route["segments"][5]["preset_flight_time_on_segment"] = 33.150045259197)

1(get_active_route["segments"][5]["preset_vertical_speed"] = -2.7723750357372)

1(get_active_route["segments"][5]["preset_remaining_fuel"] = 1117.0050993641)

1(get_active_route["segments"][5]["preset_wind_speed"] = 4.4206433296204)

1(get_active_route["segments"][5]["end"] = {})

1(get_active_route["segments"][5]["end"]["position"] = {})

1(get_active_route["segments"][5]["end"]["position"]["longitude"] = 41.175428725118)

1(get_active_route["segments"][5]["end"]["position"]["latitude"] = 43.950352682501)

1(get_active_route["segments"][5]["end"]["sub_type"] = 1)

1(get_active_route["segments"][5]["end"]["callsign"] = "KALIT")

1(get_active_route["segments"][5]["preset_ground_speed"] = 79.064643659943)

1(get_active_route["segments"][5]["preset_atmospheric_temperature"] = 21.984893798828)

1(get_active_route["segments"][5]["preset_wind_direction"] = 230.00000097659)

1(get_active_route["segments"][5]["preset_flight_method"] = 0)

1(get_active_route["name"] = "1-KALIT")

  • Like 1

[ i7 2600k 4.6GHz :: 16GB Mushkin Blackline LV :: EVGA GTX 1080ti 11GB ]

[ TM Warthog / Saitek Rudder :: Oculus Rift :: Obutto cockpit :: Acer HN274H 27" 120Hz :: 3D Vision Ready ]

Posted

excellent work indeed !!

the spirit of what I wanted to achieve and the nice touch of having it working simply and efficiently !!

 

With these ones it becomes accessible to export flight time, hour, fuel consumption and so on ... I think...

may be :

ergonomic

usefull after flight for analyzing performance

be used as a cheat... to discuss

...

I think some usefull tools could be achieved knowing these function names and formats !!!

 

I thank you very gracefully mr Topdog !!!

Posted

That output I gave as last example, is just estimated fuel of the current (active) route that is plotted into the Abris' as waypoints, so it doesn't reveal anything you can't see anyway, and it's still local instrumentation so not like a 'super radar' or anything.

 

I just use that as an example of a function you call that instead of just bringing back a simple value, can give you a whole structure of information. Some functions are like this, whilst some just give you the single values.

 

I was just happy it worked :D

 

Some of these do not work unless your camera is inside the cockpit still, because (I presume) their devices do not have the update_arguments() function available. If you try to call the functions at this time, your error log will quickly fill up with lots of 'cannot access nil value "blah"'.

 

I don't know yet how in LUA I can tell whether the camera is inside the cockpit or outside, except to try calling one of these functions that don't work outside. I would like to find a better way for that.

[ i7 2600k 4.6GHz :: 16GB Mushkin Blackline LV :: EVGA GTX 1080ti 11GB ]

[ TM Warthog / Saitek Rudder :: Oculus Rift :: Obutto cockpit :: Acer HN274H 27" 120Hz :: 3D Vision Ready ]

  • Recently Browsing   0 members

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