Re: [problem] tty: n_gsm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 27.5.2015 14:59, Greg KH wrote:
On Wed, May 27, 2015 at 02:45:47PM +0200, Jiří Prchal wrote:
Hi,

I've tried n_gsm to get up working. Is this in working condition? Trying kernel 4.1-rc5.

I made program as example in Documentation/serial/n_gsm.txt. Nodes are made
by mdev (too many 0 - 63). Or if I disable mdev then I made by program 4
nodes. Up to here looks everything OK.

Is the n_gsm line discipline set to be attached to those device nodes?

Should it be set line discipline again when opening gsmtty nodes?
I don't think so, it fails on open of node.


When I try to open node by my program or by microcom it return with this
error: microcom: can't open '/dev/gsmtty1': Level 2 halted.

Sounds like you didn't bind the line discipline properly, what program
that you ran did that?

You have to do that before you can open the device nodes.

Here are functions called in this sequence:
int
init_mux (int tty)
{
	int ldisc = N_GSM0710;
	struct gsm_config conf;
	struct termios termios;
	int r;

	// send the AT commands to switch the modem to CMUX mode
	r = at_cmd (tty, "AT+CMUX=0", NULL);
	if (r) {
		syslog (LOG_ERR, "cannot switch the modem to CMUX mode!");
		exit (-1);
	}

	// reconfigure the serial port
	tcgetattr (tty, &termios);
	termios.c_iflag = 0;
	termios.c_lflag = 0;
	tcsetattr (tty, TCSANOW, &termios);

	/* experience showed that some modems need some time before
	 being able to answer to the first MUX packet so a delay
	 may be needed here in some case */
	sleep (3);

	/* use n_gsm line discipline */
	if (ioctl (tty, TIOCSETD, &ldisc)) {
		syslog (LOG_ERR, "cannot set line discipline!");
		exit (-1);
	}

	/* get n_gsm configuration */
	if (ioctl (tty, GSMIOC_GETCONF, &conf)) {
		syslog (LOG_ERR, "cannot get configuration!");
		exit (-1);
	}
	/* we are initiator and need encoding 0 (basic) */
	conf.initiator = 1;
	conf.encapsulation = 0;
	/* our modem defaults to a maximum size of 98 bytes */
	conf.mru = 96;
	conf.mtu = 96;
	/* set the new configuration */
	if (ioctl (tty, GSMIOC_SETCONF, &conf)) {
		syslog (LOG_ERR, "cannot configure line discipline!");
		exit (-1);
	}
	return (0);
}

int
make_nodes (char *nodename)
{
	int i;
	char buf[256];
	FILE *fd;
	int major = 0;
	dev_t dev;

	//find MAJOR
	fd = fopen ("/proc/devices", "r");
	if (fd == NULL) {
		syslog (LOG_ERR, "cannot open /proc/devices!");
		exit (-1);
	}
	while (fgets (buf, sizeof(buf), fd)) {
		if (strstr (buf, "gsmtty")) {
			sscanf (buf, "%d %*s", &major);
			break;
		}
	}
	fclose (fd);
	if (major == 0) {
		syslog (LOG_ERR, "cannot find gsmtty!");
		exit (-1);
	}
	//make nodes
	for (i = 0; i < 4; i++) {
		dev = makedev (major, i);
		sprintf (buf, "%s%d", nodename, i);
		if (mknod (buf, S_IFCHR, dev)) {
			syslog (LOG_ERR, "cannot make node %s!", buf);
			exit (-1);
		}
	}
	return (0);
}

int
at_open (char *dev)
{
	int tty;

	tty = open (dev, O_RDWR | O_NOCTTY);
	if (tty < 0) {
		syslog (LOG_ERR, "unable to open %s, code %d (%s)", dev, errno, strerror (errno));
		exit (EXIT_FAILURE);
		/*fails here*/
	}
	...
}


thanks,

greg k-h

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux