#56 Implementation of DLMS protocol via PySerial

v1.0 (example)
closed
nobody
None
5
2013-10-11
2012-07-19
Anonymous
No

Hi, I have a question to all who can help….
The context of the question:
I am developing an application module in Python that is based on pySerial. The application purpose is to connect, read and write data from an electrical meter (the meter is using DLMS protocol) that is connected to my computer (my computer runs on Win7 Ultimate x64) via a USB connection.
My application module is basically trying to emulate an existing commercial application called CosemClient that implements the DLMS protocol.
Attached to this post is data obtained by sniffing the COM port data flow between the CosemClient and meter, My Application and meter.
The problem:
I sniffed the communication between a working client and the meter, and I am trying to send exactly the same data, to replicate the functionality.
While attempting to implement the Hand Shake connection between my application and the meter, first 3 out of 4 steps of this protocol are performed successfully, but at step 4, the meter will not return the last ACK that signifies a successful connection.
The question:
By studying the sniffed data in both cases I have confirmed that the bytes I send are the same as the bytes sent by the working application. The only differences I noticed are:
- FlowReplace=(???),
- XonLimit=???,
- XoffLimit=???.

Given that I’ve double-checked everything else, my current assumption is that the culprit is in these settings. To verify that, I need a way to specifically set up these parameters for the COM port I open in my application.

So:
1. How can I explicitly specify the values for those parameters?
2. Is there any other suggestion to what may be the problem that leads to such behavior? Common sense dictates that if you simply send the same bytes – it should work, but apparently I am missing something.
THX to all willing to help!

Discussion


  • Anonymous
    2012-07-19

     
    Last edit: Anonymous 2013-11-26
    Attachments
  • Chris Liechti
    Chris Liechti
    2012-08-16

    • status: open --> pending
     
  • Chris Liechti
    Chris Liechti
    2012-08-16

    > 1. How can I explicitly specify the values for those parameters?

    there is no API in pySerial to change these. you can make your own calls to the operating system (see serialwin32.py, e.g. with hComPort you get the handle for your own calls). Note that such code would be platform specific. However, I doubt that these parameters are the reason for the failure.

    > 2. Is there any other suggestion to what may be the problem that leads to such behavior? Common sense dictates that if you simply send the same bytes – it should work, but apparently I am missing something.

    Timing may also be an issue. Maybe you send the next command too fast and the device is not yet ready. It may or may not use flow control. XON/XOFF you would see in the sniffed data but hardware flow control not.

     
  • Hi,

    I do not know have you notest that there is a very popular Open Source project for DLMS, Gurux DLMS/COSEM component. It is made with C#, but several peoples are using it from Python. You can get more info: www.gurux.org

    BR,

    Mikko

     
  • Chris Liechti
    Chris Liechti
    2013-10-11

    • status: pending --> closed
    • Group: --> v1.0 (example)