@@ -12,13 +12,16 @@ modems connected to a physical serial port.
1212
1313How to use it
1414-------------
15- 1. 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,
18- 2. switch the serial line to using the n_gsm line discipline by using
19- TIOCSETD ioctl,
20- 3. configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl,
21- 4. obtain base gsmtty number for the used serial port,
15+ 1. config initiator
16+ ^^^^^^^^^^^^^^^^^^^^^
17+
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.
21+ 1.2 switch the serial line to using the n_gsm line discipline by using
22+ TIOCSETD ioctl.
23+ 1.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
24+ 1.4 obtain base gsmtty number for the used serial port.
2225
2326Major parts of the initialization program :
2427(a good starting point is util-linux-ng/sys-utils/ldattach.c)::
@@ -70,14 +73,14 @@ Major parts of the initialization program :
7073 daemon(0,0);
7174 pause();
7275
73- 5. use these devices as plain serial ports.
76+ 1.5 use these devices as plain serial ports.
7477
7578 for example, it's possible:
7679
7780 - and to use gnokii to send / receive SMS on ttygsm1
7881 - to use ppp to establish a datalink on ttygsm2
7982
80- 6. first close all virtual ports before closing the physical port.
83+ 1.6 first close all virtual ports before closing the physical port.
8184
8285 Note that after closing the physical port the modem is still in multiplexing
8386 mode. This may prevent a successful re-opening of the port later. To avoid
@@ -87,6 +90,56 @@ Major parts of the initialization program :
8790
8891 0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9.
8992
93+ 2. config requester
94+ ^^^^^^^^^^^^^^^^^^^^^
95+
96+ 2.1 receive string "AT+CMUX= command" through its serial port,initialize
97+ mux mode config
98+ 2.2 switch the serial line to using the n_gsm line discipline by using
99+ TIOCSETD ioctl.
100+ 2.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
101+ 2.4 obtain base gsmtty number for the used serial port,
102+
103+ #include <stdio.h>
104+ #include <stdint.h>
105+ #include <linux/gsmmux.h>
106+ #include <linux/tty.h>
107+ #define DEFAULT_SPEED B115200
108+ #define SERIAL_PORT /dev/ttyS0
109+
110+ int ldisc = N_GSM0710;
111+ struct gsm_config c;
112+ struct termios configuration;
113+ uint32_t first;
114+
115+ /* open the serial port */
116+ fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
117+
118+ /* configure the serial port : speed, flow control ... */
119+
120+ /* get serial data and check "AT+CMUX=command" parameter ... */
121+
122+ /* use n_gsm line discipline */
123+ ioctl(fd, TIOCSETD, &ldisc);
124+
125+ /* get n_gsm configuration */
126+ ioctl(fd, GSMIOC_GETCONF, &c);
127+ / * we are requester and need encoding 0 (basic) */
128+ c.initiator = 0;
129+ c.encapsulation = 0;
130+ / * our modem defaults to a maximum size of 127 bytes */
131+ c.mru = 127;
132+ c.mtu = 127;
133+ / * set the new configuration */
134+ ioctl(fd, GSMIOC_SETCONF, &c);
135+ / * get first gsmtty device node */
136+ ioctl(fd, GSMIOC_GETFIRST, &first);
137+ printf("first muxed line: /dev/gsmtty%i\n ", first);
138+
139+ /* and wait for ever to keep the line discipline enabled */
140+ daemon(0,0);
141+ pause();
142+
90143Additional Documentation
91144------------------------
92145More practical details on the protocol and how it's supported by industrial
0 commit comments