Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.3 103 lines 3.7 kB view raw
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 http://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, 21 22Major parts of the initialization program : 23(a good starting point is util-linux-ng/sys-utils/ldattach.c):: 24 25 #include <linux/gsmmux.h> 26 #define N_GSM0710 21 /* GSM 0710 Mux */ 27 #define DEFAULT_SPEED B115200 28 #define SERIAL_PORT /dev/ttyS0 29 30 int ldisc = N_GSM0710; 31 struct gsm_config c; 32 struct termios configuration; 33 34 /* open the serial port connected to the modem */ 35 fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY); 36 37 /* configure the serial port : speed, flow control ... */ 38 39 /* send the AT commands to switch the modem to CMUX mode 40 and check that it's successful (should return OK) */ 41 write(fd, "AT+CMUX=0\r", 10); 42 43 /* experience showed that some modems need some time before 44 being able to answer to the first MUX packet so a delay 45 may be needed here in some case */ 46 sleep(3); 47 48 /* use n_gsm line discipline */ 49 ioctl(fd, TIOCSETD, &ldisc); 50 51 /* get n_gsm configuration */ 52 ioctl(fd, GSMIOC_GETCONF, &c); 53 /* we are initiator and need encoding 0 (basic) */ 54 c.initiator = 1; 55 c.encapsulation = 0; 56 /* our modem defaults to a maximum size of 127 bytes */ 57 c.mru = 127; 58 c.mtu = 127; 59 /* set the new configuration */ 60 ioctl(fd, GSMIOC_SETCONF, &c); 61 62 /* and wait for ever to keep the line discipline enabled */ 63 daemon(0,0); 64 pause(); 65 664. create the devices corresponding to the "virtual" serial ports (take care, 67 each modem has its configuration and some DLC have dedicated functions, 68 for example GPS), starting with minor 1 (DLC0 is reserved for the management 69 of the mux):: 70 71 MAJOR=`cat /proc/devices |grep gsmtty | awk '{print $1}` 72 for i in `seq 1 4`; do 73 mknod /dev/ttygsm$i c $MAJOR $i 74 done 75 765. use these devices as plain serial ports. 77 78 for example, it's possible: 79 80 - and to use gnokii to send / receive SMS on ttygsm1 81 - to use ppp to establish a datalink on ttygsm2 82 836. first close all virtual ports before closing the physical port. 84 85 Note that after closing the physical port the modem is still in multiplexing 86 mode. This may prevent a successful re-opening of the port later. To avoid 87 this situation either reset the modem if your hardware allows that or send 88 a disconnect command frame manually before initializing the multiplexing mode 89 for the second time. The byte sequence for the disconnect command frame is:: 90 91 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9. 92 93Additional Documentation 94------------------------ 95More practical details on the protocol and how it's supported by industrial 96modems can be found in the following documents : 97 98- http://www.telit.com/module/infopool/download.php?id=616 99- http://www.u-blox.com/images/downloads/Product_Docs/LEON-G100-G200-MuxImplementation_ApplicationNote_%28GSM%20G1-CS-10002%29.pdf 100- http://www.sierrawireless.com/Support/Downloads/AirPrime/WMP_Series/~/media/Support_Downloads/AirPrime/Application_notes/CMUX_Feature_Application_Note-Rev004.ashx 101- http://wm.sim.com/sim/News/photo/2010721161442.pdf 102 10311-03-08 - Eric Bénard - <eric@eukrea.com>