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. GuruxDLMS.c Server On TI-MSP432

GuruxDLMS.c server on TI-MSP432

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 DDobrev21 , 7 October, 2021
Forums
Gurux.DLMS

Hello,
I am trying to load the GuruxDLMS.c server onto TI MSP432E and connect via the serial port to the GuruxDirector, but there are some issues. Firstly, I tried to change only the function for initialization of the serial port using the UART handlers and parameters after that I changed the UnixSerialPortThread function so that it can read and write to the UART. The problem is that this set up works only when the baud rate is 1200 or 2400, and everything seem OK until I turn up the baud rate and I cannot even pass the AARE reply successfully. After that I tried a different method of initialization of the serial port and also a different method of reading and writing the data to the UART(using extra buffer and interrupts - when a byte comes it interrupts the program and goes to store that byte into the extra buffer and when the whole frame is received the program calls handleRequest2 with the whole extra buffer with the received data and the count of the buffer elements. The problem with this method is that it is working even slower than the previous scenario even though the baud rate is 9600 or 115200). So, my question is what should I do to make this work properly.
Best regards, Dobrev.

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi Dobrev,

Hi Dobrev,

We don't have TI MSP432E so I can test this, but this sounds like your UART buffer is small and it causes the problems. Have you tried to check that UART buffer is not full before you write more data to the buffer?

BR,
Mikko

DDobrev21

4 years 8 months ago

In reply to Hi Dobrev, by Kurumi

Hello,

Hello,
Thanks for the fast reply, I have not changed the size of the buffer in the case where the program only functions at 1200 and 2400 baud rate. And how it is even possible to crash the buffer size
when changing the baud rate only. In the second case the buffer is 128 bytes, so it should be enough, because the longest frame is less than 128 bytes, isn't it.
Best regards, Dobrev.

DDobrev21

4 years 8 months ago

I am attaching logs first

I am attaching logs first from the server and then from the Director at 4800 baud rate:

RX: 7E A0 07 03 21 93 0F 01 7E svr_isTarget.
Connecting without authentication.
svr_connected to HDLC level.

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: 7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85

================= end of server log ===============

8:00:52 Send SNRM request.
7E A0 07 03 21 93 0F 01 7E
18:00:53
00 EC 04 B8 E0 FF F6 FF FE FF FF FF FF FF 98 00 F8 E0 FC 00 F4 02 FE F1 EE A0 F8 FB FB FF FD FE 00 FF F0 FD EE FC FC FB F8 E0 FB F0 D8 00 FC FF FF F4 E0 EE FD FF FF FF FF FF B0 F8 FF E8 DC FE FE FA F8 02 FC DC F7 FD FC FC ED FE FD F4 FB FE 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
18:00:53 Parsing UA reply succeeded.
18:00:53 Send AARQ request.
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 5D FF FF B3 E2 7E
18:00:58 Data send failed. Try to resend 1/3
18:01:03 Data send failed. Try to resend 2/3
18:01:08 Failed to receive reply from the device in given time.
System.TimeoutException: Failed to receive reply from the device in given time.
at GXDLMSDirector.GXDLMSCommunicator.ReadDLMSPacket(Byte[] data, Int32 tryCount, GXReplyData reply)
at GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[] data, String text, Int32 multiplier, Int32 tryCount, GXReplyData reply)
at GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[] data, String text, Int32 multiplier, GXReplyData reply)
at GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[] data, String text, GXReplyData reply)
at GXDLMSDirector.GXDLMSCommunicator.ReadDataBlock(Byte[][] data, String text, GXReplyData reply)
at GXDLMSDirector.GXDLMSCommunicator.InitializeConnection(Boolean force)
at GXDLMSDirector.GXDLMSDevice.InitializeConnection()
at GXDLMSDirector.MainForm.Connect(Object sender, GXAsyncWork work, Object[] parameters)

It seams like it cannot read the whole frame from the client, but why. When the baud rate is 1200 or 2400 the is absolutely no problem. Maybe the is a timer for emptying the UART receive buffer and when the baud rate is higher it cannot empty it in time, is it possible.

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi,

Hi,

I'm not talking from the buffer where data is saved. I mean hardware FIFO UART butter. I checked that it is 16 bytes IN TX. I believe that FIFO is full and data is overwritten. Try to read data from the UART using interrupts and then append it to the gxbytebuffer.

BR,
Mikko

DDobrev21

4 years 8 months ago

Hi,

Hi,
I have already tried the interrupt method, I am filling a receive buffer and after the whole frame is received, I send it to svr_handleRequest2() function with the count of the bytes, and it works, but it is very slow - it is far slower compared to the server example and Director connected on a PC via virtual port. I am pulling a global flag for a full frame and in the UnixSerialPortThread function there is a if statement and if the frame is received it continues with the code in the UnixSerialPortThread function and if the frame is not full it is looping the while(1) loop of the thread. And svr_handleRequest2() function is called inside the if statement. Is this the right approach ?
I am attaching a log from the Director:
10:34:26 Initializing serial connection.
10:34:27 Send SNRM request.
7E A0 07 03 21 93 0F 01 7E
10:34:28
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
10:34:28 Parsing UA reply succeeded.
10:34:28 Send AARQ request.
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 5D FF FF B3 E2 7E
10:34:33 Data send failed. Try to resend 1/3
10:34:35
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 00 18 02 00 00 07 3C B0 7E
10:34:35 Parsing AARE reply succeeded.
10:34:41 Read object type Clock index: 2
7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 02 00 60 1A 7E
10:34:42
7E A0 30 21 03 52 59 6B E6 E7 00 C4 01 C1 00 09 0C 07 F7 0C 1F 06 17 00 11 00 00 00 00 09 0F 09 0C 07 F7 0C 1F 06 17 00 11 00 00 00 00 09 0F 2E 6C 7E
10:34:42 Read object type Clock index: 3
7E A0 19 03 21 54 5F DE E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 03 00 B8 03 7E
10:34:47 Data send failed. Try to resend 1/3
10:34:49
7E A0 13 21 03 74 F3 85 E6 E7 00 C4 01 C1 00 10 00 00 BB 04 7E
10:34:49 Read object type Clock index: 4
7E A0 19 03 21 76 4F DC E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 04 00 B0 4E 7E
10:34:54 Data send failed. Try to resend 1/3
10:34:55
7E A0 12 21 03 96 54 5D E6 E7 00 C4 01 C1 00 16 00 13 00 7E
10:34:55 Read object type Clock index: 5
7E A0 19 03 21 98 3F D2 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 05 00 68 57 7E
10:35:00 Data send failed. Try to resend 1/3
10:35:02
7E A0 1E 21 03 B8 1C 02 E6 E7 00 C4 01 C1 00 09 0C FF FF 03 FE 05 00 00 00 00 80 00 00 0E 01 7E
10:35:02 Read object type Clock index: 6
7E A0 19 03 21 BA 2F D0 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 06 00 00 7D 7E
10:35:07 Data send failed. Try to resend 1/3
10:35:09
7E A0 1E 21 03 DA 08 42 E6 E7 00 C4 01 C1 00 09 0C FF FF 0A FE 02 01 00 00 00 80 00 00 DB 47 7E
10:35:09 Read object type Clock index: 7
7E A0 19 03 21 DC 1F D6 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 07 00 D8 64 7E
10:35:14 Data send failed. Try to resend 1/3
10:35:15
7E A0 12 21 03 FC 08 91 E6 E7 00 C4 01 C1 00 0F 3C 75 B9 7E
10:35:15 Read object type Clock index: 8
7E A0 19 03 21 FE 0F D4 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 08 00 10 E7 7E
10:35:20 Data send failed. Try to resend 1/3
10:35:22
7E A0 12 21 03 1E 14 55 E6 E7 00 C4 01 C1 00 03 00 3A EB 7E
10:35:22 Read object type Clock index: 9
7E A0 19 03 21 10 7F DA E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 09 00 C8 FE 7E
10:35:27 Data send failed. Try to resend 1/3
10:35:28
7E A0 12 21 03 30 68 9D E6 E7 00 C4 01 C1 00 16 02 01 23 7E
========== end of log ===============
Here I can see that the frames sent by the Director are not being received properly from the first time, is that right. The problem starts when it tries to connect at DLMS level, and I don't know whether it is because of the larger frame, sent by the Director, or it is something else. So, do You have an idea what may be causing this issue?
Best regards, Dobrev.

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi Dobrev,

Hi Dobrev,

I'm quite sure that the problem is with UART. We don't have TI MSP432E so it's not possible to make an example or test this at the moment.

BR,
Mikko

DDobrev21

4 years 8 months ago

Hello,

Hello,
I have been trying a different method and now I have a problem with reading the objects.
I am attaching logs:

========= SERVER LOG =========

RX: 7E A0 07 03 21 93 0F 01 7E svr_isTarget.
Connecting without authentication.
svr_connected to HDLC level.

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: 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 5D FF FF B3 E2 7E svr_validateAuthentication
findObject 15 0.0.40.0.0.255
svr_connected DLMS level.

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 00 18 02 00 00 07 3C B0 7E

RX: 7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 91 53 7E findObject 15 0.0.40.0.0.255
svr_getAttributeAccess
svr_preRead: 15 0.0.40.0.1.255
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_getAttributeAccess
svr_postRead: 15 0.0.40.0.1.255

TX 7E A8 86 21 03 52 7F 1B E6 E7 00 C4 02 C1 00 00 00 00 01 00 82 01 E2 01 16 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 12 63 7E

RX: 7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 91 53 7E
TX 7E A0 07 21 03 97 2B E1 7E

RX: 7E A0 07 03 21 53 03 C7 7E svr_disconnected

TX 7E A0 1E 21 03 73 C3 7A 81 80 00 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 D9 69 7E

======== END OF SERVER LOG =============

======== DIRECTOR LOG ================

13:58:08 Send SNRM request.
7E A0 07 03 21 93 0F 01 7E
13:58:09
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
13:58:09 Parsing UA reply succeeded.
13:58:09 Send AARQ request.
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 5D FF FF B3 E2 7E
13:58:11
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 00 18 02 00 00 07 3C B0 7E
13:58:11 Parsing AARE reply succeeded.
13:58:12 --- Collecting objects. ---
13:58:12 Collecting objects
7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 91 53 7E
Data send failed. Try to resend 1/3
13:58:21 Data send failed. Try to resend 1/3
7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 91 53 7E
13:58:23
7E A8 86 21 03 52 7F 1B E6 E7 00 C4 02 C1 00 00 00 00 01 00 82 01 E2 01 16 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 0D 16 01 00 02 03 0F 0B 16 01 00 01 06 02 02 0F 01 16 00 02 02 0F 02 12 63 7E 7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 0F 00 00 28 00 00 FF 02 00 91 53 7E 7E A0 07 21 03 97 2B E1 7E
System.Exception: GetObjects failed. Unacceptable frame.
at GXDLMSDirector.MainForm.RefreshDevice(GXDLMSMeter dev, Boolean bRefresh)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
13:58:26 Disconnect request
13:58:26 Disconnect request
7E A0 07 03 21 53 03 C7 7E
13:58:26
7E A0 1E 21 03 73 C3 7A 81 80 00 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 D9 69 7E
======== END OF DIRECTOR LOG ================
Do You have an idea what may be causing this? Thanks.

Best regards,
Dobrev

Profile picture for user Kurumi

Kurumi

4 years 8 months ago

Hi Dobrev,

Hi Dobrev,

The connection is established like expected. Then the client asks association view and the meter sends it, but the client is not receiving it before there is a timeout. Are you using flow control, etc. that might cause this?

BR,
Mikko

DDobrev21

4 years 8 months ago

Hi,

Hi,
Thanks for the fast reply. I am using freeRTOS functions UART_read() and UART_write(). For the read function I am filling a receive buffer and I am checking if there are 2 7E in the frame and if there are it means that the frame is full and then I call svr_handleRequest2() with that buffer and the count of the elements in it. If that can be called flow control or something like that, I don't know.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi Dobrev,

Hi Dobrev,

The reason for this was found. There is a new version available on GitHub.

BR,
Mikko

DDobrev21

4 years 7 months ago

Hi,

Hi,
You mean that there is a new version of the Gurux server on GitHub, right?
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi,

Hi,

Yes. Get the latest version from GitHub.

BR,
Mikko

DDobrev21

4 years 7 months ago

Okay thanks, have a nice day.

Okay thanks, have a nice day.
Best regards, Dobrev

DDobrev21

4 years 7 months ago

Hello,

Hello,

Have You ever tried to connect tcp client to the server and while reading it, connect a serial client and read both simultaneously. It should work the other way around as well. If You have, could You give some suggestions.

Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi,

Hi,

You need to create two instances from the server. One for the TCP/IP connection and one for the serial port connection. They can share the same OBIS codes. Then you need to allocate buffers for both connections.

Something like this:

//DLMS settings.
dlmsServerSettings serial1, tcp1;
svr_init(&serial1, 1, DLMS_INTERFACE_TYPE_HDLC, HDLC_BUFFER_SIZE, PDU_BUFFER_SIZE, frameBuff, sizeof(frameBuff), pduBuff, sizeof(pduBuff));

svr_init(&tcp1, 1, DLMS_INTERFACE_TYPE_WRAPPER, WRAPPER_BUFFER_SIZE, WRAPPER_BUFFER_SIZE, wrapperBuff, sizeof(wrapperBuff), wrapperPduBuff, sizeof(wrapperPduBuff));

BR,
Mikko

DDobrev21

4 years 7 months ago

Hello,

Hello,
Thanks for the reply, but where should I put this lines of code, I mean in which file. I suppose it should be the main.c, is that right. And also, where can I see the usage of that svr_init() function and how should I use that new serial1, for example should I change settings with serial1 anywhere in the code except here svr_handleRequest2(&settings, uartRxBuf, uartRxCount, &reply);
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi,

Hi,

Yes, it's main.c.

Call this from serial
svr_handleRequest2(&serial1, uartRxBuf, uartRxCount, &serialReply);

and this from TCP/IP:
svr_handleRequest2(&tcp1, tcpRxBuf, tcpRxCount, &tcpReply);

We can make an example at the beginning of December.

BR,
Mikko

DDobrev21

4 years 7 months ago

Hello,

Hello,
I tried initializing the buffers like you wrote but after that I have to write this line for the serial part:
settings = serial1;
in order to fill the fields of the dlmsServerSettings serial1. I tried doing the same for the tcp1 and started the program and nothing different happened(it cannot read requests and send replies to both serial and tcp simultaneously), so maybe I will wait for the example. Where are you going to uppload it. Thanks.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi,

Hi,

There is an example coming for NodeMCU and it's released on GitHub. It's supporting both serial and TCP/IP.

BR,
Mikko

DDobrev21

4 years 7 months ago

Hi,

Hi,
Okay, thanks. I have a question for the initialization of the buffers of tcp1. Where did this wrapperBuff came from, I mean should I create it and if yes, what size should it be. Can I use the same buffer as in the serial1 initialization? Thanks.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi,

Hi,

You can use the same buffer if you don't use tcp/ip and the serial at the same time. You need to create own buffer for both if you use them at the same time.

TCP/IP buffer size can be 1024 bytes.

BR,
Mikko

DDobrev21

4 years 7 months ago

Hi,

Hi,
Okay, thanks a lot. Should I do this in the main.c :

//init
svr_init(&settings, 1, DLMS_INTERFACE_TYPE_HDLC, HDLC_BUFFER_SIZE, PDU_BUFFER_SIZE, frameBuff, HDLC_HEADER_SIZE + HDLC_BUFFER_SIZE, pduBuff, PDU_BUFFER_SIZE);

svr_init(&serial1, 1, DLMS_INTERFACE_TYPE_HDLC, HDLC_BUFFER_SIZE, PDU_BUFFER_SIZE, frameBuff, sizeof(frameBuff), pduBuff, sizeof(pduBuff));

svr_init(&tcp1, 1, DLMS_INTERFACE_TYPE_WRAPPER, WRAPPER_BUFFER_SIZE, WRAPPER_BUFFER_SIZE, wrapperBuff, sizeof(wrapperBuff), wrapperPduBuff, sizeof(wrapperPduBuff));

//creating objects
if ((ret = createObjects()) != 0)
{
return ret;
}
serial1 = settings;
tcp1 = settings;

Especially the last two lines. I am doing this to create the objects for serial1 and tcp1. Thanks.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 7 months ago

Hi,

Hi,

Remove settings totally. Then in createObjects you need to add this:

OA_ATTACH(serial1.base.objects, ALL_OBJECTS);
OA_ATTACH(tcp1.base.objects, ALL_OBJECTS);

(ret = svr_initialize(&serial1)) != 0)
(ret = svr_initialize(&tcp1)) != 0)

BR,
Mikko

DDobrev21

4 years 7 months ago

Hello,

Hello,
Thanks, but what about the other functions that use settings directly? Should I change settings everywhere or I don't need them for that task.
**edit**
I removed settings and now I am working with serial1 and tcp1 only. Everything works properly when tested separately, but when I try to read simultaneously, the second device from the GuruxDirector says that the server failed to reply at a certain time, at least now it doesn't say that it has received an unacceptable frame.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 6 months ago

Hi Dobrev,

Hi Dobrev,

I believe that you are sharing PDU or frame buffer between serial and TCP. Check that first.

BR,
Mikko

DDobrev21

4 years 6 months ago

Hello,

Hello,
I think that I am using different buffers.
That is the initialization of tcp1 and serial1:

bb_attach(&reply, replyFrame, 0, sizeof(replyFrame));
bb_attach(&replyTcp, replyFrame, 0, sizeof(replyFrame));
//Start server using logical name referencing and HDLC framing.
svr_init(&serial1, 1, DLMS_INTERFACE_TYPE_HDLC, HDLC_BUFFER_SIZE, PDU_BUFFER_SIZE, serialBuff, HDLC_BUFFER_SIZE
+ HDLC_HEADER_SIZE, serialPduBuff, PDU_BUFFER_SIZE);
svr_init(&tcp1, 1, DLMS_INTERFACE_TYPE_HDLC, HDLC_BUFFER_SIZE, PDU_BUFFER_SIZE, frameBuff, HDLC_HEADER_SIZE +
HDLC_BUFFER_SIZE, pduBuff, PDU_BUFFER_SIZE);

//Allocate space for client challenge.
BB_ATTACH(serial1.base.ctoSChallenge, C2S_CHALLENGE, 0);
BB_ATTACH(tcp1.base.ctoSChallenge, C2S_CHALLENGE, 0);

//Allocate space for server challenge.
BB_ATTACH(serial1.base.stoCChallenge, S2C_CHALLENGE, 0);
BB_ATTACH(tcp1.base.stoCChallenge, S2C_CHALLENGE, 0);

BB_ATTACH(serial1.base.kek, KEK, sizeof(KEK));
BB_ATTACH(tcp1.base.kek, KEK, sizeof(KEK));

//Add COSEM objects.
if ((ret = createObjects(serial1)) != 0)
{
return ret;
}
if ((ret = createObjects(tcp1)) != 0)
{
return ret;
}

serial1.defaultClock = &clock1;
tcp1.defaultClock = &clock2;

That is the createObjects() function:

int createObjects(dlmsServerSettings* settings)
{
int ret;
OA_ATTACH(serial1.base.objects, ALL_OBJECTS);
OA_ATTACH(tcp1.base.objects, ALL_OBJECTS);

if ((ret = addLogicalDeviceName()) != 0 ||
(ret = addSapAssignment()) != 0 ||
(ret = addEventCode()) != 0 ||
(ret = addUnixTime()) != 0 ||
(ret = addInvocationCounter()) != 0 ||
(ret = addClockObject()) != 0 ||
(ret = addRegisterObject()) != 0 ||
(ret = addAssociationNone()) != 0 ||
(ret = addAssociationLow()) != 0 ||
(ret = addAssociationHigh()) != 0 ||
(ret = addAssociationHighGMac()) != 0 ||
(ret = addSecuritySetupHigh()) != 0 ||
(ret = addSecuritySetupHighGMac()) != 0 ||
(ret = addPushSetup()) != 0 ||
(ret = addscriptTableGlobalMeterReset()) != 0 ||
(ret = addscriptTableDisconnectControl()) != 0 ||
(ret = addscriptTableActivateTestMode()) != 0 ||
(ret = addscriptTableActivateNormalMode()) != 0 ||
(ret = addLoadProfileProfileGeneric()) != 0 ||
(ret = addEventLogProfileGeneric()) != 0 ||
(ret = addActionScheduleDisconnectOpen()) != 0 ||
(ret = addActionScheduleDisconnectClose()) != 0 ||
(ret = addDisconnectControl()) != 0 ||
(ret = addIecHdlcSetup()) != 0 ||
(ret = oa_verify(&serial1.base.objects)) != 0 ||
(ret = svr_initialize(&serial1)) != 0 ||
(ret = oa_verify(&tcp1.base.objects)) != 0 ||
(ret = svr_initialize(&tcp1)) != 0 )

{
GXTRACE_INT(("Failed to start the meter!"), ret);
executeTime = 0;
return ret;
}

if ((ret = loadSettings()) != 0)
{
GXTRACE_INT(("Failed to load settings!"), ret);
executeTime = 0;
return ret;
}
if ((ret = loadSecurity(settings)) != 0)
{
GXTRACE_INT(("Failed to load security settings!"), ret);
executeTime = 0;
return ret;
}
updateState(GURUX_EVENT_CODES_POWER_UP);
GXTRACE(("Meter started."), NULL);
return 0;
}

And these are my buffers:

#define HDLC_HEADER_SIZE 17
#define HDLC_BUFFER_SIZE 128
#define PDU_BUFFER_SIZE 512
#define WRAPPER_BUFFER_SIZE 8 + PDU_BUFFER_SIZE

static unsigned char serialBuff[HDLC_BUFFER_SIZE + HDLC_HEADER_SIZE];
static unsigned char serialPduBuff[PDU_BUFFER_SIZE];

static unsigned char replyFrame[HDLC_BUFFER_SIZE + HDLC_HEADER_SIZE];
static unsigned char pduBuff[PDU_BUFFER_SIZE];
static unsigned char frameBuff[HDLC_BUFFER_SIZE + HDLC_HEADER_SIZE];

I still cannot find where the problem is.
Best regards, Dobrev

DDobrev21

4 years 6 months ago

Hello,

Hello,
I am debugging my code and I noticed that I am using 'DLMS_INTERFACE_TYPE_HDLC' in the svr_init() for my tcp buffer instead of 'DLMS_INTERFACE_TYPE_WRAPPER'. When I change it, the tcp part is not working properly(there is no reply and when the client send the message for a reply not received, the server receives something that is wrong). This is the receive log of the server:
RX: 7E A0 07 03 21 93 0F 01 7E 7E A0 07 03 21 93 0F 01 7E 7E A0 07 03 21 93 0F 01 7E 7E A0 07 03 21 53 03 C7 7E 7E A0 07 03 21 53 03 C7 7E 7E A0 07 03 21 53 03 C7 7E

So my question is should I use this 'DLMS_INTERFACE_TYPE_WRAPPER, can it be the answer of my main problem(reading of the serial part cannot be at the same time with the reading of the tcp part). Thanks.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 6 months ago

Hi Dobrev,

Hi Dobrev,

You are using WRAPPER with TCP/IP, but message that you are sending is using HDLC. You need to change the interface from HDLC to WRAPPER.

Messages are using different frame structures and for that reason, the meter doesn't accept the received data. It will simply ignore it.

BR,
Mikko

DDobrev21

4 years 6 months ago

Hello,

Hello,
The tcp is working properly with the HDLC interface and not working with WRAPPER interface. What should I change - the message type or the interface type when initializing the tcp1 setting. Thanks.

Profile picture for user Kurumi

Kurumi

4 years 6 months ago

Hi,

Hi,

Your client must establish a connection with the WRAPPER. Change interface from HDLC to WRAPPER for the client side.

BR,
Mikko

DDobrev21

4 years 6 months ago

Hello,

Hello,
I tried this and it does not work, but my question is should I use this WRAPPER interface type or I can continue using the HDLC type for both tcp and serial connection. And also if I am using the same interfaces for both connections will I be able to make them work simultaneously.
Best regards, Dobrev

Profile picture for user Kurumi

Kurumi

4 years 6 months ago

Hi Dobrev,

Hi Dobrev,

You can use them simultaneously with all interface types if you have defined your own settings and buffers for both connections.

We can make an Arduino example next week that shows what needs to be done for
simultaneous serial and TC/IP connections.

BR,
Mikko
BR,
Mikko

DDobrev21

4 years 6 months ago

Ok, I have initialized the

Ok, I have initialized the settings and the buffers but it is still not working, so I will wait. Thanks.

DDobrev21

4 years 3 months ago

Hello,

Hello,

Could you send me a link to the example that can work with tcp and serial communication simultaneously. Thanks.

Best regards, Dobrev

  • 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