Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

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

Breadcrumb

  1. Home
  2. Forums
  3. Server DLMS Java and Client DLMS C

Server DLMS java and Client DLMS C

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 fernando , 30 July, 2020
Forums
Gurux.DLMS

Good morning,

I have java DLMS server running on NetBeans. In the code I have put listen to the COM4 serial port.

class Settings {

public TraceLevel trace = TraceLevel.INFO;
public int port = 4060;
public String serial = "COM4" ;
public boolean useLogicalNameReferencing = true;
}

Then I have the DLMS client in C in a virtual machine (virtualBox),listening to the COM1 serial port (/dev/ttyS0 on Ubuntu).

COM1 and COM4 serial ports are virtually connected.

I run the client with the command,
sudo ./bin/gurux.dlms.client.bin -S /dev/ttyS0
or
sudo ./bin/gurux.dlms.client.bin -S /dev/ttyS0 -c 16 -s 1

and each time it gives me different things:

GetAssociationView
GetObjects failed Send failed.
Close failed.Error. 252

SNRMRequest failed Send failed.
Error. 252

AARQRequest failed Send failed.
Close failed.Error. 252

Could you help me?
Thanks you.

Profile picture for user Kurumi

Kurumi

5 years 10 months ago

Hi,

Hi,

Check first that you can operate with the serial port.
Then give "-t Verbose" parameter for the server and the client. Check what bytes you are receiving and sending.

BR,
Mikko

fernando

5 years 10 months ago

In reply to Hi, by Kurumi

Hi,

Hi,

The server receives different things every time, these are some examples:

1.-
Client: sudo ./bin/gurux.dlms.client.bin -S /dev/ttyS0 -t Verbose
InitializeConnection
TX: 7E A0 07 03 21 93 0F 01 7E
SNRMRequest failed Send failed.
Error. 252

Server: run:
Logical Name DLMS Server in serial port COM4
----------------------------------------------------------
Press Enter to close.
RX: 7E A0 07 03 21 53 03 C7 00 7E

2.-
Client: TX: 7E A0 07 03 21 93 0F 01 7E
SNRMRequest failed Send failed.
Error. 252

Server: RX: 7E A0 07 03 21 93

It seems that the server does not receive the complete frame that the client sends
This occurs by running the client only once, but if I run the client 2 times in a row this happens:

first run

client: InitializeConnection
TX: 7E A0 07 03 21 93 0F 01 7E
SNRMRequest failed Send failed.
Error. 252

Server : RX: 7E A0 07 03 21 93 0F 01

second run

client: InitializeConnection
TX: 7E A0 07 03 21 93 0F 01 7E
RX: 7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
TX: 7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF C5 E4 7E
RX: 7E A0 37 21 03 30 6C 7C 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 1E 1D 04 00 00 07 E0 A6 7E
GetAssociationView
TX: 7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 81 00 0F 00 00 28 00 00 FF 02 00 94 9E 7E
RX: 7E A8 86 21 03 52 7F 1B E6 E7 00 C4 02 81 00 00 00 00 01 00 82 03 F4 01 1C 02 04 12 00 0F 11 02 09 06 00 00 28 00 00 FF 02 02 01 0B 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 16 01 00 02 03 0F 05 16 01 00 02 03 0F 06 16 01 00 02 03 0F 07 16 01 00 02 03 0F 08 16 01 00 02 03 0F 09 16 01 00 02 03 0F 0A 16 01 00 02 03 0F 0B 16 01 00 01 06 02 02 0F 01 16 00 02 02 0F 02 B2 B9 7E
TX: 7E A0 07 03 21 51 11 E4 7E
RX: 7E A8 86 21 03 54 49 7E 16 00 02 02 0F 03 16 00 02 02 0F 04 16 00 02 02 0F 05 16 00 02 02 0F 06 16 00 02 04 12 00 17 11 01 09 06 00 00 16 00 00 FF 02 02 01 09 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 16 01 00 02 03 0F 05 16 01 00 02 03 0F 06 16 01 00 02 03 0F 07 16 01 00 02 03 0F 08 16 01 00 02 03 0F 09 16 01 00 01 00 02 04 12 00 40 11 00 09 06 00 00 2B 00 00 FF 0F 08 7E
TX: 7E A0 07 03 21 71 13 C5 7E
RX: 7E A8 86 21 03 56 5B 5D 02 02 01 05 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 16 01 00 02 03 0F 05 16 01 00 01 02 02 02 0F 01 16 00 02 02 0F 02 16 00 02 04 12 00 01 11 00 09 06 00 00 2A 00 00 FF 02 02 01 02 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 01 00 02 04 12 00 01 11 00 09 06 01 00 00 02 00 FF 02 02 01 02 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 01 00 02 04 A6 ED 7E
TX: 7E A0 07 03 21 91 1D 22 7E
GetObjects failed Send failed.
TX: 7E A0 07 03 21 53 03 C7 7E
RX: 7E A8 86 21 03 58 25 B4 12 00 01 11 00 09 06 00 00 2B 01 00 FF 02 02 01 02 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 01 00 02 04 12 00 03 11 00 09 06 01 01 15 19 00 FF 02 02 01 03 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 01 01 02 02 0F 01 16 00 02 04 12 00 08 11 00 09 06 00 00 01 00 00 FF 02 02 01 09 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 BA 30 7E
Close failed.Error. 252

Server: RX: 7E 7E
TX: 7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
RX: A0 07 03 21 93 0F 01 7E 7E
RX: A0 2B 03 21 10 FB
RX: AF E6 E6 00 60 1D A1
RX: 09 06 07
RX: 60 85 74 05 08 01
RX: 01 BE 10 04 0E 01
RX: 00 00 00 06
RX: 5F 1F 04 00 00 1E
RX: 1D FF
RX: FF C5
RX: E4 7E
TX: 7E A0 37 21 03 30 6C 7C 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 1E 1D 04 00 00 07 E0 A6 7E
RX: 7E A0 19 03 21 32
RX: 6F D8 E6
RX: E6 00 C0
RX: 01 81 00
RX: 0F 00
RX: 00 28 00 00 FF
RX: 02 00
RX: 94 9E 7E
TX: 7E A8 86 21 03 52 7F 1B E6 E7 00 C4 02 81 00 00 00 00 01 00 82 03 F4 01 1C 02 04 12 00 0F 11 02 09 06 00 00 28 00 00 FF 02 02 01 0B 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 16 01 00 02 03 0F 05 16 01 00 02 03 0F 06 16 01 00 02 03 0F 07 16 01 00 02 03 0F 08 16 01 00 02 03 0F 09 16 01 00 02 03 0F 0A 16 01 00 02 03 0F 0B 16 01 00 01 06 02 02 0F 01 16 00 02 02 0F 02 B2 B9 7E
RX: 7E A0 07 03 21 51
RX: 11 E4 7E
TX: 7E A8 86 21 03 54 49 7E 16 00 02 02 0F 03 16 00 02 02 0F 04 16 00 02 02 0F 05 16 00 02 02 0F 06 16 00 02 04 12 00 17 11 01 09 06 00 00 16 00 00 FF 02 02 01 09 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 16 01 00 02 03 0F 05 16 01 00 02 03 0F 06 16 01 00 02 03 0F 07 16 01 00 02 03 0F 08 16 01 00 02 03 0F 09 16 01 00 01 00 02 04 12 00 40 11 00 09 06 00 00 2B 00 00 FF 0F 08 7E
RX: 7E A0 07
RX: 03 21
RX: 71 13 C5 7E
TX: 7E A8 86 21 03 56 5B 5D 02 02 01 05 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 16 01 00 02 03 0F 05 16 01 00 01 02 02 02 0F 01 16 00 02 02 0F 02 16 00 02 04 12 00 01 11 00 09 06 00 00 2A 00 00 FF 02 02 01 02 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 01 00 02 04 12 00 01 11 00 09 06 01 00 00 02 00 FF 02 02 01 02 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 01 00 02 04 A6 ED 7E
RX: 7E A0 07 03 21 91 1D 22
RX: 7E 7E
TX: 7E A8 86 21 03 58 25 B4 12 00 01 11 00 09 06 00 00 2B 01 00 FF 02 02 01 02 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 01 00 02 04 12 00 03 11 00 09 06 01 01 15 19 00 FF 02 02 01 03 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 01 01 02 02 0F 01 16 00 02 04 12 00 08 11 00 09 06 00 00 01 00 00 FF 02 02 01 09 02 03 0F 01 16 01 00 02 03 0F 02 16 01 00 02 03 0F 03 16 01 00 02 03 0F 04 BA 30 7E

With the gurux director, if it works well, I don't understand.

Thanks you.

Profile picture for user Kurumi

Kurumi

5 years 10 months ago

Hi,

Hi,

Can you run ANSI C in Windows and check if it works from there? I checked this with my Windows and Linux, and it worked without problems. What Ubuntu version you are using?

BR,
Mikko

fernando

5 years 10 months ago

Hi,

Hi,

Sorry for my ignorance, but I don't know how to run ANSI C in Windows, could you tell me how?

The Ubuntu version I use is:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04

The server uses a baud rate of 9600, the client with the command dmesg | grep tty, it tells me this:
[ 0.004000] console [tty0] enabled
[ 2.167286] 00:02: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A

but I have changed the baud rate to 9600 with the command:
setserial -v / dev / ttyS0 baud_base 9600

with the command: setserial -a / dev / ttyS0
gives me this:
/dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4
Baud_base: 9600, close_delay: 50, divisor: 0
closing_wait: 3000
Flags: spd_normal skip_test

but with the previous command: dmesg | grep tty, it gives me the same as before
[ 0.004000] console [tty0] enabled
[ 2.167286] 00:02: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A

Profile picture for user Kurumi

Kurumi

5 years 10 months ago

Hi,

Hi,

You need to use Visual Studio to build it and then you can run GuruxDLMSClientExample in the same way as in Linux.

You don't need set the serial port settings because the client app don't use tty. It communicates directly with the serial port. Default serial port settings are 9600 8None1.

BR,
Mikko

fernando

5 years 10 months ago

It is the first time that I

I just opened and compiled the project with visual studio. I have run it through the windows command line and the first time it said: GetObjects failed Send failed.

But all the other times it has worked correctly.

I must have some problem with VirtualBox or the ubuntu version.
Do you know why it could be?

Thank you very much for your help

Profile picture for user Kurumi

Kurumi

5 years 10 months ago

Hi,

Hi,

Try to start server and client in Windows first. The reason is usually in serial port settings, but it's strange if you can make the connection and it stops answering when you read association view.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin