Comments (11)
Oh! So if I change the STRINGV back to STRING128, with null
, it works!
handle.addToDataDefinition(
POSITION_DATA,
"TITLE",
null,
SimConnectDataType.STRING128,
0,
SimConnectConstants.UNUSED
);
from node-simconnect.
Hi, have you tried with STRINGV
and readStringV()
as per the samples?
https://github.com/EvenAR/node-simconnect/blob/master/samples/typescript/aircraftInformation.ts
from node-simconnect.
You're welcome!
I just tested the sample, and it does work as expected (at least on my machine). However, changing SimConnectPeriod.ONCE
to something else (like SimConnectPeriod.SECOND
) gives me the same exception (28). It looks like STRINGV
can only be used with SimConnectPeriod.ONCE
.
I think you can close this issue. I will update the sample to use STRING32
and STRING128
right away to avoid future confusion 😃
from node-simconnect.
I had not, because the MSFS Simvar docs says its unit is "String (max 128 chars)". Are there docs somewhere that explain when node-simconnect needs a StringV
type and when it needs String<num>
?
from node-simconnect.
Updated the code to StringV, looks like the same problem (testing this while sitting in-sim with an airplane loaded on the apron):
import {
open,
Protocol,
SimConnectDataType,
SimConnectPeriod,
SimConnectConstants,
} from "node-simconnect";
const POSITION_DATA = 1;
const REQUEST_ID_POSITION_DATA = 1;
const EVENT_ID_PAUSE = 1;
open("My app", Protocol.FSX_SP2)
.then(function ({ recvOpen, handle }) {
console.log("Connected to", recvOpen.applicationName);
handle.addToDataDefinition(
POSITION_DATA,
"PLANE LATITUDE",
"degrees",
SimConnectDataType.FLOAT64,
0.0,
SimConnectConstants.UNUSED
);
handle.addToDataDefinition(
POSITION_DATA,
"PLANE LONGITUDE",
"degrees",
SimConnectDataType.FLOAT64,
0.0,
SimConnectConstants.UNUSED
);
handle.addToDataDefinition(
POSITION_DATA,
"TITLE",
"string",
SimConnectDataType.STRINGV,
0.0,
SimConnectConstants.UNUSED
);
handle.requestDataOnSimObject(
REQUEST_ID_POSITION_DATA,
POSITION_DATA,
SimConnectConstants.OBJECT_ID_USER,
SimConnectPeriod.SECOND,
0,
0,
0,
0
);
handle.subscribeToSystemEvent(EVENT_ID_PAUSE, "Pause");
handle.on("event", function (recvEvent) {
switch (recvEvent.eventID) {
case EVENT_ID_PAUSE:
console.log(recvEvent.data === 1 ? "Sim paused" : "Sim unpaused");
break;
}
});
handle.on("simObjectData", function (recvSimObjectData) {
switch (recvSimObjectData.requestID) {
case POSITION_DATA:
console.log({
latitude: recvSimObjectData.data.readFloat64(),
longitude: recvSimObjectData.data.readFloat64(),
title: recvSimObjectData.data.readStringV(),
});
break;
}
});
handle.on("quit", function () {
console.log("Quit");
});
})
.catch(function (error) {
console.log("Connection failed:", error);
});
Error:
D:\temp>node repro.js
Connected to KittyHawk
D:\temp\node_modules\bytebuffer\dist\bytebuffer-node.js:1861
throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.length);
^
RangeError: Illegal offset: 0 <= 44 (+1) <= 44
at ByteBuffer.module.exports.ByteBufferPrototype.readCString (D:\temp\node_modules\bytebuffer\dist\bytebuffer-node.js:1861:23)
at makeString (D:\temp\node_modules\node-simconnect\dist\RawBuffer.js:150:24)
at RawBuffer.readStringV (D:\temp\node_modules\node-simconnect\dist\RawBuffer.js:139:16)
at SimConnectConnection.<anonymous> (file:///D:/temp/repro.js:69:44)
at SimConnectConnection.emit (node:events:513:28)
at SimConnectConnection.emit (D:\temp\node_modules\node-simconnect\dist\SimConnectConnection.js:78:22)
at SimConnectConnection._handleMessage (D:\temp\node_modules\node-simconnect\dist\SimConnectConnection.js:1031:22)
at SimConnectSocket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
from node-simconnect.
What happens if you replace "string"
with "NULL"
or null
? According to the official docs for SimConnect_AddToDataDefinition, units name should be "NULL"
when requesting strings or structures. In the samples I have used null
, so perhaps both variants works 🤷
from node-simconnect.
If I set it to null
, the script seems to just "hang", where it logs Connected to KittyHawk
and then doesn't generate any output until I kill node. If I try "NULL"
or "null"
, I get the same crash as above.
from node-simconnect.
Hmm, ok. There could be a SimConnect exception happening. Do you get anything if you add this?
handle.on("exception", function (ex) {
console.log(ex);
});
from node-simconnect.
ooh, you're right: RecvException { exception: 28, sendId: 4, index: 2 }
, so it looks like that's SIMCONNECT_EXCEPTION_DEFINITION_ERROR
, which is described as
Specifies that there is a problem with a data definition. Currently this is only used if a variable length definition is sent with SimConnect_RequestDataOnSimObject.
though I admit I'm not sure what a variable length definition is in this context.
from node-simconnect.
My only guess is that it refers to variable length strings (STRINGV)
Edit: Great! 🙌
from node-simconnect.
@EvenAR @RobsonMi thanks for the (ridiculously fast! =D) help! Should I close this and file a new issue to update the .ts example(s), or keep this one open?
from node-simconnect.
Related Issues (20)
- Multibyte chars in Paths - Size Mismatch HOT 4
- Need example on how to write simulation variables HOT 6
- Bytebuffer format on electron. HOT 6
- Add some code to the README.md to show how to get and set values? HOT 14
- add .once and .off to SimConnectConnection? HOT 1
- It looks like open() logs a registry key on failure HOT 4
- How to call transmitClientEvent HOT 2
- Write data variables into created ia aircraft not working HOT 1
- Post NZ World Update 11 - FaclityDataRequest issue crashes sim HOT 1
- Having some issues with `unSubscribeToFacilitiesEx1` HOT 10
- Is it possible to read pmdg CDU screen data? HOT 1
- Pressing the cdu buttons. HOT 2
- Not a real issue, just a heck of a lot of appreciation. HOT 2
- Better type safety for `DataRequestId`, `DataDefinitionId`, `ClientDataDefinitionId`, etc
- Implement new input events API
- Implement SimConnect_EnumerateControllers
- Implement data definition filter API
- Busy-loop caused by subscribeToFacilitiesEx1 HOT 3
- Inconsistent increment/decrement when sending input events
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-simconnect.