€•CµŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ2/translations/zh_CN/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ2/translations/zh_TW/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ2/translations/it_IT/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ2/translations/ja_JP/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ2/translations/ko_KR/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ2/translations/pt_BR/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ2/translations/sp_SP/driver-api/serial/serial-rs485”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒRS485 Serial Communications”h]”hŒRS485 Serial Communications”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒL/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485.rst”h´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ1. Introduction”h]”hŒ1. Introduction”…”�”}”(hhÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhËh²hh³hÊh´KubhŒ block_quote”“”)�”}”(hXUEIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the electrical characteristics of drivers and receivers for use in balanced digital multipoint systems. This standard is widely used for communications in industrial automation because it can be used effectively over long distances and in electrically noisy environments. ”h]”hŒ paragraph”“”)�”}”(hXTEIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the electrical characteristics of drivers and receivers for use in balanced digital multipoint systems. This standard is widely used for communications in industrial automation because it can be used effectively over long distances and in electrically noisy environments.”h]”hXTEIA-485, also known as TIA/EIA-485 or RS-485, is a standard defining the electrical characteristics of drivers and receivers for use in balanced digital multipoint systems. This standard is widely used for communications in industrial automation because it can be used effectively over long distances and in electrically noisy environments.”…”�”}”(hhäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´KhhÞubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ1. introduction”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ"2. Hardware-related Considerations”h]”hŒ"2. Hardware-related Considerations”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KubhÝ)�”}”(hXSome CPUs/UARTs (e.g., Atmel AT91 or 16C950 UART) contain a built-in half-duplex mode capable of automatically controlling line direction by toggling RTS or DTR signals. That can be used to control external half-duplex hardware like an RS485 transceiver or any RS232-connected half-duplex devices like some modems. For these microcontrollers, the Linux driver should be made capable of working in both modes, and proper ioctls (see later) should be made available at user-level to allow switching from one mode to the other, and vice versa. ”h]”(hã)�”}”(hX:Some CPUs/UARTs (e.g., Atmel AT91 or 16C950 UART) contain a built-in half-duplex mode capable of automatically controlling line direction by toggling RTS or DTR signals. That can be used to control external half-duplex hardware like an RS485 transceiver or any RS232-connected half-duplex devices like some modems.”h]”hX:Some CPUs/UARTs (e.g., Atmel AT91 or 16C950 UART) contain a built-in half-duplex mode capable of automatically controlling line direction by toggling RTS or DTR signals. That can be used to control external half-duplex hardware like an RS485 transceiver or any RS232-connected half-duplex devices like some modems.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Khjubhã)�”}”(hŒáFor these microcontrollers, the Linux driver should be made capable of working in both modes, and proper ioctls (see later) should be made available at user-level to allow switching from one mode to the other, and vice versa.”h]”hŒáFor these microcontrollers, the Linux driver should be made capable of working in both modes, and proper ioctls (see later) should be made available at user-level to allow switching from one mode to the other, and vice versa.”…”�”}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Khjubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khjh²hubeh}”(h]”Œhardware-related-considerations”ah ]”h"]”Œ"2. hardware-related considerations”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ23. Data Structures Already Available in the Kernel”h]”hŒ23. Data Structures Already Available in the Kernel”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj?h²hh³hÊh´KubhÝ)�”}”(hX3The Linux kernel provides the struct serial_rs485 to handle RS485 communications. This data structure is used to set and configure RS485 parameters in the platform data and in ioctls. The device tree can also provide RS485 boot time parameters [#DT-bindings]_. The serial core fills the struct serial_rs485 from the values given by the device tree when the driver calls uart_get_rs485_mode(). Any driver for devices capable of working both as RS232 and RS485 should implement the ``rs485_config`` callback and provide ``rs485_supported`` in the ``struct uart_port``. The serial core calls ``rs485_config`` to do the device specific part in response to TIOCSRS485 ioctl (see below). The ``rs485_config`` callback receives a pointer to a sanitizated struct serial_rs485. The struct serial_rs485 userspace provides is sanitized before calling ``rs485_config`` using ``rs485_supported`` that indicates what RS485 features the driver supports for the ``struct uart_port``. TIOCGRS485 ioctl can be used to read back the struct serial_rs485 matching to the current configuration. ”h]”(hã)�”}”(hŒ·The Linux kernel provides the struct serial_rs485 to handle RS485 communications. This data structure is used to set and configure RS485 parameters in the platform data and in ioctls.”h]”hŒ·The Linux kernel provides the struct serial_rs485 to handle RS485 communications. This data structure is used to set and configure RS485 parameters in the platform data and in ioctls.”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K hjPubhã)�”}”(hŒÐThe device tree can also provide RS485 boot time parameters [#DT-bindings]_. The serial core fills the struct serial_rs485 from the values given by the device tree when the driver calls uart_get_rs485_mode().”h]”(hŒDestination address for RS485 addressing mode (used only when ”…”�”}”(hj5h²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ADDR_DEST``”h]”hŒSER_RS485_ADDR_DEST”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj5ubhŒ is set).”…”�”}”(hj5h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´Kxhj2ubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j%h³j1h´Kyhj"ubj&)�”}”(hŒ$``padding0`` Padding (set to zero). ”h]”(j,)�”}”(hŒ ``padding0``”h]”j”)�”}”(hjhh]”hŒpadding0”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjfubah}”(h]”h ]”h"]”h$]”h&]”uh1j+h³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´KzhjbubjF)�”}”(hhh]”hã)�”}”(hŒPadding (set to zero).”h]”hŒPadding (set to zero).”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³j}h´Kzhj~ubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhjbubeh}”(h]”h ]”h"]”h$]”h&]”uh1j%h³j}h´Kzhj"ubj&)�”}”(hŒ#``padding1`` Padding (set to zero).”h]”(j,)�”}”(hŒ ``padding1``”h]”j”)�”}”(hj¡h]”hŒpadding1”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjŸubah}”(h]”h ]”h"]”h$]”h&]”uh1j+h³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´Kzhj›ubjF)�”}”(hhh]”hã)�”}”(hŒPadding (set to zero).”h]”hŒPadding (set to zero).”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K{hj·ubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhj›ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j%h³j¶h´Kzhj"ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j hjÔubeh}”(h]”h ]”Œ kernelindent”ah"]”h$]”h&]”uh1jÒhj?h²hh³Nh´Nubhã)�”}”(hŒ**Description**”h]”jÝ)�”}”(hjäh]”hŒ Description”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÜhjâubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K~hj?h²hubhã)�”}”(hŒôSerial interface for controlling RS485 settings on chips with suitable support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your platform. The set function returns the new state, with any unsupported bits reverted appropriately.”h]”hŒôSerial interface for controlling RS485 settings on chips with suitable support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your platform. The set function returns the new state, with any unsupported bits reverted appropriately.”…”�”}”(hjúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K~hj?h²hubhã)�”}”(hŒThe flag bits are:”h]”hŒThe flag bits are:”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´Kƒhj?h²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒ.``SER_RS485_ENABLED`` - RS485 enabled.”h]”hã)�”}”(hj!h]”(j”)�”}”(hŒ``SER_RS485_ENABLED``”h]”hŒSER_RS485_ENABLED”…”�”}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj#ubhŒ - RS485 enabled.”…”�”}”(hj#h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K…hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒG``SER_RS485_RTS_ON_SEND`` - Logical level for RTS pin when sending.”h]”hã)�”}”(hjGh]”(j”)�”}”(hŒ``SER_RS485_RTS_ON_SEND``”h]”hŒSER_RS485_RTS_ON_SEND”…”�”}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjIubhŒ. - Logical level for RTS pin when sending.”…”�”}”(hjIh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K†hjEubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒE``SER_RS485_RTS_AFTER_SEND`` - Logical level for RTS pin after sent.”h]”hã)�”}”(hjmh]”(j”)�”}”(hŒ``SER_RS485_RTS_AFTER_SEND``”h]”hŒSER_RS485_RTS_AFTER_SEND”…”�”}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjoubhŒ) - Logical level for RTS pin after sent.”…”�”}”(hjoh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K‡hjkubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒ7``SER_RS485_RX_DURING_TX`` - Full-duplex RS485 line.”h]”hã)�”}”(hj“h]”(j”)�”}”(hŒ``SER_RS485_RX_DURING_TX``”h]”hŒSER_RS485_RX_DURING_TX”…”�”}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj•ubhŒ - Full-duplex RS485 line.”…”�”}”(hj•h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´Kˆhj‘ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒF``SER_RS485_TERMINATE_BUS`` - Enable bus termination (if supported).”h]”hã)�”}”(hj¹h]”(j”)�”}”(hŒ``SER_RS485_TERMINATE_BUS``”h]”hŒSER_RS485_TERMINATE_BUS”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj»ubhŒ+ - Enable bus termination (if supported).”…”�”}”(hj»h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K‰hj·ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒ=``SER_RS485_ADDRB`` - Enable RS485 addressing mode.”h]”hã)�”}”(hjßh]”(j”)�”}”(hŒ``SER_RS485_ADDRB``”h]”hŒSER_RS485_ADDRB”…”�”}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjáubhŒ* - Enable RS485 addressing mode.”…”�”}”(hjáh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´KŠhjÝubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒg``SER_RS485_ADDR_RECV`` - Receive address filter (enables **addr_recv**). Requires ``SER_RS485_ADDRB``.”h]”hã)�”}”(hjh]”(j”)�”}”(hŒ``SER_RS485_ADDR_RECV``”h]”hŒSER_RS485_ADDR_RECV”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjubhŒ# - Receive address filter (enables ”…”�”}”(hjh²hh³Nh´NubjÝ)�”}”(hŒ **addr_recv**”h]”hŒ addr_recv”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÜhjubhŒ ). Requires ”…”�”}”(hjh²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ADDRB``”h]”hŒSER_RS485_ADDRB”…”�”}”(hj.h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjubhŒ.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K‹hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒd``SER_RS485_ADDR_DEST`` - Destination address (enables **addr_dest**). Requires ``SER_RS485_ADDRB``.”h]”hã)�”}”(hjOh]”(j”)�”}”(hŒ``SER_RS485_ADDR_DEST``”h]”hŒSER_RS485_ADDR_DEST”…”�”}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjQubhŒ - Destination address (enables ”…”�”}”(hjQh²hh³Nh´NubjÝ)�”}”(hŒ **addr_dest**”h]”hŒ addr_dest”…”�”}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÜhjQubhŒ ). Requires ”…”�”}”(hjQh²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ADDRB``”h]”hŒSER_RS485_ADDRB”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjQubhŒ.”…”�”}”(hjQh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´KŒhjMubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubj)�”}”(hŒO``SER_RS485_MODE_RS422`` - Enable RS422. Requires ``SER_RS485_ENABLED``. ”h]”hã)�”}”(hŒM``SER_RS485_MODE_RS422`` - Enable RS422. Requires ``SER_RS485_ENABLED``.”h]”(j”)�”}”(hŒ``SER_RS485_MODE_RS422``”h]”hŒSER_RS485_MODE_RS422”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj›ubhŒ - Enable RS422. Requires ”…”�”}”(hj›h²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ENABLED``”h]”hŒSER_RS485_ENABLED”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj›ubhŒ.”…”�”}”(hj›h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³Œj/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-rs485:52: ./include/uapi/linux/serial.h”h´K�hj—ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1jh³j>h´K…hj?h²hubeh}”(h]”Œ/data-structures-already-available-in-the-kernel”ah ]”h"]”Œ23. data structures already available in the kernel”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ4. Usage from user-level”h]”hŒ4. Usage from user-level”…”�”}”(hjãh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjàh²hh³hÊh´K8ubhÝ)�”}”(hXaFrom user-level, RS485 configuration can be get/set using the previous ioctls. For instance, to set RS485 you can use the following code:: #include /* Include definition for RS485 ioctls: TIOCGRS485 and TIOCSRS485 */ #include /* Open your specific device (e.g., /dev/mydevice): */ int fd = open ("/dev/mydevice", O_RDWR); if (fd < 0) { /* Error handling. See errno. */ } struct serial_rs485 rs485conf; /* Enable RS485 mode: */ rs485conf.flags |= SER_RS485_ENABLED; /* Set logical level for RTS pin equal to 1 when sending: */ rs485conf.flags |= SER_RS485_RTS_ON_SEND; /* or, set logical level for RTS pin equal to 0 when sending: */ rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND); /* Set logical level for RTS pin equal to 1 after sending: */ rs485conf.flags |= SER_RS485_RTS_AFTER_SEND; /* or, set logical level for RTS pin equal to 0 after sending: */ rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND); /* Set rts delay before send, if needed: */ rs485conf.delay_rts_before_send = ...; /* Set rts delay after send, if needed: */ rs485conf.delay_rts_after_send = ...; /* Set this flag if you want to receive data even while sending data */ rs485conf.flags |= SER_RS485_RX_DURING_TX; if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) { /* Error handling. See errno. */ } /* Use read() and write() syscalls here... */ /* Close the device when finished: */ if (close (fd) < 0) { /* Error handling. See errno. */ } ”h]”(hã)�”}”(hŒŠFrom user-level, RS485 configuration can be get/set using the previous ioctls. For instance, to set RS485 you can use the following code::”h]”hŒ‰From user-level, RS485 configuration can be get/set using the previous ioctls. For instance, to set RS485 you can use the following code:”…”�”}”(hjõh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K:hjñubjø)�”}”(hX/#include /* Include definition for RS485 ioctls: TIOCGRS485 and TIOCSRS485 */ #include /* Open your specific device (e.g., /dev/mydevice): */ int fd = open ("/dev/mydevice", O_RDWR); if (fd < 0) { /* Error handling. See errno. */ } struct serial_rs485 rs485conf; /* Enable RS485 mode: */ rs485conf.flags |= SER_RS485_ENABLED; /* Set logical level for RTS pin equal to 1 when sending: */ rs485conf.flags |= SER_RS485_RTS_ON_SEND; /* or, set logical level for RTS pin equal to 0 when sending: */ rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND); /* Set logical level for RTS pin equal to 1 after sending: */ rs485conf.flags |= SER_RS485_RTS_AFTER_SEND; /* or, set logical level for RTS pin equal to 0 after sending: */ rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND); /* Set rts delay before send, if needed: */ rs485conf.delay_rts_before_send = ...; /* Set rts delay after send, if needed: */ rs485conf.delay_rts_after_send = ...; /* Set this flag if you want to receive data even while sending data */ rs485conf.flags |= SER_RS485_RX_DURING_TX; if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) { /* Error handling. See errno. */ } /* Use read() and write() syscalls here... */ /* Close the device when finished: */ if (close (fd) < 0) { /* Error handling. See errno. */ }”h]”hX/#include /* Include definition for RS485 ioctls: TIOCGRS485 and TIOCSRS485 */ #include /* Open your specific device (e.g., /dev/mydevice): */ int fd = open ("/dev/mydevice", O_RDWR); if (fd < 0) { /* Error handling. See errno. */ } struct serial_rs485 rs485conf; /* Enable RS485 mode: */ rs485conf.flags |= SER_RS485_ENABLED; /* Set logical level for RTS pin equal to 1 when sending: */ rs485conf.flags |= SER_RS485_RTS_ON_SEND; /* or, set logical level for RTS pin equal to 0 when sending: */ rs485conf.flags &= ~(SER_RS485_RTS_ON_SEND); /* Set logical level for RTS pin equal to 1 after sending: */ rs485conf.flags |= SER_RS485_RTS_AFTER_SEND; /* or, set logical level for RTS pin equal to 0 after sending: */ rs485conf.flags &= ~(SER_RS485_RTS_AFTER_SEND); /* Set rts delay before send, if needed: */ rs485conf.delay_rts_before_send = ...; /* Set rts delay after send, if needed: */ rs485conf.delay_rts_after_send = ...; /* Set this flag if you want to receive data even while sending data */ rs485conf.flags |= SER_RS485_RX_DURING_TX; if (ioctl (fd, TIOCSRS485, &rs485conf) < 0) { /* Error handling. See errno. */ } /* Use read() and write() syscalls here... */ /* Close the device when finished: */ if (close (fd) < 0) { /* Error handling. See errno. */ }”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j”j•uh1j÷h³hÊh´K=hjñubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K:hjàh²hubeh}”(h]”Œusage-from-user-level”ah ]”h"]”Œ4. usage from user-level”ah$]”h&]”uh1hµhh·h²hh³hÊh´K8ubh¶)�”}”(hhh]”(h»)�”}”(hŒ5. Multipoint Addressing”h]”hŒ5. Multipoint Addressing”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KlubhÝ)�”}”(hXâThe Linux kernel provides addressing mode for multipoint RS-485 serial communications line. The addressing mode is enabled with ``SER_RS485_ADDRB`` flag in struct serial_rs485. The struct serial_rs485 has two additional flags and fields for enabling receive and destination addresses. Address mode flags: - ``SER_RS485_ADDRB``: Enabled addressing mode (sets also ADDRB in termios). - ``SER_RS485_ADDR_RECV``: Receive (filter) address enabled. - ``SER_RS485_ADDR_DEST``: Set destination address. Address fields (enabled with corresponding ``SER_RS485_ADDR_*`` flag): - ``addr_recv``: Receive address. - ``addr_dest``: Destination address. Once a receive address is set, the communication can occur only with the particular device and other peers are filtered out. It is left up to the receiver side to enforce the filtering. Receive address will be cleared if ``SER_RS485_ADDR_RECV`` is not set. Note: not all devices supporting RS485 support multipoint addressing. ”h]”(hã)�”}”(hXThe Linux kernel provides addressing mode for multipoint RS-485 serial communications line. The addressing mode is enabled with ``SER_RS485_ADDRB`` flag in struct serial_rs485. The struct serial_rs485 has two additional flags and fields for enabling receive and destination addresses.”h]”(hŒ€The Linux kernel provides addressing mode for multipoint RS-485 serial communications line. The addressing mode is enabled with ”…”�”}”(hj4h²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ADDRB``”h]”hŒSER_RS485_ADDRB”…”�”}”(hj<h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj4ubhŒ‰ flag in struct serial_rs485. The struct serial_rs485 has two additional flags and fields for enabling receive and destination addresses.”…”�”}”(hj4h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Knhj0ubj!)�”}”(hhh]”(j&)�”}”(hŒÒAddress mode flags: - ``SER_RS485_ADDRB``: Enabled addressing mode (sets also ADDRB in termios). - ``SER_RS485_ADDR_RECV``: Receive (filter) address enabled. - ``SER_RS485_ADDR_DEST``: Set destination address. ”h]”(j,)�”}”(hŒAddress mode flags:”h]”hŒAddress mode flags:”…”�”}”(hj[h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j+h³hÊh´KwhjWubjF)�”}”(hhh]”j)�”}”(hhh]”(j)�”}”(hŒJ``SER_RS485_ADDRB``: Enabled addressing mode (sets also ADDRB in termios).”h]”hã)�”}”(hjqh]”(j”)�”}”(hŒ``SER_RS485_ADDRB``”h]”hŒSER_RS485_ADDRB”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjsubhŒ7: Enabled addressing mode (sets also ADDRB in termios).”…”�”}”(hjsh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Kuhjoubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjlubj)�”}”(hŒ:``SER_RS485_ADDR_RECV``: Receive (filter) address enabled.”h]”hã)�”}”(hj–h]”(j”)�”}”(hŒ``SER_RS485_ADDR_RECV``”h]”hŒSER_RS485_ADDR_RECV”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj˜ubhŒ#: Receive (filter) address enabled.”…”�”}”(hj˜h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Kvhj”ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjlubj)�”}”(hŒ2``SER_RS485_ADDR_DEST``: Set destination address. ”h]”hã)�”}”(hŒ1``SER_RS485_ADDR_DEST``: Set destination address.”h]”(j”)�”}”(hŒ``SER_RS485_ADDR_DEST``”h]”hŒSER_RS485_ADDR_DEST”…”�”}”(hjÁh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj½ubhŒ: Set destination address.”…”�”}”(hj½h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Kwhj¹ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjlubeh}”(h]”h ]”h"]”h$]”h&]”jÖŒ-”uh1jh³hÊh´Kuhjiubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhjWubeh}”(h]”h ]”h"]”h$]”h&]”uh1j%h³hÊh´KwhjTubj&)�”}”(hŒ�Address fields (enabled with corresponding ``SER_RS485_ADDR_*`` flag): - ``addr_recv``: Receive address. - ``addr_dest``: Destination address. ”h]”(j,)�”}”(hŒFAddress fields (enabled with corresponding ``SER_RS485_ADDR_*`` flag):”h]”(hŒ+Address fields (enabled with corresponding ”…”�”}”(hjöh²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ADDR_*``”h]”hŒSER_RS485_ADDR_*”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjöubhŒ flag):”…”�”}”(hjöh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1j+h³hÊh´K{hjòubjF)�”}”(hhh]”j)�”}”(hhh]”(j)�”}”(hŒ``addr_recv``: Receive address.”h]”hã)�”}”(hj h]”(j”)�”}”(hŒ ``addr_recv``”h]”hŒ addr_recv”…”�”}”(hj# h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj ubhŒ: Receive address.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Kzhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubj)�”}”(hŒ$``addr_dest``: Destination address. ”h]”hã)�”}”(hŒ#``addr_dest``: Destination address.”h]”(j”)�”}”(hŒ ``addr_dest``”h]”hŒ addr_dest”…”�”}”(hjI h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjE ubhŒ: Destination address.”…”�”}”(hjE h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K{hjA ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj ubeh}”(h]”h ]”h"]”h$]”h&]”jÖjåuh1jh³hÊh´Kzhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jEhjòubeh}”(h]”h ]”h"]”h$]”h&]”uh1j%h³hÊh´K{hjTubeh}”(h]”h ]”h"]”h$]”h&]”uh1j hj0ubhã)�”}”(hXOnce a receive address is set, the communication can occur only with the particular device and other peers are filtered out. It is left up to the receiver side to enforce the filtering. Receive address will be cleared if ``SER_RS485_ADDR_RECV`` is not set.”h]”(hŒÝOnce a receive address is set, the communication can occur only with the particular device and other peers are filtered out. It is left up to the receiver side to enforce the filtering. Receive address will be cleared if ”…”�”}”(hj h²hh³Nh´Nubj”)�”}”(hŒ``SER_RS485_ADDR_RECV``”h]”hŒSER_RS485_ADDR_RECV”…”�”}”(hj‡ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj ubhŒ is not set.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K}hj0ubhã)�”}”(hŒENote: not all devices supporting RS485 support multipoint addressing.”h]”hŒENote: not all devices supporting RS485 support multipoint addressing.”…”�”}”(hjŸ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K‚hj0ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Knhjh²hubeh}”(h]”Œmultipoint-addressing”ah ]”h"]”Œ5. multipoint addressing”ah$]”h&]”uh1hµhh·h²hh³hÊh´Klubh¶)�”}”(hhh]”(h»)�”}”(hŒ 6. References”h]”hŒ 6. References”…”�”}”(hj¾ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj» h²hh³hÊh´K…ubhŒfootnote”“”)�”}”(hŒ3Documentation/devicetree/bindings/serial/rs485.yaml”h]”(hŒlabel”“”)�”}”(hhh]”hŒ1”…”�”}”(hjÔ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jÒ hjÎ h²hh³Nh´Nubhã)�”}”(hjÐ h]”hŒ3Documentation/devicetree/bindings/serial/rs485.yaml”…”�”}”(hjá h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K‡hjÎ ubeh}”(h]”j}ah ]”h"]”Œ dt-bindings”ah$]”h&]”jvaj{Kj~juh1jÌ h³hÊh´K‡hj» h²hubeh}”(h]”Œ references”ah ]”h"]”Œ 6. references”ah$]”h&]”uh1hµhh·h²hh³hÊh´K…ubeh}”(h]”Œrs485-serial-communications”ah ]”h"]”Œrs485 serial communications”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j( Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œ dt-bindings”]”jlasŒrefids”}”j}]”jlasŒnameids”}”(j jÿ hýhúj<j9jÝjÚjjj¸ jµ jú j÷ jò j}uŒ nametypes”}”(j ‰hý‰j<‰j݉j‰j¸ ‰jú ‰jò ˆuh}”(jÿ h·húhËj9jjÚj?jvjlj@jIjjàjµ jj÷ j» j}jÎ uŒ footnote_refs”}”jh ]”jlasŒ citation_refs”}”Œ autofootnotes”]”jÎ aŒautofootnote_refs”]”jlaŒsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”j6 Ks…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.