All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Very strange error with rtcanconfig.
@ 2017-04-13 12:26 Ashwin Narayan
  2017-04-15 18:24 ` Ashwin Narayan
  0 siblings, 1 reply; 2+ messages in thread
From: Ashwin Narayan @ 2017-04-13 12:26 UTC (permalink / raw)
  To: xenomai

Hey all,

I've been working with the PCM-3680I - a can bus module. I'm trying to
set up a simple C program that can send and receive can bus messages
but I'm getting a very strange error.

In my code, when I call socket(), I always get -1 in response.

If I call

sudo LD_LIBRARY_PATH=/usr/xenomai/lib /usr/xenomai/sbin/rtcanconfig
rtcan0 -b 1000000 -v start

I get the expected response:
mode: start (0x1)
baudrate: 1000000

Then I copied and pasted the rtcanconfig.c example from the
documentation and compiled it and it gave me the error about sockets
again

sudo LD_LIBRARY_PATH=/usr/xenomai/lib ./rtcanconfig rtcan0 -b 1000000 -v start
mode: start (0x1)
Cannot open RTDM CAN socket. Maybe driver not loaded?

I'm sure that the driver is loaded and the precompiled rtcanconfig
seems to be working.

Any idea what's going on here?

Thanks,
-Ashwin


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Xenomai] Very strange error with rtcanconfig.
  2017-04-13 12:26 [Xenomai] Very strange error with rtcanconfig Ashwin Narayan
@ 2017-04-15 18:24 ` Ashwin Narayan
  0 siblings, 0 replies; 2+ messages in thread
From: Ashwin Narayan @ 2017-04-15 18:24 UTC (permalink / raw)
  To: xenomai

On Thu, Apr 13, 2017 at 8:26 PM, Ashwin Narayan
<ashwinnarayan1994@gmail.com> wrote:
> Hey all,
>
> I've been working with the PCM-3680I - a can bus module. I'm trying to
> set up a simple C program that can send and receive can bus messages
> but I'm getting a very strange error.
>
> In my code, when I call socket(), I always get -1 in response.
>
> If I call
>
> sudo LD_LIBRARY_PATH=/usr/xenomai/lib /usr/xenomai/sbin/rtcanconfig
> rtcan0 -b 1000000 -v start
>
> I get the expected response:
> mode: start (0x1)
> baudrate: 1000000
>
> Then I copied and pasted the rtcanconfig.c example from the
> documentation and compiled it and it gave me the error about sockets
> again
>
> sudo LD_LIBRARY_PATH=/usr/xenomai/lib ./rtcanconfig rtcan0 -b 1000000 -v start
> mode: start (0x1)
> Cannot open RTDM CAN socket. Maybe driver not loaded?
>
> I'm sure that the driver is loaded and the precompiled rtcanconfig
> seems to be working.
>
> Any idea what's going on here?
>
> Thanks,
> -Ashwin

So I got the code to work finally and figured out what was wrong -
after many iterations of recompiling the kernel with different
options. I feel like it's not very easy to figure this out from the
documentation alone: When you compile the program you need to add
--rtdm to the CFLAGS and LDFLAGS. For future reference, I'll leave my
makefile up for others to refer to.

SRC=rtcanconfig
TARGET=rtcanconfig

CFLAGS := $(shell xeno-config --alchemy --rtdm --cflags)
LDFLAGS := $(shell xeno-config --alchemy --rtdm --ldflags)
CC := $(shell xeno-config --cc)

$(TARGET): $(SRC).c
    $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)

-Ashwin


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-15 18:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13 12:26 [Xenomai] Very strange error with rtcanconfig Ashwin Narayan
2017-04-15 18:24 ` Ashwin Narayan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.