Giter Site home page Giter Site logo

timeout about libsml HOT 6 CLOSED

ckohrt avatar ckohrt commented on September 24, 2024
timeout

from libsml.

Comments (6)

andig avatar andig commented on September 24, 2024

/cc @r00t-

from libsml.

r00t- avatar r00t- commented on September 24, 2024

@ckohrt:
i'm not sure if this within the scope of libsml...

sml_server is a simple program intended to demonstrate the use of the library (it lives in an "examples" directory).
sml_server uses some simple i/o utility functions that libsml provides in sml_trasport.[ch],
which use blocking i/o and do not support timeouts.
i'd say, you are very welcome to write your own program using libsml that implements more advanced semantics.
by replacing sml_transport_listen() and sml_transport_read() with your own code, and passing the data to sml_transport_receiver().
we might want to offer a more flexible variant of sml_transport_read() that can be used with non-blocking io, or otherwise provide the scanning for start sequence and reading of a datagram in a more generic interface.
but as stated above, now sure if this is within scope,
it would also mean an ABI change.

why are you not using vzlogger?
it can read multiple meters in a single process and forward the data to your processing of choice.

as an alternative, if you insist on scripting around sml_server, have you considered simply wrapping sml_server in https://www.gnu.org/software/coreutils/timeout ?

from libsml.

ckohrt avatar ckohrt commented on September 24, 2024

hi @r00t-!
Thank you very much. I ended up with:

Z_1_182=$(timeout --foreground 10 /usr/bin/sml_server /dev/zaehler_1 | head -n10 | grep -oP '1\.8\.2\*255#\K.*(?=#)')

which works. Of course vzlogger is a better alternative, but I didn't want to get vzlogger running on my raspberry as I already have a working solution. It's just the time invest.... and with the timeout solution it works nearly without any time invest!

Big thanks!
Christian

from libsml.

r00t- avatar r00t- commented on September 24, 2024

@ckohrt:
--foreground should not be necessary.

from libsml.

ckohrt avatar ckohrt commented on September 24, 2024

@ckohrt: --foreground should not be necessary.

Thanks!

from libsml.

ckohrt avatar ckohrt commented on September 24, 2024

Solution:
Z_1_182=$(timeout 10 /usr/bin/sml_server /dev/zaehler_1 | head -n10 | grep -oP '1\.8\.2\*255#\K.*(?=#)')

from libsml.

Related Issues (20)

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.