Skip to main content
Home
for DLMS smart meters

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. GXSerial and Windows COM Ports

GXSerial and Windows COM ports

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By murrayi, 24 January, 2023
Forums
Gurux.Serial

When passing the serial port as an argument in Linux to the GXSerial constructor, it is working fine. However this error occurs for Windows:

Exception in thread "main" java.lang.Exception: The handle is invalid.

at gurux.io.NativeCode.openSerialPort(Native Method)
at gurux.serial.GXSerial.open(GXSerial.java:526)

It seems like the library can't handle Windows COM ports?

holmium_user

1 year 3 months ago

I am having the similar…

I am having the similar issue. I am testing Gurux DLMS Client Example in python in raspberry PI as well as in windows 11. The code is working when using raspberry pi but getting timeout response when using windows. I have my doubt on GXSerial as in raspberry pi it shows available ports but in wondows it does not show COM ports

Image

holmium_user

1 year 3 months ago

When I put the COM Port in…

When I put the COM Port in source setting the response is attached below

Image
Profile picture for user Kurumi

Kurumi

1 year 3 months ago

Hi, Windows COM ports are…

Hi,

Windows COM ports are used all the time.
The handle is invalid error means that you try to open serial port that doesn't exist.
Check that you use the correct serial port.

BR,
Mikko

Profile picture for user Kurumi

Kurumi

1 year 3 months ago

Hi holmium_user, Check your…

Hi holmium_user,

Check your serial port from Windows Device Manager and update drivers if needed.
If you don't see any serial ports you haven't any on your Windows.

Note! Several USB to RS-232 converters don't work in Windows 11. They are only working on Windows 10 and Windows 8.

BR,
Mikko

holmium_user

1 year 3 months ago

Hi Kurumi, I think the USB…

Hi Kurumi,

I think the USB to RS232 converter is working fine. As I am able to read the meter using DLMS Director from same PC and same converter. But when I try to use the Python Library on the same PC to read the meter then the Client Example is not able to read it. I get broken response at the end of timeout exception.

Profile picture for user Kurumi

Kurumi

1 year 3 months ago

Hi, In Windows available…

Hi,

In Windows available serial ports are read from the registry. I can't understand why your serial port is shown as "LADA0".

Can you run this and let me know the python version:
python --version

What language your Windows 11 is using? If you can share this, we can install the same Windows localization and test this.

The connection fails because your device settings are different than the meter expects. When you select the meter in GXDLMSDirector, you can see the correct command-line arguments that you must use.

BR,
Mikko

holmium_user

1 year 3 months ago

Hi, The python version is 3…

Hi,

The python version is 3.12.3. The screen shot is attached. I don't get your point about the windows language.

When I used raspberry Pi to read meter using RS232 then it was reading some responses by proving only one resource that is COM Port. I have also tried with setting used in DLMS Director, but it did not work.

I have also tried in separate PC having windows 11 and python version 3.12.3. There I was getting port names but the response for SNRM Packet was not coming. And after three retry count I receive some response bytes in RX buffer as per the attachment.

Image

holmium_user

1 year 3 months ago

PS C:\Users\Holmi\Gurux.DLMS…

PS C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python> py main.py -S COM10
gurux_dlms version: 1.0.150
gurux_net version: 1.0.19
gurux_serial version: 1.0.20
Authentication: 0
ClientAddress: 0x10
ServerAddress: 0x1
Standard: 0
error code= 0
Data send failed. Try to resend 1/3
error code= 0
Data send failed. Try to resend 2/3
error code= 0
RX: 14:29:33
DisconnectRequest
Traceback (most recent call last):
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\main.py", line 113, in main
reader.readAll(settings.outputFile)
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 554, in readAll
self.initializeConnection()
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 317, in initializeConnection
self.readDLMSPacket(data, reply)
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 119, in readDLMSPacket
self.readDLMSPacket2(data, reply)
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 172, in readDLMSPacket2
raise e
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 165, in readDLMSPacket2
raise TimeoutException("Failed to receive reply from the device in given time.")
gurux_common.TimeoutException.TimeoutException: Failed to receive reply from the device in given time.
Ended. Press any key to continue.
PS C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python> py main.py -S COM11
gurux_dlms version: 1.0.150
gurux_net version: 1.0.19
gurux_serial version: 1.0.20
Authentication: 0
ClientAddress: 0x10
ServerAddress: 0x1
Standard: 0
error code= 0
Data send failed. Try to resend 1/3
error code= 0
Data send failed. Try to resend 2/3
error code= 0
RX: 14:30:35 7E A0 20 21 03 73 73 98 81 80 14 05 02 02 00 06 02 02
DisconnectRequest
Traceback (most recent call last):
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\main.py", line 113, in main
reader.readAll(settings.outputFile)
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 554, in readAll
self.initializeConnection()
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 317, in initializeConnection
self.readDLMSPacket(data, reply)
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 119, in readDLMSPacket
self.readDLMSPacket2(data, reply)
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 172, in readDLMSPacket2
raise e
File "C:\Users\Holmi\Gurux.DLMS.Python\Gurux.DLMS.Client.Example.python\GXDLMSReader.py", line 165, in readDLMSPacket2
raise TimeoutException("Failed to receive reply from the device in given time.")
gurux_common.TimeoutException.TimeoutException: Failed to receive reply from the device in given time.
Ended. Press any key to continue.

Profile picture for user Kurumi

Kurumi

1 year 3 months ago

Hi, I checked this from the…

Hi,
I checked this from the source code and noticed that it expects that Windows is using Unicode format.
Can you start Windows PowerShell.
Then run this command and add the results here.

Get-InstalledLanguage

This affects only how available serial ports are shown. You can use the client application if you set the correct settings that GXDLMSDirector shows.

BR,
Mikko

Profile picture for user Kurumi

Kurumi

1 year 3 months ago

Hi, Can you add this to get…

Hi,

Can you add this to get a better trace:
-t Verbose

I can see that the meter is using a different server address. What server address are you using in GXDLMSDirector?

BR,
Mikko

holmium_user

1 year 3 months ago

Hi, Check the response for…

Hi,

Check the response for installed Language

Image

holmium_user

1 year 3 months ago

Response after adding -t…

Response after adding -t Verbose and using the correct details as used in DLMS Director.

Image
Profile picture for user Kurumi

Kurumi

1 year 2 months ago

Hi, Can you add the hex…

Hi,

Can you add the hex trace from GXDLMSDictor log? The first row is enough.
Please, don't add pictures. The hex string is hard to read from the pic.

BR,
Mikko

holmium_user

1 year 2 months ago

13:43:28 Send SNRM request…

13:43:28 Send SNRM request.
TX: 7E A0 07 03 41 93 5A 64 7E
13:43:28
RX: 7E A0 20 41 03 73 3E 9D 81 80 14 05 02 02 00 06 02 02 00 07 04 00 00 00 01 08 04 00 00 00 01 6F EF 7E
13:43:28 Send AARQ request.
TX: 7E A0 44 03 41 10 B3 E1 E6 E6 00 60 36 A1 09 06 07 60 85 74 05 08 01 01 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 41 42 43 44 30 30 30 31 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 5D FF FF 6B 70 7E
13:43:28
RX: 7E A0 37 41 03 30 21 79 E6 E7 00 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 00 10 14 02 00 00 07 BC 85 7E

Profile picture for user Kurumi

Kurumi

1 year 2 months ago

Hi, This looks strange. It…

Hi,

This looks strange. It looks like the meter is sending the beginning of the data and the end is missing. It is even strange if you can read this with GXDLMSDirector.

Are you running python and GXDLMSDirector on the same PC? What USB to the serial port converter you are using?

BR,
Mikko

shaaa

1 year 2 months ago

Hi Sir, i also have the same…

Hi Sir,
i also have the same problem. i cant read the data from the meter. im using Visual Studio .NET 6.0.

Image

shaaa

1 year 2 months ago

how i can change the com…

how i can change the com port on my code?

Profile picture for user Kurumi

Kurumi

1 year 2 months ago

Dear shaaa, Please, create a…

Dear shaaa,

Please, create a new topic if you have a new question.

serial.PortName = "YOUR_COM";

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 07/09/2025 - 16:41
    Gurux.Serial.Android 2.0.13
  • Wed, 07/09/2025 - 12:07
    gurux.dlms.c 9.0.2507.0901
  • Sat, 07/05/2025 - 15:04
    Gurux.DLMS.Python 1.0.188
  • Tue, 07/01/2025 - 10:09
    Gurux.DLMS.Python 1.0.187
  • Tue, 07/01/2025 - 09:54
    gurux.dlms.c 9.0.2507.0101

New forum topics

  • Regarding the dlms android project
  • Unable to read attribute =3 (1.0.94.91.0.255) IC=7 for Indian Metering, while I'm able to read attribute 3 for other Profile generic class
  • Register Activation class (class_id = 9) attribute index 3 data is not visible
  • Load profile
  • DLMS Decryption Implementation Status and Clarification Needed
More

Who's new

  • octavio.diaz
  • Владислав
  • boukon
  • SauberlA
  • CRISTIAN13
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin