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. Selection of Serial Port Baudrate

Selection of serial port baudrate

Profile picture for user DrClaudio
By DrClaudio , 25 August, 2023
Project
gurux.dlms.cpp
Status
Closed (fixed)

Dear Mikko,

I do not know if it is correct to report in this modality 'issues' relevant to example code. Nevertheless, with the sake of contributing, let me please share with you that I experienced an issue when using the '-S' command line option for the Client example (GuruxDLMSClientExample).

The '-S' option, as far as I have understood, is meant to allow the selection of serial port communication parameters, including the baudrate, with this syntax:

-S [COM1:9600:8None1]

However, the baurate isn't actually affected by the specified command line parameter (e.g.: -S [COM1:38400:8None1]) will default to 9600 baud.

I used this command line (so you can check if I made any mistake preventing to proper use of ‘-S’ command line option):

./bin/gurux.dlms.client.bin -c 16 -s 1 -S "/dev/ttyS0:57600:8None1" -r ln -i HDLC -T "4775727578313233" -A D0A1A2A3A4A5A6A7A8A9AAABACADAEAF -B 300102030405060708090A0B0C0D0E0F -V "Suite0" -f 2000 -w 1 -P "Claudio" -a "None" -C "None"

To this extent, I made these small modifications in file [communication.cpp]:

- in line 443 change:

unsigned short baudRate;

to

unsigned int baudRate;

- in line 611 change

cfsetospeed(&options, B9600);
cfsetispeed(&options, B9600);

to

speed_t baudRate_speed=getTermiosSpeed(baudRate,1);
cfsetospeed(&options, baudRate_speed);
cfsetispeed(&options, baudRate_speed);

- adding a the getTermiosSpeed() function as per this code:

https://github.com/stephane/libmodbus/blob/b25629bfb508bdce7d519884c0fa….

Thank you
Best regards,
Claudio

Priority
Minor
Category
Bug report
Profile picture for user Kurumi

Kurumi

2 years 11 months ago

Hi Claudio, Thank you for…

Hi Claudio,
Thank you for pointing this out. This is now fixed and a new client example is in GitHub.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
  • DLMS server - serving multiple similar datasets gathered from multiple meters across distinct logical addresses
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin