STRUCT SERIAL_RS485(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

ok so this is the manual page for struct serial_rs485 β€” the serial interface for controlling RS485 settings, and honestly it's giving "small struct, big responsibilities." the manual name is struct serial_rs485(9) and it lives in the Kernel API Manual, and yes bestie we're reading the whole thing together 🫢


✨ SYNOPSIS ✨

no cap, here's the whole struct exactly as it is, do not come for me about the semicolons, they're canon:

struct serial_rs485 {
    __u32 flags;
  #define SER_RS485_ENABLED               _BITUL(0);
  #define SER_RS485_RTS_ON_SEND           _BITUL(1);
  #define SER_RS485_RTS_AFTER_SEND        _BITUL(2);
  #define SER_RS485_RX_DURING_TX          _BITUL(4);
  #define SER_RS485_TERMINATE_BUS         _BITUL(5);
  #define SER_RS485_ADDRB                 _BITUL(6);
  #define SER_RS485_ADDR_RECV             _BITUL(7);
  #define SER_RS485_ADDR_DEST             _BITUL(8);
  #define SER_RS485_MODE_RS422            _BITUL(9);
    __u32 delay_rts_before_send;
    __u32 delay_rts_after_send;
    union {
      __u32 padding[5];
      struct {
        __u8 addr_recv;
        __u8 addr_dest;
        __u8 padding0[2];
        __u32 padding1[4];
      };
    };
 };

like… look at it. it ate. πŸ”₯


πŸŽ€ Members πŸŽ€

every field, one by one, no skipping, we're being thorough bestie:

  • flags β€” the RS485 feature flags. this is the main character of the struct ngl.
  • delay_rts_before_send β€” delay before send, in milliseconds. that's ms, not vibes.
  • delay_rts_after_send β€” delay after send, in milliseconds.
  • {unnamed_union} β€” anonymous. it has no name. it simply is. πŸ¦‹
  • padding β€” lowkey deprecated πŸ’€ use padding0 and padding1 instead. and do not use it with addr_recv and addr_dest (due to overlap). read that again, seriously.
  • {unnamed_struct} β€” anonymous too. matching anonymous energy, iconic.
  • addr_recv β€” receive filter for RS485 addressing mode (used only when SER_RS485_ADDR_RECV is set).
  • addr_dest β€” destination address for RS485 addressing mode (used only when SER_RS485_ADDR_DEST is set).
  • padding0 β€” padding (set to zero). zero. okay? 0 xoxo.
  • padding1 β€” padding (set to zero). same rule, no exceptions.

🌸 Description 🌸

so basically: this is the serial interface for controlling RS485 settings on chips that actually have suitable support. you set it with TIOCSRS485 and get it with TIOCGRS485 β€” if your platform supports it, which, respectfully, check first.

the set function returns the new state, with any unsupported bits reverted appropriately. so if you asked for something the hardware can't do, it just… un-asks for it. it's fine. it's handled. 😌

and now the flag bits, all nine of them, in order because we're not monsters:

  • SER_RS485_ENABLED β€” RS485 enabled.
  • SER_RS485_RTS_ON_SEND β€” logical level for RTS pin when sending.
  • SER_RS485_RTS_AFTER_SEND β€” logical level for RTS pin after sent.
  • SER_RS485_RX_DURING_TX β€” full-duplex RS485 line.
  • SER_RS485_TERMINATE_BUS β€” enable bus termination (if supported).
  • SER_RS485_ADDRB β€” enable RS485 addressing mode.
  • SER_RS485_ADDR_RECV β€” receive address filter (enables addr_recv). requires SER_RS485_ADDRB.
  • SER_RS485_ADDR_DEST β€” destination address (enables addr_dest). requires SER_RS485_ADDRB.
  • SER_RS485_MODE_RS422 β€” enable RS422. requires SER_RS485_ENABLED.
ok real talk 🫢 the "requires" ones are not suggestions, they're requirements. skip the prerequisite and the flag does nothing for you. iykyk.

⭐ SEE ALSO ⭐

  • Kernel file ./include/uapi/linux/serial.h

go read it, it's right there, it's basically the source material and it's lowkey obsessed with itself (as it should be).


mwah πŸ’‹ that's the whole page! this little gem came out of ./include/uapi/linux and it's dated October 2026 β€” so go forth, configure your RS485, set your paddings to zero, and remember: <rainbow>the flags are reverted appropriately and so are you</rainbow> βœ¨πŸŽ€πŸ‘‘

πŸ“¦ where this page comes from