CAN Efus7UL ioctl(soc, SIOCGIFINDEX, &ifr) error

  • Hi all,


    I'm developing a CAN app under Qt Creator 3.3.2 with Efus7UL. I'm using the example provided in the buildroot "can.c" and I have an error when ioctl(soc, SIOCGIFINDEX, &ifr), in open_port() function, is executed. The error given by errno is 19.


    Is this error ENODEV 19 /* No such device */?


    What means and how can I solve this error? I am not sure if I am using the correct CAN driver...


    Thanks.


    Joaquim.

  • I think your CAN device is not availble. Have you brought it up first?
    With ifconfig (ifconfig -a if it is down) you can see your can devices.


    E.G. to bring can0 device up run: ip link set can0 up type can bitrate 125000
    After that you can run the can example.


    Best Regards
    Yout F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hi,


    Thank for the answer, but I have still the same problem.


    As I developing my own app under Qt, I have modified the example, specifically the "open port" function, that follows. Basically the function not receives the argv of the port, and it is configured in the function (in bold).



    The error in the command windows is the same as reported in Qt:


    Code
    1. # ./EVA_DEMO -qws
    2. CAN Port Can0
    3. error ioctl 19
    4. failed to initialize socket


    Thank you.
    Joaquim

  • Hi again,


    I have found the problem partially. The port name must be "can0" and not "Can0"...


    Now the ioctl error is 2. Is this error "Permission denied" ? I wrote first "ip link set can0 up type can bitrate 125000"


    Thanks.

  • Error 2 is "no such file or directory". You can find the error codes in the Linux source code in


    include/uapi/asm-generic/errno-base.h
    include/uapi/asm-generic/errno.h


    or on your host PC in


    /usr/include/asm-generic/errno-base.h
    /usr/include/asm-generic/errno.h


    So you have to find out what file is missing. A good idea is to start your program with strace, then all system calls are listed. This may be a rather long list because also the loading of the libraries at program start is shown, but near the end of the list you should find the cause of the problem.


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hi,


    Sorry, but I don't have experience with "strace" command. Can I execute this command in my C++ code? If yes, how? I have tried to execute it in the command window (after booting kernel) of the Efus via Serial connection as follow, but I get this error message:


    # strace ./myapp -qws
    -sh: strace: not found


    Thanks.

  • Hi,
    Is strace activated in your buildroot and available on your board?
    You can find out if your system knows strace with the 'which' command.
    If it is available it should look like this:


    # which strace
    /usr/bin/strace


    Best Regards
    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hmm, if strace is not available in your system, then you probably are working on an old release version. Is your kernel 3.14 or 4.1? If 3.14, then please update to fsimx6ul-V2.0. This may solve quite a lot of problems.


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • You can add strace easily to your rootfilesystem.


    (If you haven't ran a config before type 'make fsimx6ul_std_defconfig' first)


    Type 'make menuconfig' in your buildroot source folder strace is located here:
    'Target packages -> Debugging, profiling and benchmark –> strace'
    Then type 'make' to rebuild.


    On the system call strace as you have described above.


    Best Regards,
    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Dear Martinez,


    i modified your program, compiled it in c and it works. Do you get the same error message like before "failed to initialize socket"?


    In the attachment you get the c-file and the executable of the file. You can execute it and you see if the problem is caused from the IO connection or if it is a QT problem.


    Best Regards,
    Your F&S Support Team

    Files

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

    Edited once, last by fs-support_PJ ().