Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 0
  • *Guests: 32
  • *Total: 32

Our Discord

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

Offline Trevor Hale

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

 

Recent Posts

What have you done for your simulator today?
by B763
[Today at 04:58:46 PM]
Display Glare FDS w/Pic
by jackpilot
[Today at 03:45:11 PM]
Dispatch and Career Add-on
by Bob Reed
[Today at 12:15:37 PM]
Free Jet Ranger.
by geneb
[August 23, 2019, 06:16:52 PM]
items/oem from overhead
by gufau
[August 23, 2019, 12:49:15 PM]
Hi everyone!
by jskibo
[August 23, 2019, 08:05:33 AM]
737-800 Front window post size
by kurt-olsson
[August 23, 2019, 03:35:11 AM]
Shipping Woes
by Caflyt
[August 22, 2019, 10:47:49 AM]
Official WF 2019 Route
by dougsnow
[August 21, 2019, 07:49:35 PM]
Worldflight 2019 Open for Business
by Trevor Hale
[August 21, 2019, 08:28:13 AM]
More ?'s - annunciators?
by kattz
[August 21, 2019, 05:44:21 AM]
Looking for annunciators
by kattz
[August 19, 2019, 10:36:39 PM]
OK, So here we go!
by Caflyt
[August 19, 2019, 02:32:28 PM]
Flight Illusion Boeing Press Gauge for sale
by XOrionFE
[August 19, 2019, 08:40:35 AM]
Shell placement and yoke placement questions
by helloo
[August 18, 2019, 02:37:26 PM]
panel sismo oh
by gufau
[August 17, 2019, 04:17:00 AM]
My next sim?
by fsaviator
[August 16, 2019, 06:54:51 PM]
Looking for gear lever from 747-400, 757
by navymustang
[August 13, 2019, 10:05:44 AM]
Quick way to attach low res/smaller file size pics in your posts...
by Vincent T.
[August 12, 2019, 09:58:46 PM]
Cant post attachments from my iphone
by Trevor Hale
[August 12, 2019, 09:26:08 AM]
For Sale: Engravity 737 Window Frames
by Caflyt
[August 11, 2019, 05:02:28 PM]
737-800 Arduino X-Plane Build
by kurt-olsson
[August 10, 2019, 01:43:57 PM]
Help identifying a connector
by kurt-olsson
[August 10, 2019, 10:59:31 AM]
For Sale GoFlight Jet Console, 2 Private Pilot Racks all with GoFlight Modules.
by blueskydriver
[August 08, 2019, 09:40:02 PM]
Flightdeck Solutions Works with X-Plane11
by Michael_B737_ATP
[August 07, 2019, 02:59:21 PM]
Boeing Dual Linked Yokes for sale
by tennyson
[August 07, 2019, 07:34:58 AM]
CPFLight Backlighting
by mickc
[August 05, 2019, 10:09:53 PM]
Three Projector 210 degree with P3D4
by Nat Crea
[August 03, 2019, 08:36:50 PM]
Looking for part numbers from the 737 NG IPC
by mickc
[August 02, 2019, 11:20:49 PM]
WF2019
by Sam Llorca
[August 02, 2019, 09:22:56 PM]