tbird20d / grabserial

Grabserial - python-based serial dump and timing program - good for embedded Linux development
GNU General Public License v2.0
195 stars 77 forks source link

unable to open port #45

Closed EduardVidalTulsa closed 3 years ago

EduardVidalTulsa commented 3 years ago

Dears, i try to connect a scale via usb port. few months ago it was working fine, but now is no working. I try to read my serial port with this command grabserial -d /dev/ttyACM0 -e 1 -o /tmp/data -Q and that error appear :

Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 323, in _reconfigure_port orig_attr = termios.tcgetattr(self.fd) termios.error: (25, 'Inappropriate ioctl for device')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/grabserial", line 630, in grab(sys.argv[1:]) File "/usr/bin/grabserial", line 442, in grab sd.open() File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 272, in open self._reconfigure_port(force_update=True) File "/usr/lib/python3.8/site-packages/serial/serialposix.py", line 326, in _reconfigure_port raise SerialException("Could not configure port: {}".format(msg)) serial.serialutil.SerialException: Could not configure port: (25, 'Inappropriate ioctl for device') Can your program need other python than my distro take inside? I have this python related packages on a archlinuxarm in a rpi4 pacman -Q |grep python
python 3.8.4-1 python-acme 1.6.0-1 python-appdirs 1.4.4-1 python-asn1crypto 1.3.0-1 python-cffi 1.14.1-1 python-chardet 3.0.4-5 python-configargparse 1.2.3-1 python-configobj 5.0.6-7 python-cryptography 3.0-1 python-distro 1.5.0-1 python-future 0.18.2-3 python-gobject 3.36.1-1 python-idna 2.10-1 python-josepy 1.3.0-1 python-mock 3.0.5-3 python-ordered-set 4.0.2-1 python-packaging 20.4-1 python-parsedatetime 2.6-1 python-pbr 5.4.5-1 python-ply 3.11-5 python-pycparser 2.20-1 python-pyopenssl 19.1.0-2 python-pyparsing 2.4.7-1 python-pyrfc3339 1.1-5 python-pyserial 3.4-4 python-pytz 2020.1-1 python-requests 2.24.0-1 python-requests-toolbelt 0.9.1-3 python-setuptools 1:49.2.0-1 python-six 1.15.0-1 python-urllib3 1.25.10-1 python-zope-component 4.6.2-1 python-zope-deferredimport 4.3.1-4 python-zope-deprecation 4.4.0-3 python-zope-event 4.4-3 python-zope-hookable 5.0.1-1 python-zope-interface 5.1.0-1 python-zope-proxy 4.3.5-1

tbird20d commented 3 years ago

I'm not sure what the issue is, but it could be something in the serial module (it sounds like maybe you recently updated python on your machine?) or it could be something with the device.

I do most of my testing of grabserial with python 2.7, but I also test with python 3.5. I checked the serialposix.py file in the 'serial' module, and looked a the function _reconfigure_port(). It hasn't changed much between those versions of python, and they both have the call to termios.tcgetattr(). I suspect that is not the problem, but you can check to see if serialposix.py is different in python 3.8 from python 2.7.

There's a comment in the source code at the point where the exception is raised that says: "if a port is nonexistent but has a /dev file, it'll fail here". I think that's a likely candidate for the problem.

Can you check to see if other programs have problems with the port? (You could try minicom, cu, screen or even just setserial -g /dev/ttyACM0.

It's possible you're having a hardware error. I have seen devices load and then drop due to a flaky cable or hub. You can try disconnecting the USB cable and reconnecting it, and watching the status with (in separate terminal windows);

$ watch -n 0 ls /dev/serial/by-id and $ dmesg -w

If it's a flaky hub, you might try applying power to it (if that's an option), or switching the USB cable to a different port on the hub. For a flaky cable, I would recommend trying a different cable and seeing if you get different results.

Let me know what you find out.