I am trying to read the Landys-Gyr E650, via a Kocos optical eye. I have had success connecting with the GXDLMSDirector but I cannot connect using the python example. I am VERY new to this sort of thing so please bear with me.
I try to copy/ paste the command line given by the Director but the results are the following:
Thanks for the quick response. I no longer receive that error. However, I now have an issue with Python crashing. Do you perhaps know what could be causing this?
I ran this command:
py -u -m trace -t Gurux.DLMS.Client.Example.python\main.py -S COM3:9600:8None1 -r sn -iHdlcWithModeE -n 95669535 -t Verbose
Below is the last but of the trace:
--- modulename: traceback, funcname: _format_final_exc_line
traceback.py(146): valuestr = _some_str(value)
--- modulename: traceback, funcname: _some_str
traceback.py(154): try:
traceback.py(155): return str(value)
traceback.py(147): if value is None or not valuestr:
traceback.py(150): line = "%s: %s\n" % (etype, valuestr)
traceback.py(151): return line
traceback.py(105): print(line, file=file, end="")
Exception: Failed to received reply from the media.
traceback.py(103): for line in TracebackException(
--- modulename: traceback, funcname: format
--- modulename: traceback, funcname: format_exception_only
main.py(116): settings.media.close()
--- modulename: GXSerial, funcname: close
GXSerial.py(244): if self.__receiver:
main.py(117): reader = None
main.py(119): if reader:
main.py(124): print("Ended. Press any key to continue.")
Ended. Press any key to continue.
--- modulename: GXWindowsHandler, funcname: __del__
GXWindowsHandler.py(198): if self._closing != INVALID_HANDLE_VALUE:
GXWindowsHandler.py(199): ctypes.windll.Kernel32.CloseHandle(self._closing)
GXWindowsHandler.py(200): self._closing = INVALID_HANDLE_VALUE
I am still having trouble. Let me give you some extra details and maybe it would help us resolve this.
I am currently using remote access to log onto a server that has the Landis+gyr unit connected up via the Kocos optical cable. Now, this is not my server and there are some existing programs on there that might not be up to date.
I see they have python 2.7 and I have recently installed Python 3.9. When I run some commands, like the last one you mentioned, Python seems to crash. I will attach a screenshot.
Besides the occasional crash, the unit does not respond.
Can you install GXDLMSDirector on the PC and try to read the meter with it? This looks like a driver issue, but I can't test this because we don't have Kocos optical head. If you can read the meter with GXDLMSDirector then the reason is in python.
I have done some reading and tried a few different methods but still no luck. The Director can connect and I can read the data but I am still having issues. I believe it must be with python but I cannot figure it out. Any pointers on this? Would it be easier to debug if I use a different connection method? So not using the optical head but something else?
This is strange because it looks like python is crashing. Are you running python and GXDLMSDirector on the same PC? Can you send GXDLMSDirector log file to me by email? I can check if there is anything that might help with this.
I have requested they set the unit up on a different system. So I'm going to get the python example all set up and see if I can get it working. I'll get back to you if I still have trouble.
Thanks for this info. Let me know if you have any problems. I have to find Kocos optical head and test also with that if you have problems also in the second PC.
It has taken some time, but I have some feedback. I hope it is alright to remain in this thread.
I tried to get it working on the new PC but had little success. I couldn't get the Director to work either. So I requested the meter get sent to me. I now have the meter and optical eye in my possession and have downloaded the python example library. I have tested it on the Director, and I can access the meter without any issues.
The problem I am having now is that Python is still crashing. I have done loads of research and cannot identify why this is happening.
Your assistance is greatly appreciated.
When I run the comment in a terminal outside of VS code, I get a Segmentation Error. Which I believe means that Python does not have permission to access the COM port. Do you perhaps know a way around this?
Are you using Kocos optical eye on your PC? If the program crash, the serial port driver is causing the problem. Do you have a link for your optical probe on Kocos web page? I want to make sure that the same optical probe is ordered.
I am using the Kocos Optical eye. I could not access the driver download from the Kocos website so I downloaded FTDI drivers from here -> https://ftdichip.com/drivers/
My thinking is that if the Director can read it, wouldn't that mean the drivers are correct?
I'm still new to Python but I'm digging around trying to isolate the issue. iIt doesn't ALWAYS crash Python. Depending on the command parsed. But when it does crash, it always crashes after the message 'Disconnect Request'
So it must be hitting a line somewhere that is causing it.
I also see this in my windows Event log (But not all teh time, Also depend on what I parse):
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{2593F8B9-4EAF-457C-B68A-50F6B8EA6B54}
and APPID
{15C20B67-12E7-4BB6-92BB-7AFF07997402}
to the user DESKTOP-2870BLF\Dylan SID (S-1-5-21-4177633267-48614475-520285453-1001) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.
The reason why I believe that this is a driver issue is that python crash. GXDLMSDirector is handling serial ports differently than Python. There is no native support for serial ports in Python.
I believe that you don't receive any reply from the meter and the application crashes when the close is called.
Can you try to comment on this line in close?
self.media.close()
I believe that you are running Python in Windows and you are not using Windows Subsystem for Linux?
It's interesting because I would understand your error if it occurs when you open the connection, but it occurs when you close the connection.
Do you see any errors if you select device manager and select Serial port?
I am running in windows without Windows Subsystem for Linux. Should I have WSL enabled?
No errors when looking in the device manager, at the serial port.
I'm not so clued up on the HdlcWithModeE, but does it do something where it switches the Baud Rate, Bits, Parity, etc. during the connection? I'm just pitching ideas here. Maybe the COM port settings? ie: Flow Control (Again, very little knowledge on this)
I will continue looking into serial port connection issues around Python in the meantime.
The reason I asked about HdlcWithModeE and the switching was that, when I was trying different commands, I found using this command:
'py Gurux.DLMS.Client.Example.python\main.py -S COM4:300:7Even1 -r sn -i HdlcWithModeE -n 95669535 -t Verbose'
causes the system to freeze up (Meaning Python does not send a crash report and I am unable to continue in the terminal) and requires I end all running Python processes. The only difference is the specified baud rate, bits, parity, etc.
You don't need the WSL. I wanted to know this so we can try to make the same thing happened in our PC. Have you used HdlcWithModeE with GXDLMSDirector? You should use it when you are operating with the optical probe. The current python version ignores -i parameter and the optical probe is used when -i parameter is used.
You don't need usually to set serial port settings when you are using HDLC with mode E.
Can you select Device manager in Windows. Then select Kocos Optical serial port and options.
If you select 5th tab you will found VID and PID. Something like this:
Device USB\VID_10C4&PID_EA60\0001
Can you add those values here so I can check them? I believe that we have the same serial port chipset that we can use for testing.
I wasn't sure if you needed the info from the COM port or the USB so I got both:
I also couldn't match exactly the path you mentioned. I found this under details/ then selected 'Hardware Ids'. Let me know if this is correct.
We have the same chipset and everything works without problems. Windows driver version is 2.12.28.0 and the date is 8/16/2017. What version you are using?
This is very interesting.
Driver version: 2.12.36.4
Driver Date: 2021/07/05
There must be something I have incorrect here. Perhaps my Python folder structure. Maybe effecting permissions? I'm not sure. I am still playing around and researching possible causes fo this issue.
I don't believe that it's the Python folder structure. If you can access the meter from GXDLMSDirector I don't believe it's the permission. Is your Windows 32 or 64 Bit?
So was the test PC. I found one error in your command line parameters. -sn parameter was missing.
Can you try with this:
py Gurux.DLMS.Client.Example.python\main.py -S COM4 -r sn -i HdlcWithModeE -t Verbose
I have been running it from the terminal, inside Visual Studio Code. I have tried from the command line run as administrator. But I have not tried from the command line many times. I will try some different commands you have suggested in the command line as an administrator.
Note: I am running with Python3.9 is this alright?
$ python -Xfaulthandler Gurux.DLMS.Client.Example.python/main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
Windows fatal exception: access violation
Current thread 0x000043fc (most recent call first):
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 95 in updatecache
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 47 in getlines
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 16 in getline
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 285 in line
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 363 in extract
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 508 in __init__
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 104 in print_exception
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 163 in print_exc
File "Gurux.DLMS.Client.Example.python/main.py", line 112 in main
File "Gurux.DLMS.Client.Example.python/main.py", line 124 in <module>
Segmentation fault
This looks more and more like a driver issue, but there is one change in the client example that might help to solve this. Get the latest version from the client example and give it a try.
I got the latest version client example and the result is more or less the same:
$ python -Xfaulthandler Gurux.DLMS.Client.Example.python/main.py -S COM3 -r sn -i HdlcWithModeE
Windows fatal exception: access violation
Current thread 0x00003cd8 (most recent call first):
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 95 in updatecache
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 47 in getlines
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 16 in getline
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 285 in line
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 363 in extract
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 508 in __init__
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 104 in print_exception
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 163 in print_exc
File "Gurux.DLMS.Client.Example.python/main.py", line 112 in main
File "Gurux.DLMS.Client.Example.python/main.py", line 125 in <module>
Segmentation fault
I removed the driver and it rolled back to version 2.12.28.0 Before it was a new version. Python seems to crash a lot less but still no success. I'm going to try a system restart just to see what happens.
There is one PC where this error can be repeated. There were also issues in the example, but there is also a strange error that is happening on one PC when FTDI is used.
But we can now repeat this, I hope it's the same error, and I'll let you know as soon as this is fixed.
The new version is released (1.0.109). Get the source codes from the GitHub. Note! You must update gurux-serial component for Python to version 1.0.15.
I find the code hanging sometimes. I have to restart the terminal.
$ py main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
Traceback (most recent call last):
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\main.py", line 108, in main
reader.readAll(settings.outputFile)
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 528, in readAll
self.initializeConnection()
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 301, in initializeConnection
self.initializeOpticalHead()
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 199, in initializeOpticalHead
if not self.media.receive(p):
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\site-packages\gurux_serial\GXSerial.py", line 385, in receive
return self.__syncBase.receive(args)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\site-packages\gurux_serial\_GXSynchronousMediaBase.py", line 243, in receive
foundPosition = self.__findData(args)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\site-packages\gurux_serial\_GXSynchronousMediaBase.py", line 193, in __findData
isReceived = self.__receivedEvent.wait(waitTime / 1000)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\threading.py", line 574, in wait
signaled = self._cond.wait(timeout)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\threading.py", line 316, in wait
gotit = waiter.acquire(True, timeout)
KeyboardInterrupt
Hi Dylan,
Hi Dylan,
I just notest that GXDLMSDirector shows stop bits wrong.
Correct serial port settings are:
-S COM3:9600:8None1
BR,
Mikko
Hi Mikko,
Hi Mikko,
Thanks for the quick response. I no longer receive that error. However, I now have an issue with Python crashing. Do you perhaps know what could be causing this?
I ran this command:
py -u -m trace -t Gurux.DLMS.Client.Example.python\main.py -S COM3:9600:8None1 -r sn -iHdlcWithModeE -n 95669535 -t Verbose
Below is the last but of the trace:
--- modulename: traceback, funcname: _format_final_exc_line
traceback.py(146): valuestr = _some_str(value)
--- modulename: traceback, funcname: _some_str
traceback.py(154): try:
traceback.py(155): return str(value)
traceback.py(147): if value is None or not valuestr:
traceback.py(150): line = "%s: %s\n" % (etype, valuestr)
traceback.py(151): return line
traceback.py(105): print(line, file=file, end="")
Exception: Failed to received reply from the media.
traceback.py(103): for line in TracebackException(
--- modulename: traceback, funcname: format
--- modulename: traceback, funcname: format_exception_only
main.py(116): settings.media.close()
--- modulename: GXSerial, funcname: close
GXSerial.py(244): if self.__receiver:
main.py(117): reader = None
main.py(119): if reader:
main.py(124): print("Ended. Press any key to continue.")
Ended. Press any key to continue.
--- modulename: GXWindowsHandler, funcname: __del__
GXWindowsHandler.py(198): if self._closing != INVALID_HANDLE_VALUE:
GXWindowsHandler.py(199): ctypes.windll.Kernel32.CloseHandle(self._closing)
GXWindowsHandler.py(200): self._closing = INVALID_HANDLE_VALUE
Thanks!
Dylan
Hi,
Hi,
"Failed to received reply from the media" error means that the meter didn't reply. Are you using optical probe or RS-232?
If you are using the optical probe, use just this:
-S COM3
BR,
Mikko
BR,
Mikko
Hey,
Hey,
I am using the optical probe. I ran it as you mentioned and the error has changed:
"Failed to receive reply from the device in given time."
Hi,
Hi,
Do you try to run app with command line parameters like this?
py Gurux.DLMS.Client.Example.python\main.py -S COM3 -r sn -i HdlcWithModeE -n 95669535 -t Verbose
Try also with this:
py Gurux.DLMS.Client.Example.python\main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
BR,
Mikko
Hi Mikko
Hi Mikko
Sorry for the late response. I was off sick for the past few days.
I tried running the 2 commands as you mentioned but I got this response;
PS C:\wamp64\www\Gurux.DLMS.Python-master> py Gurux.DLMS.Client.Example.python\main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
gurux_dlms version: 1.0.104
gurux_net version: 1.0.17
gurux_serial version: 1.0.15
Invalid parameter: HdlcWithModeE
Ended. Press any key to continue.
Kind regards,
Dylan
Hi Mikko,
Hi Mikko,
I trust you are well.
Just popping you another message to bring attention to my previous post. I am still having trouble.
Kind regards,
Dylan
Hi Dylan,
Hi Dylan,
I'm sorry. I didn't remember that the new version for Python is not released yet. Use arguments:
py Gurux.DLMS.Client.Example.python\main.py -S COM3 -r sn -i -t Verbose
BR,
Mikko
Hi Mikko,
Hi Mikko,
I am still having trouble. Let me give you some extra details and maybe it would help us resolve this.
I am currently using remote access to log onto a server that has the Landis+gyr unit connected up via the Kocos optical cable. Now, this is not my server and there are some existing programs on there that might not be up to date.
I see they have python 2.7 and I have recently installed Python 3.9. When I run some commands, like the last one you mentioned, Python seems to crash. I will attach a screenshot.
Besides the occasional crash, the unit does not respond.
Hi Dylan,
Hi Dylan,
Can you install GXDLMSDirector on the PC and try to read the meter with it? This looks like a driver issue, but I can't test this because we don't have Kocos optical head. If you can read the meter with GXDLMSDirector then the reason is in python.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I have done some reading and tried a few different methods but still no luck. The Director can connect and I can read the data but I am still having issues. I believe it must be with python but I cannot figure it out. Any pointers on this? Would it be easier to debug if I use a different connection method? So not using the optical head but something else?
Kinds regards,
Dylan
Hi,
Hi,
This is strange because it looks like python is crashing. Are you running python and GXDLMSDirector on the same PC? Can you send GXDLMSDirector log file to me by email? I can check if there is anything that might help with this.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I have requested they set the unit up on a different system. So I'm going to get the python example all set up and see if I can get it working. I'll get back to you if I still have trouble.
Thanks again!
Kind regards,
Dylan
Hi Dylan,
Hi Dylan,
Thanks for this info. Let me know if you have any problems. I have to find Kocos optical head and test also with that if you have problems also in the second PC.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I trust you are well.
It has taken some time, but I have some feedback. I hope it is alright to remain in this thread.
I tried to get it working on the new PC but had little success. I couldn't get the Director to work either. So I requested the meter get sent to me. I now have the meter and optical eye in my possession and have downloaded the python example library. I have tested it on the Director, and I can access the meter without any issues.
The problem I am having now is that Python is still crashing. I have done loads of research and cannot identify why this is happening.
Your assistance is greatly appreciated.
Kind regards,
Dylan
Adding to my previous reply;
Adding to my previous reply;
When I run the comment in a terminal outside of VS code, I get a Segmentation Error. Which I believe means that Python does not have permission to access the COM port. Do you perhaps know a way around this?
Hi Dylan,
Hi Dylan,
Are you using Kocos optical eye on your PC? If the program crash, the serial port driver is causing the problem. Do you have a link for your optical probe on Kocos web page? I want to make sure that the same optical probe is ordered.
BR,
Mikko
Hey Mikko,
Hey Mikko,
I am using the Kocos Optical eye. I could not access the driver download from the Kocos website so I downloaded FTDI drivers from here -> https://ftdichip.com/drivers/
Here is a link to the company Brochure (The model is the last on the list. Called 'Ancillary')->
https://teslaes.com/wp-content/uploads/2021/03/Meter-Accessories-Brochu…
My thinking is that if the Director can read it, wouldn't that mean the drivers are correct?
I'm still new to Python but I'm digging around trying to isolate the issue. iIt doesn't ALWAYS crash Python. Depending on the command parsed. But when it does crash, it always crashes after the message 'Disconnect Request'
So it must be hitting a line somewhere that is causing it.
I also see this in my windows Event log (But not all teh time, Also depend on what I parse):
The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{2593F8B9-4EAF-457C-B68A-50F6B8EA6B54}
and APPID
{15C20B67-12E7-4BB6-92BB-7AFF07997402}
to the user DESKTOP-2870BLF\Dylan SID (S-1-5-21-4177633267-48614475-520285453-1001) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.
I hope this helps :)
Thanks!
Regards,
Dylan
Hi Dylan,
Hi Dylan,
The reason why I believe that this is a driver issue is that python crash. GXDLMSDirector is handling serial ports differently than Python. There is no native support for serial ports in Python.
I believe that you don't receive any reply from the meter and the application crashes when the close is called.
Can you try to comment on this line in close?
self.media.close()
Is the app still crashing?
BR,
Mikko
Hi Mikko,
Hi Mikko,
I commented that line out (Line 103 - GXDLMSReader.py) and the app stopped crashing. I still get "Failed to received reply from the media."
Regards,
Dylan
Hi Dylan,
Hi Dylan,
I believe that you are running Python in Windows and you are not using Windows Subsystem for Linux?
It's interesting because I would understand your error if it occurs when you open the connection, but it occurs when you close the connection.
Do you see any errors if you select device manager and select Serial port?
BR,
Mikko
Hi Mikko,
Hi Mikko,
I am running in windows without Windows Subsystem for Linux. Should I have WSL enabled?
No errors when looking in the device manager, at the serial port.
I'm not so clued up on the HdlcWithModeE, but does it do something where it switches the Baud Rate, Bits, Parity, etc. during the connection? I'm just pitching ideas here. Maybe the COM port settings? ie: Flow Control (Again, very little knowledge on this)
I will continue looking into serial port connection issues around Python in the meantime.
Regards,
Dylan
Hi Mikko,
Hi Mikko,
The reason I asked about HdlcWithModeE and the switching was that, when I was trying different commands, I found using this command:
'py Gurux.DLMS.Client.Example.python\main.py -S COM4:300:7Even1 -r sn -i HdlcWithModeE -n 95669535 -t Verbose'
causes the system to freeze up (Meaning Python does not send a crash report and I am unable to continue in the terminal) and requires I end all running Python processes. The only difference is the specified baud rate, bits, parity, etc.
Hopefully, this holds some insight.
Regards,
Dylan
Hi,
Hi,
You don't need the WSL. I wanted to know this so we can try to make the same thing happened in our PC. Have you used HdlcWithModeE with GXDLMSDirector? You should use it when you are operating with the optical probe. The current python version ignores -i parameter and the optical probe is used when -i parameter is used.
BR,
Mikko
Hi Mikko,
Hi Mikko,
Okay great. I do not have WSL enabled. I use HdlcWithModeE on the director and in the Python commands.
I have attached a screenshot of the settings I change when using the Director
Regards,
Dylan
Some more info:
Some more info:
py Gurux.DLMS.Client.Example.python\main.py -S COM4 -r sn -i HdlcWithModeE -n 95669535 -t Verbose
- Python crash
py Gurux.DLMS.Client.Example.python\main.py -S COM4:9600:8None1 -r sn -i HdlcWithModeE -n 95669535 -t Verbose
-Python crash
py Gurux.DLMS.Client.Example.python\main.py -S COM4:9600:8None1 -i HdlcWithModeE -t Verbose
-Failed to receive reply from media
Regards,
Dylan
Hi,
Hi,
You don't need usually to set serial port settings when you are using HDLC with mode E.
Can you select Device manager in Windows. Then select Kocos Optical serial port and options.
If you select 5th tab you will found VID and PID. Something like this:
Device USB\VID_10C4&PID_EA60\0001
Can you add those values here so I can check them? I believe that we have the same serial port chipset that we can use for testing.
BR,
Mikko
Hi,
Hi,
I wasn't sure if you needed the info from the COM port or the USB so I got both:
I also couldn't match exactly the path you mentioned. I found this under details/ then selected 'Hardware Ids'. Let me know if this is correct.
Ports (COM & LT) - FTDIBUS\COMPORT&VID_0403&PID_6001
USB - USB\VID_0403&PID_6001&REV_0400
- USB\VID_0403&PID_6001
Thanks!
Regards,
Dylan
Hi,
Hi,
We have the same chipset and everything works without problems. Windows driver version is 2.12.28.0 and the date is 8/16/2017. What version you are using?
BR,
Mikko
Hi Mikko,
Hi Mikko,
This is very interesting.
Driver version: 2.12.36.4
Driver Date: 2021/07/05
There must be something I have incorrect here. Perhaps my Python folder structure. Maybe effecting permissions? I'm not sure. I am still playing around and researching possible causes fo this issue.
Hi,
Hi,
I don't believe that it's the Python folder structure. If you can access the meter from GXDLMSDirector I don't believe it's the permission. Is your Windows 32 or 64 Bit?
BR,
Mikko
Windows 64 bit
Windows 64 bit
Hi,
Hi,
So was the test PC. I found one error in your command line parameters. -sn parameter was missing.
Can you try with this:
py Gurux.DLMS.Client.Example.python\main.py -S COM4 -r sn -i HdlcWithModeE -t Verbose
BR,
Mikko
Hi Mikko,
Hi Mikko,
This was mentioned in one of my previous comments I think. When adding the -sn parameter, it also causes Python to crash.
Regards,
Dylan
Hi,
Hi,
It might be that that was missing from the comment.
http://www.gurux.fi/comment/22077#comment-22077
I need to verify that you are running Python from the command line? Have you tried to start the command line with elevated privileges?
BR,
Mikko
Hi,
Hi,
I have been running it from the terminal, inside Visual Studio Code. I have tried from the command line run as administrator. But I have not tried from the command line many times. I will try some different commands you have suggested in the command line as an administrator.
Note: I am running with Python3.9 is this alright?
Regards,
Dylan
Hi Dylan,
Hi Dylan,
Python 3.9 is OK.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I got this in terminal this morning when testing:
$ python -Xfaulthandler Gurux.DLMS.Client.Example.python/main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
Windows fatal exception: access violation
Current thread 0x000043fc (most recent call first):
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 95 in updatecache
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 47 in getlines
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 16 in getline
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 285 in line
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 363 in extract
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 508 in __init__
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 104 in print_exception
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 163 in print_exc
File "Gurux.DLMS.Client.Example.python/main.py", line 112 in main
File "Gurux.DLMS.Client.Example.python/main.py", line 124 in <module>
Segmentation fault
Could this be related to the problem?
Regards,
Dylan
Hi,
Hi,
This looks more and more like a driver issue, but there is one change in the client example that might help to solve this. Get the latest version from the client example and give it a try.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I got the latest version client example and the result is more or less the same:
$ python -Xfaulthandler Gurux.DLMS.Client.Example.python/main.py -S COM3 -r sn -i HdlcWithModeE
Windows fatal exception: access violation
Current thread 0x00003cd8 (most recent call first):
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 95 in updatecache
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 47 in getlines
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 16 in getline
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 285 in line
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 363 in extract
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 508 in __init__
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 104 in print_exception
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python37\lib\traceback.py", line 163 in print_exc
File "Gurux.DLMS.Client.Example.python/main.py", line 112 in main
File "Gurux.DLMS.Client.Example.python/main.py", line 125 in <module>
Segmentation fault
-------------------------------------------------------------------------------------
Below is some trace from this command:
python -u -m trace -t Gurux.DLMS.Client.Example.python/main.py -S COM3 -r sn -i HdlcWithModeE
--- modulename: GXSerial, funcname: receive
GXSerial.py(377): return self.__syncBase.receive(args)
--- modulename: _GXSynchronousMediaBase, funcname: receive
_GXSynchronousMediaBase.py(241): if args.eop is None and args.count == 0:
--- modulename: ReceiveParameters, funcname: __getEop
ReceiveParameters.py(58): return self.__eop
_GXSynchronousMediaBase.py(243): foundPosition = self.__findData(args)
--- modulename: _GXSynchronousMediaBase, funcname: __findData
_GXSynchronousMediaBase.py(154): nSize = 0
_GXSynchronousMediaBase.py(155): foundPosition = -1
_GXSynchronousMediaBase.py(156): lastBuffSize = 0
_GXSynchronousMediaBase.py(157): startTime = datetime.datetime.now().time().microsecond
_GXSynchronousMediaBase.py(158): terminator = None
_GXSynchronousMediaBase.py(159): nMinSize = args.count
--- modulename: ReceiveParameters, funcname: __getCount
ReceiveParameters.py(67): return self.__count
_GXSynchronousMediaBase.py(160): if nMinSize < nSize:
_GXSynchronousMediaBase.py(163): waitTime = args.waitTime
--- modulename: ReceiveParameters, funcname: __getWaitTime
ReceiveParameters.py(78): return self.__waitTime
_GXSynchronousMediaBase.py(164): self.exception = None
_GXSynchronousMediaBase.py(165): if waitTime <= 0:
_GXSynchronousMediaBase.py(167): if args.eop:
--- modulename: ReceiveParameters, funcname: __getEop
ReceiveParameters.py(58): return self.__eop
_GXSynchronousMediaBase.py(168): terminator = self.toBytes(args.eop)
--- modulename: ReceiveParameters, funcname: __getEop
ReceiveParameters.py(58): return self.__eop
--- modulename: _GXSynchronousMediaBase, funcname: toBytes
_GXSynchronousMediaBase.py(285): if isinstance(value, bytearray):
_GXSynchronousMediaBase.py(287): elif isinstance(value, str):
_GXSynchronousMediaBase.py(288): value = bytearray(value.encode())
_GXSynchronousMediaBase.py(297): return value
_GXSynchronousMediaBase.py(169): nSize = len(terminator)
_GXSynchronousMediaBase.py(171): while foundPosition == -1:
_GXSynchronousMediaBase.py(172): if waitTime == 0:
_GXSynchronousMediaBase.py(180): if waitTime != - 1:
_GXSynchronousMediaBase.py(181): waitTime = args.waitTime - ((datetime.datetime.now().time().microsecond - startTime) / 1000)
--- modulename: ReceiveParameters, funcname: __getWaitTime
ReceiveParameters.py(78): return self.__waitTime
_GXSynchronousMediaBase.py(182): if waitTime < 0:
_GXSynchronousMediaBase.py(185): with self.__sync:
_GXSynchronousMediaBase.py(186): isReceived = not (lastBuffSize == self.__receivedSize or self.__receivedSize < nMinSize)
_GXSynchronousMediaBase.py(189): if not isReceived:
_GXSynchronousMediaBase.py(190): if waitTime == - 1:
_GXSynchronousMediaBase.py(192): elif waitTime != 0:
_GXSynchronousMediaBase.py(193): isReceived = self.__receivedEvent.wait(waitTime / 1000)
--- modulename: threading, funcname: wait
threading.py(549): with self._cond:
--- modulename: threading, funcname: __enter__
threading.py(241): return self._lock.__enter__()
threading.py(550): signaled = self._flag
threading.py(551): if not signaled:
threading.py(552): signaled = self._cond.wait(timeout)
--- modulename: threading, funcname: wait
threading.py(287): if not self._is_owned():
--- modulename: threading, funcname: _is_owned
threading.py(258): if self._lock.acquire(0):
threading.py(262): return True
threading.py(289): waiter = _allocate_lock()
threading.py(290): waiter.acquire()
threading.py(291): self._waiters.append(waiter)
threading.py(292): saved_state = self._release_save()
--- modulename: threading, funcname: _release_save
threading.py(250): self._lock.release() # No state to save
threading.py(293): gotit = False
threading.py(294): try: # restore state no matter what (e.g., KeyboardInterrupt)
threading.py(295): if timeout is None:
threading.py(299): if timeout > 0:
threading.py(300): gotit = waiter.acquire(True, timeout)
threading.py(303): return gotit
threading.py(305): self._acquire_restore(saved_state)
--- modulename: threading, funcname: _acquire_restore
threading.py(253): self._lock.acquire() # Ignore saved state
threading.py(306): if not gotit:
threading.py(307): try:
threading.py(308): self._waiters.remove(waiter)
threading.py(553): return signaled
--- modulename: threading, funcname: __exit__
threading.py(244): return self._lock.__exit__(*args)
_GXSynchronousMediaBase.py(194): self.__receivedEvent.clear()
--- modulename: threading, funcname: clear
threading.py(531): with self._cond:
--- modulename: threading, funcname: __enter__
threading.py(241): return self._lock.__enter__()
threading.py(532): self._flag = False
--- modulename: threading, funcname: __exit__
threading.py(244): return self._lock.__exit__(*args)
_GXSynchronousMediaBase.py(195): if self.exception:
_GXSynchronousMediaBase.py(198): if not isReceived:
_GXSynchronousMediaBase.py(200): if args.allData:
_GXSynchronousMediaBase.py(203): foundPosition = -1
_GXSynchronousMediaBase.py(204): break
_GXSynchronousMediaBase.py(231): if nSize == 0:
_GXSynchronousMediaBase.py(233): return foundPosition
_GXSynchronousMediaBase.py(244): data = None
_GXSynchronousMediaBase.py(245): if foundPosition != -1:
_GXSynchronousMediaBase.py(280): return foundPosition != -1
GXDLMSReader.py(199): raise Exception("Failed to received reply from the media.")
GXDLMSReader.py(546): except (KeyboardInterrupt, SystemExit):
GXDLMSReader.py(551): self.close()
--- modulename: GXDLMSReader, funcname: close
GXDLMSReader.py(89): if self.media and self.media.isOpen():
--- modulename: GXSerial, funcname: isOpen
GXSerial.py(328): return self.__h and self.__h.isOpen()
--- modulename: GXWindowsHandler, funcname: isOpen
GXWindowsHandler.py(335): return self.h != INVALID_HANDLE_VALUE
GXDLMSReader.py(90): print("DisconnectRequest")
--- modulename: cp1252, funcname: encode
cp1252.py(19): return codecs.charmap_encode(input,self.errors,encoding_table)[0]
DisconnectRequest --- modulename: cp1252, funcname: encode
cp1252.py(19): return codecs.charmap_encode(input,self.errors,encoding_table)[0]
GXDLMSReader.py(91): reply = GXReplyData()
--- modulename: GXReplyData, funcname: __init__
GXReplyData.py(56): self.moreData = more
GXReplyData.py(58): self.command = cmd
GXReplyData.py(60): self.data = buff
GXReplyData.py(61): if not self.data:
GXReplyData.py(62): self.data = GXByteBuffer()
--- modulename: GXByteBuffer, funcname: __init__
GXByteBuffer.py(60): self._data = bytearray()
GXByteBuffer.py(61): self.__size = 0
GXByteBuffer.py(62): self.__position = 0
GXByteBuffer.py(63): if isinstance(value, (bytearray, bytes)):
GXByteBuffer.py(66): elif isinstance(value, GXByteBuffer):
--- modulename: abc, funcname: __instancecheck__
abc.py(139): return _abc_instancecheck(cls, instance)
--- modulename: abc, funcname: __subclasscheck__
abc.py(143): return _abc_subclasscheck(cls, subclass)
--- modulename: _collections_abc, funcname: __subclasshook__
_collections_abc.py(304): if cls is Reversible:
_collections_abc.py(306): return NotImplemented
GXByteBuffer.py(69): elif isinstance(value, int):
GXByteBuffer.py(71): elif isinstance(value, str):
GXByteBuffer.py(74): self.setCapacity(0)
--- modulename: GXByteBuffer, funcname: setCapacity
GXByteBuffer.py(100): if capacity == 0:
GXByteBuffer.py(101): self._data = bytearray()
GXByteBuffer.py(102): self.__size = 0
GXByteBuffer.py(103): self.__position = 0
GXReplyData.py(64): self.complete = forComplete
GXReplyData.py(66): self.error = err
GXReplyData.py(67): self.value = None
GXReplyData.py(69): self.echo = False
GXReplyData.py(71): self.commandType = 0
GXReplyData.py(73): self.frameId = 0
GXReplyData.py(75): self.dataValue = None
GXReplyData.py(77): self.totalCount = 0
GXReplyData.py(80): self.readPosition = 0
GXReplyData.py(82): self.packetLength = 0
GXReplyData.py(84): self.peek = False
GXReplyData.py(86): self.cipherIndex = 0
GXReplyData.py(88): self.time = None
GXReplyData.py(90): self.xml = None
GXReplyData.py(92): self.invokeId = 0
GXReplyData.py(94): self.blockNumber = 0
GXReplyData.py(96): self.blockNumberAck = 0
GXReplyData.py(98): self.streaming = False
GXReplyData.py(100): self.windowSize = 0
GXReplyData.py(104): self.clientAddress = 0
GXReplyData.py(108): self.serverAddress = 0
GXReplyData.py(110): self.gateway = None
GXReplyData.py(112): self.valueType = DataType.NONE
GXDLMSReader.py(92): try:
GXDLMSReader.py(96): if self.client.interfaceType == InterfaceType.WRAPPER or self.client.ciphering.security != Security.NONE:
--- modulename: GXDLMSClient, funcname: __getInterfaceType
GXDLMSClient.py(384): return self.settings.interfaceType
--- modulename: GXDLMSSecureClient, funcname: __getCiphering
GXDLMSSecureClient.py(122): return self.settings.cipher
GXDLMSReader.py(101): reply.clear()
--- modulename: GXReplyData, funcname: clear
GXReplyData.py(118): self.moreData = RequestTypes.NONE
GXReplyData.py(119): self.command = Command.NONE
GXReplyData.py(120): self.commandType = 0
GXReplyData.py(121): self.data.capacity = 0
--- modulename: GXByteBuffer, funcname: setCapacity
GXByteBuffer.py(100): if capacity == 0:
GXByteBuffer.py(101): self._data = bytearray()
GXByteBuffer.py(102): self.__size = 0
GXByteBuffer.py(103): self.__position = 0
GXReplyData.py(122): self.complete = False
GXReplyData.py(123): self.error = 0
GXReplyData.py(124): self.totalCount = 0
GXReplyData.py(125): self.dataValue = None
GXReplyData.py(126): self.readPosition = 0
GXReplyData.py(127): self.packetLength = 0
GXReplyData.py(128): self.valueType = DataType.NONE
GXReplyData.py(129): self.cipherIndex = 0
GXReplyData.py(130): self.time = None
GXReplyData.py(131): if self.xml:
GXReplyData.py(133): self.invokeId = 0
GXReplyData.py(134): self.value = None
GXDLMSReader.py(102): self.readDLMSPacket(self.client.disconnectRequest(), reply)
--- modulename: GXDLMSClient, funcname: disconnectRequest
GXDLMSClient.py(651): self.settings.maxPduSize = 0xFFFF
GXDLMSClient.py(652): if not force and self.settings.connected == ConnectionState.NONE:
GXDLMSClient.py(653): return None
--- modulename: GXDLMSReader, funcname: readDLMSPacket
GXDLMSReader.py(115): if not reply:
GXDLMSReader.py(117): if isinstance(data, bytearray):
GXDLMSReader.py(119): elif data:
GXDLMSReader.py(103): self.media.close()
--- modulename: GXSerial, funcname: close
GXSerial.py(244): if self.__receiver:
GXSerial.py(245): self.__closing.set()
--- modulename: threading, funcname: set
threading.py(520): with self._cond:
--- modulename: threading, funcname: __enter__
threading.py(241): return self._lock.__enter__()
threading.py(521): self._flag = True
threading.py(522): self._cond.notify_all()
--- modulename: threading, funcname: notify_all
threading.py(365): self.notify(len(self._waiters))
--- modulename: threading, funcname: notify
threading.py(345): if not self._is_owned():
--- modulename: threading, funcname: _is_owned
threading.py(258): if self._lock.acquire(0):
threading.py(262): return True
threading.py(347): all_waiters = self._waiters
threading.py(348): waiters_to_notify = _deque(_islice(all_waiters, n))
threading.py(349): if not waiters_to_notify:
threading.py(350): return
--- modulename: threading, funcname: __exit__
threading.py(244): return self._lock.__exit__(*args)
GXSerial.py(246): self.__notifyMediaStateChange(MediaState.CLOSING)
--- modulename: GXSerial, funcname: __notifyMediaStateChange
GXSerial.py(175): for it in self.__listeners:
GXSerial.py(247): self.__h.close()
--- modulename: GXWindowsHandler, funcname: close
GXWindowsHandler.py(341): if self.h != INVALID_HANDLE_VALUE:
GXWindowsHandler.py(342): ctypes.windll.Kernel32.SetEvent(self._closing)
--- modulename: __init__, funcname: __getattr__
__init__.py(375): if name.startswith('__') and name.endswith('__'):
__init__.py(377): func = self.__getitem__(name)
--- modulename: __init__, funcname: __getitem__
__init__.py(382): func = self._FuncPtr((name_or_ordinal, self))
__init__.py(383): if not isinstance(name_or_ordinal, int):
__init__.py(384): func.__name__ = name_or_ordinal
__init__.py(385): return func
__init__.py(378): setattr(self, name, func)
__init__.py(379): return func
GXWindowsHandler.py(343): self.__closed.wait()
GXWindowsHandler.py(502): if ret == 0:
GXWindowsHandler.py(503): self.__closed.set()
--- modulename: threading, funcname: set
--- modulename: threading, funcname: waitthreading.py(520): with self._cond:
--- modulename: threading, funcname: __enter__
threading.py(241): return self._lock.__enter__()
threading.py(521): self._flag = True
threading.py(522): self._cond.notify_all()
--- modulename: threading, funcname: notify_allthreading.py(549): with self._cond:
threading.py(365): self.notify(len(self._waiters))
--- modulename: threading, funcname: notify
threading.py(345): if not self._is_owned():
--- modulename: threading, funcname: _is_owned
threading.py(258): if self._lock.acquire(0):
--- modulename: threading, funcname: __enter__threading.py(262): return True
threading.py(241): return self._lock.__enter__()
threading.py(347): all_waiters = self._waiters
threading.py(348): waiters_to_notify = _deque(_islice(all_waiters, n))
threading.py(349): if not waiters_to_notify:
threading.py(350): return
--- modulename: threading, funcname: __exit__
threading.py(244): return self._lock.__exit__(*args)
GXWindowsHandler.py(504): return None
GXSerial.py(210): if data is not None:
threading.py(550): signaled = self._flag
threading.py(551): if not signaled:
threading.py(553): return signaled
--- modulename: threading, funcname: __exit__GXSerial.py(207): while not self.__closing.isSet():
threading.py(244): return self._lock.__exit__(*args)
GXWindowsHandler.py(344): if self._overlapped_read:
GXWindowsHandler.py(345): ctypes.windll.Kernel32.CloseHandle(self._overlapped_read.hEvent)
--- modulename: __init__, funcname: __getattr__
--- modulename: threading, funcname: is_set__init__.py(375): if name.startswith('__') and name.endswith('__'):
__init__.py(377): func = self.__getitem__(name)
--- modulename: __init__, funcname: __getitem__
__init__.py(382): func = self._FuncPtr((name_or_ordinal, self))
__init__.py(383): if not isinstance(name_or_ordinal, int):
__init__.py(384): func.__name__ = name_or_ordinal
__init__.py(385): return func
threading.py(509): return self._flag
__init__.py(378): setattr(self, name, func)
__init__.py(379): return func
GXWindowsHandler.py(346): self._overlapped_read = None
GXWindowsHandler.py(347): if self._overlapped_write:
GXWindowsHandler.py(348): ctypes.windll.Kernel32.CloseHandle(self._overlapped_write.hEvent)
GXWindowsHandler.py(349): self._overlapped_write = None
GXWindowsHandler.py(350): ctypes.windll.Kernel32.CloseHandle(self.h)
GXWindowsHandler.py(351): self.h = INVALID_HANDLE_VALUE
GXSerial.py(248): if self.__receiver:
GXSerial.py(249): self.__receiver.join()
--- modulename: threading, funcname: join
threading.py(1036): if not self._initialized:
threading.py(1038): if not self._started.is_set():
--- modulename: threading, funcname: is_set
threading.py(509): return self._flag
threading.py(1040): if self is current_thread():
threading.py(874): del self._target, self._args, self._kwargs
--- modulename: threading, funcname: current_thread
threading.py(1233): try:
threading.py(1234): return _active[get_ident()]
threading.py(1043): if timeout is None:
threading.py(1044): self._wait_for_tstate_lock()
--- modulename: threading, funcname: _wait_for_tstate_lock
threading.py(1057): lock = self._tstate_lock
threading.py(1058): if lock is None: # already determined that the C code is done
threading.py(1060): elif lock.acquire(block, timeout):
threading.py(1061): lock.release()
threading.py(1062): self._stop()
--- modulename: threading, funcname: _stop
threading.py(994): lock = self._tstate_lock
threading.py(995): if lock is not None:
threading.py(996): assert not lock.locked()
threading.py(997): self._is_stopped = True
threading.py(998): self._tstate_lock = None
threading.py(999): if not self.daemon:
--- modulename: threading, funcname: daemon
threading.py(1129): assert self._initialized, "Thread.__init__() not called"
threading.py(1130): return self._daemonic
threading.py(1000): with _shutdown_locks_lock:
threading.py(1001): _shutdown_locks.discard(lock)
GXSerial.py(250): self.__receiver = None
--- modulename: _weakrefset, funcname: _remove
_weakrefset.py(39): self = selfref()
_weakrefset.py(40): if self is not None:
_weakrefset.py(41): if self._iterating:
_weakrefset.py(44): self.data.discard(item)
GXSerial.py(251): self.__notifyMediaStateChange(MediaState.CLOSED)
--- modulename: GXSerial, funcname: __notifyMediaStateChange
GXSerial.py(175): for it in self.__listeners:
GXSerial.py(252): self.__bytesSent = 0
GXSerial.py(253): self.__syncBase.resetReceivedSize()
--- modulename: _GXSynchronousMediaBase, funcname: resetReceivedSize
_GXSynchronousMediaBase.py(68): self.__receivedSize = 0
main.py(109): except (ValueError, GXDLMSException, GXDLMSExceptionResponse, GXDLMSConfirmedServiceError) as ex:
main.py(111): except (KeyboardInterrupt, SystemExit, Exception) as ex:
main.py(112): traceback.print_exc()
--- modulename: traceback, funcname: print_exc
traceback.py(163): print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
--- modulename: traceback, funcname: print_exception
traceback.py(101): if file is None:
traceback.py(102): file = sys.stderr
traceback.py(103): for line in TracebackException(
traceback.py(104): type(value), value, tb, limit=limit).format(chain=chain):
--- modulename: traceback, funcname: __init__
traceback.py(471): if _seen is None:
traceback.py(472): _seen = set()
traceback.py(473): _seen.add(id(exc_value))
traceback.py(476): if (exc_value and exc_value.__cause__ is not None
traceback.py(487): cause = None
traceback.py(488): if (exc_value and exc_value.__context__ is not None
traceback.py(499): context = None
traceback.py(500): self.exc_traceback = exc_traceback
traceback.py(501): self.__cause__ = cause
traceback.py(502): self.__context__ = context
traceback.py(504): exc_value.__suppress_context__ if exc_value else False
traceback.py(506): self.stack = StackSummary.extract(
traceback.py(507): walk_tb(exc_traceback), limit=limit, lookup_lines=lookup_lines,
traceback.py(508): capture_locals=capture_locals)
--- modulename: traceback, funcname: extract
traceback.py(332): if limit is None:
traceback.py(333): limit = getattr(sys, 'tracebacklimit', None)
traceback.py(334): if limit is not None and limit < 0:
traceback.py(336): if limit is not None:
traceback.py(342): result = klass()
traceback.py(343): fnames = set()
traceback.py(344): for f, lineno in frame_gen:
--- modulename: traceback, funcname: walk_tb
traceback.py(308): while tb is not None:
traceback.py(309): yield tb.tb_frame, tb.tb_lineno
traceback.py(345): co = f.f_code
traceback.py(346): filename = co.co_filename
traceback.py(347): name = co.co_name
traceback.py(349): fnames.add(filename)
traceback.py(350): linecache.lazycache(filename, f.f_globals)
--- modulename: linecache, funcname: lazycache
linecache.py(160): if filename in cache:
linecache.py(161): if len(cache[filename]) == 1:
linecache.py(164): return False
traceback.py(352): if capture_locals:
traceback.py(355): f_locals = None
traceback.py(356): result.append(FrameSummary(
traceback.py(357): filename, lineno, name, lookup_line=False, locals=f_locals))
--- modulename: traceback, funcname: __init__
traceback.py(254): self.filename = filename
traceback.py(255): self.lineno = lineno
traceback.py(256): self.name = name
traceback.py(257): self._line = line
traceback.py(258): if lookup_line:
traceback.py(260): self.locals = {k: repr(v) for k, v in locals.items()} if locals else None
traceback.py(344): for f, lineno in frame_gen:
--- modulename: traceback, funcname: walk_tb
traceback.py(310): tb = tb.tb_next
traceback.py(308): while tb is not None:
traceback.py(309): yield tb.tb_frame, tb.tb_lineno
traceback.py(345): co = f.f_code
traceback.py(346): filename = co.co_filename
traceback.py(347): name = co.co_name
traceback.py(349): fnames.add(filename)
traceback.py(350): linecache.lazycache(filename, f.f_globals)
--- modulename: linecache, funcname: lazycache
linecache.py(160): if filename in cache:
linecache.py(161): if len(cache[filename]) == 1:
linecache.py(164): return False
traceback.py(352): if capture_locals:
traceback.py(355): f_locals = None
traceback.py(356): result.append(FrameSummary(
traceback.py(357): filename, lineno, name, lookup_line=False, locals=f_locals))
--- modulename: traceback, funcname: __init__
traceback.py(254): self.filename = filename
traceback.py(255): self.lineno = lineno
traceback.py(256): self.name = name
traceback.py(257): self._line = line
traceback.py(258): if lookup_line:
traceback.py(260): self.locals = {k: repr(v) for k, v in locals.items()} if locals else None
traceback.py(344): for f, lineno in frame_gen:
--- modulename: traceback, funcname: walk_tb
traceback.py(310): tb = tb.tb_next
traceback.py(308): while tb is not None:
traceback.py(309): yield tb.tb_frame, tb.tb_lineno
Segmentation fault
Sorry for the long post. Should I try looking for different driver versions?
Regards,
Dylan
Hi,
Hi,
Try to remove your driver and let Windows find the driver. It should be 2.12.28.0.
Let me know if it still fails. Do you have any specific in your PC?
BR,
Mikko
Hi,
Hi,
I removed the driver and it rolled back to version 2.12.28.0 Before it was a new version. Python seems to crash a lot less but still no success. I'm going to try a system restart just to see what happens.
Regards,
Dylan
Hi Mikko,
Hi Mikko,
Still no luck on my side. I'm still getting the same errors.
Hi Mikko,
Hi Mikko,
If I send through a file with full Python traceback, would that help to debug my issue?
Regards,
Dylan
Hi Dylan,
Hi Dylan,
There is one PC where this error can be repeated. There were also issues in the example, but there is also a strange error that is happening on one PC when FTDI is used.
But we can now repeat this, I hope it's the same error, and I'll let you know as soon as this is fixed.
BR,
Mikko
Hi,
Hi,
The new version is released (1.0.109). Get the source codes from the GitHub. Note! You must update gurux-serial component for Python to version 1.0.15.
BR,
Mikko
Hi MIkko
Hi MIkko
I have updated the serial component for Python, and I got the latest code from Github. It's definitely progress but Still 100%.
I tried: py main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
Response:
gurux_dlms version: 1.0.107
gurux_net version: 1.0.17
gurux_serial version: 1.0.17
Authentication: Authentication.NONE
ClientAddress: 0x10
ServerAddress: 0x1
Standard: Standard.DLMS
TX: 12:21:21 /?!
RX: 12:21:22 bytearray(b'/LGZ5\\2ZMD3104407.B24\r\n')
Bitrate is : 9600
TX: 12:21:23 06 32 35 32 0D 0A
RX: 12:21:24 None
TX: 12:21:25 7E A0 07 03 21 93 0F 01 7E
RX: 12:21:25
DisconnectRequest
Invalid Interface type.
Regards,
Dylan
Hi Mikko
Hi Mikko
I have successfully connected to the meter with this command:
py main.py -S COM3 -r sn -t Verbose
I did not need to specify an InterfaceType
Seems like it's working. I'll confirm in the next hour or so.
Regards,
Dylan
Hi Dylan,
Hi Dylan,
You should usually use -i HdlcWithModeE parameter if you communicate with LG using an optical probe.
I'm glad if you can read the meter.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I find the code hanging sometimes. I have to restart the terminal.
$ py main.py -S COM3 -r sn -i HdlcWithModeE -t Verbose
Traceback (most recent call last):
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\main.py", line 108, in main
reader.readAll(settings.outputFile)
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 528, in readAll
self.initializeConnection()
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 301, in initializeConnection
self.initializeOpticalHead()
File "C:\wamp64\www\personal\projects\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 199, in initializeOpticalHead
if not self.media.receive(p):
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\site-packages\gurux_serial\GXSerial.py", line 385, in receive
return self.__syncBase.receive(args)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\site-packages\gurux_serial\_GXSynchronousMediaBase.py", line 243, in receive
foundPosition = self.__findData(args)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\site-packages\gurux_serial\_GXSynchronousMediaBase.py", line 193, in __findData
isReceived = self.__receivedEvent.wait(waitTime / 1000)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\threading.py", line 574, in wait
signaled = self._cond.wait(timeout)
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python39\lib\threading.py", line 316, in wait
gotit = waiter.acquire(True, timeout)
KeyboardInterrupt