GithubHelp home page GithubHelp logo

Comments (6)

m-unkel avatar m-unkel commented on September 26, 2024

Hey,
first of all the transmission should be fast enough to wait for the response, but technically it would be possible to add an argument for a non-blocking transmission.
How many commands do you want to send per second?
Maybe there is an undesired locking problem.
Does the problem occur only by sending the same point multiple times or also by sending different points at the same time?

Your code does not show how send_point(...) is called.
But your thread calls transmit in a loop without any sleep.. you are bombing your RTU with command messages, which is not an to be expected behavior unless you want to attack a system. Is that the case?

By the way.. the callbacks you define (cl_pt_on_receive_point, cl_on_new_station cl_on_new_point) reproduce exactly the default behavior in case the callback is not set, so you could remove them unless you want to add additional logic.

from iec104-python.

jeremykalvar avatar jeremykalvar commented on September 26, 2024

Hi,
Thanks for the reply!
No my goal is not to attack a system haha... Yet !
Ideally, I would like to be able to send 1 command every second.
Right now I am working on a single point, so yes, the problem seems to occur only by sending the same point multiple times.

I am using it in a fastApi router:

@router.post("/send-iec-point")
    async def send_iec_point(, ioa: int, filename: str):
        value = self.csv_handler.read_next_line_from_csv(filename, ioa)
        iec_master_client.send_point(ioa=ioa, value=float(value))
        return value

If the endpoint is called more than once every 3 seconds, my app breaks.
I may be missing something...

from iec104-python.

divinity666 avatar divinity666 commented on September 26, 2024

I was also playing with this beautiful library and ended up at a similar point:

I am also receiving False as a response to transmit, though I implemented the on_receive callback and always return c104.ResponseState.SUCCESS.

The transmit call always runs into the command_timeout in this case - no idea why.

Sounds pretty much, like the same issue.

from iec104-python.

divinity666 avatar divinity666 commented on September 26, 2024

Ok, I found the root cause for me:

I was calling transmit(cause=c104.Cot.SPONTANEOUS). If I change the call to transmit(cause=c104.Cot.ACTIVATION) it works as expected.

Nevermind.

from iec104-python.

m-unkel avatar m-unkel commented on September 26, 2024

I am also receiving False as a response to transmit, though I implemented the on_receive callback and always return c104.ResponseState.SUCCESS.

This is the default behavior, you do not have to implement the callback to always simply return c104.ResponseState.SUCCESS.

Ok, I found the root cause for me:

I was calling transmit(cause=c104.Cot.SPONTANEOUS). If I change the call to transmit(cause=c104.Cot.ACTIVATION) it works as expected.

Nevermind.

Yes SPONTANEOUS should be used in monitoring direction only and ACTIVATION is the right choice here AFAIK.

from iec104-python.

m-unkel avatar m-unkel commented on September 26, 2024

@jeremykalvar could you please generate some logging information? A command+confirmation should consume milliseconds not seconds..

c104.set_debug_mode(mode=c104.Debug.Client|c104.Debug.Connection)


def con_receive_raw(connection: c104.Connection, data: bytes) -> None:
    print("RECV] {1} [{0}] | CONN OA {2}".format(data.hex(), c104.explain_bytes_dict(apdu=data), connection.originator_address))


def con_send_raw(connection: c104.Connection, data: bytes) -> None:
    print("SEND] <--| {1} [{0}] | CONN OA {2}".format(data.hex(), c104.explain_bytes_dict(apdu=data), connection.originator_address))

class IECClient:
    def __init__(...):
        # [...] 
        # append the following to your __init__
        self.connection.on_receive_raw(callable=con_receive_raw)
        self.connection.on_send_raw(callable=con_send_raw)

from iec104-python.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.