Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » Can Protocol(missing cansocket class in can project)
Can Protocol [message #1776429] Thu, 16 November 2017 12:00 Go to next message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
Hello

I am trying to make a can interface with kura. From the existed "org.eclipse.kura.protocol.can" project i came to know that cansocket class is missing .So i added cansocket class and then i have made a jar file and deployed in target.

When i diag the bundle with diag command it showing error like
Quote:

!ENTRY org.eclipse.equinox.ds 4 0 2017-11-16 11:52:16.893
!MESSAGE [SCR] Exception while activating instance org.eclipse.kura.protocol.can.CanConnectionServiceImpl@47a661 of component org.eclipse.kura
!STACK 0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:999)
at org.eclipse.equinox.console.commands.EquinoxCommandProvider.getResolutionReport(EquinoxCommandProvider.java:1933)
at org.eclipse.equinox.console.commands.EquinoxCommandProvider.diag(EquinoxCommandProvider.java:1922)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Console.run(Console.java:62)
at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.eclipse.equinox.console.telnet.TelnetConnection.run(TelnetConnection.java:94)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.kura.protocol.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:55)
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.activate(CanConnectionServiceImpl.java:34)
... 52 more
Root exception:
java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.kura.protocol.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:55)
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.activate(CanConnectionServiceImpl.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:915)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482)
at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:999)
at org.eclipse.equinox.console.commands.EquinoxCommandProvider.getResolutionReport(EquinoxCommandProvider.java:1933)
at org.eclipse.equinox.console.commands.EquinoxCommandProvider.diag(EquinoxCommandProvider.java:1922)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Console.run(Console.java:62)
at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.eclipse.equinox.console.telnet.TelnetConnection.run(TelnetConnection.java:94)




when i type ls command it showing unsatisfied
Quote:

81 Unsatisfied org.eclipse.kura.protocol.can.CanConnectionServiceImpl org.eclipse.kura.protocol.can(bid=140)


what may be the reason ?

Regards
khaleel
Re: Can Protocol [message #1776437 is a reply to message #1776429] Thu, 16 November 2017 12:50 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
in which condition you found out that cansocket class is missing? From the Eclipse IDE?

In gogo shell doing "comp 81", what is the result?

Best regards,
Matteo
Re: Can Protocol [message #1776506 is a reply to message #1776437] Fri, 17 November 2017 06:38 Go to previous messageGo to next message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
yes, from Eclipse IDE only i found that.
comp output is here
Quote:

Component[
name = org.eclipse.kura.protocol.can.CanConnectionServiceImpl
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = org.eclipse.kura.protocol.can.CanConnectionServiceImpl
state = Unsatisfied
properties = {service.pid=org.eclipse.kura.protocol.can.CanConnectionService}
serviceFactory = false
serviceInterface = [org.eclipse.kura.protocol.can.CanConnectionService]
references = null
located in bundle = org.eclipse.kura.protocol.can_2.0.200.201711171159 [138]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
objectClass = String[org.eclipse.kura.protocol.can.CanConnectionService]
service.pid = org.eclipse.kura.protocol.can.CanConnectionService
component.name = org.eclipse.kura.protocol.can.CanConnectionServiceImpl
component.id = 68
Instances:
No instances were created because: Can not activate instance of component org.eclipse.kura.protocol.can.CanConnectionServiceImpl. The actin


and below is the class i have created CanSocket
package org.eclipse.kura.protocol.can;

import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Objects;
import java.util.Set;

public final class CanSocket implements Closeable {

    static {
        final String LIB_JNI_SOCKETCAN = "jni_socketcan";
        try {
            System.loadLibrary(LIB_JNI_SOCKETCAN);
        } catch (final UnsatisfiedLinkError e) {
            try {
                loadLibFromJar(LIB_JNI_SOCKETCAN);
            } catch (final IOException _e) {
                throw new UnsatisfiedLinkError(LIB_JNI_SOCKETCAN);
            }
        }
    }

    private static void copyStream(final InputStream in, final OutputStream out) throws IOException {
        final int BYTE_BUFFER_SIZE = 0x1000;
        final byte[] buffer = new byte[BYTE_BUFFER_SIZE];
        for (int len; (len = in.read(buffer)) != -1;) {
            out.write(buffer, 0, len);
        }
    }

    private static void loadLibFromJar(final String libName) throws IOException {
        Objects.requireNonNull(libName);
        final String fileName = "/lib/lib" + libName + ".so";
        final FileAttribute<Set<PosixFilePermission>> permissions = PosixFilePermissions
                .asFileAttribute(PosixFilePermissions.fromString("rw-------"));
        final Path tempSo = Files.createTempFile(CanSocket.class.getName(), ".so", permissions);
        try {
            try (final InputStream libstream = CanSocket.class.getResourceAsStream(fileName)) {
                if (libstream == null) {
                    throw new FileNotFoundException("jar:*!" + fileName);
                }
                try (final OutputStream fout = Files.newOutputStream(tempSo, StandardOpenOption.WRITE,
                        StandardOpenOption.TRUNCATE_EXISTING)) {
                    copyStream(libstream, fout);
                }
            }
            System.load(tempSo.toString());
        } finally {
            Files.delete(tempSo);
        }
    }

    public static final CanInterface CAN_ALL_INTERFACES = new CanInterface(0);

    private static native int _getCANID_SFF(final int canid);

    private static native int _getCANID_EFF(final int canid);

    private static native int _getCANID_ERR(final int canid);

    private static native boolean _isSetEFFSFF(final int canid);

    private static native boolean _isSetRTR(final int canid);

    private static native boolean _isSetERR(final int canid);

    private static native int _setEFFSFF(final int canid);

    private static native int _setRTR(final int canid);

    private static native int _setERR(final int canid);

    private static native int _clearEFFSFF(final int canid);

    private static native int _clearRTR(final int canid);

    private static native int _clearERR(final int canid);

    private static native int _openSocketRAW() throws IOException;

    private static native int _openSocketBCM() throws IOException;

    private static native void _close(final int fd) throws IOException;

    private static native int _fetchInterfaceMtu(final int fd, final String ifName) throws IOException;

    private static native int _fetch_CAN_MTU();

    private static native int _fetch_CAN_FD_MTU();

    private static native int _discoverInterfaceIndex(final int fd, final String ifName) throws IOException;

    private static native String _discoverInterfaceName(final int fd, final int ifIndex) throws IOException;

    private static native void _bindToSocket(final int fd, final int ifId) throws IOException;

    private static native CanFrame _recvFrame(final int fd) throws IOException;

    private static native void _sendFrame(final int fd, final int canif, final int canid, final byte[] data)
            throws IOException;

    public static final int CAN_MTU = _fetch_CAN_MTU();
    public static final int CAN_FD_MTU = _fetch_CAN_FD_MTU();

    private static native int _fetch_CAN_RAW_FILTER();

    private static native int _fetch_CAN_RAW_ERR_FILTER();

    private static native int _fetch_CAN_RAW_LOOPBACK();

    private static native int _fetch_CAN_RAW_RECV_OWN_MSGS();

    private static native int _fetch_CAN_RAW_FD_FRAMES();

    private static final int CAN_RAW_FILTER = _fetch_CAN_RAW_FILTER();
    private static final int CAN_RAW_ERR_FILTER = _fetch_CAN_RAW_ERR_FILTER();
    private static final int CAN_RAW_LOOPBACK = _fetch_CAN_RAW_LOOPBACK();
    private static final int CAN_RAW_RECV_OWN_MSGS = _fetch_CAN_RAW_RECV_OWN_MSGS();
    private static final int CAN_RAW_FD_FRAMES = _fetch_CAN_RAW_FD_FRAMES();

    private static native void _setsockopt(final int fd, final int op, final int stat) throws IOException;

    private static native int _getsockopt(final int fd, final int op) throws IOException;

    public final static class CanId implements Cloneable {

        private int _canId = 0;

        public static enum StatusBits {
            ERR,
            EFFSFF,
            RTR
        }

        public CanId(final int address) {
            _canId = address;
        }

        public boolean isSetEFFSFF() {
            return _isSetEFFSFF(_canId);
        }

        public boolean isSetRTR() {
            return _isSetRTR(_canId);
        }

        public boolean isSetERR() {
            return _isSetERR(_canId);
        }

        public CanId setEFFSFF() {
            _canId = _setEFFSFF(_canId);
            return this;
        }

        public CanId setRTR() {
            _canId = _setRTR(_canId);
            return this;
        }

        public CanId setERR() {
            _canId = _setERR(_canId);
            return this;
        }

        public CanId clearEFFSFF() {
            _canId = _clearEFFSFF(_canId);
            return this;
        }

        public CanId clearRTR() {
            _canId = _clearRTR(_canId);
            return this;
        }

        public CanId clearERR() {
            _canId = _clearERR(_canId);
            return this;
        }

        public int getCanId_SFF() {
            return _getCANID_SFF(_canId);
        }

        public int getCanId_EFF() {
            return _getCANID_EFF(_canId);
        }

        public int getCanId_ERR() {
            return _getCANID_ERR(_canId);
        }

        @Override
        protected Object clone() {
            return new CanId(_canId);
        }

        private Set<StatusBits> _inferStatusBits() {
            final EnumSet<StatusBits> bits = EnumSet.noneOf(StatusBits.class);
            if (isSetERR()) {
                bits.add(StatusBits.ERR);
            }
            if (isSetEFFSFF()) {
                bits.add(StatusBits.EFFSFF);
            }
            if (isSetRTR()) {
                bits.add(StatusBits.RTR);
            }
            return Collections.unmodifiableSet(bits);
        }

        @Override
        public String toString() {
            return "CanId [canId=" + (isSetEFFSFF() ? getCanId_EFF() : getCanId_SFF()) + "flags=" + _inferStatusBits()
                    + "]";
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + _canId;
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            CanId other = (CanId) obj;
            if (_canId != other._canId)
                return false;
            return true;
        }
    }

    public final static class CanInterface implements Cloneable {

        private final int _ifIndex;
        private String _ifName;

        public CanInterface(final CanSocket socket, final String ifName) throws IOException {
            this._ifIndex = _discoverInterfaceIndex(socket._fd, ifName);
            this._ifName = ifName;
        }

        private CanInterface(int ifIndex, String ifName) {
            this._ifIndex = ifIndex;
            this._ifName = ifName;
        }

        private CanInterface(int ifIndex) {
            this(ifIndex, null);
        }

        public int getInterfaceIndex() {
            return _ifIndex;
        }

        @Override
        public String toString() {
            return "CanInterface [_ifIndex=" + _ifIndex + ", _ifName=" + _ifName + "]";
        }

        public String getIfName() {
            return _ifName;
        }

        public String resolveIfName(final CanSocket socket) {
            if (_ifName == null) {
                try {
                    _ifName = _discoverInterfaceName(socket._fd, _ifIndex);
                } catch (IOException e) {
                    /* EMPTY */ }
            }
            return _ifName;
        }

        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + _ifIndex;
            result = prime * result + ((_ifName == null) ? 0 : _ifName.hashCode());
            return result;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            CanInterface other = (CanInterface) obj;
            if (_ifIndex != other._ifIndex)
                return false;
            if (_ifName == null) {
                if (other._ifName != null)
                    return false;
            } else if (!_ifName.equals(other._ifName))
                return false;
            return true;
        }

        @Override
        protected Object clone() {
            return new CanInterface(_ifIndex, _ifName);
        }
    }

    public final static class CanFrame implements Cloneable {

        private final CanInterface canIf;
        private final CanId canId;
        private final byte[] data;

        public CanFrame(final CanInterface canIf, final CanId canId, byte[] data) {
            this.canIf = canIf;
            this.canId = canId;
            this.data = data;
        }

        /* this constructor is used in native code */
        @SuppressWarnings("unused")
        private CanFrame(int canIf, int canid, byte[] data) {
            if (data.length > 8) {
                throw new IllegalArgumentException();
            }
            this.canIf = new CanInterface(canIf);
            this.canId = new CanId(canid);
            this.data = data;
        }

        public CanId getCanId() {
            return canId;
        }

        public byte[] getData() {
            return data;
        }

        public CanInterface getCanInterfacae() {
            return canIf;
        }

        @Override
        public String toString() {
            return "CanFrame [canIf=" + canIf + ", canId=" + canId + ", data=" + Arrays.toString(data) + "]";
        }

        @Override
        protected Object clone() {
            return new CanFrame(canIf, (CanId) canId.clone(), Arrays.copyOf(data, data.length));
        }
    }

    public static enum Mode {
        RAW,
        BCM
    }

    private final int _fd;
    private final Mode _mode;
    private CanInterface _boundTo;

    public CanSocket(Mode mode) throws IOException {
        switch (mode) {
        case BCM:
            _fd = _openSocketBCM();
            break;
        case RAW:
            _fd = _openSocketRAW();
            break;
        default:
            throw new IllegalStateException("unkown mode " + mode);
        }
        this._mode = mode;
    }

    public void bind(CanInterface canInterface) throws IOException {
        _bindToSocket(_fd, canInterface._ifIndex);
        this._boundTo = canInterface;
    }

    public void send(CanFrame frame) throws IOException {
        _sendFrame(_fd, frame.canIf._ifIndex, frame.canId._canId, frame.data);
    }

    public CanFrame recv() throws IOException {
        return _recvFrame(_fd);
    }

    @Override
    public void close() throws IOException {
        _close(_fd);
    }

    public int getMtu(final String canif) throws IOException {
        return _fetchInterfaceMtu(_fd, canif);
    }

    public void setLoopbackMode(final boolean on) throws IOException {
        _setsockopt(_fd, CAN_RAW_LOOPBACK, on ? 1 : 0);
    }

    public boolean getLoopbackMode() throws IOException {
        return _getsockopt(_fd, CAN_RAW_LOOPBACK) == 1;
    }

    public void setRecvOwnMsgsMode(final boolean on) throws IOException {
        _setsockopt(_fd, CAN_RAW_RECV_OWN_MSGS, on ? 1 : 0);
    }

    public boolean getRecvOwnMsgsMode() throws IOException {
        return _getsockopt(_fd, CAN_RAW_RECV_OWN_MSGS) == 1;
    }

    public void setCanFilter(int canId, int canMask) {

    }

}


cansocket java file showing a '?' on it.


[Updated on: Fri, 17 November 2017 06:43]

Report message to a moderator

Re: Can Protocol [message #1776521 is a reply to message #1776506] Fri, 17 November 2017 09:21 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
CanSocket class is already implemented in the lib provided. You don't have to reimplement it.
Otherwise, to remove Eclipse errors you should modify the java build path to reference the jar in lib folder. This should remove the error and allow you to compile from Eclipse.
The problem does not exist if you are building with Maven.

I've tested in my environment and the default protocol.can bundle in develop seems to be fully working.

Best regards,
Matteo
Re: Can Protocol [message #1776535 is a reply to message #1776521] Fri, 17 November 2017 12:12 Go to previous messageGo to next message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
HI
first thank you very much for such fast reply. before asking i would like to give you the precedure i followed for eclipse kura.
1.) through eclipse installer i installed kura setup where i find multiple bundles(projects) in package explorer tab of eclipse.
2.) CanSocket class gives error because there is no lib folder in project "org.eclipse.kura.protocol.can" by default so cant find jar file.
3.) for resolve this i create a lib folder, downloaded jar file (libsocket-can-java-1.0.1.jar) and modify the java build path to reference the jar in lib folder and compiled successfully.
4.) i deploy the bundle in target.
5.) the error is could not initialize de.entropia.can.CanSocket.java....mentioned above.

and please sujjest the procedure to create and deploy bundle to target after building from maven ??
please help with a working CAN project if possible.
Re: Can Protocol [message #1776615 is a reply to message #1776535] Sat, 18 November 2017 14:53 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
You are right, the lib folder will be there after a successful maven build.
To have a proper setup, I would suggest you to use the Oomph setup that will clone all the needed resources and build for you the project using Maven under the hood.

Best regards,
Matteo

[Updated on: Sat, 18 November 2017 14:55]

Report message to a moderator

Re: Can Protocol [message #1776667 is a reply to message #1776615] Mon, 20 November 2017 07:51 Go to previous messageGo to next message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
i already followed the Oomph setup and clone all needed resource . Other projects are working fine except CAN(having error for class CanSocket) because lib is absent bydeafult.
i found somehing from Oomph Setup related can
The below quote is from this link https://eclipse.github.io/kura/dev/kura-setup.html#oomph-installer
Quote:

The result will be installed Eclipse IDE with all the recommended plug-ins already available, code will be checked out and built, workspace will be set up, a few Working Sets will be prepared with most projects building without errors

The next step is to get the rest of the projects to build, for which you might need to build them in the console with specific profiles available e.g. can.


what doest it mean and how to solve this??.



Re: Can Protocol [message #1776669 is a reply to message #1776667] Mon, 20 November 2017 08:18 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
I believe the easiest option for you is to try a maven build from the Kura project folder by running: mvn -f kura/pom.xml clean install -Pcan

After the build refresh your Kura workspace.

[Updated on: Mon, 20 November 2017 08:19]

Report message to a moderator

Re: Can Protocol [message #1776681 is a reply to message #1776669] Mon, 20 November 2017 10:46 Go to previous messageGo to next message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
Hi

I build kura projects with ur command and got lib folder in CAN project. To solve errors i modified the java build path to reference the jar in lib folder.
I deploy " org.eclipse.kura.protocol.can " and " org.eclipse.kura.example.can " bundles in target. protocol can seems to be ok where as example can showing unsatisfied.
ouput of diag
Quote:

java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket


Is any thing needs to be done with org.eclipse.kura.example.can

[Updated on: Mon, 20 November 2017 11:29]

Report message to a moderator

Re: Can Protocol [message #1776757 is a reply to message #1776681] Tue, 21 November 2017 09:11 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
do you have any error in Kura-console.log or kura.log?
Have you checked that the protocol.can jar effectively has the lib folder and the desired jar?

Best regards,
Matteo
Re: Can Protocol [message #1776859 is a reply to message #1776757] Wed, 22 November 2017 10:43 Go to previous messageGo to next message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
Hi
log of kura-console.log
Quote:

!ENTRY org.eclipse.equinox.ds 4 0 2017-11-22 10:37:18.127
!MESSAGE [SCR] Exception while activating instance org.eclipse.kura.example.can.CanSocketExample@159958c of component org.eclipse.kura.example.can.CanSocketExample
!STACK 0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
... 15 more
Root exception:
java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)

!ENTRY org.eclipse.equinox.ds 4 0 2017-11-22 10:37:18.174
!MESSAGE [SCR] Exception while activating instance org.eclipse.kura.example.can.CanSocketExample@159958c of component org.eclipse.kura.example.can.CanSocketExample
!STACK 0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
... 15 more
Root exception:
java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)

!ENTRY org.eclipse.equinox.ds 4 0 2017-11-22 10:37:20.199
!MESSAGE [SCR] Exception while activating instance org.eclipse.kura.example.can.CanSocketExample@165490a of component org.eclipse.kura.example.can.CanSocketExample
!STACK 0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:363)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:303)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:91)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
... 15 more
Root exception:
java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:363)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:303)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:91)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)

!ENTRY org.eclipse.equinox.ds 4 0 2017-11-22 10:37:20.248
!MESSAGE [SCR] Exception while activating instance org.eclipse.kura.example.can.CanSocketExample@165490a of component org.eclipse.kura.example.can.CanSocketExample
!STACK 0
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:363)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:303)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:91)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
... 15 more
Root exception:
java.lang.NoClassDefFoundError: Could not initialize class de.entropia.can.CanSocket
at org.eclipse.kura.protocol.can.CanConnectionServiceImpl.connectCanSocket(CanConnectionServiceImpl.java:59)
at org.eclipse.kura.example.can.CanSocketExample.activate(CanSocketExample.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:235)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:363)
at org.eclipse.equinox.internal.ds.SCRManager.processConfigurationEvent(SCRManager.java:303)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:91)
at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)


And i am sure that my protocol.can having lib folder and jar file in it
Re: Can Protocol [message #1776997 is a reply to message #1776859] Thu, 23 November 2017 13:49 Go to previous messageGo to next message
Matteo Maiero is currently offline Matteo MaieroFriend
Messages: 423
Registered: July 2015
Location: Italy
Senior Member
Hi,
are you using the protocol.can implementation bundle currently in develop?
I cannot find a correspondence between your stack trace and the actual develop code.

Best regards,
Matteo
Re: Can Protocol [message #1777744 is a reply to message #1776997] Mon, 04 December 2017 06:43 Go to previous message
khaleel shaik is currently offline khaleel shaikFriend
Messages: 19
Registered: November 2017
Junior Member
Hi

Now im able to communicate my can device with kura.
i downloaded libsocket library and compiled with respect to my target device. Replaced the " libjni_socketcan.so" file in lib folder of org.eclipse.kura.protocol.can then it is working
May be .so file is not compatible with my target.
Thanks for your support
Previous Topic:Create new Asset
Next Topic:Raspberry pi B, kura, mqtt
Goto Forum:
  


Current Time: Fri Apr 19 22:34:14 GMT 2024

Powered by FUDForum. Page generated in 0.04650 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top