mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
Merge tag 'tty-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty and serial driver updates from Greg KH:
"Here is the big set of tty and serial driver updates for 5.19-rc1.
Lots of tiny cleanups in here, the major stuff is:
- termbit cleanups and unification by Ilpo. A much needed change that
goes a long way to making things simpler for all of the different
arches
- tty documentation cleanups and movements to their own place in the
documentation tree
- old tty driver cleanups and fixes from Jiri to bring some existing
drivers into the modern world
- RS485 cleanups and unifications to make it easier for individual
drivers to support this mode instead of having to duplicate logic
in each driver
- Lots of 8250 driver updates and additions
- new device id additions
- n_gsm continued fixes and cleanups
- other minor serial driver updates and cleanups
All of these have been in linux-next for weeks with no reported issues"
* tag 'tty-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (166 commits)
tty: Rework receive flow control char logic
pcmcia: synclink_cs: Don't allow CS5-6
serial: stm32-usart: Correct CSIZE, bits, and parity
serial: st-asc: Sanitize CSIZE and correct PARENB for CS7
serial: sifive: Sanitize CSIZE and c_iflag
serial: sh-sci: Don't allow CS5-6
serial: txx9: Don't allow CS5-6
serial: rda-uart: Don't allow CS5-6
serial: digicolor-usart: Don't allow CS5-6
serial: uartlite: Fix BRKINT clearing
serial: cpm_uart: Fix build error without CONFIG_SERIAL_CPM_CONSOLE
serial: core: Do stop_rx in suspend path for console if console_suspend is disabled
tty: serial: qcom-geni-serial: Remove uart frequency table. Instead, find suitable frequency with call to clk_round_rate.
dt-bindings: serial: renesas,em-uart: Add RZ/V2M clock to access the registers
serial: 8250_fintek: Check SER_RS485_RTS_* only with RS485
Revert "serial: 8250_mtk: Make sure to select the right FEATURE_SEL"
serial: msm_serial: disable interrupts in __msm_console_write()
serial: meson: acquire port->lock in startup()
serial: 8250_dw: Use dev_err_probe()
serial: 8250_dw: Use devm_add_action_or_reset()
...
This commit is contained in:
@@ -23,7 +23,9 @@ properties:
|
||||
- fsl,imx8qxp-lpuart
|
||||
- fsl,imxrt1050-lpuart
|
||||
- items:
|
||||
- const: fsl,imx8ulp-lpuart
|
||||
- enum:
|
||||
- fsl,imx93-lpuart
|
||||
- fsl,imx8ulp-lpuart
|
||||
- const: fsl,imx7ulp-lpuart
|
||||
- items:
|
||||
- enum:
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
%YAML 1.2
|
||||
---
|
||||
$id: "http://devicetree.org/schemas/serial/qcom,serial-geni-qcom.yaml#"
|
||||
$schema: "http://devicetree.org/meta-schemas/core.yaml#"
|
||||
|
||||
title: Qualcomm Geni based QUP UART interface
|
||||
|
||||
maintainers:
|
||||
- Andy Gross <agross@kernel.org>
|
||||
- Bjorn Andersson <bjorn.andersson@linaro.org>
|
||||
|
||||
allOf:
|
||||
- $ref: /schemas/serial/serial.yaml#
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
enum:
|
||||
- qcom,geni-uart
|
||||
- qcom,geni-debug-uart
|
||||
|
||||
clocks:
|
||||
maxItems: 1
|
||||
|
||||
clock-names:
|
||||
const: se
|
||||
|
||||
interconnects:
|
||||
maxItems: 2
|
||||
|
||||
interconnect-names:
|
||||
items:
|
||||
- const: qup-core
|
||||
- const: qup-config
|
||||
|
||||
interrupts:
|
||||
minItems: 1
|
||||
items:
|
||||
- description: UART core irq
|
||||
- description: Wakeup irq (RX GPIO)
|
||||
|
||||
operating-points-v2: true
|
||||
|
||||
pinctrl-0: true
|
||||
pinctrl-1: true
|
||||
|
||||
pinctrl-names:
|
||||
minItems: 1
|
||||
items:
|
||||
- const: default
|
||||
- const: sleep
|
||||
|
||||
power-domains:
|
||||
maxItems: 1
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- clocks
|
||||
- clock-names
|
||||
- interrupts
|
||||
- reg
|
||||
|
||||
unevaluatedProperties: false
|
||||
|
||||
examples:
|
||||
- |
|
||||
#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
#include <dt-bindings/clock/qcom,gcc-sc7180.h>
|
||||
#include <dt-bindings/interconnect/qcom,sc7180.h>
|
||||
|
||||
serial@a88000 {
|
||||
compatible = "qcom,geni-uart";
|
||||
reg = <0xa88000 0x7000>;
|
||||
interrupts = <GIC_SPI 355 IRQ_TYPE_LEVEL_HIGH>;
|
||||
clock-names = "se";
|
||||
clocks = <&gcc GCC_QUPV3_WRAP0_S0_CLK>;
|
||||
pinctrl-0 = <&qup_uart0_default>;
|
||||
pinctrl-names = "default";
|
||||
interconnects = <&qup_virt MASTER_QUP_CORE_0 0 &qup_virt SLAVE_QUP_CORE_0 0>,
|
||||
<&gem_noc MASTER_APPSS_PROC 0 &config_noc SLAVE_QUP_0 0>;
|
||||
interconnect-names = "qup-core", "qup-config";
|
||||
};
|
||||
...
|
||||
@@ -9,12 +9,16 @@ title: Renesas EMMA Mobile UART Interface
|
||||
maintainers:
|
||||
- Magnus Damm <magnus.damm@gmail.com>
|
||||
|
||||
allOf:
|
||||
- $ref: serial.yaml#
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
const: renesas,em-uart
|
||||
oneOf:
|
||||
- items:
|
||||
- enum:
|
||||
- renesas,r9a09g011-uart # RZ/V2M
|
||||
- const: renesas,em-uart # generic EMMA Mobile compatible UART
|
||||
|
||||
- items:
|
||||
- const: renesas,em-uart # generic EMMA Mobile compatible UART
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
@@ -23,10 +27,31 @@ properties:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
maxItems: 1
|
||||
minItems: 1
|
||||
items:
|
||||
- description: UART functional clock
|
||||
- description: Internal clock to access the registers
|
||||
|
||||
clock-names:
|
||||
const: sclk
|
||||
minItems: 1
|
||||
items:
|
||||
- const: sclk
|
||||
- const: pclk
|
||||
|
||||
allOf:
|
||||
- $ref: serial.yaml#
|
||||
|
||||
- if:
|
||||
properties:
|
||||
compatible:
|
||||
contains:
|
||||
const: renesas,r9a09g011-uart
|
||||
then:
|
||||
properties:
|
||||
clocks:
|
||||
minItems: 2
|
||||
clock-names:
|
||||
minItems: 2
|
||||
|
||||
required:
|
||||
- compatible
|
||||
|
||||
@@ -51,10 +51,16 @@ properties:
|
||||
- renesas,hscif-r8a77980 # R-Car V3H
|
||||
- renesas,hscif-r8a77990 # R-Car E3
|
||||
- renesas,hscif-r8a77995 # R-Car D3
|
||||
- renesas,hscif-r8a779a0 # R-Car V3U
|
||||
- const: renesas,rcar-gen3-hscif # R-Car Gen3 and RZ/G2
|
||||
- const: renesas,hscif # generic HSCIF compatible UART
|
||||
|
||||
- items:
|
||||
- enum:
|
||||
- renesas,hscif-r8a779a0 # R-Car V3U
|
||||
- renesas,hscif-r8a779g0 # R-Car V4H
|
||||
- const: renesas,rcar-gen4-hscif # R-Car Gen4
|
||||
- const: renesas,hscif # generic HSCIF compatible UART
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
|
||||
@@ -113,6 +119,7 @@ if:
|
||||
enum:
|
||||
- renesas,rcar-gen2-hscif
|
||||
- renesas,rcar-gen3-hscif
|
||||
- renesas,rcar-gen4-hscif
|
||||
then:
|
||||
required:
|
||||
- resets
|
||||
|
||||
@@ -60,12 +60,12 @@ properties:
|
||||
- renesas,scif-r8a77980 # R-Car V3H
|
||||
- renesas,scif-r8a77990 # R-Car E3
|
||||
- renesas,scif-r8a77995 # R-Car D3
|
||||
- renesas,scif-r8a779a0 # R-Car V3U
|
||||
- const: renesas,rcar-gen3-scif # R-Car Gen3 and RZ/G2
|
||||
- const: renesas,scif # generic SCIF compatible UART
|
||||
|
||||
- items:
|
||||
- enum:
|
||||
- renesas,scif-r8a779a0 # R-Car V3U
|
||||
- renesas,scif-r8a779f0 # R-Car S4-8
|
||||
- const: renesas,rcar-gen4-scif # R-Car Gen4
|
||||
- const: renesas,scif # generic SCIF compatible UART
|
||||
|
||||
@@ -33,6 +33,11 @@ properties:
|
||||
description: drive RTS low when sending (default is high).
|
||||
$ref: /schemas/types.yaml#/definitions/flag
|
||||
|
||||
rs485-rx-active-high:
|
||||
description: Polarity of receiver enable signal (when separate from RTS).
|
||||
True indicates active high (default is low).
|
||||
$ref: /schemas/types.yaml#/definitions/flag
|
||||
|
||||
linux,rs485-enabled-at-boot-time:
|
||||
description: enables the rs485 feature at boot time. It can be disabled
|
||||
later with proper ioctl.
|
||||
|
||||
@@ -20,7 +20,10 @@ properties:
|
||||
maxItems: 1
|
||||
|
||||
clocks:
|
||||
minItems: 1
|
||||
maxItems: 1
|
||||
|
||||
resets:
|
||||
maxItems: 1
|
||||
|
||||
auto-flow-control:
|
||||
description: enable automatic flow control support.
|
||||
|
||||
@@ -101,6 +101,7 @@ available subsections can be seen below.
|
||||
surface_aggregator/index
|
||||
switchtec
|
||||
sync_file
|
||||
tty/index
|
||||
vfio-mediated-device
|
||||
vfio
|
||||
vfio-pci-device-specific-driver-acceptance
|
||||
|
||||
@@ -311,7 +311,7 @@ hardware.
|
||||
This call must not sleep
|
||||
|
||||
set_ldisc(port,termios)
|
||||
Notifier for discipline change. See Documentation/tty/tty_ldisc.rst.
|
||||
Notifier for discipline change. See ../tty/tty_ldisc.rst.
|
||||
|
||||
Locking: caller holds tty_port->mutex
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ Serial drivers
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
moxa-smartio
|
||||
n_gsm
|
||||
serial-iso7816
|
||||
serial-rs485
|
||||
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
==============================
|
||||
GSM 0710 tty multiplexor HOWTO
|
||||
==============================
|
||||
|
||||
This line discipline implements the GSM 07.10 multiplexing protocol
|
||||
detailed in the following 3GPP document:
|
||||
|
||||
https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip
|
||||
|
||||
This document give some hints on how to use this driver with GPRS and 3G
|
||||
modems connected to a physical serial port.
|
||||
|
||||
How to use it
|
||||
-------------
|
||||
1. config initiator
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
1.1 initialize the modem in 0710 mux mode (usually AT+CMUX= command) through
|
||||
its serial port. Depending on the modem used, you can pass more or less
|
||||
parameters to this command.
|
||||
|
||||
1.2 switch the serial line to using the n_gsm line discipline by using
|
||||
TIOCSETD ioctl.
|
||||
|
||||
1.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
|
||||
|
||||
1.4 obtain base gsmtty number for the used serial port.
|
||||
|
||||
Major parts of the initialization program :
|
||||
(a good starting point is util-linux-ng/sys-utils/ldattach.c)::
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <linux/gsmmux.h>
|
||||
#include <linux/tty.h>
|
||||
#define DEFAULT_SPEED B115200
|
||||
#define SERIAL_PORT /dev/ttyS0
|
||||
|
||||
int ldisc = N_GSM0710;
|
||||
struct gsm_config c;
|
||||
struct termios configuration;
|
||||
uint32_t first;
|
||||
|
||||
/* open the serial port connected to the modem */
|
||||
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
/* configure the serial port : speed, flow control ... */
|
||||
|
||||
/* send the AT commands to switch the modem to CMUX mode
|
||||
and check that it's successful (should return OK) */
|
||||
write(fd, "AT+CMUX=0\r", 10);
|
||||
|
||||
/* experience showed that some modems need some time before
|
||||
being able to answer to the first MUX packet so a delay
|
||||
may be needed here in some case */
|
||||
sleep(3);
|
||||
|
||||
/* use n_gsm line discipline */
|
||||
ioctl(fd, TIOCSETD, &ldisc);
|
||||
|
||||
/* get n_gsm configuration */
|
||||
ioctl(fd, GSMIOC_GETCONF, &c);
|
||||
/* we are initiator and need encoding 0 (basic) */
|
||||
c.initiator = 1;
|
||||
c.encapsulation = 0;
|
||||
/* our modem defaults to a maximum size of 127 bytes */
|
||||
c.mru = 127;
|
||||
c.mtu = 127;
|
||||
/* set the new configuration */
|
||||
ioctl(fd, GSMIOC_SETCONF, &c);
|
||||
/* get first gsmtty device node */
|
||||
ioctl(fd, GSMIOC_GETFIRST, &first);
|
||||
printf("first muxed line: /dev/gsmtty%i\n", first);
|
||||
|
||||
/* and wait for ever to keep the line discipline enabled */
|
||||
daemon(0,0);
|
||||
pause();
|
||||
|
||||
1.5 use these devices as plain serial ports.
|
||||
|
||||
for example, it's possible:
|
||||
|
||||
- and to use gnokii to send / receive SMS on ttygsm1
|
||||
- to use ppp to establish a datalink on ttygsm2
|
||||
|
||||
1.6 first close all virtual ports before closing the physical port.
|
||||
|
||||
Note that after closing the physical port the modem is still in multiplexing
|
||||
mode. This may prevent a successful re-opening of the port later. To avoid
|
||||
this situation either reset the modem if your hardware allows that or send
|
||||
a disconnect command frame manually before initializing the multiplexing mode
|
||||
for the second time. The byte sequence for the disconnect command frame is::
|
||||
|
||||
0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9.
|
||||
|
||||
2. config requester
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
2.1 receive string "AT+CMUX= command" through its serial port,initialize
|
||||
mux mode config
|
||||
|
||||
2.2 switch the serial line to using the n_gsm line discipline by using
|
||||
TIOCSETD ioctl.
|
||||
|
||||
2.3 configure the mux using GSMIOC_GETCONF / GSMIOC_SETCONF ioctl.
|
||||
|
||||
2.4 obtain base gsmtty number for the used serial port::
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <linux/gsmmux.h>
|
||||
#include <linux/tty.h>
|
||||
#define DEFAULT_SPEED B115200
|
||||
#define SERIAL_PORT /dev/ttyS0
|
||||
|
||||
int ldisc = N_GSM0710;
|
||||
struct gsm_config c;
|
||||
struct termios configuration;
|
||||
uint32_t first;
|
||||
|
||||
/* open the serial port */
|
||||
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
/* configure the serial port : speed, flow control ... */
|
||||
|
||||
/* get serial data and check "AT+CMUX=command" parameter ... */
|
||||
|
||||
/* use n_gsm line discipline */
|
||||
ioctl(fd, TIOCSETD, &ldisc);
|
||||
|
||||
/* get n_gsm configuration */
|
||||
ioctl(fd, GSMIOC_GETCONF, &c);
|
||||
/* we are requester and need encoding 0 (basic) */
|
||||
c.initiator = 0;
|
||||
c.encapsulation = 0;
|
||||
/* our modem defaults to a maximum size of 127 bytes */
|
||||
c.mru = 127;
|
||||
c.mtu = 127;
|
||||
/* set the new configuration */
|
||||
ioctl(fd, GSMIOC_SETCONF, &c);
|
||||
/* get first gsmtty device node */
|
||||
ioctl(fd, GSMIOC_GETFIRST, &first);
|
||||
printf("first muxed line: /dev/gsmtty%i\n", first);
|
||||
|
||||
/* and wait for ever to keep the line discipline enabled */
|
||||
daemon(0,0);
|
||||
pause();
|
||||
|
||||
Additional Documentation
|
||||
------------------------
|
||||
More practical details on the protocol and how it's supported by industrial
|
||||
modems can be found in the following documents :
|
||||
|
||||
- http://www.telit.com/module/infopool/download.php?id=616
|
||||
- http://www.u-blox.com/images/downloads/Product_Docs/LEON-G100-G200-MuxImplementation_ApplicationNote_%28GSM%20G1-CS-10002%29.pdf
|
||||
- http://www.sierrawireless.com/Support/Downloads/AirPrime/WMP_Series/~/media/Support_Downloads/AirPrime/Application_notes/CMUX_Feature_Application_Note-Rev004.ashx
|
||||
- http://wm.sim.com/sim/News/photo/2010721161442.pdf
|
||||
|
||||
11-03-08 - Eric Bénard - <eric@eukrea.com>
|
||||
@@ -36,18 +36,16 @@ In-detail description of the named TTY structures is in separate documents:
|
||||
tty_struct
|
||||
tty_ldisc
|
||||
tty_buffer
|
||||
n_tty
|
||||
tty_internals
|
||||
|
||||
Writing TTY Driver
|
||||
==================
|
||||
|
||||
Before one starts writing a TTY driver, they must consider
|
||||
:doc:`Serial <../driver-api/serial/driver>` and :doc:`USB Serial
|
||||
<../usb/usb-serial>` layers
|
||||
first. Drivers for serial devices can often use one of these specific layers to
|
||||
implement a serial driver. Only special devices should be handled directly by
|
||||
the TTY Layer. If you are about to write such a driver, read on.
|
||||
:doc:`Serial <../serial/driver>` and :doc:`USB Serial <../../usb/usb-serial>`
|
||||
layers first. Drivers for serial devices can often use one of these specific
|
||||
layers to implement a serial driver. Only special devices should be handled
|
||||
directly by the TTY Layer. If you are about to write such a driver, read on.
|
||||
|
||||
A *typical* sequence a TTY driver performs is as follows:
|
||||
|
||||
@@ -61,3 +59,15 @@ A *typical* sequence a TTY driver performs is as follows:
|
||||
Steps regarding driver, i.e. 1., 3., and 5. are described in detail in
|
||||
:doc:`tty_driver`. For the other two (devices handling), look into
|
||||
:doc:`tty_port`.
|
||||
|
||||
Other Documentation
|
||||
===================
|
||||
|
||||
Miscellaneous documentation can be further found in these documents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
moxa-smartio
|
||||
n_gsm
|
||||
n_tty
|
||||
153
Documentation/driver-api/tty/n_gsm.rst
Normal file
153
Documentation/driver-api/tty/n_gsm.rst
Normal file
@@ -0,0 +1,153 @@
|
||||
==============================
|
||||
GSM 0710 tty multiplexor HOWTO
|
||||
==============================
|
||||
|
||||
.. contents:: :local:
|
||||
|
||||
This line discipline implements the GSM 07.10 multiplexing protocol
|
||||
detailed in the following 3GPP document:
|
||||
|
||||
https://www.3gpp.org/ftp/Specs/archive/07_series/07.10/0710-720.zip
|
||||
|
||||
This document give some hints on how to use this driver with GPRS and 3G
|
||||
modems connected to a physical serial port.
|
||||
|
||||
How to use it
|
||||
=============
|
||||
|
||||
Config Initiator
|
||||
----------------
|
||||
|
||||
#. Initialize the modem in 0710 mux mode (usually ``AT+CMUX=`` command) through
|
||||
its serial port. Depending on the modem used, you can pass more or less
|
||||
parameters to this command.
|
||||
|
||||
#. Switch the serial line to using the n_gsm line discipline by using
|
||||
``TIOCSETD`` ioctl.
|
||||
|
||||
#. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl.
|
||||
|
||||
#. Obtain base gsmtty number for the used serial port.
|
||||
|
||||
Major parts of the initialization program
|
||||
(a good starting point is util-linux-ng/sys-utils/ldattach.c)::
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <linux/gsmmux.h>
|
||||
#include <linux/tty.h>
|
||||
|
||||
#define DEFAULT_SPEED B115200
|
||||
#define SERIAL_PORT /dev/ttyS0
|
||||
|
||||
int ldisc = N_GSM0710;
|
||||
struct gsm_config c;
|
||||
struct termios configuration;
|
||||
uint32_t first;
|
||||
|
||||
/* open the serial port connected to the modem */
|
||||
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
/* configure the serial port : speed, flow control ... */
|
||||
|
||||
/* send the AT commands to switch the modem to CMUX mode
|
||||
and check that it's successful (should return OK) */
|
||||
write(fd, "AT+CMUX=0\r", 10);
|
||||
|
||||
/* experience showed that some modems need some time before
|
||||
being able to answer to the first MUX packet so a delay
|
||||
may be needed here in some case */
|
||||
sleep(3);
|
||||
|
||||
/* use n_gsm line discipline */
|
||||
ioctl(fd, TIOCSETD, &ldisc);
|
||||
|
||||
/* get n_gsm configuration */
|
||||
ioctl(fd, GSMIOC_GETCONF, &c);
|
||||
/* we are initiator and need encoding 0 (basic) */
|
||||
c.initiator = 1;
|
||||
c.encapsulation = 0;
|
||||
/* our modem defaults to a maximum size of 127 bytes */
|
||||
c.mru = 127;
|
||||
c.mtu = 127;
|
||||
/* set the new configuration */
|
||||
ioctl(fd, GSMIOC_SETCONF, &c);
|
||||
/* get first gsmtty device node */
|
||||
ioctl(fd, GSMIOC_GETFIRST, &first);
|
||||
printf("first muxed line: /dev/gsmtty%i\n", first);
|
||||
|
||||
/* and wait for ever to keep the line discipline enabled */
|
||||
daemon(0,0);
|
||||
pause();
|
||||
|
||||
#. Use these devices as plain serial ports.
|
||||
|
||||
For example, it's possible:
|
||||
|
||||
- to use *gnokii* to send / receive SMS on ``ttygsm1``
|
||||
- to use *ppp* to establish a datalink on ``ttygsm2``
|
||||
|
||||
#. First close all virtual ports before closing the physical port.
|
||||
|
||||
Note that after closing the physical port the modem is still in multiplexing
|
||||
mode. This may prevent a successful re-opening of the port later. To avoid
|
||||
this situation either reset the modem if your hardware allows that or send
|
||||
a disconnect command frame manually before initializing the multiplexing mode
|
||||
for the second time. The byte sequence for the disconnect command frame is::
|
||||
|
||||
0xf9, 0x03, 0xef, 0x03, 0xc3, 0x16, 0xf9
|
||||
|
||||
Config Requester
|
||||
----------------
|
||||
|
||||
#. Receive ``AT+CMUX=`` command through its serial port, initialize mux mode
|
||||
config.
|
||||
|
||||
#. Switch the serial line to using the *n_gsm* line discipline by using
|
||||
``TIOCSETD`` ioctl.
|
||||
|
||||
#. Configure the mux using ``GSMIOC_GETCONF``/``GSMIOC_SETCONF`` ioctl.
|
||||
|
||||
#. Obtain base gsmtty number for the used serial port::
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <linux/gsmmux.h>
|
||||
#include <linux/tty.h>
|
||||
#define DEFAULT_SPEED B115200
|
||||
#define SERIAL_PORT /dev/ttyS0
|
||||
|
||||
int ldisc = N_GSM0710;
|
||||
struct gsm_config c;
|
||||
struct termios configuration;
|
||||
uint32_t first;
|
||||
|
||||
/* open the serial port */
|
||||
fd = open(SERIAL_PORT, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
/* configure the serial port : speed, flow control ... */
|
||||
|
||||
/* get serial data and check "AT+CMUX=command" parameter ... */
|
||||
|
||||
/* use n_gsm line discipline */
|
||||
ioctl(fd, TIOCSETD, &ldisc);
|
||||
|
||||
/* get n_gsm configuration */
|
||||
ioctl(fd, GSMIOC_GETCONF, &c);
|
||||
/* we are requester and need encoding 0 (basic) */
|
||||
c.initiator = 0;
|
||||
c.encapsulation = 0;
|
||||
/* our modem defaults to a maximum size of 127 bytes */
|
||||
c.mru = 127;
|
||||
c.mtu = 127;
|
||||
/* set the new configuration */
|
||||
ioctl(fd, GSMIOC_SETCONF, &c);
|
||||
/* get first gsmtty device node */
|
||||
ioctl(fd, GSMIOC_GETFIRST, &first);
|
||||
printf("first muxed line: /dev/gsmtty%i\n", first);
|
||||
|
||||
/* and wait for ever to keep the line discipline enabled */
|
||||
daemon(0,0);
|
||||
pause();
|
||||
|
||||
11-03-08 - Eric Bénard - <eric@eukrea.com>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user