in4lio / ev3dev-c

LEGO MINDSTORMS EV3 Debian C library + Python, Ruby and Perl wrappers
MIT License
71 stars 30 forks source link

Files in /sys don't match source code. #29

Closed gantzm closed 4 years ago

gantzm commented 5 years ago

I've installed the ev3dev distribution onto the EV3 device and everything boots fine.

I've cloned and built the ev3dev-c library with no problem. But it appears I've either done something incredibly wrong or misunderstood what is compatible with what.

The file ev3_led.c refers to the following files:

static const char *const led_attr_brightness[] = {
    "/sys/class/leds/ev3:left:green:ev3dev/brightness",
    "/sys/class/leds/ev3:right:green:ev3dev/brightness",
    "/sys/class/leds/ev3:left:red:ev3dev/brightness",
    "/sys/class/leds/ev3:right:red:ev3dev/brightness",
    "/sys/class/leds/outA::ev3dev/brightness",
    "/sys/class/leds/outB::ev3dev/brightness",
    "/sys/class/leds/outC::ev3dev/brightness",
    "/sys/class/leds/outD::ev3dev/brightness",

};

But when I look in /sys/class/leds I find the following:

lrwxrwxrwx 1 root root 0 Sep 14 12:35 ath9k_htc-phy0 -> ../../devices/platform/soc@1c00000/ohci-da8xx/usb1/1-1/1-1:1.0/leds/ath9k_htc-phy0
lrwxrwxrwx 1 root root 0 Sep 14 12:35 led0:green:brick-status -> ../../devices/platform/soc@1c00000/ti-pruss/1c32000.pru1/remoteproc/remoteproc0/virtio0/virtio0.ev3-tacho-rpmsg.-1.0/leds/led0:green:brick-status
lrwxrwxrwx 1 root root 0 Sep 14 12:35 led0:red:brick-status -> ../../devices/platform/soc@1c00000/ti-pruss/1c32000.pru1/remoteproc/remoteproc0/virtio0/virtio0.ev3-tacho-rpmsg.-1.0/leds/led0:red:brick-status
lrwxrwxrwx 1 root root 0 Sep 14 12:35 led1:green:brick-status -> ../../devices/platform/soc@1c00000/ti-pruss/1c32000.pru1/remoteproc/remoteproc0/virtio0/virtio0.ev3-tacho-rpmsg.-1.0/leds/led1:green:brick-status
lrwxrwxrwx 1 root root 0 Sep 14 12:35 led1:red:brick-status -> ../../devices/platform/soc@1c00000/ti-pruss/1c32000.pru1/remoteproc/remoteproc0/virtio0/virtio0.ev3-tacho-rpmsg.-1.0/leds/led1:red:brick-status

Did I skip an important step somewhere that normalises the file names or something? Or am I using mixed versions of things that aren't compatible?

gantzm commented 5 years ago

Aha! I did not realise there was a stretch branch! I'm building the branch now to see if it resolves my issues.

gantzm commented 5 years ago

No joy, the stretch branch file paths still don't match my device paths. I would be more than willing to submit pull requests to fix this but I'm not sure which piece is in error: the code or my device.

WasabiFan commented 5 years ago

One option is to check driver changelogs, docs, and issue history, but the easier way to figure out the right stuff would be to look at what they Python library does: https://github.com/ev3dev/ev3dev-lang-python

tcwan commented 5 years ago

Are you running ev3dev stretch? The /sys/class/led output you provided matches that for stretch.

Please check the ev3_led-dict.yu file in the ev3dev-c/source/ev3/ folder. The version for stretch should show this:

($dict LED
    (` LED_NAME                  LED_ID           )
    (`
    (  "led0:green:brick-status" EV3_LEFT_GREEN   )
    (  "led1:green:brick-status" EV3_RIGHT_GREEN  )
    (  "led0:red:brick-status"   EV3_LEFT_RED     )
    (  "led1:red:brick-status"   EV3_RIGHT_RED    )
    (  "outA::ev3dev"            LED_OUTA         )
    (  "outB::ev3dev"            LED_OUTB         )
    (  "outC::ev3dev"            LED_OUTC         )
    (  "outD::ev3dev"            LED_OUTD         )
    )
)

If it is identical, it means you need to rebuild the ev3dev-c source files using the yupp preprocessor. By right the files that you checkout from the stretch branch should already be up to date. In addition, when you rebuild the ev3dev-c libraries, it should automatically trigger a preprocessor step to update the .h and .c files from the *.yu files. SKIP_PP in source/ev3/makefile should evaluate to 0.

I suspect that you didn't checkout the stretch branch of ev3dev-c?

Use git branch to show the active branch:

$ git branch
  master
  pr/11
  pr/9
* stretch

(You can ignore anything other than master, jessie and stretch)

gantzm commented 5 years ago

I suspect that you didn't checkout the stretch branch of ev3dev-c?

OK, I think I know what I did. I built the stretch branch and the paths were wrong. After a bit of research I think I realized I needed to rebuild the .h .c files. But, at that point I had switched back to master. I will switch back to the stretch branch and enable the rebuilding of .h and .c files.

gantzm commented 5 years ago

Finally got back to this. I have the stretch branch checked out, but the file ev3_led-dict.yu does not contain the following:

($dict LED
    (` LED_NAME                  LED_ID           )
    (`
    (  "led0:green:brick-status" EV3_LEFT_GREEN   )
    (  "led1:green:brick-status" EV3_RIGHT_GREEN  )
    (  "led0:red:brick-status"   EV3_LEFT_RED     )
    (  "led1:red:brick-status"   EV3_RIGHT_RED    )
    (  "outA::ev3dev"            LED_OUTA         )
    (  "outB::ev3dev"            LED_OUTB         )
    (  "outC::ev3dev"            LED_OUTC         )
    (  "outD::ev3dev"            LED_OUTD         )
    )
)

instead it contains

($dict LED
        (` LED_NAME                  LED_ID           )
        (`
        (  "ev3:left:green:ev3dev"   EV3_LEFT_GREEN   )
        (  "ev3:right:green:ev3dev"  EV3_RIGHT_GREEN  )
        (  "ev3:left:red:ev3dev"     EV3_LEFT_RED     )
        (  "ev3:right:red:ev3dev"    EV3_RIGHT_RED    )
        (  "outA::ev3dev"            LED_OUTA         )
        (  "outB::ev3dev"            LED_OUTB         )
        (  "outC::ev3dev"            LED_OUTC         )
        (  "outD::ev3dev"            LED_OUTD         )
        )
)
tcwan commented 5 years ago

Finally got back to this. I have the stretch branch checked out, but the file ev3_led-dict.yu does not contain the following:

Sorry, I just verified the logs for the file, including the ev3_led.* files. You are correct. Somehow that was missed in this repository. I've fixed it in my fork, and I thought it was picked up by in4lio already.

You can check out my fork of the project, I've synced up with the main repository.

https://github.com/tcwan/ev3dev-c/tree/stretch

tcwan commented 5 years ago

See Issue #31