LORD-MicroStrain / MSCL

MicroStrain Communication Library
https://www.microstrain.com/software/mscl
MIT License
76 stars 57 forks source link

node connection (WSDA-200-USB with node adress 57233) #368

Open xin-bee-maker opened 10 months ago

xin-bee-maker commented 10 months ago

"I am able to establish communication with my gateway, but I am unable to recognize the sensor. I cannot read its information and set its status to sleep mode. Below is my code. I have made some improvements based on previous issues raised by others, but I still cannot achieve it and cannot read any information about the node. However, I can automatically recognize this sensor through the "sensor connect" platform." mscl::WirelessNode node(57233, baseStation); baseStation.timeout(50); baseStation.readWriteRetries(2);

msclissa commented 10 months ago

The code provided does not show any functions that actually attempt to communicate with the node. It may be helpful to know what function is failing and what the error message is.

A couple things to check:

In Sleep and Sampling modes, the only command the node will respond to is Set to Idle. In these modes nodes listen for the Set to Idle at configurable intervals, so the base station continuously sends the command until the node responds. Below is an example of how to call setToIdle and wait for it to resolve:

// send Set to Idle command and wait for response
mscl::SetToIdleStatus status = node.setToIdle();
while (!status.complete())
{
    // add timeout logic here so doesn't spin forever if unable to communicate with node
    continue;
}

Hopefully this helps, otherwise I will need more information about what exactly is failing and the error message or behavior you are seeing!

xin-bee-maker commented 10 months ago

Thank you! According to the loop, I can currently set the node into idle mode, but what I want to do is not to put it to idel but instead read some information from it. How can I achieve this? Also, why can't I use a loop to set a timeout, such as "timeout(10000)"? The timeout period has been set very long, but I cannot set the node into idle mode. What factors might cause this problem?