Jump to content
The simFlight Network Forums

Tom_G_2010

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by Tom_G_2010

  1. If I followed the exchange correctly this is a bug in the C library and the function as designed isn't able to produce the result I need. But it is possible to evaluate and format the integer portion of the number separate from the decimal portion to get each to a fixed length and then concatenate the result for my output string, yes? using ans = string.format("%02d", val1) .. '.' .. string.format("%02d", val2) I will try this after I get off work today and follow up here to let you know how it works for me. THANKS!!!
  2. Scott, Thanks for pointing me to the syntax references I'm experimenting with various things now. Still not able to get a leading zero on there via the format function but that may just be my poor programing skills. I found one delphi reference on how to do it but the syntax does not seem to be supported in lua as it causes the script to fail. Until I figire it out I am evaluating the varable with an if statement to determine when it goes below 10.00 and if so I am concatenating a leading zero onto the string to be sent. If you have any other thoughts on this your assistance would be greatly appreciated. In the interim I'll keep plugging away. Thanks! Tom G.
  3. Scott, Thanks! That takes care of the characters following the decimal. I'm still dropping the leading character below 10 though. So, 12.3000... volts shows as 12.30 but 9.3000... shows as 9.30 not 09.30 Any further thoughts on the integer portion? Tom G.
  4. I am working on a lua script to monitor several values from P3D and send them to an Arduino via serial com as strings. I need the values to be fixed in length in order to interact with existing Arduino code monitoring the com port . For example, for my bus voltages I have a function to round the values to two decimal places but this removes any trailing zeros. And of course I loose the leading zero when the voltage drops below 10. So while 28.3157... results in 28.32 which is what I want, 28.3000 results in 28.3 but I need it to be 28.30 And, on the other side I would need 9.3157 to be 09.32 From what I've read in the lua docs and online I think I should be able to accomplish this with "string.format()" but I can't seem to make it work and the examples I'm finding aren't helping. Will string.format accomplish what I need? If so, what is the correct syntax? If string.format is not the answer any ideas on how to accomplish this would be greatly appreciated. Thanks! Tom G.
  5. Paul, Thanks! My plan is to load up P3DV4 sometime after FlightSimCon. My PC drives are on sleds and I just ordered another pair of sleds for this. I'll be setting up an alternate set of drives with P3DV4 so I don't mess up my current P3DV3 rig. I appreciate your advice and the approach you suggest. This looks like it may be on the top of my summer project list. I'm sure I'll have plenty of questions and I'll try to post progress updates as well. Again, Thanks! Tom G. PS: If your interested you can check out my sim pit build at https://www.facebook.com/mycessnasim/ or http://www.mycessnasim.info
  6. First, full disclosure, I'm not a programmer. I am self taught to some degree with C++ (at least the subset of it that Arduino's use), a bit of VB and some basic LUA and VBA. I've been a long time FSUIPC user but just recently noticed the FSUIPC Client DLL for .NET subforum and it caught my attention. I need to solve for a problem if I am to make the move to P3DV4 and I'm trying ot figure out of this might be a starting point. My Cockpit build (A Cessna 172) uses Arduino cards for everyting from my Avionics stack to my wet compass and air speed sensatve vents. They are at present interfaces to P3D via a discntinued program (Link2FSMulti) that passes many of the P3D offsets to the Arduinos via serial USB as a simple set of text strings (for example air speed might be <T090) that I can read and the Arduino's in return control codes that the app coverts to P3D offsets. The app allows me to select which offsets I want to pass and to what serial port. The app is unfortunatley not compatible with the new P3DV4. As I search for a replacement app I am finding many that allow for some form of I/O between P3D and the Arduino but most do so by loading their own code onto the Arduino that takes over the Arduino and creates an interface that the developer thinks is ideal. I am finding that most fuction far different or in a few cases fall far short in fuctionality to what I have developed. As an example they will control the 7 segment displays on radios and allow tuning but they would not allow me to replicate the 32 channel memory that I have coded into my current radios. So I would have to toss a great deal of my current code in the bit bucket and give up on functionality to use those apps. To cut to the chase I want to develop a very basic interface that allows me to pass a selected set of offsets (if possiblle in the form of a very basic serial strings as noted above) from P3D to specific USB serial ports and then via those same ports pass serial strings back that interface would pass back to P3D as offsets. I was pondering writting a big LUA script to do all this but, as I said cae across this forum and I am wondering if this might allow me to write a somewhat more userfriendly VB app that would accomplish what I need. Any thoughts or advice would be greatly appreciated.
  7. Arrggghhhh!!!!! I just noticed why and feel really embarrassed for all this activity over what may only be a case sensitive issue. I declared speed=9600 but my com.open was looking for Speed
  8. Pete, SERIAL DATA FLOW PROBLEM SOLVED!!! My original com open statement in the Lua script looked like this: speed = 9600 handshake = 0 ArdComPrt = com.open("COM8", Speed, handshake) Just now to strip it all the way down and eliminate any other problem sources I took out the variable declarations and ran it as follows: ArdComPrt = com.open("COM8", 9600, 0) That works! The Com Port opens and the data keeps flowing. Should that have made a difference? Should the 9600 or 0 been in quotes when I declared them? I am running into some other problems with my LVars but I'll start a separate post about that If I am unable to solve those issues on my own.
  9. A user on an Arduino forum pointed out that the Arduino is designed to do a reset any time that a connection is open via the USB port. I guess they did this to make uploading code to the board easier for users. However, I'm told this may be what is stalling my serial port. I am reading up on some ways to disable that reset. But I am also curious why the Arduino IDEs serial monitor doesn't cause the same problem. If I connect it and the port resets why then does the serial data resume. I'm asking out on the Arduino forum to see if there's some sort of string I can return to the Arduino from the lua script to wake it up.
  10. Pete, I'm doing some reading on a couple Arduino sites trying to figure out what the Arduino is expecting. I haven't found much yet. On the official Arduino sites reference page I don't see any mention of flow control and the only serial parameters I seem to have control of are data bits, parity and stop bits. By default it's set to 8N1. I can configure the data bits from 5 to 8, parity None, Odd, or Even and, stop bits 1 or 2. I haven't found anything on flow control yet but I've tried all four options from com.open in my lua script and none resolve the issue. I've also posted out on one of the Arduino forums to see if anyone there might have some additional information. Tom G.
  11. As an additional test I removed event.com line from the script so that the only thing affecting the com port was com open and the data still stops flowing so it appears to be the com.open that is stalling the port.
  12. Pete, To clarify what the serial monitor is showing their is a 2 second pause between 41 34 35 0d 0a and 41 34 36 0d 0a that I failed to note in my reply above., I started to edit my lua script per your suggestions and before I got too far I discovered something. Prior to this I had been running the serial monitor program (Device Monitor Studio) only briefly just to confirm the strings being sent by the Arduino. For this round of testing I left it running and observed it as I ran the lua script. For testing I have the lua script assigned to two buttons. One to launch it and the second to kill it. I was watching the serial monitor during this round of testing and noticed that the data stream coming form Com 8 (the Arduino) stops any time I launch the lua script. Having discovered this I did it a few more times just to confirm I could replicate it and I can. When it occurs I can jump start the serial port again by killing the lua script and turning the Auduino IDE's serial monitor on and then back off. As soon as I do that the Device Monitor Studio shows the data flowing again. But, if I launch the lua script the data stops. Any thoughts on what would cause that?
  13. Pete, I removed com.test as suggested and it didn't make a difference. I've also changed the Lua script to use event.com. Another user sent me a code example from there setup that is working for them and it also used event.com Here's what I'm doing to test this now. Ardiono test code same as before: void setup() { Serial.begin(9600); } void loop() { Serial.println("A45"); delay(2000); Serial.println("A46"); delay(2000); } Lua Script: speed = 9600 handshake = 0 ArdComPrt = com.open("COM8", Speed, handshake) if ArdComPrt == 0 then ipc.display("Could not open ARDUINO Com Port") ipc.sleep(1000) ipc.exit() elseif ArdComPrt ~= 0 then ipc.display("ARDUINO Com Port OPEN") ipc.sleep(1000) ipc.display("") end function ArdData(ArdComPrt, datastring, length) if datastring == "A45" then ipc.writeLvar("L:kma26SelectorKnob_pos",1) elseif datastring == "A46" then ipc.writeLvar("L:kma26SelectorKnob_pos",2) end end event.com(ArdComPrt, 10, 1, 10, "ArdData") Using a serial monitor program to watch the port I see the following repeating in Hex 41 34 35 0d 0a 41 34 36 0d 0a So, the A45 and A46 are each being sent with a Line break and Carriage Return. But still no joy. The Com Port indicates open but the script doesn't appear to be detecting the serial traffic. I've also switched out Arduino cards and serial ports. Any further thoughts?
  14. Pete, Thanks! I like the idea of using a terminating character. I'll be sure to try that. With the variable length of the strings it sounds like that would be the cleanest way to deal with it. I'll get back to you with my findings on com.test, read, and readlast. Work is getting a bit crazy though, I just got pulled into a multi day fire dril, so it may be a few days, but, I'll be sure to post my progress as soon as possible.
  15. A good question and my honest answer is lack of experience. The received strings will have a minimum of 3 characters similar to the test string "A45" which will active Comm 1 xmit. However, some of the codes will be followed by 1 to 5 digits to do things like set a radio frequency or select a DME, etc. So I I could receive the first three characters all at one time consistently and listen for additional depending on the code string sent. I will need to do some reading and research on the terminator to figure that out. The serial.println is supposed to send a line feed. If that might be messing it up I'll try a regular serial.print for sending the strings. I did a couple basic test to confirm the Com port and it does appear to be correct, Com 8. For example knowing that it can only be used by one program at a time I turned on the Arduino IDE serial monitor and could see the test strings being sent. With it on the lua script could not open the com port. I did the reverse and opened com port 8 with the lua script and the IDE could no longer access Com 8. So, I think that shows I've got the correct Com Port, yes? I also downloaded a program to monitor USB serial ports and when I set it to watch Com 8 I see the test strings as traffic on the port. Assuming the Com Port is correct and the data can be seen on the port by the monitor, any further thoughts on trouble shooting steps that I can take? Thanks, I'll modify the script accordingly. I'll read up on the use of event.com and modify my code. Thanks for the reply! I'll do some more work on this and come back with any further questions.
  16. I am attempting to come up with a lua script that will monitor a com port and based on received strings trigger some LVars to control the Avionics stack in my Add On aircraft. This is my first attempt at doing anything with the com library and I'm at a bit of a loss for why what I have isn't working. My sim pit has an Ardiono based avionics stack and it works well with several of my add on aircraft via a program called LinktoFS Multi. However, my newest Add On, an A2A 172 has some advanced features that require LVars. Several months ago I came across another pit builder who was working on a similar project and had already come up with a script. Unfortunately I can't find his name or a link to the source in my notes so I can neither give that person credit or ask them questions. To try and test this I setup a temporary Ardiono sending two test strings. It sends "A45" and "A46" alternately every two seconds. Those are the existing strings I use to switch Comm Audio 1 and 2 via the other program so I want to keep them for consistency. Here's the lua script: speed = 9600 handshake = 0 ArdComPrt = com.open("COM8", Speed, handshake) if ArdComPrt == 0 then ipc.display("Could not open ARDUINO Com Port") ipc.sleep(2500) ipc.exit() end while ArdComPrt > 0 do Frm_Arduino = "" char = "" if (com.test(ArdComPrt)>0) then while com.test(ArdComPrt) > 0 do char = com.read(ArdComPrt,1) Frm_Arduino = Frm_Arduino..char end end if Frm_Arduino == "A45" then ipc.writeLvar("L:kma26SelectorKnob_pos",1) elseif Frm_Arduino == "A46" then ipc.writeLvar("L:kma26SelectorKnob_pos",2) end ipc.sleep(50) end and here's what I have the Arduino on com 8 doing as a test source: void setup() { Serial.begin(9600); } void loop() { Serial.println("A45"); delay(2000); Serial.println("A46"); delay(2000); } Via the Arduino IDE's serial monitor I can see the "A45 and "A46" going out every two seconds. I can also see the Tx LED on the Arduino flashing every two second. I placed some ipc.display commands in my lua script and I can see that ArdComPrt handle returns a value of 904947972 repeatedly and following it each time com.test(ArdComPrt) returns a 0. So it appears that the Lua script is not seeing the strings my Ardiono is sending. Any thoughts or ideas on what I'm doing wrong would be greatly appreciated. As I said above, being new to the com library I'm at a bit of a loss for why what I have isn't working. Thanks! Tom G.
  17. Pete, Thanks, I was able to log the L:Vars and write a bit of LUA code to get the fuel selector working. if ipc.testbutton(0, 28) == true then ipc.writeLvar("L:KNOB_FUEL_SELECTOR",2) ipc.control(65955) elseif ipc.testbutton(0, 25) == true then ipc.writeLvar("L:KNOB_FUEL_SELECTOR",-1) ipc.control(65957) elseif ipc.testbutton(0, 26) == true then ipc.writeLvar("L:KNOB_FUEL_SELECTOR",0) ipc.control(65956) elseif ipc.testbutton(0, 27) == true then ipc.writeLvar("L:KNOB_FUEL_SELECTOR",1) ipc.control(65958) end
  18. Sorry Pete, I inadvertently added the work Tank in my original post. I was typing the message while on break at work from memory. I now have the default FSX 172 working and my Carenado 172N working. But, No Luck on my Carenado/Alabeo 172RG For the two that work after a few different attempts with no results I decided to manually edited the config file to deleted the button assignments. I don't know what was wrong in the config, nothing jumped out at me but, after reentering the button assignments via FSUIPC it now works for the default 172 and my Carenado 172N using the Fuel selector left, Fuel selector right, Fuel selector all for the default 172 and adding Fuel selector off for the Carenado 172N. So I then tried to figure out the Carenado/Alabeo 172RG Based on Paul's reply above I decided to experiment with the Fuel selector Set function. I ran a log to look at what parameters were being sent when I used the Mouse to switch the selector on screen. I then set my button inputs to do the same but it's still not working. Here's a copy of the log after I did this where I used the mouse on screen followed by pressing my corresponding button to see how the two compared. To my very untrained eye the two appear to be doing the same thing yet the mouse click works and the button press does not.. ********* FSUIPC4, Version 4.938f by Pete Dowson ********* User Name="Tom Gauvin" User Addr="tom@xxxxxxxxxxxx.xxx" FSUIPC4 Key is provided WideFS7 Key is provided 4257579 System time = 05/02/2015 00:04:25, Simulator time = 12:14:11 (17:14Z) [Continuation log requested by user] Running inside FSX on Windows 7 Module base=613B0000 4257579 LogOptions changed, now 60000000 00000001 4257610 [Buttons] now profile-specific: 4257610 0=P0,28,C65962,0 4257610 1=P0,25,C65962,2 4257610 2=P0,26,C65962,3 4257610 3=P0,27,C65962,16 4264334 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 0 (0x00000000) FUEL_SELECTOR_SET 4266674 Button changed: bRef=0, Joy=1, Btn=15, Pressed 4266674 [Buttons] 55=P1,15,C65962,0 4266674 FS Control Sent: Ctrl=65962, Param=0 4266674 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 0 (0x00000000) FUEL_SELECTOR_SET 4266799 Button changed: bRef=0, Joy=1, Btn=15, Released 4269014 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 3 (0x00000003) FUEL_SELECTOR_SET 4271245 Button changed: bRef=0, Joy=1, Btn=14, Pressed 4271245 [Buttons] 54=P1,14,C65962,3 4271245 FS Control Sent: Ctrl=65962, Param=3 4271260 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 3 (0x00000003) FUEL_SELECTOR_SET 4271354 Button changed: bRef=0, Joy=1, Btn=14, Released 4273195 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 16 (0x00000010) FUEL_SELECTOR_SET 4275035 Button changed: bRef=0, Joy=1, Btn=13, Pressed 4275035 [Buttons] 56=P1,13,C65962,16 4275035 FS Control Sent: Ctrl=65962, Param=16 4275035 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 16 (0x00000010) FUEL_SELECTOR_SET 4275176 Button changed: bRef=0, Joy=1, Btn=13, Released 4278514 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 2 (0x00000002) FUEL_SELECTOR_SET 4282492 Button changed: bRef=0, Joy=1, Btn=12, Pressed 4282492 [Buttons] 53=P1,12,C65962,2 4282492 FS Control Sent: Ctrl=65962, Param=2 4282508 *** EVENT: Cntrl= 65962 (0x000101aa), Param= 2 (0x00000002) FUEL_SELECTOR_SET 4282633 Button changed: bRef=0, Joy=1, Btn=12, Released 4289700 Sim stopped: average frame rate for last 32 secs = 29.9 fps 4295877 LogOptions changed, now 00000000 00000001
  19. Thanks!!! I'll give that a go this evening after work.
  20. I just added a 4 position switch to my C172 sim pit build to function as the fuel tank selector switch. I configured it via FSUIPC so that each of the four positions corresponds to FUEL_TANK_SELECTOR_LEFT, RIGHT, ALL, and OFF. Unfortunately FSX is not responding to the inputs. I can operate the fuel selector within the 3D cockpit via mouse. I have checked functionality using both the FSX default 172 and a couple add on 172s but none respond. I'm running FSX w/Acceleration on a Win7 64Bit pc with the latest release of FSUIPC. I am not sure where to go from here in terms of trouble shooting or steps I can take to gather more intel to assist in trouble shooting. Any advice or direction would be greatly appreciated. Thanks! Tom G.
  21. Paul and Pete Thanks! I have it working now with ipc.axis I'm also going to try the com library to see if I can get that working and see how each works. Tom G.
  22. I am trying to understand how to get a Joystick Axis value into a LUA script. I've read the documentation and read through several forum posts here but I'm just not connecting the dots. I'm frustrated with myself overt this as I feel the answer is sitting there in front of me in the documentation but it's just not penetrating my thick skull... done venting, sorry, onto my questions. I think I need a real FSUIPC & LUA for dummies jump start here. 1. I have an available joystick axis Joy # 1 Axis # U, What type of action and drop down selection should I set up on the FSUIPC Axis Assignment tab to send the joystick axis value to my LUA Script called A2AC172R.lua? 2. What line of code should I write in the LUA script to pick up that value? I've read about ipc.axis, and the various ipc.read__'s and have been trying to use them with various axis actions from FSUIPC but I'm missing something (likely something very obvious) and can't seem to make it work. What I am ultimately trying to accomplish is to get the instrument panel light dimmers, and the cabin heat and air slide controls of my A2A C172 to work via some extra axis I have to work with.
  23. Pete, Thanks much! I used the Offset Byte Setbits as you suggested and it works great. I may try this through a lua script as well to see what other twin engine controls I can consolidate using that same switch. I'm doing more sim flying now with twins, both piston and turbine and on top of being very space constrained my desktop sim pit was never setup for that. This makes it a more workable solution. For my fuselage conversion won't need this as I plan to build some modular components to emulate either single or twin configurations, but until that's done this will hold me over. Again, Thanks! Tom G.
  24. I am starting to read up on how to do some compound button functions using FSUIPC for my desktop sim pit where space is at a high premium. For example a set of switches will affect Engine 1 or engine 2 depending on the selection of a Master A/B switch. I have the same space problem with my throttles. I am wondering if it is possible to do something similar with Throttle, Mixture, and Prop controls. For example, have a center off switch where in the left position those three axis affect the left engine, in the center neither (to allow for repositioning the control to match the sim condition) and to the right, of course, affect the right engine. Can axis assignments be affected like a compound button function from within FSUIPC, or maybe changed via a lua script. The other thought I had was could I setup a pair of complimentary aircraft configs to affect axis assignments and somehow switch configs programmatically perhaps via a lua script or some other method. If this is all beyond what can be done then for my desktop sim pit I may be limited to the old standby of common control for both engines, But, if this could be done, it would allow me to handle start up, balancing engines, and engine failure procedures all with one set of controls. Not overly realistic but very cool for a limited space setup like my desktop rig. Thanks! Tom G.
  25. Pete, I think in general I'm all set here. I was missing some obvious stuff. Sometimes the lua docs remind me of the phrase in my old college texts "The advances student will recognize..." That's not a reflection on the quality of the doc's, but more a recognition on my part that sometimes I'm a little thick headed. And, yes there's more than my initial question about lua variables that found its way into this post, but I started a new post about the Carenado Timers to parse out that issue. Thanks! Tom G.
×
×
  • 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.