Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 1
  • *Guests: 47
  • *Total: 48

Our Discord

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

Offline Trevor Hale

  • Administrator
  • I am chained to this website!
  • *
  • Posts: 3,838
    • 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: 817
  • 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,838
    • 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: 203
  • 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,838
    • 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: 203
  • 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: 203
  • 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,838
    • 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

737-800 Arduino X-Plane Build
by mickc
[Today at 08:34:19 AM]
Flooring Installed!
by Mach7
[Today at 08:27:54 AM]
737 Throttle Conversion OC + ProSim
by kattz
[June 16, 2019, 11:39:03 AM]
A friendly FYI on Boeing rudder pedals
by kattz
[June 15, 2019, 10:36:39 AM]
Wanted - 737 Audio Panels - OEM
by jackpilot
[June 14, 2019, 08:08:09 PM]
2020 Microsoft Flight Simulator - new at E3 2019
by 757Simulator
[June 14, 2019, 03:39:07 AM]
737 starter switch mechanism
by paulnd
[June 13, 2019, 02:58:39 PM]
Make up your mind, Microsoft!
by jmlohrenz
[June 12, 2019, 07:25:10 PM]
What have you done for your simulator today?
by C150DIY
[June 12, 2019, 12:53:27 PM]
Complete 737-800 cockpit - moving sale
by FaustoP
[June 12, 2019, 01:26:39 AM]
Flyengravity desktop MIP
by patiju
[June 10, 2019, 01:01:06 PM]
the perfect thing to complete your sim hanger
by fsaviator
[June 09, 2019, 03:12:50 PM]
Wanted - COMPLETE set of Boeing 727 or 737 rudder pedals
by kattz
[June 08, 2019, 01:26:09 PM]
For sale: 200° Curved screen with 3 projectors
by sim172
[June 08, 2019, 09:07:03 AM]
Visual system screen by Northern Flight Sim for sale $500
by peterkwu
[June 08, 2019, 06:07:39 AM]
Wanted: GoFlight T8
by C150DIY
[June 07, 2019, 02:32:29 PM]
For Sale - CPFlight MCP737 + EFIS
by ZillaUK
[June 07, 2019, 09:54:58 AM]
737 FWD Overhead Switch Diagram
by bernard S
[June 07, 2019, 08:21:46 AM]
Change the Forum Theme to suit your own Needs.
by AdamMilstead
[June 07, 2019, 06:20:41 AM]
Aileron & Elevator jump back to center
by iwik
[June 06, 2019, 08:01:24 PM]
Join me on Vatsim Tonight
by Trevor Hale
[June 05, 2019, 05:17:13 PM]
Machinery for home cockpit building
by giaviv
[June 04, 2019, 04:12:10 PM]
PROMOCION STEERING FREE
by alvaro castillo
[June 04, 2019, 11:42:43 AM]
FLIGHTSIMEXPO LAUNCHES DISCOUNTED ADVANCE REGISTRATION FOR ORLANDO 2019 EVENT
by fsaviator
[June 03, 2019, 06:52:44 PM]
Question about linking the yokes
by jackpilot
[June 01, 2019, 02:22:10 PM]
Wanted: Jetmax 737
by nisx
[May 30, 2019, 01:49:24 AM]
Cessna 150 Builder
by C150DIY
[May 27, 2019, 04:59:48 AM]
A trick to get SPST toggles interfaced to XPlane 11 Easily...
by C150DIY
[May 26, 2019, 02:13:42 PM]
Amphenol female pin size?
by mickc
[May 24, 2019, 08:37:21 PM]
GSX across networked client visual computers
by FredK
[May 24, 2019, 03:32:34 PM]