Need help understanding setDataOnSimObject() #104
Answered
by
EvenAR
yourcptainspeaking
asked this question in
Q&A
|
I'm trying to use this function to set lvars using the public setLVar(name: string, value: number, units: string): void {
const definitionId = this.generateDefId(2000)
this.api.handle.addToDataDefinition(
definitionId,
`L:${name}`,
units,
SimConnectDataType.FLOAT64
)
const dataToSet = new RawBuffer(4)
dataToSet.writeInt32(value)
this.api.handle.setDataOnSimObject(
definitionId,
SimConnectConstants.OBJECT_ID_USER,
{
buffer: dataToSet,
arrayCount: 0,
tagged: false
}
)
} |
Answered by
EvenAR
Jun 19, 2024
Replies: 1 comment 3 replies
|
Hi! I see you specify |
3 replies
Answer selected by
yourcptainspeaking
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I see you specify
FLOAT64(8 bytes) in the data definition, but when writing to the rawbuffer you usewriteInt32(4 bytes). This will cause a size mismatch between theRawBufferand the data definition, which could be related to the exception you are getting. Try replacing it withwriteFloat64(or alternatively useINT32in the data definition).