Skip to content Skip to sidebar Skip to footer

Serialwin32.py And Serialutil.py Error When Run Invensense Demo Python Client

Good days, I'm new to python and trying to run a demo provided by Invensense.(9-axis MPU9250 connects a STM32F407G discovery board, I used code and python client in motion_driver_6

Solution 1:

Looking online, I found this Github repo that appears to correspond to the code you are working with. It appears eMPL-client.py is incompatible with newer versions of pyserial. Specifically, the __main__ routine requires numeric port identifiers, but the pyserial 3.3 serial.Serialrequires textual port identifiers. I do not have the setup to test this, but you can try the following.

  1. Install a fresh copy of Python 2.7, which is what eMPL-client.py targets. This is unrelated to pyserial 2.7.
  2. In the fresh copy, install pyserial 2.7 and the other dependencies. Per the source, pyserial 2.7 uses numbers for ports. Pyserial 3.3 uses names for ports, whence the "port must be a string" error.

That should get you past the initial error, which is similar to this answer to the question you linked. At that point, it's probably time to pull out your oscilloscope and make sure the board is generating signals. If so, check the speed/baud/parity. I see that the source runs at 115200bps; maybe try 57600 instead, if your hardware supports it.

An alternative

To use eMPL-client.py with pyserial 3.3, in eMPL-client.py, look for the lines:

if __name__ == "__main__":
    if len(sys.argv) == 2:
        comport = int(sys.argv[1]) - 1#### This is the line that triggers the issueelse:
        print"usage: " + sys.argv[0] + " port"
        sys.exit(-1)

Change the ####-marked line to

comport = sys.argv[1]

(make sure to keep the indentation the same!)

Then, in cmd.exe, run

python eMPL-client.py COM7

with the string port name, e.g., COM7, instead of a port number, e.g., 7.

Post a Comment for "Serialwin32.py And Serialutil.py Error When Run Invensense Demo Python Client"