1 ==============================
2 GSM 0710 tty multiplexor HOWTO
3 ==============================
7 This line discipline implements the GSM 07.10 multiplexing protocol
8 detailed in the following 3GPP document:
10 https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip
12 This document give some hints on how to use this driver with GPRS and 3G
13 modems connected to a physical serial port.
21 #. Initialize the modem in 0710 mux mode (usually ``AT+CMUX=`` command) through
22 its serial port. Depending on the modem used, you can pass more or less
23 parameters to this command.
25 #. Switch the serial line to using the n_gsm line discipline by using
28 #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl.
30 #. Obtain base gsmtty number for the used serial port.
32 Major parts of the initialization program
33 (a good starting point is util-linux-ng/sys-utils/ldattach.c)::
37 #include <linux/gsmmux.h>
38 #include <linux/tty.h>
40 #define DEFAULT_SPEED B115200
41 #define SERIAL_PORT /dev/ttyS0
43 int ldisc = N_GSM0710;
45 struct termios configuration;
48 /* open the serial port connected to the modem */
49 fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
51 /* configure the serial port : speed, flow control ... */
53 /* send the AT commands to switch the modem to CMUX mode
54 and check that it's successful (should return OK) */
55 write(fd, "AT+CMUX=0\r", 10);
57 /* experience showed that some modems need some time before
58 being able to answer to the first MUX packet so a delay
59 may be needed here in some case */
62 /* use n_gsm line discipline */
63 ioctl(fd, TIOCSETD, &ldisc);
65 /* get n_gsm configuration */
66 ioctl(fd, GSMIOC_GETCONF, &c);
67 /* we are initiator and need encoding 0 (basic) */
70 /* our modem defaults to a maximum size of 127 bytes */
73 /* set the new configuration */
74 ioctl(fd, GSMIOC_SETCONF, &c);
75 /* get first gsmtty device node */
76 ioctl(fd, GSMIOC_GETFIRST, &first);
77 printf("first muxed line: /dev/gsmtty%i\n", first);
79 /* and wait for ever to keep the line discipline enabled */
83 #. Use these devices as plain serial ports.
85 For example, it's possible:
87 - to use *gnokii* to send / receive SMS on ``ttygsm1``
88 - to use *ppp* to establish a datalink on ``ttygsm2``
90 #. First close all virtual ports before closing the physical port.
92 Note that after closing the physical port the modem is still in multiplexing
93 mode. This may prevent a successful re-opening of the port later. To avoid
94 this situation either reset the modem if your hardware allows that or send
95 a disconnect command frame manually before initializing the multiplexing mode
96 for the second time. The byte sequence for the disconnect command frame is::
98 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9
103 #. Receive ``AT+CMUX=`` command through its serial port, initialize mux mode
106 #. Switch the serial line to using the *n_gsm* line discipline by using
109 #. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl.
111 #. Obtain base gsmtty number for the used serial port::
115 #include <linux/gsmmux.h>
116 #include <linux/tty.h>
117 #define DEFAULT_SPEED B115200
118 #define SERIAL_PORT /dev/ttyS0
120 int ldisc = N_GSM0710;
122 struct termios configuration;
125 /* open the serial port */
126 fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
128 /* configure the serial port : speed, flow control ... */
130 /* get serial data and check "AT+CMUX=command" parameter ... */
132 /* use n_gsm line discipline */
133 ioctl(fd, TIOCSETD, &ldisc);
135 /* get n_gsm configuration */
136 ioctl(fd, GSMIOC_GETCONF, &c);
137 /* we are requester and need encoding 0 (basic) */
140 /* our modem defaults to a maximum size of 127 bytes */
143 /* set the new configuration */
144 ioctl(fd, GSMIOC_SETCONF, &c);
145 /* get first gsmtty device node */
146 ioctl(fd, GSMIOC_GETFIRST, &first);
147 printf("first muxed line: /dev/gsmtty%i\n", first);
149 /* and wait for ever to keep the line discipline enabled */
153 11-03-08 - Eric BĂ©nard - <eric@eukrea.com>