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

3 years 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

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Security vulnerability report — request for a private contact (GuruxDLMS.c / ANSI C)
  • Topic: Insufficient Memory Error When Reading Class 7 Profile Generic Objects
  • SN ReadResponse returns all-null values when response spans multiple HDLC frames
  • Gurux.Serial.Android 3.0.6 – CH340 (HL-340) USB-Serial Adapter Not Working,
  • Trying to talk to a L&G E360 meter (Using Python Gurux)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin