1 ==============================
2 GSM 0710 tty multiplexor HOWTO
3 ==============================
5 This line discipline implements the GSM 07.10 multiplexing protocol
6 detailed in the following 3GPP document:
8 https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip
10 This document give some hints on how to use this driver with GPRS and 3G
11 modems connected to a physical serial port.
18 1.1 initialize the modem in 0710 mux mode (usually AT+CMUX= command) through
19 its serial port. Depending on the modem used, you can pass more or less
20 parameters to this command.
22 1.2 switch the serial line to using the n_gsm line discipline by using
25 1.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
27 1.4 obtain base gsmtty number for the used serial port.
29 Major parts of the initialization program :
30 (a good starting point is util-linux-ng/sys-utils/ldattach.c)::
34 #include <linux/gsmmux.h>
35 #include <linux/tty.h>
36 #define DEFAULT_SPEED B115200
37 #define SERIAL_PORT /dev/ttyS0
39 int ldisc = N_GSM0710;
41 struct termios configuration;
44 /* open the serial port connected to the modem */
45 fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
47 /* configure the serial port : speed, flow control ... */
49 /* send the AT commands to switch the modem to CMUX mode
50 and check that it's successful (should return OK) */
51 write(fd, "AT+CMUX=0\r", 10);
53 /* experience showed that some modems need some time before
54 being able to answer to the first MUX packet so a delay
55 may be needed here in some case */
58 /* use n_gsm line discipline */
59 ioctl(fd, TIOCSETD, &ldisc);
61 /* get n_gsm configuration */
62 ioctl(fd, GSMIOC_GETCONF, &c);
63 /* we are initiator and need encoding 0 (basic) */
66 /* our modem defaults to a maximum size of 127 bytes */
69 /* set the new configuration */
70 ioctl(fd, GSMIOC_SETCONF, &c);
71 /* get first gsmtty device node */
72 ioctl(fd, GSMIOC_GETFIRST, &first);
73 printf("first muxed line: /dev/gsmtty%i\n", first);
75 /* and wait for ever to keep the line discipline enabled */
79 1.5 use these devices as plain serial ports.
81 for example, it's possible:
83 - and to use gnokii to send / receive SMS on ttygsm1
84 - to use ppp to establish a datalink on ttygsm2
86 1.6 first close all virtual ports before closing the physical port.
88 Note that after closing the physical port the modem is still in multiplexing
89 mode. This may prevent a successful re-opening of the port later. To avoid
90 this situation either reset the modem if your hardware allows that or send
91 a disconnect command frame manually before initializing the multiplexing mode
92 for the second time. The byte sequence for the disconnect command frame is::
94 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9.
99 2.1 receive string "AT+CMUX= command" through its serial port,initialize
102 2.2 switch the serial line to using the n_gsm line discipline by using
105 2.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
107 2.4 obtain base gsmtty number for the used serial port::
111 #include <linux/gsmmux.h>
112 #include <linux/tty.h>
113 #define DEFAULT_SPEED B115200
114 #define SERIAL_PORT /dev/ttyS0
116 int ldisc = N_GSM0710;
118 struct termios configuration;
121 /* open the serial port */
122 fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
124 /* configure the serial port : speed, flow control ... */
126 /* get serial data and check "AT+CMUX=command" parameter ... */
128 /* use n_gsm line discipline */
129 ioctl(fd, TIOCSETD, &ldisc);
131 /* get n_gsm configuration */
132 ioctl(fd, GSMIOC_GETCONF, &c);
133 /* we are requester and need encoding 0 (basic) */
136 /* our modem defaults to a maximum size of 127 bytes */
139 /* set the new configuration */
140 ioctl(fd, GSMIOC_SETCONF, &c);
141 /* get first gsmtty device node */
142 ioctl(fd, GSMIOC_GETFIRST, &first);
143 printf("first muxed line: /dev/gsmtty%i\n", first);
145 /* and wait for ever to keep the line discipline enabled */
149 Additional Documentation
150 ------------------------
151 More practical details on the protocol and how it's supported by industrial
152 modems can be found in the following documents :
154 - http://www.telit.com/module/infopool/download.php?id=616
155 - http://www.u-blox.com/images/downloads/Product_Docs/LEON-G100-G200-MuxImplementation_ApplicationNote_%28GSM%20G1-CS-10002%29.pdf
156 - http://www.sierrawireless.com/Support/Downloads/AirPrime/WMP_Series/~/media/Support_Downloads/AirPrime/Application_notes/CMUX_Feature_Application_Note-Rev004.ashx
157 - http://wm.sim.com/sim/News/photo/2010721161442.pdf
159 11-03-08 - Eric BĂ©nard - <eric@eukrea.com>