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. Connecting To Dual Clients. Optical & NIC

connecting to dual clients. optical & NIC

Profile picture for user batulzii
By batulzii , 16 February, 2024
Forums
Gurux.DLMS

Hello,
Is Gurux stack can manage connection to more than one clients at the same time? for example, meter has optical port and NIC mesh. both are could connected at the same time. Server has singular clientSAP. Do you have sample code?
Thanks and Best Regards!

Profile picture for user Kurumi

Kurumi

2 years 3 months ago

Hi, It's possible to handle…

Hi,

It's possible to handle multiple clients at the same time. You need to create your own instance from the server intence for each interface, e.g. one for optical and one for NIC.

Server instances can share the same COSEM objects. This needs to be done because connections might use different communication interfaces, e.g. HDLC and WRAPPER.

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 3 months ago

Hello, Thanks for kind…

Hello,
Thanks for kind support! Do you have sample ANSI server with several servers? Can you show short snippets, if do not have yet
BR,

Profile picture for user Kurumi

Kurumi

2 years 3 months ago

Hi, You need to allocate own…

Hi,

You need to allocate own memory for both servers. Something like this:

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

//DLMS WRAPPER settings.
dlmsServerSettings srapperSettings;
svr_init(&srapperSettings, 1, DLMS_INTERFACE_TYPE_WRAPPER, WRAPPER_BUFFER_SIZE, PDU_BUFFER_SIZE, wrapperBuff, sizeof(wrapperBuff), wrapperPduBuff, sizeof(wrapperPduBuff));

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 3 months ago

Hello, settings used in…

Hello,
settings used in server codes like " if ((ret = cosem_getValue(&uartSettings.base, &e)) != 0)" in lot of places. i have 2 different intiated server settings.
please, advice
BR,

Profile picture for user Kurumi

Kurumi

2 years 3 months ago

Hi, You need to handle both…

Hi,

You need to handle both separately if you are using a different PDU size or all data can't fit into the one PDU.

Make sure that you don't make any changes to the server.c file. All the changes are made for the main.c file.

BR,
Mikko

Profile picture for user batulzii

batulzii

2 years 3 months ago

Hello, Can add new Uart…

Hello,
Can add new Uart instance for NIC instead of server? Because NIC interface is uart too. Like bellow snippets?
while (true)
{

// Serial port connection.
if (uartBufferPosition != 0)
{
uart_irq_rx_disable(uart_dev);
if (svr_handleRequest2(&uartSettings, UART_BUFFER, uartBufferPosition, &uartReply) != 0)
{
bb_clear(&uartReply);
}
uartBufferPosition = 0;
uart_irq_rx_enable(uart_dev);
if (uartReply.size != 0)
{
// Send reply.
for (size_t i = 0; i < uartReply.size; i++)
{
uart_poll_out(uart_dev, uartReply.data[i]);
}
bb_clear(&uartReply);
}
}
// Serial port connection.
if (nicBufferPosition != 0)
{
uart_irq_rx_disable(uart_dev_nic);
if (svr_handleRequest2(&nicSettings, UART_BUFFER, nicBufferPosition, &nicReply) != 0)
{
bb_clear(&nicReply);
}
nicBufferPosition = 0;
uart_irq_rx_enable(uart_dev_nic);
if (nicReply.size != 0)
{
// Send reply.
for (size_t i = 0; i < nicReply.size; i++)
{
uart_poll_out(uart_dev_nic, nicReply.data[i]);
}
bb_clear(&nicReply);
}
}
k_msleep(100); // Adjust sleep duration as needed
}

Profile picture for user Kurumi

Kurumi

2 years 3 months ago

Hi, You can add as many…

Hi,

You can add as many instances as you need if you have enough memory. You may have your own meter for each UART.

Just make own instance from settings like this:

dlmsServerSettings uart1Settings;
dlmsServerSettings uart2Settings;

while (true)
{
//Read data from UART1 and add it to the UART1 buffer.
if (svr_handleRequest2(&uart1Settings, UART1_BUFFER, uart1BufferPosition, &uart1Reply) != 0)
{
bb_clear(&uartReply);
}
...
//Read data from UART2 and add it to the UART2 buffer.
if (svr_handleRequest2(&uart2Settings, UART2_BUFFER, uart2BufferPosition, &uart2Reply) != 0)
{
bb_clear(&uartReply);
}
}

It's mandatory that you have your own buffer for both UARTs.

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
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin