×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Can't send commands to INDI server using NodeJS and indi-client

  • Posts: 2
  • Thank you received: 0
Hello astronomers,
I'm trying to build an INDI client with this Node.js library (www.npmjs.com/package/indi-client),
www.npmjs.com/package/indi-client

To begin, I installed wINDI server on my Windows pc to run an INDI server. I tested it with stellarium, and my mount is moving correctly.

But when I'm trying to control my mount using the indi-client library, my command is received by the server, but my mount is not moving. What did I've done wrong?

Here's my code :
const { newSwitchVector, INDIClient } = require("indi-client");
 
const indiHost = process.env.INDI_HOST || "127.0.0.1";
const indiPort = process.env.INDI_PORT ? parseInt(process.env.INDI_PORT) : 7624;
 
const indiClient = new INDIClient(indiHost, indiPort);
 
indiClient.on("connect", () => {
  console.log("indi connection connected");
 
  // You may need to adjust the target coordinates
  const targetRA = 11.04; // Replace with your desired RA coordinate
  const targetDec = 79.678; // Replace with your desired Dec coordinate
 
  // Create a newNumberVector object for the telescope coordinates
  const slewCommand = new newSwitchVector(
    "ASCOM OnStep Telescope",
    "TELESCOPE_MOTION_NS",
    new Date(),
    [
      {
        name: "MOTION_NORTH",
        value: "On",
      },
      {
        name: "MOTION_SOUTH",
        value: "Off",
      },
    ]
  );
 
  console.log(slewCommand);
 
  // Send the slew command to the telescope
  indiClient.send(slewCommand);
});
 
indiClient.on("close", () => {
  console.log("indi connection closed");
});
 
indiClient.connect();

And here is the wINDI log file :
2024-01-21 13:57:53.84 LISTENER = Starting server listener loop on 0.0.0.0:7624
2024-01-21 13:57:59.75 LISTENER = Creating protocol handler #0
2024-01-21 13:57:59.75 LISTENER = Creating wrapper for ASCOM.OnStep.Telescope
2024-01-21 13:57:59.80 HANDLER#0 = Starting protocol handler loop
2024-01-21 13:57:59.96 HANDLER#0 > <newSwitchVector device="ASCOM OnStep Telescope" name="TELESCOPE_MOTION_NS" timestamp="2024-01-21T12:57:59.879"><oneSwitch name="MOTION_NORTH">On</oneSwitch><oneSwitch name="MOTION_SOUTH">Off</oneSwitch></newSwitchVector>
2024-01-21 13:57:59.99 HANDLER#0 = Failed to set TELESCOPE_MOTION_NS property
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
à wINDI.TelescopeWrapper.telescopeMotionNSHandler(Operation operation, State state, String message, Dictionary`2 values)
à wINDI.DeviceWrapper.newXXXVector(String name, Dictionary`2 values)


Does anyone know the problem or/and has a working code example in Node.js ?

Thank you per advice,
Astronomically,

Zoliex
3 months 1 week ago #98302

Please Log in or Create an account to join the conversation.

  • Posts: 211
  • Thank you received: 104
You forget indiClient.getProperties();
The following user(s) said Thank You: Enzo
3 months 1 week ago #98306

Please Log in or Create an account to join the conversation.

  • Posts: 1187
  • Thank you received: 370
I would recommend starting with an existing INDI client (e.g. KStars/EKOS) to observe, which INDI commands are used.

Slewing to the target is not done with TELESKOPE_MOTION_XY. Better take a look at Mount::sendCoords(SkyPoint * ScopeTarget) in KStars, which shows the complexity of simply slewing

Cheers
Wolfgang
3 months 1 week ago #98308

Please Log in or Create an account to join the conversation.

  • Posts: 211
  • Thank you received: 104
A good place to learn the basic properties is the Standard Properties page: www.indilib.org/develop/developer-manual...dard-properties.html
Then you can try the different function with the command indi_setprop to be sure it do what you expect.
I also suggest you start with the mount simulator to prevent unwanted effect on your real mount.
3 months 1 week ago #98311

Please Log in or Create an account to join the conversation.

  • Posts: 2
  • Thank you received: 0
I changed my code to add indiClient.getProperties(), but the code is still not working as expected...
Can you send me an example code ? (pls not the mqtt example that is the only example given with the library).

A big thank you per advice,

Astronomically,
Enzo

Here's my new code :
const { newSwitchVector, INDIClient } = require("indi-client");
 
const indiHost = process.env.INDI_HOST || "127.0.0.1";
const indiPort = process.env.INDI_PORT ? parseInt(process.env.INDI_PORT) : 7624;
 
const indiClient = new INDIClient(indiHost, indiPort);
 
indiClient.on("connect", async () => {
  indiClient.getProperties();
 
  console.log("indi connection connected");
 
  // Create a newSwitchVector object for the telescope coordinates
  const slewCommand = new newSwitchVector(
    "ASCOM OnStep Telescope",
    "TELESCOPE_MOTION_NS",
    new Date(),
    [
      {
        name: "MOTION_NORTH",
        value: "On",
      },
      {
        name: "MOTION_SOUTH",
        value: "Off",
      },
    ]
  );
 
  // Send the slew command to the telescope
  await indiClient.send(slewCommand);
});
 
indiClient.on("close", () => {
  console.log("indi connection closed");
});
 
// Connect to the INDI server
indiClient.connect();
 
3 months 6 days ago #98334

Please Log in or Create an account to join the conversation.

  • Posts: 2
  • Thank you received: 0
I still have a problem using this corrected code, my mount is not moving, can you send me an example code please ?
Because the library lacks of documentation....

Thank you per advice !
Astronomically,

Enzo

Here's the modified code :
const { newSwitchVector, INDIClient } = require("indi-client");
 
const indiHost = process.env.INDI_HOST || "127.0.0.1";
const indiPort = process.env.INDI_PORT ? parseInt(process.env.INDI_PORT) : 7624;
 
const indiClient = new INDIClient(indiHost, indiPort);
 
indiClient.on("connect", async () => {
  indiClient.getProperties();
 
  console.log("indi connection connected");
 
  // Create a newSwitchVector object for the telescope coordinates
  const slewCommand = new newSwitchVector(
    "ASCOM OnStep Telescope",
    "TELESCOPE_MOTION_NS",
    new Date(),
    [
      {
        name: "MOTION_NORTH",
        value: "On",
      },
      {
        name: "MOTION_SOUTH",
        value: "Off",
      },
    ]
  );
 
  // Send the slew command to the telescope
  await indiClient.send(slewCommand);
});
 
indiClient.on("close", () => {
  console.log("indi connection closed");
});
 
// Connect to the INDI server
indiClient.connect();
Last edit: 3 months 6 days ago by Enzo.
3 months 6 days ago #98336

Please Log in or Create an account to join the conversation.

Time to create page: 0.575 seconds