Jump to content
The simFlight Network Forums

r2500

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by r2500

  1. There is support for GoFLight modules in FSUIPC, but not in WideClient. Instead, one can use GFdisplay.exe. But I thought it might be amusing to develop some Lua code to perform some of the same functions, both as a way to learn some Lua and because coding in Lua provides opportunities for quite elaborate functionality. My code is in the attached zip file. The reason the code is not a full replacement for GFdisplay is quite simply that I own only two modules, the display module GF-46 and the RP48 rotary/pushbutton/LED module. I like to think that adding other modules would not be at all difficult. When someone sends me the hardware, I'll give it a try :smile:. That said, if you want to try the software, extract the four files in the attached zip. "gfDisplay.lua" goes in the same directory as WideClient. Create a subdirectory of the WideClient directory name "modules" and put the other files there. That is, if C:\flight contains WideClient.exe, C:\flight will have at a minimum three files, WideClient.exe, WideClient.ini, and gfDisplay.lua, and one directory "modules". "modules" will contain three files, gf46.lua, rp48.lua, and util.lua When WideClient connects to the server, it will run gfDisplay.lua which in turns sets up all the necessary code and connections. On my system, for reasons I don't understand, it takes an additional 24 seconds for the display values to match the cockpit. Once that delay is past, updates are instantaneous. In the code supplied, there are 3 sets of display items; one set contains 4 display items (autopilot altitude, autopilot vertical speed, heading bug, and OBS1), and the others each contain two. Each set can contain as many items as you wish and there can be as many sets as you want as well. You can switch the item displayed in any given set by using the pushbutton on the GF-46 module or by rotating the rightmost knob on the RP48. The latter is more convenient and you can go forwards or backwards. By rotating the 3rd RP48 knob (rightmost but one), you change the set being displayed. If you don't have the RP48, then of course you can have only one set of display values, though you could write code to substitute key presses, say, for the RP48 knobs. The second display set, as coded, shows NAV2 standby and transponder settings. The third set shows wind speed and time smoothed simulator frames per second. The knob on the GF-46 is used to change the displayed value in the simulator. For instance, if the heading bug is displayed, turning the knob changes the bug position by one degree per click, and pressing the knob and turning changes the bug 10 degrees per rotary position. To alter what is displayed on the GF-46 module, you will need to change the configuration tables at the start of gf46.lua. Note that each display set has a label (unused) and a current index value. In each set, each display item is encoded in a pair of tables. The first contains the display label, offset to monitor, type of offset (unsigned word or "UW", say), the ipc.read function, a display format for string.format, and a scaling table -- multiplier, divisor, and inversion flag [reciprocal of datum is what's to be scaled and displayed]. The second table holds the control values to be sent to FSUIPC via the ipc.control function for knob turned cw or ccw, or pressed and turned cw/ccw. Code handling the RP48 is less clean. Just for fun, I've included code to use the 8 LEDs of the RP48 to show taxi speed, with all lights lit at speeds of 20 mph or higher. Richard GoFDisplay.zip
  2. Ah, how pleasant. That works very nicely. Code is much cleaner now. I just ran across this note on stack overflow. I imagine this is what you're doing. This function is really useful at runtime to construct function "pointers" when you have the name (string) and the name of the module (string) in which the function resides. Of course, often, the module name is the file name, but probably it's better if that doesn't appear in the code explicitly. Something like module(..., package.seeall) modname = ... .. "." --best use of 5 periods in a Lua statement!? fn = findfunction(modname .. "some function name as string") --pass this fn in data structures and it can be used without needing to resolve the "." structure On an irrelevant matter, yes I do use an editor with line numbers. After over three decades of Unix, I'm a vi addict and so use gvim. Newer editors handle class structure and the like better, but ... Richard
  3. Found a comment that says that Lua_getglobal does not handle "." Maybe it doesn't handle "[]" notation either.
  4. Last things first, correct, I don't mean the FS modules folder, but one I created as a sub directory of the folder in which WideClient is located. Then "require" knows where to look without my doing anything with the package loaded/loadlib/etc code. I'm very new to Lua and there are vast areas in which mis-understanding could get me lost for a long time<g>. Which means I know nothing about the C code underlying Lua. A quick test says that "myf = M.f" does work. But I don't want the top level code to know what's in M, so to speak. I'll have to experiment more with name passing though my data structures, though I may not have time to do so for a day. Since myf = M.f worked (at least once<g>), I'm wondering if the code in the event library (or the C code it calls) does some massaging of the string function, like removing brackets, dots, and the like, to make it a simple name.I have experimented a bit with printing out environments and it looks as if everything is where one expects it (and event.offset should be able to see the modular structure). Too bad the error message doesn't say which proc not found. Richard
  5. I would like to be able to call event.offset(offset, type, "fn") where fn is a function in a Lua module included in the main program with a "require" statement. It is possible to do this by making "fn" the name of a function in the main program that in turn calls the function in the module, but that means that the main program has to know about details of the "required" module, and that's undesirable. That I can't make it work can be seen in the code that follows ... "Event proc not found". Is what I want possible using WideClient? Richard What follows are two very short Lua programs, one that resides in the modules subdirectory, and a "main" program to be run by WideClient. --==========Start of file "modules\M.lua"============== module(..., package.seeall) function f(offset, value) print(string.format("heading %d", value)) -- ignoring scaling needed in the real code end -- this doesn't work --event.offset(0x7CC, "UW", "f") --==============end of file=============== -- Start of Initial.lua require "M" function doit(offset, value) M.f(offset, value) end -- these both print "type function" print(string.format("Trying M.f, type %s", type(M.f))) print(string.format('Trying _G["M"]["f"] , type %s', type(_G["M"]["f"]))) -- this works event.offset(0x7CC, "UW", "doit") -- these don't. They both generate a compile time error --[[ ********* LUA: "Initial" Log [from WideClient] ********* Date (dmy): 07/02/11, Time 16:46:36.415: Client name is FRANZ 546 LUA: beginning "C:\Do Flight\Initial.LUA" 561 LUA: Trying M.f, type function -- from the print statement above 561 LUA: Trying _G["M"]["f"] , type function -- ditto 561 *** LUA Error: C:\Do Flight\Initial.LUA:27: Event proc not found 561 LUA: ended "C:\Do Flight\Initial.LUA" ********* LUA execution terminated: Log Closed ********* --]] --[[ -- remove the comment delineators to see the error event.offset(0x07CC, "UW", '_G["M"]["f"]') -- heading bug event.offset(0x07CC, "UW", "M.f") -- heading bug --]] --===============end of file====================
  6. Yes, that was just stupid of me. Of course they are controls, written using ipc.control() That fixed the problem. Instead of ipc.control(65892, 1) where the "1" value from the event call and which is sometimes 2 or more (fast knob turn), I changed as you suggested to ipc.control(65892) and the problem went away. Permanently, I trust.
  7. Is there anything unusual about the AP_ALT_VAR_INC/DEC offsets? (Surely not ... but) GoFLight GF46 connected to WideClient computer with controls and display run by my lua code on the WideClient computer. The pushbutton changes what is displayed and the rotary knob changes the value (or when pressed and rotated, changes a related offset). This all works except for access to the autopilot altitude offsets. (The fast offsets work as expected). Data is sent to FSX but nothing changes. I've included below a chunk of the WideServer log and the WideClient log as well as the two lua tables that determine what control offsets go with what and what is read and then displayed. Since everything in the table works as desired except the two offsets at 65892/3, I'm both perplexed and wondering where to look for my mistake. In the logs below, I start on the VS (Autopilot vertical speed) and rotate the knob twice to the right and then press it and rotate once more to the right. This has the desired effect of increasing the vertical speed by 100 twice and then by 1000, just as one expects from the descriptions of the offsets. I then press the button to switch to the ALT display (which reads correctly) and repeat ... twice clockwise and then once while pressed. As can be seen from the logs, when the knob is rotated for ALT, the correct offset information and param value (=1) is sent, but unlike the other instances, nothing is returned. (For VS, VS FAST and ALT FAST, everything works). Puzzled. ********* WideServer.DLL Log [version 7.654] ********* Blocksize guide = 4096 (double allowed) Date (dmy): 09/02/11, Time 18:08:37.667: Server name is GIUSEPPE 15242 Initialising TCP/IP server 15257 Initialising IPX/SPX server 15257 IPX/SPX socket() failed [Error=10044] Socket type not supported 15257 Failed to start IPX/SPX Server 15257 Initialising UDP/IP server 16100 Broadcasting service every 1000 mSecs 33041 Incoming connection Accepted ok (skt=9140) TCP 33166 Restarting service due to zero reception! 33182 Failed to start IPX/SPX Server 36177 Incoming connection Accepted ok (skt=9084) TCP 36333 Connected to computer "FRANZ" running WideClient version 6.841 (skt=9084) TCP ....break connection, reconnect more than once but this doesn't change the behavior 331612 Incoming connection Accepted ok (skt=8680) TCP 331674 Connected to computer "FRANZ" running WideClient version 6.841 (skt=8680) TCP 331674 Read: Offset=81FF, Size=0101 331674 Read: Offset=3320, Size=0002 331674 Read: Offset=D000, Size=0014 331674 Read: Offset=C824, Size=0004 331674 Read: Offset=CC04, Size=03FC 331674 Read: Offset=0FF0, Size=0110 331674 Read: Offset=0371, Size=0001 331674 Read: Offset=0598, Size=0018 331674 Read: Offset=3F02, Size=0002 331674 Read: Offset=3BD2, Size=0002 331674 Read: Offset=32FC, Size=0002 331674 Read: Offset=3304, Size=000A 331674 Read: Offset=3D00, Size=0200 331674 Read: Offset=5B00, Size=0080 331674 Read: Offset=5400, Size=0006 331674 Read: Offset=320C, Size=00E4 333843 Read: Offset=330F, Size=0013 333843 Read: Offset=0371, Size=0001 336027 Read: Offset=330F, Size=0013 336027 Read: Offset=0598, Size=0018 338211 Read: Offset=330F, Size=0013 338211 Read: Offset=0FF0, Size=0110 340410 Read: Offset=330F, Size=0013 340410 Read: Offset=320C, Size=00E4 342594 Read: Offset=330F, Size=0013 342594 Read: Offset=32FC, Size=0002 344778 Read: Offset=330F, Size=0013 344778 Read: Offset=3304, Size=000A 346947 Read: Offset=330F, Size=0013 346947 Read: Offset=330F, Size=0013 349131 Read: Offset=330F, Size=0013 349131 Read: Offset=3BD2, Size=0002 351330 Read: Offset=330F, Size=0013 351330 Read: Offset=3D00, Size=0200 351876 Read: Offset=07F2, Size=0002 352391 Read: Offset=07D4, Size=0004 352890 Read: Offset=07CC, Size=0002 353389 Read: Offset=0352, Size=0002 353889 Read: Offset=0354, Size=0002 354388 Read: Offset=0C4E, Size=0002 356634 Read: Offset=330F, Size=0013 356634 Read: Offset=3F02, Size=0002 357648 Write: Offset=3110, Size=0008 66 01 01 00 01 00 00 00 358382 Write: Offset=3110, Size=0008 66 01 01 00 01 00 00 00 358818 Read: Offset=330F, Size=0013 358818 Read: Offset=5400, Size=0006 359567 Write: Offset=3110, Size=0008 FF 03 00 00 01 00 00 00 361002 Read: Offset=330F, Size=0013 361002 Read: Offset=5B00, Size=0080 363186 Read: Offset=330F, Size=0013 363186 Read: Offset=81FF, Size=0101 364809 Write: Offset=3110, Size=0008 64 01 01 00 01 00 00 00 365355 Read: Offset=330F, Size=0013 365355 Read: Offset=C824, Size=0004 365807 Write: Offset=3110, Size=0008 64 01 01 00 01 00 00 00 367118 Write: Offset=3110, Size=0008 F9 03 00 00 01 00 00 00 367554 Read: Offset=330F, Size=0013 367554 Read: Offset=CC04, Size=0410 369738 Read: Offset=330F, Size=0013 371938 Read: Offset=330F, Size=0013 371938 Read: Offset=0352, Size=0004 372702 Error 10053: client socket disconnected at Client: removing (skt=8680) TCP 421858 Close signalled to clients 422950 Closing down now ... Memory managed: Offset records: 780 alloc, 778 free Read buffer usage: 208 alloc, 208 free, max in session: 1 Write buffer usage: 7179 alloc, 7179 free, max in session: 1 Throughput maximum achieved: 30 frames/sec, 820 bytes/sec Throughput average achieved for complete session: 8 frames/sec, 212 bytes/sec Average receive rate from "FRANZ": 0 frames/sec, 14 bytes/sec ********* Log file closed ********* ********* WideClient Log [version 6.841] Class=FS98MAIN ********* Date (dmy): 09/02/11, Time 18:14:16.700: Client name is FRANZ 1887 Timing Thread Started 2402 SendReq Thread Started 2418 Trying TCP/IP host "Giuseppe" port 8002 ... 2418 ... Okay, IP Address = 192.168.1.102 2433 LUA: "C:\Do Flight\Initial.LUA": not found 2511 Sending computer name and requesting base data ... 2511 Button Thread Started 13899 Lost contact with ASE WX requester 23197 499 ReadOk: Offset=07F2, Size=0002 00 00 23696 499 ReadOk: Offset=07D4, Size=0004 00 00 00 00 24195 499 ReadOk: Offset=07CC, Size=0002 00 00 24695 500 ReadOk: Offset=0352, Size=0002 00 00 25194 499 ReadOk: Offset=0354, Size=0002 00 00 25693 499 ReadOk: Offset=0C4E, Size=0002 00 00 25693 0 ReadLocal: Offset=07F2, Size=0002 00 00 25709 0 ReadLocal: Offset=07F2, Size=0002 F4 01 25709 0 ReadLocal: Offset=07D4, Size=0004 D0 CC 2A 04 25709 0 ReadLocal: Offset=0352, Size=0002 60 10 25709 0 ReadLocal: Offset=0354, Size=0002 00 12 25709 0 ReadLocal: Offset=0C4E, Size=0002 54 01 28470 GF8.0: dwData= 00000001 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 28470 GF8.0: Sending joy=125, dw=00004000 28470 Preparing button change block 28470 Button change block sent 28485 Write: Offset=3110, Size=0008 66 01 01 00 01 00 00 00 28579 0 ReadLocal: Offset=07F2, Size=0002 58 02 29203 GF8.0: dwData= 00000001 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 29203 GF8.0: Sending joy=125, dw=00000000 29203 Preparing button change block 29203 Button change block sent 29234 Write: Offset=3110, Size=0008 66 01 01 00 01 00 00 00 29312 0 ReadLocal: Offset=07F2, Size=0002 BC 02 30389 GF8.0: dwData= 00010000 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 30389 GF8.0: Sending joy=125, dw=00000400 30389 Preparing button change block 30389 Button change block sent 30420 Write: Offset=3110, Size=0008 FF 03 00 00 01 00 00 00 30498 0 ReadLocal: Offset=07F2, Size=0002 A4 06 33212 GF8.0: dwData= 00000000 03BFFF01 02C734C6 03BFFF94 02FFE650 00000000 33212 GF8.0: Sending joy=125, dw=00000401 33212 Preparing button change block 33212 Button change block sent 33243 0 ReadLocal: Offset=07D4, Size=0004 D0 CC 2A 04 33353 GF8.0: dwData= 00000000 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 33353 GF8.0: Sending joy=125, dw=00000400 33353 Preparing button change block 33353 Button change block sent 35583 GF8.0: dwData= 00000001 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 35583 GF8.0: Sending joy=125, dw=00004400 35583 Preparing button change block 35583 Button change block sent 35615 Write: Offset=3110, Size=0008 64 01 01 00 01 00 00 00 36629 GF8.0: dwData= 00000001 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 36629 GF8.0: Sending joy=125, dw=00000400 36629 Preparing button change block 36629 Button change block sent 36660 Write: Offset=3110, Size=0008 64 01 01 00 01 00 00 00 37908 GF8.0: dwData= 00010000 03BFFF00 02C734C6 03BFFF94 02FFE650 00000000 37908 GF8.0: Sending joy=125, dw=00000000 37908 Preparing button change block 37908 Button change block sent 37939 Write: Offset=3110, Size=0008 F9 03 00 00 01 00 00 00 38048 0 ReadLocal: Offset=07D4, Size=0004 98 99 5B 05 43539 Timing Thread Terminated 43539 Button Thread Terminated 43539 SendReq Thread Terminated 43555 ****** End of session performance summary ****** 43555 Total time connected = 39 seconds 43555 Reception maximum: 50 frames/sec, 1292 bytes/sec 43555 Reception average whilst connected: 28 frames/sec, 711 bytes/sec 43555 Transmission maximum: 3 frames/sec, 104 bytes/sec 43555 Transmission average whilst connected: 0 frames/sec, 40 bytes/sec 43555 Max receive buffer = 2163, Max send depth = 2, Send frames lost = 0 43555 ********* Log file closed (Buffers: MaxUsed 3, Alloc 1157 Freed 1157 Refused 0) ********* ------------------------------------------------------------------------- Lua code snippet gfrdata = {} gfcdata = {} gfrdata[1] = { "VS" , 0x7F2, "SW", ipc.readSW, 1, 1, "%d" } gfrdata[2] = { "ALT", 0x7D4, "SD", ipc.readSD, 1, 19974, "%d" } gfrdata[3] = { "HDG", 0x7CC, "UW", ipc.readUW, 360, 65536, "%d" } gfrdata[4] = { "NAV2", 0x352, "UW", ipc.readUW, 1, 1, util.bcd, 4, 2, "1" } gfrdata[5] = { "TPDR", 0x354, "UW", ipc.readUW, 1, 1, util.bcd, 4, 0, ""} gfrdata[6] = { "OBS1", 0xC4e, "UW", ipc.readUW, 1, 1, "%d" } -- knob+ knob- pressed cw/ccw gfcdata[1] = { 65894, 65895, 1023, 1022 } gfcdata[2] = { 65892, 65893, 1017, 1016 } gfcdata[3] = { 65879, 65880, 1025, 1024 } gfcdata[4] = { 65645, 65644, 65647, 65646 } gfcdata[5] = { 1057, 1056, 1055, 1054 } gfcdata[6] = { 65663, 65662, 1027, 1026 } -- Vor1 Obi
  8. I understand that starting WideClient first is preferred, but for testing I need to stop, change code, restart and so it's convenient to let FSX just idle at the gate. Anyhow, WideClient is 6.841 and WideServer is 7.654. I've discovered that perhaps there's some merit in the notion that patience is a virtue: If I just wait for 22 seconds after WideServer/Client connect, everything starts working. I've measured it at 22 several times (ipc.read, if zero sleep 1000ms loop, if non-zero report loop count and exit loop), but I won't swear it's always that. Still, I can live with it though it would be nice to eliminate it, or at least know why it happens. Richard
  9. FSInterrogate works fine both on the FSX machine and on the wideClient machine. I've discovered that my code will work correctly after FSInterrogate starts running. The sequence is 1) start FSX and wait until the default flight is loaded and running. Then start WideClient on the "slave" machine. This in turn will run the one lua file in that folder (gfDisplay.lua). This code seems work fine except that all ipc.readxx calls return zero. Then start FSInterrogate and when it finishes loading the database, my lua code begins to operate correctly. Exit FSInterrogate and my code continues to work. It's very much as if I'm missing a system call to unplug <g> the Server-Client connection. WideClient logs "New Client Application: "FSInterrogate2std" (Id=7848) and the Individual client application activity section which contains just the Client 7848 summary with no other indication that there's other code wanting to talk across the link (but of course, it's a lua program run by WideClient so it's not really a client of WideClient).. WideServer log sees the connection and disconnection from WideClient. I've tried to attach the FSUIPC.log file, but the system says I'm not permitted, so here it is in-line: ********* FSUIPC4, Version 4.654 by Pete Dowson ********* Reading options from "F:\Flight Simulator X\Modules\FSUIPC4.ini" Trying to connect to SimConnect Acc/SP2 Oct07 ... User Name="Richard Wolff" User Addr="rjwolff@gmail.com" FSUIPC4 Key is provided WideFS7 Key is provided Running inside FSX on Windows 7 (using SimConnect Acc/SP2 Oct07) Module base=61000000 Wind smoothing fix is fully installed DebugStatus=255 156 System time = 06/02/2011 10:35:07 172 FLT UNC path = "\\GIUSEPPE\Documents\Flight Simulator X Files\" 172 FS UNC path = "\\GIUSEPPE\Flight Simulator X\" 952 LogOptions=00000000 00000001 952 SimConnect_Open succeeded: waiting to check version okay 9672 Running in "Microsoft Flight Simulator X", Version: 10.0.61472.0 (SimConnect: 10.0.61259.0) 9672 Initialising SimConnect data requests now 9672 FSUIPC Menu entry added 9719 \\GIUSEPPE\Documents\flight simulator x files\Bonanza in Tucson.FLT 9719 \\GIUSEPPE\Flight Simulator X\SimObjects\Airplanes\Carenado BONANZA F33A\Carenado_F33.AIR 36738 System time = 06/02/2011 10:35:43, Simulator time = 10:35:16 (17:35Z) 36738 Aircraft="BONANZA F33A BLUERED" 43072 Advanced Weather Interface Enabled 178809 Sim stopped: average frame rate for last 139 secs = 45.3 fps 178809 Average weather filter write interval in that time = 1087.9 msecs 185875 Weather Mode now = Custom 185875 \\GIUSEPPE\Users\rwolff\AppData\Roaming\Microsoft\FSX\Previous flight.FLT 477551 System time = 06/02/2011 10:43:04, Simulator time = 10:37:35 (17:37Z) 477551 *** FSUIPC log file being closed Average frame rate for running time of 139 secs = 45.3 fps Average weather filter write interval in that time = 1088.2 msecs Memory managed: 184 Allocs, 184 Freed ********* FSUIPC Log file closed *********** Richard
  10. I'm trying to write some lua code to be run in the WideClient environment. The problem I'm having is that all my ipc.readxx calls return zero. For instance, ipc.readSB(0x0238) should return the hour of the local time. I get zero (and it's only 9pm!). (WideClient connects and that's evident in the log, and on the FSX window title). Most of the read attempts have been within event handlers and I see the button presses and the code runs. I just get zero from the ipc read calls. I've tried setting the Log parameter in the WideClient.ini to "Yes", and while the button presses show up clearly, there's nothing that suggests the ipc.readSB(xxxx) ran. Is there some setup required before any ipc.readxx calls are made? ipc.log does run fine. Richard
  11. Unable to let go, I guess. WideClient 6.481 ; Lua Library Reference date Jan 19, 2011. Com library. "com.hidopen(...)" is apparently wrongly documented. I believe it should be "com.openhid(...)". With that change, I can read a GF-46, and after some fuss, determined that writing to the "setFeature" with a leading byte of '3' or '5' allows me to write bit patterns to the displays. So maybe lua can even now handle a remote goFlight module. But writing various bit patterns in the hopes of finding ones that work is at best tedious. Is there any documentation publicly available that details the way to write to the displays? Or maybe some C or lua code that maps ascii to the display segments?
  12. Indeed, I had docs from March, 2010. In the up to date documentation, the restriction is quite clearly marked. I can comfortably make do with gfdisplay.exe. Thanks for the rapid reply. Richard
  13. I have some GoFlight units connected to a client computer and then through WideClient/WideFS to FSX. This works acceptably if I use GFDisplay.exe to operate the GoFlight displays and leds and FSUIPC to handle programming the knobs and buttons. It seems reasonably clear that if the GoFlight modules were connected directly to the FSX computer, I could use Lua code to program and control all aspects of the hardware. But can I do everything via Lua when the hardware is connected to a client computer? My coding experiments suggest that it is not: the "gfd" part of the Lua library seems not to be in WideClient and an error message that "gfd" is "nil" is logged when I attempt to run code such as gfdDisplay.lua. But I'd like to be sure before I do very much more with the GFDisplay.ini file.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.