Cockpit

* User Profile

Welcome, Guest. Please login or register.

Login with username, password and session length

Who's Online

  • *Users: 3
  • *Guests: 56
  • *Total: 59

Our Discord

WORLDFLIGHT 2019 - TEAM USA SUPPORTERS (HERO'S)

 
Worldflight 2019
Donations Starting Early
With 50 Days Left, it's time to start Counting Down to Worldflight 2019.  Beginning in August, we had 2 kind gentleman lead the way on our quest for donations to this amazing Charity Event.  Over the Past 6 Years, we (This community) Has helped to raise over $25,000.00USD to help the kids and their families of the All Children's Hospital in St. Petersburgh, Florida.  Kicking off the donations this year these Two Hero's are leading the way to another Successful Year.  I personally want to thank these two Gentleman and use this opportunity to have all of you donate to our wonderful cause. 
Thank you in advance for your help and please wish us much success for our 2019 event.
       
  ---Worldflight 2019 HEROS---

 James Williams, Warren Soeldner,  Sam Llorca, Doug Snow, Ryan O'Keefe, Edwin Burton, Vincent Thomas, Fred Kurasiewicz       





Thanks to all of you, You are all helping to make Worldflight 2019 a success..
Because of all you wonderful people so far we have raised a total of:

$2745.00 USD


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

Offline Trevor Hale

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

Mickey's Flightdeck - A Boeing 737-800 Cockpit on Youtube
by paulnd
[Today at 03:12:52 PM]
My New Computer Specs (feedback please)
by Caflyt
[Today at 01:52:57 PM]
757/767 PROJECT
by helloo
[Today at 11:13:43 AM]
Server Upgrade, and SSL Integration
by Trevor Hale
[Today at 10:50:39 AM]
727/737 yokes
by Caflyt
[September 15, 2019, 02:11:06 PM]
WORLDFLIGHT 2019 - Scenery Check Volunteers Needed
by Vincent T.
[September 14, 2019, 03:08:00 PM]
WORLDFLIGHT 2019 - FLIGHT BIDS
by Vincent T.
[September 14, 2019, 03:00:40 PM]
WORLDFLIGHT 2019 - AVAILABILITY
by Trevor Hale
[September 14, 2019, 07:25:32 AM]
WORLDFLIGHT 2019 - Employer matching for Donations...
by RayS
[September 14, 2019, 12:03:45 AM]
SimFest-West 2019 Videos
by RayS
[September 13, 2019, 07:27:16 PM]
737 MAX Build
by helloo
[September 13, 2019, 04:41:17 PM]
A little pucker factor here, I'm sure... nerves of steel
by RayS
[September 12, 2019, 06:30:45 PM]
Which size fuses to use in fuse block supplying FDS boards?
by blueskydriver
[September 11, 2019, 05:56:37 PM]
I finally got the shell pulled off the ATC-810...
by geneb
[September 11, 2019, 07:29:51 AM]
Wanted: Optoma GT1080Darbee Short Throw Projector
by Flightdeck57
[September 11, 2019, 12:24:08 AM]
F16 Simulator For Sale
by blueskydriver
[September 06, 2019, 03:52:34 PM]
Ebay Assistance
by iwik
[September 06, 2019, 02:00:00 PM]
Matrox 3
by jackpilot
[September 05, 2019, 10:45:00 AM]
So I got a big crate the other day...
by geneb
[September 05, 2019, 09:20:22 AM]
Official WF 2019 Route
by fsaviator
[September 05, 2019, 08:20:10 AM]
Are some sellers off their trolly
by kurt-olsson
[September 02, 2019, 12:39:54 PM]
Display Glare FDS w/Pic
by Joe Lavery
[September 01, 2019, 02:33:47 AM]
MCP
by Caflyt
[August 27, 2019, 06:57:41 PM]
Dispatch and Career Add-on
by fsaviator
[August 26, 2019, 10:42:45 AM]
What have you done for your simulator today?
by B763
[August 25, 2019, 04:58:46 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]