1============================== 2GSM 0710 tty multiplexor HOWTO 3============================== 4 5This line discipline implements the GSM 07.10 multiplexing protocol 6detailed in the following 3GPP document: 7 8 https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip 9 10This document give some hints on how to use this driver with GPRS and 3G 11modems connected to a physical serial port. 12 13How to use it 14------------- 151. initialize the modem in 0710 mux mode (usually AT+CMUX= command) through 16 its serial port. Depending on the modem used, you can pass more or less 17 parameters to this command, 182. switch the serial line to using the n_gsm line discipline by using 19 TIOCSETD ioctl, 203. configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl, 214. obtain base gsmtty number for the used serial port, 22 23Major parts of the initialization program : 24(a good starting point is util-linux-ng/sys-utils/ldattach.c):: 25 26 #include <stdio.h> 27 #include <stdint.h> 28 #include <linux/gsmmux.h> 29 #include <linux/tty.h> 30 #define DEFAULT_SPEED B115200 31 #define SERIAL_PORT /dev/ttyS0 32 33 int ldisc = N_GSM0710; 34 struct gsm_config c; 35 struct termios configuration; 36 uint32_t first; 37 38 /* open the serial port connected to the modem */ 39 fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 40 41 /* configure the serial port : speed, flow control ... */ 42 43 /* send the AT commands to switch the modem to CMUX mode 44 and check that it's successful (should return OK) */ 45 write(fd, "AT+CMUX=0\r", 10); 46 47 /* experience showed that some modems need some time before 48 being able to answer to the first MUX packet so a delay 49 may be needed here in some case */ 50 sleep(3); 51 52 /* use n_gsm line discipline */ 53 ioctl(fd, TIOCSETD, &ldisc); 54 55 /* get n_gsm configuration */ 56 ioctl(fd, GSMIOC_GETCONF, &c); 57 /* we are initiator and need encoding 0 (basic) */ 58 c.initiator = 1; 59 c.encapsulation = 0; 60 /* our modem defaults to a maximum size of 127 bytes */ 61 c.mru = 127; 62 c.mtu = 127; 63 /* set the new configuration */ 64 ioctl(fd, GSMIOC_SETCONF, &c); 65 /* get first gsmtty device node */ 66 ioctl(fd, GSMIOC_GETFIRST, &first); 67 printf("first muxed line: /dev/gsmtty%i\n", first); 68 69 /* and wait for ever to keep the line discipline enabled */ 70 daemon(0,0); 71 pause(); 72 735. use these devices as plain serial ports. 74 75 for example, it's possible: 76 77 - and to use gnokii to send / receive SMS on ttygsm1 78 - to use ppp to establish a datalink on ttygsm2 79 806. first close all virtual ports before closing the physical port. 81 82 Note that after closing the physical port the modem is still in multiplexing 83 mode. This may prevent a successful re-opening of the port later. To avoid 84 this situation either reset the modem if your hardware allows that or send 85 a disconnect command frame manually before initializing the multiplexing mode 86 for the second time. The byte sequence for the disconnect command frame is:: 87 88 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9. 89 90Additional Documentation 91------------------------ 92More practical details on the protocol and how it's supported by industrial 93modems can be found in the following documents : 94 95- http://www.telit.com/module/infopool/download.php?id=616 96- http://www.u-blox.com/images/downloads/Product_Docs/LEON-G100-G200-MuxImplementation_ApplicationNote_%28GSM%20G1-CS-10002%29.pdf 97- http://www.sierrawireless.com/Support/Downloads/AirPrime/WMP_Series/~/media/Support_Downloads/AirPrime/Application_notes/CMUX_Feature_Application_Note-Rev004.ashx 98- http://wm.sim.com/sim/News/photo/2010721161442.pdf 99 10011-03-08 - Eric Bénard - <eric@eukrea.com> 101