Dominik Posted December 30, 2021 Report Posted December 30, 2021 Hello, I'm trying to read the offset 0x034E - COM1 frequency, using lua, Here is the code while 1 do file = io.open("test.txt", "w") ppp = ipc.readUW(0x034E) file:write(ppp, "\n") file:close() ipc.sleep(50) end The loop writes the value of this offset to the file. The value of this offset is 6194, com1 frequency is set to 118.050 It reads this value wrong and I don't know where I went wrong. Please help. Dominik.
Dominik Posted December 31, 2021 Author Report Posted December 31, 2021 I think I found a solution to the problem, I have to use string.format("%04X", value)
John Dowson Posted December 31, 2021 Report Posted December 31, 2021 1 hour ago, Dominik said: I think I found a solution to the problem, I have to use string.format("%04X", value) Yes - the offset is in BCD format, so you need to look at the hex representation, as it says in the offset status documentation: Quote COM1 frequency, 4 digits in BCD format. A frequency of 123.45 is represented by 0x2345. The leading 1 is assumed.
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