Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 2
  • *Guests: 51
  • *Total: 53

Our Discord

Author Topic: IPCREADY.LUA EXPLAINED!  (Read 4283 times)

Offline Trevor Hale

  • Administrator
  • I am chained to this website!
  • *
  • Posts: 3,824
    • Cockpitbuilders.com
  • First Name: Trevor
  • Home Location: New Liskeard, Ontario
IPCREADY.LUA EXPLAINED!
« on: April 08, 2015, 07:32:17 AM »
This file gets put into your FSUIPC MODULES DIRECTORY.

Once FSX is Loaded and FSUIPC Starts, this file runs.

Lets look at the bottom of the code.


Quote

-- Arduino Gauges/Servos
event.offset (0x0be0, "UD", "call_flaps") -- aircraft Flaps
event.offset (0x02c8, "SD", "call_vertical") -- aircraft Vertical Speed
event.offset (0x0be0, "UD", "call_flaps") -- aircraft Flaps
event.offset (0x0b7c, "UD", "call_lfuel") -- aircraft Left Fuel

event.offset (0x0b94, "UD", "call_rfuel") -- aircraft Right Fuel

event.offset (0x0bc2, "SW", "call_trim") -- aircraft Trim
event.offset (0x0e8c, "SW", "call_oat") -- aircraft Outside Air Temp


these lines of code specify the "FSUIPC OFFSETS" I am looking for in FSX to change.

event.offset (Means that I am looking for an offset change)
0x (means Offset Location in HEX)
0E8C (Is the OFFSET ADDERSS taken from this list -->  http://737ngsim.co.uk/wp-content/uploads/2012/12/FSUIPC4-Offsets-Status.pdf)
S (means Signed bit "Could be a + or a - Value)
W (Means WORD which is a representation of 16 Bits which is the size of the offset from this list "2nd column" --> -->  http://737ngsim.co.uk/wp-content/uploads/2012/12/FSUIPC4-Offsets-Status.pdf)

call_oat (means when the offset changes go to the "Function Block" in the program called call_oat)

Are you with me so far?  Good.

Now we will look at the easy part of the code...

Quote
-- Open Seial Port and connect to Arduino
speed = 115200
handshake = 0
serial_wait = 100
inited = 0
states = {}
dev = com.open("COM3", speed, handshake) -- Change Port Number for your Arduino
if dev == 0 then
    ipc.display("Could not open device port")
    ipc.exit()
end

-- Finish Serial Connect

This just works, its humble jumble..  it basically just tells the LUA Script where the ardino is.
Just change the COM3 to Com1, Com2, Com4 or whatever comp port your arduino is connected to.

Lastly Look at the meat of the CODE

Quote
function call_oat (offset, value)
    value = (value/256)
    ipc.log ("writes com = ?c"..string.format("%04d", value).. "\n")
    com.write (dev, "?c" .. string.format("%04d", value) .. "\n")
    ipc.sleep(serial_wait)
end

function call_oat (offset, value)   "Think of this as the title of the function block that runs when that offset changes. (Remember above we said to come here?)"
value = (value/256) "this means whatever value the offset changed to, divide it by 256 and go on."
ipc.log ("writes com = ?c"..string.format("%04d", value).. "\n") " basically is humble jumble for when this offset changes write the value to fsuipc.log so I can watch if it is working - HOWEVER I USE THE ?c as a trigger for my Arduino program to know when I am sending outside Air Temperature Value"

com.write (dev, "?c" .. string.format("%04d", value) .. "\n") Same thing as above only this is what it is sending to the COM PORT (ARDUINO) again the ?c in my arduino code means OUTSIDE AIR TEMP

ipc.sleep(serial_wait) " Means give the com port a break, it gets tired (Serial_wait) was defined at 100 in the Serial port setup we did above which means 100 mili seconds."

end "means I can go on to the next offset that changes.

Thats it, that is my lua code explained.  now if you have specific questions, I can try to answer them.




I attached my LUA Code to this post also for ease of explanation.  NOW, This is 1/2 of the code...  I will detail the arduino code in a different post.  remember, this just sends the data to the com port.  In the Arduino, that code needs to tell your gauge what to do with that code when it gets the message.


And if you don't know WHAT FSUIPC IS or DOES.  You need to do a lot of reading, because until you understand that..  this is still not going to be of any help to you.[/quote]
« Last Edit: April 08, 2015, 01:46:42 PM by Trevor Hale »
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

Offline pcpilotmd80

  • Forum GURU
  • *
  • Posts: 32
  • DC-9/MD-80 Enthusiast
  • First Name: Mike
  • Home Location: St. Louis, MO
Re: IPCREADY.LUA EXPLAINED!
« Reply #1 on: April 08, 2015, 04:58:05 PM »
Hey Trev, I hope you didn't do that just for me Jk haha!, thanks for detail explaination, starting to make sence thanks for help, so is cold beer!

Mike

Offline RayS

  • I spend way too much on this forum!
  • *
  • Posts: 814
  • Private Pilot, Sim Enthusiast
    • Anthony Scott Photography
  • First Name: Ray Sotkiewicz
  • Home Location: Seattle, WA
Re: IPCREADY.LUA EXPLAINED!
« Reply #2 on: April 08, 2015, 06:59:41 PM »

...what's this "FSCIUPD" thingy you speak of?  ::)
Ray Sotkiewicz

Offline Trevor Hale

  • Administrator
  • I am chained to this website!
  • *
  • Posts: 3,824
    • Cockpitbuilders.com
  • First Name: Trevor
  • Home Location: New Liskeard, Ontario
Re: IPCREADY.LUA EXPLAINED!
« Reply #3 on: April 09, 2015, 06:35:35 AM »
LOL @ Ray thats funny..  I have no idea :)

Mike, Yes I did, and I will try to get time to do the same thing for my Arduino code also..  But things are very busy right now.

I will try.

Trev
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

Offline Ed

  • Forum GURU
  • *
  • Posts: 202
  • Aviation Enthusiast
    • My 737NGX800 Homebuilt Cockpit
  • First Name: Edwin
  • Home Location: Marathon, Ontario, Canada
Re: IPCREADY.LUA EXPLAINED!
« Reply #4 on: April 12, 2015, 08:57:48 AM »
Thanks for posting that explanation. Quite helpful.  I understand most of it but am new to Arduino. Was gifted an Uno recently so dabbling into the Arduino sketch coding. Want to use it for displaying seven segment displays in an NGX FSX environment.

The Lua code you list...is  that similar to a 'sketch' code or does one have to download another program to run Lua code? I'm currently digging into the Links2FS interface and playing around with small sketches .

Ed
Ed
FSX-SE,P3D4,W10-I7@4.8,W7-i7 920 ,W10-Dual Core@2.66.,FSUIPC 4 + 5,WideFS.Prosim737,JSV2,ASN, ,Vpilot,GSX,Pro-ATC/X,RAAS Pro,UT2,PFPX,TopCat,Accu-Feel
http://www.737ngxca.com/

Offline Trevor Hale

  • Administrator
  • I am chained to this website!
  • *
  • Posts: 3,824
    • Cockpitbuilders.com
  • First Name: Trevor
  • Home Location: New Liskeard, Ontario
Re: IPCREADY.LUA EXPLAINED!
« Reply #5 on: April 12, 2015, 09:25:08 AM »
Hi Ed.

This lua COde just runs in the fsuipc directory when fsx loads. The idea is it extracts the data from flightsim and just sends it to a serial port.

The arduino code is different and hence must be written to capture the data coming into the serial port from the lua program.

You really just need FSUIPC in order for the lua program to work.

Trev
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

Offline Ed

  • Forum GURU
  • *
  • Posts: 202
  • Aviation Enthusiast
    • My 737NGX800 Homebuilt Cockpit
  • First Name: Edwin
  • Home Location: Marathon, Ontario, Canada
Re: IPCREADY.LUA EXPLAINED!
« Reply #6 on: April 12, 2015, 11:31:33 PM »
Hi Trevor,

Thanks for the reply. Will take a look about for the  Lua script module and see if I can make heads or tails of it.


Ed
FSX-SE,P3D4,W10-I7@4.8,W7-i7 920 ,W10-Dual Core@2.66.,FSUIPC 4 + 5,WideFS.Prosim737,JSV2,ASN, ,Vpilot,GSX,Pro-ATC/X,RAAS Pro,UT2,PFPX,TopCat,Accu-Feel
http://www.737ngxca.com/

Offline Ed

  • Forum GURU
  • *
  • Posts: 202
  • Aviation Enthusiast
    • My 737NGX800 Homebuilt Cockpit
  • First Name: Edwin
  • Home Location: Marathon, Ontario, Canada
Re: IPCREADY.LUA EXPLAINED!
« Reply #7 on: April 16, 2015, 03:51:56 PM »
Hi Trevor,

Couple more questions . Where can I get the Lua script and the Linda editor? I thought it comes packaged with the Registered Version of FSUIPC.. but on initial glances I dont see it. Can you point me in the right direction please.
Ed
FSX-SE,P3D4,W10-I7@4.8,W7-i7 920 ,W10-Dual Core@2.66.,FSUIPC 4 + 5,WideFS.Prosim737,JSV2,ASN, ,Vpilot,GSX,Pro-ATC/X,RAAS Pro,UT2,PFPX,TopCat,Accu-Feel
http://www.737ngxca.com/

Offline Trevor Hale

  • Administrator
  • I am chained to this website!
  • *
  • Posts: 3,824
    • Cockpitbuilders.com
  • First Name: Trevor
  • Home Location: New Liskeard, Ontario
Re: IPCREADY.LUA EXPLAINED!
« Reply #8 on: April 18, 2015, 07:30:54 PM »
Hi the Lua script is an attachment to my first post. And I didn't use Linda for it. I downloaded a generic editor called notepad ++

Trev
Trevor Hale

Owner
http://www.cockpitbuilders.com

Director of Operations
Worldflight Team USA
http://www.worldflightusa.com

VATSIM:

 

FlightSimExpo 2019

FsExpo

Recent Posts

Question on B737NG center pedestal instrument availability
by kattz
[Today at 01:20:20 AM]
Wanted - Jetmax B737 TQ
by kattz
[Today at 12:57:09 AM]
Multi-Projector color calibration
by jmlohrenz
[April 21, 2019, 05:33:40 PM]
Bernard...info
by FredK
[April 20, 2019, 06:29:17 PM]
Complete 200 degree curved visual system with projectors
by fsaviator
[April 20, 2019, 04:25:12 PM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[April 20, 2019, 11:26:43 AM]
Old Projector(s)
by fsaviator
[April 20, 2019, 10:53:59 AM]
OEM 737NG project - Long overdue update
by Karl737
[April 19, 2019, 09:56:23 PM]
CPFlight 737 NG MCP Pro and Efis Pro
by patiju
[April 19, 2019, 06:14:33 PM]
Goflight Airliners collection stuff for sale
by Steenos
[April 19, 2019, 03:22:12 PM]
German B738NG Homecockpit-Projekt
by Joe Lavery
[April 19, 2019, 04:59:21 AM]
Teensy LC Throttle Quadrant
by RayS
[April 18, 2019, 03:38:14 PM]
FSDream Team Couatl crashes when shutting down computers - any ideas
by navymustang
[April 18, 2019, 08:25:11 AM]
FLIGHTSIMEXPO RELEASES 2019 SPEAKER SCHEDULE, ANNOUNCES NEW PARTNERSHIP WITH EAA
by 757Simulator
[April 18, 2019, 04:20:53 AM]
737-800 Arduino X-Plane Build
by kurt-olsson
[April 17, 2019, 05:10:03 AM]
Teensy as Joystick
by kurt-olsson
[April 16, 2019, 01:54:29 PM]
Which Processor i7 - 8700K or i7 - 9700K
by Joe Lavery
[April 15, 2019, 04:00:33 PM]
Computer / Projector Combo
by blueskydriver
[April 15, 2019, 02:50:24 PM]
Flyengravity desktop MIP
by Steenos
[April 15, 2019, 02:22:39 PM]
TV Screen Position
by Trevor Hale
[April 15, 2019, 07:17:07 AM]
Join me on Vatsim Tonight
by Trevor Hale
[April 14, 2019, 05:07:50 PM]
Interfacing real instruments in p3d
by Steve Mount
[April 14, 2019, 04:56:08 PM]
Flight Sim Visual System on Public Surplus...
by bernard S
[April 14, 2019, 12:53:56 PM]
Aerosoft Australia 747 MCP
by 737simAdelaide
[April 14, 2019, 05:16:58 AM]
CPFlight 737 EL MCP For Sale
by 737simAdelaide
[April 14, 2019, 05:12:54 AM]
CPflight radios B737.
by avan1001
[April 14, 2019, 04:12:07 AM]
Anyone can recognize this material?
by 757Simulator
[April 14, 2019, 03:21:26 AM]
F18 military trainer cockpit for sale
by navymustang
[April 13, 2019, 10:19:06 PM]
FLIGHT ILLUSION gauges
by patiju
[April 13, 2019, 12:58:25 PM]
wanted FDS CDU
by 757Simulator
[April 13, 2019, 03:35:00 AM]