cellular55 Posted March 13, 2013 Report Share Posted March 13, 2013 Hi, I'm tring to write in the Offset 130 the address and the name of the flight plan that I would load in FSX. Doing this through Widefs I use the UNC format, but nothing happens and the flight is not loaded. Here the code I'm using in my VB program: PLANTXT = "\\FSX-PC\Users\ffffff\My Documents\File di Flight Simulator X\LIRA Ciampino - LIML Linate.pln" Call FSUIPC_Write(&H130, 256, VarPtr(PLANTXT), dwresult) Call FSUIPC_Process(dwresult) What am I doing wrong here? Thanks for the support and best regards Joe Link to comment Share on other sites More sharing options...
Pete Dowson Posted March 13, 2013 Report Share Posted March 13, 2013 Here the code I'm using in my VB program: PLANTXT = "\\FSX-PC\Users\ffffff\My Documents\File di Flight Simulator X\LIRA Ciampino - LIML Linate.pln" Call FSUIPC_Write(&H130, 256, VarPtr(PLANTXT), dwresult) Call FSUIPC_Process(dwresult) What am I doing wrong here? I don't really know VB, but aren't VB strings in wide character format, with two bytes per character? FS only uses plain ASCII, one byte per character. And also I thought whilst FS needs a zero terminator on strings, VB puts a length at the start instead? Mind you, I'm not sure about that either. Hopefully someone will contribute who knows VB. One other thing, again I don't know VB, but in C/C++, the '\' character is an escape character, so that controls like '\n' for newline can be included. To get a true '\' you have to use '\\'. Maybe the same applies in VB? Pete Link to comment Share on other sites More sharing options...
Paul Henty Posted March 15, 2013 Report Share Posted March 15, 2013 Pete is correct. VB strings are Unicode not ASCII. To write a string to FSUIPC you need to build a byte array from the string, converting each character into its single-byte ASCII equivalent. To read string you must read a byte array and convert each byte into the equivalent Unicode character. A discussion of both these techniques (including sample code) can be found in the UIPC_SDK_VisualBasic.zip file in the FSUIPC SDK. It's called "VB6 and strings in FSUIPC.txt". If you need further help understanding what's written there or getting the sample code to work, post back here and I'll try to help. By the way, the '\' is not an escape character in VB so your path string is fine as it is. (Apart from being in Unicode of course!). Paul Link to comment Share on other sites More sharing options...
cellular55 Posted March 15, 2013 Author Report Share Posted March 15, 2013 Hi, thanks a lot for the answers. I will try what suggested and I'll let you know about results. Joe Link to comment Share on other sites More sharing options...
cellular55 Posted March 18, 2013 Author Report Share Posted March 18, 2013 Hi, I have tried but without success. I think that the issue here is that I'm not able to understand how to properly write in the offset all the array in the correct way (I think I'm writing always the same byte at the offset, but I do not have idea how to change the offset pointer when I write the different elements of the array).. Below the code I have tried: ------------------------------------------- Public Sub Load_Plan() Dim dwresult1 As Long Dim plnx(256) As Byte PLANTXT = "\\FSX-PC\Users\ffffff\My Documents\File di Flight Simulator X\LIRA Ciampino - LIML Linate.pln" For i = 1 To Len(PLANTXT) plnx(i) = Asc(Mid(PLANTXT, i, 1)) Call FSUIPC_Write1(&H130, 256, VarPtr(plnx(i)), dwresult1) Next plnx(i + 1) = 0: rem put null char at the end of the sring Call FSUIPC_Write1(&H130, 256, VarPtr(plnx(i+1)), dwresult1) Call FSUIPC_Process1(dwresult1) End Sub ----------------------------------------------- Any help will be more than welcome Thanks and kind regards Joe Link to comment Share on other sites More sharing options...
Paul Henty Posted March 18, 2013 Report Share Posted March 18, 2013 I'm not able to understand how to properly write in the offset all the array in the correct way You need to build the entire array first, then send it to FSUIPC in a single write. To do this you just use the address of the first byte of the array. Because you're passing 256 as the size it'll take the next 255 bytes as well. I've modified your code. It should be OK but I have no way of testing it. Public Sub Load_Plan() Dim dwresult1 As Long Dim plnx(256) As Byte PLANTXT = "\\FSX-PC\Users\ffffff\My Documents\File di Flight Simulator X\LIRA Ciampino - LIML Linate.pln" For i = 1 To Len(PLANTXT) plnx(i) = Asc(Mid(PLANTXT, i, 1)) Next plnx(i + 1) = 0: rem put null char at the end of the sring Call FSUIPC_Write1(&H130, 256, VarPtr(plnx(1)), dwresult1) Call FSUIPC_Process1(dwresult1) End Sub Paul Link to comment Share on other sites More sharing options...
cellular55 Posted March 25, 2013 Author Report Share Posted March 25, 2013 Hi, I have modified the code as suggested, but nothing cahnges: plan is not loaded. I think that the issue here is that with this code I write always only one byte at the offset address and not the entire lenght of the plan string Joe Link to comment Share on other sites More sharing options...
Paul Henty Posted March 25, 2013 Report Share Posted March 25, 2013 Hi, I think that the issue here is that with this code I write always only one byte at the offset address and not the entire lenght of the plan string I've looked at it again and I don't think that's the case. You are clearly passing 256 for the length of the offset. I don't have VB6 so the only way you can check is to use the Logging facilities in FSUIPC. If you run your application on the FSX PC then you can enable the logging on the FSUIPC interface (logging tab - tick IPC Writes). If you run your application under wideclient then you need to edit the wideclient.exe and add or change the line Log=Yes under the [users] section. The results will be in the FSUIPC4.Log file (in the FSX Modules folder) or the WideClient.Log (in the same folder as WideClient.exe). Remember to turn the logging off when you're finished with it. This will tell you exactly what is being written to that offset by your code. If it's wrong show it to me and I'll fix the code. If the logging shows the path being written correctly then maybe the path is wrong? Paul Link to comment Share on other sites More sharing options...
mgh Posted March 26, 2013 Report Share Posted March 26, 2013 According to the SDK, offset 0x0130 is The current flight Plan path & file name (in UNC format if WideFS is in use). What happens if you copy "\" instead of the leading "\\" Link to comment Share on other sites More sharing options...
cellular55 Posted March 28, 2013 Author Report Share Posted March 28, 2013 Hi, I have done what suggested activating the log in widefs and effectively the offset is correctly written, but the flight is not loaded in fsx. I have also tried putting "\" instead of "\\" but with no changes. Suggestions are more than welcome Thanks Joe Link to comment Share on other sites More sharing options...
Paul Henty Posted March 29, 2013 Report Share Posted March 29, 2013 Suggestions are more than welcome I would think that the path has to be from the perspective of the FX PC (server) not the client. From the path you are sending it looks like the flight plan is on the server PC. Try passing the local path, so something like C:\Users\..... If the flight plan was on the WideClient pc then you would need the UNC path to the client pc's shared folder. Paul Link to comment Share on other sites More sharing options...
cellular55 Posted March 29, 2013 Author Report Share Posted March 29, 2013 Hi, Bingo !!! That was the point. What I do not understand is that effectively the plan is on the Server PC (where FSX is) and not on the client where I have the program and the wideclient , but putting the local path of the Server PC the plan is correctly loaded. Once more thanks a lot Paul. Joe Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now