Hello,
I try run example code on Rpi zero with Rasbian. I carried out all the steps as in the video and i recive in command promt:
Traceback (most recent call last):
File "main.py", line 44, in <module>
from gurux_serial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/__init__.py", line 35, in <module>
from .GXSerial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/GXSerial.py", line 51, in <module>
from ._handlers.GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/__init__.py", line 40, in <module>
from .GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/GXLinuxHandler.py", line 183
raise Exception("getBaudRate failed. ") from e
^
SyntaxError: invalid syntax
I should use python 2.7 or 3?
Maybe do you know where i'm making mistake?
On Windows i use GXDLMS Director and work very well with my Pafal meter.
This is a serial port issue and it Python version doesn't matter. What USB to the serial port converter you are using? You can get this information if you run: lsusb.
Thank you for the answer.
I use: Bus 001 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter. It is cheap RS485 converter from Aliexpress.
But i have basic ask: Where I can define authentication level? I am beginner with Python and i didn't see information about that in readme on Github.
BR,
Damian
EDIT: I see problem from firts post after only run: "python main.py" also command : "python main.py -S /dev/ttyUSB0" not working, but this show that problem isn't in rs485 converter
I check com port number using dmesg | grep tty.
Full command prompt:
pi@raspberrypi:~/gurux.dlms.python/Gurux.DLMS.Client.Example.python $ python main.py
Traceback (most recent call last):
File "main.py", line 44, in <module>
from gurux_serial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/__init__.py", line 35, in <module>
from .GXSerial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/GXSerial.py", line 51, in <module>
from ._handlers.GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/__init__.py", line 40, in <module>
from .GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/GXLinuxHandler.py", line 183
raise Exception("getBaudRate failed. ") from e
^
SyntaxError: invalid syntax
pi@raspberrypi:~/gurux.dlms.python/Gurux.DLMS.Client.Example.python $ python main.py -S /dev/ttyUSB0
Traceback (most recent call last):
File "main.py", line 44, in <module>
from gurux_serial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/__init__.py", line 35, in <module>
from .GXSerial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/GXSerial.py", line 51, in <module>
from ._handlers.GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/__init__.py", line 40, in <module>
from .GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/GXLinuxHandler.py", line 183
raise Exception("getBaudRate failed. ") from e
^
SyntaxError: invalid syntax
pi@raspberrypi:~/gurux.dlms.python/Gurux.DLMS.Client.Example.python $
There is an error in the log the describes that getting BaudRate failed from the USB converter. dmesg doesn't try to read the baud rate, so it's not checked.
We have HL-340 USB converter. I'll let you know more after it's tested with Raspberry Pi.
Hi Mikko,
I also have this driver in my Raspberry. Maybe could you make image of yours SD card test raspbberry?
If I run your image on my hardware and I have still problem the solution will be in my hardware.
Hi Damian,
Hi Damian,
This is a serial port issue and it Python version doesn't matter. What USB to the serial port converter you are using? You can get this information if you run: lsusb.
BR,
Mikko
Thank you for the answer.
Thank you for the answer.
I use: Bus 001 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter. It is cheap RS485 converter from Aliexpress.
But i have basic ask: Where I can define authentication level? I am beginner with Python and i didn't see information about that in readme on Github.
BR,
Damian
EDIT: I see problem from firts post after only run: "python main.py" also command : "python main.py -S /dev/ttyUSB0" not working, but this show that problem isn't in rs485 converter
I check com port number using dmesg | grep tty.
Full command prompt:
pi@raspberrypi:~/gurux.dlms.python/Gurux.DLMS.Client.Example.python $ python main.py
Traceback (most recent call last):
File "main.py", line 44, in <module>
from gurux_serial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/__init__.py", line 35, in <module>
from .GXSerial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/GXSerial.py", line 51, in <module>
from ._handlers.GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/__init__.py", line 40, in <module>
from .GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/GXLinuxHandler.py", line 183
raise Exception("getBaudRate failed. ") from e
^
SyntaxError: invalid syntax
pi@raspberrypi:~/gurux.dlms.python/Gurux.DLMS.Client.Example.python $ python main.py -S /dev/ttyUSB0
Traceback (most recent call last):
File "main.py", line 44, in <module>
from gurux_serial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/__init__.py", line 35, in <module>
from .GXSerial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/GXSerial.py", line 51, in <module>
from ._handlers.GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/__init__.py", line 40, in <module>
from .GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/GXLinuxHandler.py", line 183
raise Exception("getBaudRate failed. ") from e
^
SyntaxError: invalid syntax
pi@raspberrypi:~/gurux.dlms.python/Gurux.DLMS.Client.Example.python $
Hi,
Hi,
There is an error in the log the describes that getting BaudRate failed from the USB converter. dmesg doesn't try to read the baud rate, so it's not checked.
We have HL-340 USB converter. I'll let you know more after it's tested with Raspberry Pi.
BR,
Mikko
Hi,
Hi,
This is tested with and it worked without problems.
Bus 001 Device 003: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Check your versions:
gurux_dlms version: 1.0.109
gurux_serial version: 1.0.17
If your versions are the same let me know what Raspberry Pi version you are using.
This was tested with Raspberry Pi 10.11
BR,
Mikko
Hi,
Hi,
I use Rpi Zero with WiFi, but I also test RPi 4 without good results.
I check my version and there is ok.
Below I copy full comand promtp from installation on RPi 4
pi@raspberrypi:~ $ git clone https://github.com/gurux/Gurux.DLMS.Python
Cloning into 'Gurux.DLMS.Python'...
remote: Enumerating objects: 2464, done.
remote: Counting objects: 100% (618/618), done.
remote: Compressing objects: 100% (457/457), done.
remote: Total 2464 (delta 469), reused 282 (delta 161), pack-reused 1846
Receiving objects: 100% (2464/2464), 1.28 MiB | 692.00 KiB/s, done.
Resolving deltas: 100% (2070/2070), done.
pi@raspberrypi:~ $ Cd g*
-bash: Cd: command not found
pi@raspberrypi:~ $ ls
Bookshelf Gurux.DLMS.Python
pi@raspberrypi:~ $ cd gur*
-bash: cd: gur*: No such file or directory
pi@raspberrypi:~ $ cd Gu*
pi@raspberrypi:~/Gurux.DLMS.Python $ cd Gurux.DLMS.C*
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ pip instal l -r requirments.txt
Could not open requirements file: [Errno 2] No such file or directory: 'requirme nts.txt'
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ ls
Gurux.DLMS.Client.Example.python.pyproj GXDLMSReader.py LICENSE
Gurux.DLMS.Client.Example.python.sln GXSettings.py main.py
GXCmdParameter.py __init__.py requirements.txt
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ pip instal l -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting gurux-common==1.0.13 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/dd/b2/9c92b62f2b1b2324fa3f 9310a14b27ab3b8c5d426191f3b849e4fef84c1f/gurux_common-1.0.13.tar.gz
Collecting gurux-dlms==1.0.109 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/df/f9/c0a1d63b9660c040348c 401c84a40c2809d26e8e1230f9f939cb59019b94/gurux_dlms-1.0.109.tar.gz (275kB)
100% |████████████████████████████████| 276kB 764kB/s
Collecting gurux-net==1.0.17 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/44/eb/deb08c8eaccdadb347ba 5c06965db21f51a2f1efbdd33f50e8b727a80ba5/gurux_net-1.0.17.tar.gz
Collecting gurux-serial==1.0.17 (from -r requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/69/a7/722cb6c083c6671432d7 c9b3b2959a44ab37a7815f4635b990518bf2304a/gurux_serial-1.0.17.tar.gz
Building wheels for collected packages: gurux-common, gurux-dlms, gurux-net, gur ux-serial
Running setup.py bdist_wheel for gurux-common ... done
Stored in directory: /home/pi/.cache/pip/wheels/1c/9a/a8/f7e53fd231d936acef177 cc391fccbdcf49150c2bdb256278c
Running setup.py bdist_wheel for gurux-dlms ... done
Stored in directory: /home/pi/.cache/pip/wheels/a0/db/d3/2b1e8b4a4c577f162073a f3253bf516ab8622d8c681d2e51c2
Running setup.py bdist_wheel for gurux-net ... done
Stored in directory: /home/pi/.cache/pip/wheels/e4/e3/35/260766fe7cf06c89232ed 6a01aa5925fc0397197161b63f084
Running setup.py bdist_wheel for gurux-serial ... done
Stored in directory: /home/pi/.cache/pip/wheels/7f/6a/8c/87aa1c667c0520a4392ce 062e1ca6e2031e5ff2003fd84170d
Successfully built gurux-common gurux-dlms gurux-net gurux-serial
Installing collected packages: gurux-common, gurux-dlms, gurux-net, gurux-serial
Successfully installed gurux-common-1.0.13 gurux-dlms-1.0.109 gurux-net-1.0.17 g urux-serial-1.0.17
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ dmesg | gr ep tty
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=0 snd_bcm2835 .enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 smsc95xx.macaddr=DC:A6:32:23:11 :AA vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 console=ttyS0,115200 console=tty1 root=PARTUUID=afafeb9b-02 rootfstype=ext4 elevator=deadline fsck.re pair=yes rootwait quiet splash plymouth.ignore-serial-consoles
[ 0.001058] printk: console [tty1] enabled
[ 1.181992] fe201000.serial: ttyAMA0 at MMIO 0xfe201000 (irq = 29, base_baud = 0) is a PL011 rev2
[ 533.755688] usb 1-1.3: ch341-uart converter now attached to ttyUSB0
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ python mai n.py
Traceback (most recent call last):
File "main.py", line 37, in <module>
from gurux_serial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/__init__.py", l ine 35, in <module>
from .GXSerial import GXSerial
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/GXSerial.py", l ine 51, in <module>
from ._handlers.GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/__ini t__.py", line 40, in <module>
from .GXLinuxHandler import GXLinuxHandler
File "/home/pi/.local/lib/python2.7/site-packages/gurux_serial/_handlers/GXLin uxHandler.py", line 183
raise Exception("getBaudRate failed. ") from e
^
SyntaxError: invalid syntax
pi@raspberrypi:~/Gurux.DLMS.Python/Gurux.DLMS.Client.Example.python $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
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"
Thanks for help,
BR
Damian
update 18.10.2021:
Hello,
I also tried on industrial converter ICP CON without good results.
[ 6753.415390] usb 1-1.3: pl2303 converter now attached to ttyUSB0
Hi,
Hi,
Can you run this and check what is your driver version number?
find /sys
In the test Raspberry PI it is 8152:
/sys/module/r8152/drivers/usb:r8152
BR,
Mikko
Hi Mikko,
Hi Mikko,
I also have this driver in my Raspberry. Maybe could you make image of yours SD card test raspbberry?
If I run your image on my hardware and I have still problem the solution will be in my hardware.
BR,
Damian
Hello,
Hello,
@Kurumi do you have any idea what I can do with that?
BR
Damian
Hi,
Hi,
I'm also getting the error: ("getBaudRate failed. ") from e
I'm using raspberry pi Rs485 CAN HAT https://www.waveshare.com/rs485-can-hat.htm
any advice?
Hi,
Hi,
Please, create a new topic if you have a new question and I'll answer there for your question.
http://www.gurux.fi/ForumRules
BR,
Mikko