linux-can.vger.kernel.org archive mirror
 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).