shorthauler Posted September 23, 2023 Report Posted September 23, 2023 Hi folks, This seems to be a new (and interesting) problem, so I am opening a new thread. I am searching a string for certain characters, and depending on whether they are found or not, a free offset is either set to 1 or 0. The string is either SPD plus a number or MACH or a number ("SPD245" or "MACH 0.78"). Or, in managed mode, it is "---*". spdstate = ipc.readSTR(0xABCD, 9) if (string.find(spdstate, "%-") and string.find(spdstate, "%*")) then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,1) elseif string.find(spdstate, "%-") then ipc.writeUB(0x66C2,1) ipc.writeUB(0x66C3,0) elseif string.find(spdstate, "%*") then ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,1) else ipc.writeUB(0x66C2,0) ipc.writeUB(0x66C3,0) end This works well. Now the conundrum: I am also monitoring (FS Window) free offset 66C1 which in an older script was used to extract other elements of the string. This offset is not used anymore in any of my lua scripts. Still, in managed mode, when offets 66C2 and 66C3 both show "1", 66C1 it shows the value of 256 in signed 16-bit value (S16) or 65792 in signed 16-bit value (S32). In selected mode, when the string shows either a SPD or MACH value, it is 0. As this seems to be an FSUIPC related question rather than a Lua question, I am posting it here. Any input appreciated! -shorthauler Log: ********* LUA: "A320 SPD split" Log [from FSUIPC version 4.977] ********* 1712937 System time = 23/09/2023 13:45:07, Simulator time = 13:23:27 (12:23Z) 1712937 LUA: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 1712937 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 1712937 LUA: Global: ipcPARAM = 0 1712937 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 1712937 LUA: Global: spdstate = SPD 250 1712937 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:14 1712953 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:17 1712953 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:21 1713000 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:22 1713000 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:23 1713000 >>> Thread forced exit (ipc.exit or os.exit) <<< 1713000 System time = 23/09/2023 13:45:07, Simulator time = 13:23:27 (12:23Z) ********* LUA execution terminated: Log Closed ********* ********* LUA: "A320 SPD split" Log [from FSUIPC version 4.977] ********* 1729640 System time = 23/09/2023 13:45:24, Simulator time = 13:23:39 (12:23Z) 1729640 LUA: beginning "E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua" 1729640 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:3 1729640 LUA: Global: ipcPARAM = 0 1729640 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:11 1729640 LUA: Global: spdstate = SPD ---* 1729640 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:12 1729718 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:13 1729718 LUA: E:\FSX\Flight Simulator X\Modules\A320 SPD split.lua:23 1729718 >>> Thread forced exit (ipc.exit or os.exit) <<< 1729718 System time = 23/09/2023 13:45:24, Simulator time = 13:23:39 (12:23Z) ********* LUA execution terminated: Log Closed *********
John Dowson Posted September 23, 2023 Report Posted September 23, 2023 5 hours ago, shorthauler said: Still, in managed mode, when offets 66C2 and 66C3 both show "1", 66C1 it shows the value of 256 in signed 16-bit value (S16) or 65792 in signed 16-bit value (S32). In selected mode, when the string shows either a SPD or MACH value, it is 0. If you are reading 66C1 as a 16-bit/2-byte value, you are also reading offset 66C2, which is changing.
shorthauler Posted September 23, 2023 Author Report Posted September 23, 2023 Thanks a lot, can you give me a keyword, so I can read up on this on the documentation? 66C1 is to be sent to a display, will these interferences influence the value that is being sent? Should I space the offsets further apart?
John Dowson Posted September 23, 2023 Report Posted September 23, 2023 1 minute ago, shorthauler said: Thanks a lot, can you give me a keyword, so I can read up on this on the documentation? Not really...just think about it. If you write one bye to offset 66C1, it will occupy that byte. If you write 2 bytes, it will occupy 66C1 and 66C2. And the same when you read them, so if you are reading 2-bytes, starting at 66C1, then you are reading 66C1 and 66C2. Similarly, if you were reading it as 4-bytes, you would be reading 66C1, 66C2, 66C3 & 66C4. When you are using offsets for your own needs, remember also to respect byte-boundaries. This means that a 2-byte word must start on a 2-byte boundary (offset address ending in 0,2,4,6,8,A,C or E), a 4-byte double-word must start on a 4-byte boundary (offset address ending in 0, 4, 8 or C), etc. 10 minutes ago, shorthauler said: 66C1 is to be sent to a display, will these interferences influence the value that is being sent? It should be ok if you send it as a single-byte. if you are sending it as a 16-bit word (2-bytes) you shoul move it to a 2-byte boundary. 11 minutes ago, shorthauler said: Should I space the offsets further apart? You should space them as needed, and respect the boundaries when using more than one byte (strings excepted, they don't need to be aligned).
shorthauler Posted September 24, 2023 Author Report Posted September 24, 2023 Thanks a lot, sorry to have missed this!
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