• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    DI Counter on Web, but not in /sys

    Official EVOK API
    2
    7
    1301
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      knebb last edited by knebb

      Hi again,

      I am using DI 2.01 on an Neuron M103.

      I connected (thanks to support here!) a device which sends impulses.

      When I browse to the Evok Web-Page, go to "configuration" and select 2.01 I can see the counter going upwards. So it counts perfectly. Being at 78, a second later it states 79. Nice!

      Now I want to get this value by some scripting software and tried to access the counter value through the sysfs. I am in /sys/devices/platform/unipi_plc/io_group2/di_2_01 and see the following files:

      insgesamt 0
      -rw-rw---- 1 root root 4096 Mai 10 12:32 counter
      -rw-rw---- 1 root root 4096 Mai 10 12:32 debounce
      -rw-rw---- 1 root root 4096 Mai 10 12:32 direct_switch_enable
      -rw-rw---- 1 root root 4096 Mai 10 12:32 direct_switch_polarity
      -rw-rw---- 1 root root 4096 Mai 10 12:32 direct_switch_toggle
      -r--r----- 1 root root 4096 Mai 10 12:32 di_value
      lrwxrwxrwx 1 root root    0 Mai 10 12:32 driver -> ../../../../../bus/spi/drivers/NEURONSPI
      -rw-r--r-- 1 root root 4096 Mai 10 12:32 driver_override
      drwxr-xr-x 3 root root    0 Mai 10 12:32 gpio
      drwxrwx--- 3 root gpio    0 Mai  7 08:18 gpiochip3
      -r--r--r-- 1 root root 4096 Mai 10 12:32 modalias
      drwxr-xr-x 2 root root    0 Mai 10 12:32 power
      lrwxrwxrwx 1 root root    0 Mai 10 12:32 subsystem -> ../../../../../bus/platform
      -r--r----- 1 root root 4096 Mai 10 12:32 sys_gpio_di_base
      -r--r----- 1 root root 4096 Mai 10 12:32 sys_gpio_di_count
      -r--r----- 1 root root 4096 Mai 10 12:32 sys_gpio_di_prefix
      -rw-r--r-- 1 root root 4096 Mai 10 12:32 uevent
      

      So it looks pretty nice. there is a file called "counter"- unfortunately it is still on 0. And no other file here has a content which equals to the counter the EVOK Web frontend displays.
      So where do I get the counter from the sysfs? Oh, and additionally- what is the maximum value of the counter?

      Thanks again!

      K 1 Reply Last reply Reply Quote 0
      • K
        knebb @knebb last edited by

        Me again.

        MEanwhile I figured out (thanks to sysfs-docs from here I can even write to the file named "counter" with echo "9" > counter.

        Well, when I do so the value on the web front end changes to something like 655359 and continues counting. While the file I wrote to stays on the "9".

        Anyone having a clue how these two matches?

        1 Reply Last reply Reply Quote 0
        • T
          TomasKnot last edited by TomasKnot

          This looks like a mistake in the sysfs, I'll try to get it fixed shortly. For background - the counters are stored as 2 16-bit values, which is where the behaviour you see probably comes from - you are reading and writing only to the top part of the counter value.

          If you could post the output from "uname -a" I could send you a test library binary, it's only a couple dozen kilobytes in size.

          Otherwise it may take a while before it is updated everywhere.

          1 Reply Last reply Reply Quote 0
          • K
            knebb last edited by

            Here you are:

            uname -a
            Linux zentrale 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU/Linux
            
            1 Reply Last reply Reply Quote 0
            • T
              TomasKnot last edited by TomasKnot

              It should now be fixed in the kernel module git repository, I will send you the binary via a private message.

              K 1 Reply Last reply Reply Quote 0
              • K
                knebb @TomasKnot last edited by

                @TomasKnot
                Thanks. If you let me know what file it is I can get it through git (I am not a coder but I know at least how to download through git) and copy it to the proper destination folder on my device.

                1 Reply Last reply Reply Quote 0
                • T
                  TomasKnot last edited by TomasKnot

                  I'd rather send it directly, it's only in source code on git and compiling it is not trivial.

                  You should have the link in your messages now.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post