IIC to Serial Dual UART module (DFR0627) Raspberry Pi python issues

userHead Ville.Lepistö 2024-03-05 10:31:22 389 Views4 Replies

Hi!

 

I'm having an issue with IIC to Serial UART module.

 

Issue:

 

"

pi@raspberrypi:~/DFRobot_IICSerial/python/raspberrypi/examples $ python demo_tx_and_rx.py
Traceback (most recent call last):
 File "/home/pi/DFRobot_IICSerial/python/raspberrypi/examples/demo_tx_and_rx.py", line 23, in <module>
   from DFRobot_IIC_Serial import *
 File "/home/pi/DFRobot_IICSerial/python/raspberrypi/DFRobot_IIC_Serial.py", line 24, in <module>
   from serial.serialutil import SerialBase, SerialException, to_bytes, \
ImportError: cannot import name 'portNotOpenError' from 'serial.serialutil' (/usr/local/lib/python3.9/dist-packages/serial/serialutil.py)
"

 

I have tried to reinstall PySerial with no success. Any advices are welcomed :)

 

OS:

pi@raspberrypi:~ $ cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $ getconf LONG_BIT
32
 

2024-03-07 15:14:28

Hi!

 

I'm cofirming that the module works also on Rpi Zero 2W version with Dietpi distro with modifications on DFRobot_IIC_Serial.py mentioned earlier :

 

dietpi@DietPi:~/DFRobot_IICSerial/python/raspberrypi/examples$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
dietpi@DietPi:~/DFRobot_IICSerial/python/raspberrypi/examples$ getconf LONG_BIT
64
dietpi@DietPi:~/DFRobot_IICSerial/python/raspberrypi/examples$

 

dietpi@DietPi:~/DFRobot_IICSerial/python/raspberrypi/examples$ sudo python3 demo_tx_and_rx.py

+--------------------------------------------+
|  Connected UART1's TX pin to RX pin.       |
|  Connected UART2's TX pin to RX pin.       |
|  UART1 send a String: "hello, Serial2!"    |
|  UART2 send a number: 123                  |
+--------------------------------------------+
Serial to print UART1 and UART2's receive data.

UART1 receive data: 123
UART2 receive data: hello, Serial2!

 

 

userHeadPic Ville.Lepistö
Raj.Kunwor wrote:

Great! Modify that file according to your need. In that file some of the classes are obsolute and replaced by new version of the library.

Hope you'r project give expected outcome.

 

2024-03-07 17:31:10
1 Replies
2024-03-07 14:49:54

Hi!

 

Raj, you are The Life Saviour! 

 

I spell checked DFRobot_IIC_Serial.py and there was miss spelling in line 25. I had took out also "writeTimeoutError", there is no reference in serialutil.py for that, I presume that is obsolete. Test script demo_tx_and_rx.py works ok now with crosswiring tx-rx from UART1 to UART2!

 

"

ville@Paja:~/DFRobot_IICSerial/python/raspberrypi/examples$ sudo python3 demo_tx_and_rx.py

+--------------------------------------------+
|  Connected UART1's TX pin to RX pin.       |
|  Connected UART2's TX pin to RX pin.       |
|  UART1 send a String: "hello, Serial2!"    |
|  UART2 send a number: 123                  |
+--------------------------------------------+
Serial to print UART1 and UART2's receive data.

"

 

 

 

userHeadPic Ville.Lepistö
2024-03-07 13:08:32

Hi

There is a spelling error.

Use PortNotOpenError

userHeadPic Raj.Kunwor