LORD-MicroStrain / MSCL

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

Unable to retirieve data, but can ping it #363

Open gilbertgonz opened 11 months ago

gilbertgonz commented 11 months ago

Hi,

I followed the quickstart guide from this link: https://lord-microstrain.github.io/MSCL/Documentation/Getting%20Started/index.html?python#inertial

I am able to ping the device using success = node.ping() as it returns true. However, when I try running the python example provided I cannot retrieve data packets from the device, there is no output when running the script, it just hangs. See below for the script I am using:

import sys
sys.path.append("/usr/share/python3-mscl")
import mscl

try:
    #create a Serial Connection with the specified COM Port, default baud rate of 921600
    connection = mscl.Connection.Serial("/dev/ttyUSB0", 115200)

    #create an InertialNode with the connection
    node = mscl.InertialNode(connection)

    #endless loop of reading in data
    while (True):        
        #get all the data packets from the node, with a timeout of 500 milliseconds
        packets = node.getDataPackets(500)

        for packet in packets:

            #print out the data
            print("Packet Received")

            #iterate over all the data points in the packet
            for dataPoint in packet.data():

                #print out the channel data
                print(str(dataPoint.channelName()) + ":" + str(dataPoint.as_string()) + " ")

                #if the dataPoint is invalid
                if(dataPoint.valid() == False):
                    print("Invalid")

except mscl.Error as e:
    print("Error:", e)

I am on Ubuntu 22 and Python 3.10. The device port is in fact /dev/ttyUSB0

The IMU I am using is the 3DMGX5-IMU

I was able to confirm that the device is able to transmit data using on Windows SensorConnect app

Please let me know if any other information is needed