All of lore.kernel.org
 help / color / mirror / Atom feed
* Trying to use ESD CAN-USB with SocketCAN
@ 2013-02-28 17:57 GeoffO
  2013-02-28 18:22 ` uescher
  2013-02-28 19:59 ` Oliver Hartkopp
  0 siblings, 2 replies; 5+ messages in thread
From: GeoffO @ 2013-02-28 17:57 UTC (permalink / raw)
  To: linux-can

I wanted to setup SocketCAN on my PC to prepare for an embedded Linux project,
so I purchased a USB device from ESD who claimed it supports SocketCAN.
I could not get it to work after the following these steps: 
Downloaded and installed can-utils
Loaded modules to the kernal
	sudo modprobe can
	sudo modprobe can_raw
	sudo modprobe can_bcm
	sudo modprobe vcan

Checked that modules are loaded
	lsmod | grep can
	vcan                    1314  0 
	can_bcm                11942  0 
	can_raw                 5381  0 
	can                    21728  2 can_bcm,can_raw

Plugged-in ESD CAN-USB/Micro and got this new device
	/dev/ttyACM0

Tried to attach the USB device to SocketCAN
	sudo slcan_attach /dev/ttyACM0
	ioctl TIOCSETD: Invalid argument

I got this error, so I checked the code of slcan_attach to find the problem,
and wrote this small program to isolate the problem:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#define LDISC_N_SLCAN 17 // default slcan line discipline since Kernel 2.6.25
int main(int argc, char **argv)
{
	int fd;
	int ldisc = LDISC_N_SLCAN;
	char *tty = "/dev/ttyACM0";//device for ESD CAN/USB Micro
	if ((fd = open (tty, O_WRONLY | O_NOCTTY)) < 0) {
		perror(tty);
		exit(1);
	}
	// set slcan line discipline on given tty
	if (ioctl (fd, TIOCSETD, &ldisc) < 0) {
		perror("ioctl TIOCSETD");
		exit(1);
	}
	return 0;
}

This program writes "ioctl TIOCSETD: Invalid argument" to the consul.  The
problem is apparently caused when ioctl() tries to set the LDISC_N_SLCAN line
discipline for /dev/ttyACM0 and detects an invalid argument.  I tried setting
the line discipline to N_TTY and it did not complain.  I am running Ubuntu
10.04 with kernal version 2.6.32.  Any Idea what might be the problem?  
Is this device supported by by SocketCAN?  ESD claims it is.




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

* Re: Trying to use ESD CAN-USB with SocketCAN
  2013-02-28 17:57 Trying to use ESD CAN-USB with SocketCAN GeoffO
@ 2013-02-28 18:22 ` uescher
  2013-02-28 21:27   ` Geoff Olson
  2013-02-28 19:59 ` Oliver Hartkopp
  1 sibling, 1 reply; 5+ messages in thread
From: uescher @ 2013-02-28 18:22 UTC (permalink / raw)
  To: linux-can; +Cc: GeoffO

Am 28.02.2013 18:57, schrieb GeoffO:
> Tried to attach the USB device to SocketCAN
> 	sudo slcan_attach /dev/ttyACM0
> 	ioctl TIOCSETD: Invalid argument
>
Did you test the communication with the device with raw slcan commands?
Like cat /dev/ttyACM0 and echo -ne "O" > /dev/ttyACM0 ?

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

* Re: Trying to use ESD CAN-USB with SocketCAN
  2013-02-28 17:57 Trying to use ESD CAN-USB with SocketCAN GeoffO
  2013-02-28 18:22 ` uescher
@ 2013-02-28 19:59 ` Oliver Hartkopp
  1 sibling, 0 replies; 5+ messages in thread
From: Oliver Hartkopp @ 2013-02-28 19:59 UTC (permalink / raw)
  To: GeoffO; +Cc: linux-can

On 28.02.2013 18:57, GeoffO wrote:

> I wanted to setup SocketCAN on my PC to prepare for an embedded Linux project,
> so I purchased a USB device from ESD who claimed it supports SocketCAN.


> Plugged-in ESD CAN-USB/Micro and got this new device
> 	/dev/ttyACM0
> 


Ugh?!

The ESD USB/Micro is a separate USB CAN driver, see:

http://lxr.linux.no/#linux+v3.8.1/drivers/net/can/usb/Kconfig#L9

and

http://lxr.linux.no/#linux+v3.8.1/drivers/net/can/usb/esd_usb2.c

Therefore i wonder why a /dev/ttyACM is created and not just a 'can0'.

Can you send the dmesg output when plugging the interface?
What kernel version do you use?
What does 'lsusb -v -v' tell about the ESD adapter?

Regards,
Oliver

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

* RE: Trying to use ESD CAN-USB with SocketCAN
  2013-02-28 18:22 ` uescher
@ 2013-02-28 21:27   ` Geoff Olson
  2013-02-28 22:35     ` uescher
  0 siblings, 1 reply; 5+ messages in thread
From: Geoff Olson @ 2013-02-28 21:27 UTC (permalink / raw)
  To: 'uescher', linux-can

Thanks for the quick reply.   Good suggestion.  I will try to get it wired
up to something today I can communicate to.

Am 28.02.2013 18:57, schrieb GeoffO:
> Tried to attach the USB device to SocketCAN
> 	sudo slcan_attach /dev/ttyACM0
> 	ioctl TIOCSETD: Invalid argument
>
Did you test the communication with the device with raw slcan commands?
Like cat /dev/ttyACM0 and echo -ne "O" > /dev/ttyACM0 ?


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

* Re: Trying to use ESD CAN-USB with SocketCAN
  2013-02-28 21:27   ` Geoff Olson
@ 2013-02-28 22:35     ` uescher
  0 siblings, 0 replies; 5+ messages in thread
From: uescher @ 2013-02-28 22:35 UTC (permalink / raw)
  To: linux-can; +Cc: Geoff Olson

Am 28.02.2013 22:27, schrieb Geoff Olson:
> Thanks for the quick reply.   Good suggestion.  I will try to get it wired
> up to something today I can communicate to.
It should work without an real CAN-Bus.
You can ask the CAN-USB about his Version and so things.
If the communication with slcan work, the you will get an answer.

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

end of thread, other threads:[~2013-02-28 22:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28 17:57 Trying to use ESD CAN-USB with SocketCAN GeoffO
2013-02-28 18:22 ` uescher
2013-02-28 21:27   ` Geoff Olson
2013-02-28 22:35     ` uescher
2013-02-28 19:59 ` Oliver Hartkopp

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.