Need help understanding setDataOnSimObject() #104
-
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
}
)
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi! I see you specify |
Beta Was this translation helpful? Give feedback.
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 theRawBuffer
and the data definition, which could be related to the exception you are getting. Try replacing it withwriteFloat64
(or alternatively useINT32
in the data definition).