Discussion - Motor Guide (Making a Mobile Robot Pt 7)

Currently no blog post for this video

This is the discussion topic for the video and blog post linked above. Please keep all replies relevant to the content, otherwise create a new topic.

Hi, I’ve ran into an issue trying to get miniterm to work. I’m having trouble discerning the issue and how to resolve it (error is below). any help would be much appreciated. i have basically all the same hardware as in the video (raspi 4 model B, arduino nano, L298N driver).

Note: my pi wasn’t recognizing the ‘miniterm’ command so found a workaround as depicted below. I’ve also added the user to the dialout group.

jon@jon-pi:~$ python3 -m serial.tools.miniterm -e /dev/ttyAMA0 57600
— Miniterm on /dev/ttyAMA0 57600,8,N,1 —
— Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H —
Exception in thread rx:
Traceback (most recent call last):
File “/usr/lib/python3.10/threading.py”, line 1016, in _bootstrap_inner
File “/usr/lib/python3.10/threading.py”, line 953, in run
self._target(*self._args, **self._kwargs)
File “/usr/lib/python3/dist-packages/serial/tools/miniterm.py”, line 499, in reader
data = self.serial.read(self.serial.in_waiting or 1)
File “/usr/lib/python3/dist-packages/serial/serialposix.py”, line 549, in in_waiting
s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 25] Inappropriate ioctl for device

Ok, after a day of troubleshooting, I finally figured out the issue. Posting the solution to others if they get here…

For one, AMA0 isn’t the right address. This took a bit of work to find, but I used the following command to find which USB address my Pi was assigning to the Arduino by using the following command on the Pi:

sudo dmesg | grep ttyUSB

This command showed that my Pi was assigning the Arduino to ttyUSB0 (just like in the tutorial) whenever I plugged in or unplugged the arduino. GREAT!

HOWEVER - this wasn’t the only issue. I was still unable to get miniterm to connect successfully. It would say ‘[Errno] No such file or directory’.

So, I used the following command to monitor what happens when I plug in the arduino:

sudo dmesg --human --follow

And it showed that the system was disconnecting my arduino from ttyUSB0 as soon as it was plugged in, and gave the following error:

usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1

It seems that some utility called BRLTTY was interfering with the connection, so I used the following commands to disable BRLTTY in the ssh terminal on the Pi:

for f in /usr/lib/udev/rules.d/*brltty*.rules; do
    sudo ln -s /dev/null "/etc/udev/rules.d/$(basename "$f")"
sudo udevadm control --reload-rules
sudo systemctl mask brltty.path

[Thanks to this stack exchange answer]

Then restarted the Pi, and the arduino was staying connected to ttyUSB0, miniterm worked as expected, and my motor came to life!!

In the end, the miniterm command that worked for me after disabling BRLTTY was:

python3 -m serial.tools.miniterm -e /dev/ttyUSB0 57600

Just came on to reply to your original message and saw you got it solved.
That seems like quite an ordeal, so well done for solving it and I really appreciate you posting your solution here for others to find in the future!

Glad it’s sorted :slight_smile:

1 Like

Hey Josh, I seem to be getting some weird behavior on the encoder for the left motor using the miniterm bridge. I consistently get good encoder readings on the right motor but not the left (pins A4/A5). I’ve swapped the motors, replaced the motors, and checked that I’m getting good oscillations using an oscilloscope on the encoder pins, but miniterm only ever says -1, 0, 1, or 2 for the left motor (even if I swap the motors). Any ideas what could be going on? I suspect there’s something going on in the code but it’s a pretty complex for me to debug. Thanks!

I think in my head I had replied to this one but apparently not! (That seems to be happening a bit lately)…

That’s very strange, and someone on the Discord server seemed to have a similar issue (which I believe they have not resolved).

What model Arduino are you using?

hi ,
I am running the following command in Pi using SSH terminal.
ros2 run serial_motor_demo driver --ros-args -p serial_por:=/dev/ttyUSB0 -p loop_rate:=30 -p encoder_cpr:=3450
that command is run but when i run the the command ( ros2 run serial_motor_demo gui ) it shows the gui but not running the motor.
and while running the miniterm -e, the encoder values is different while running the same speed. what can i do ??