Skip to content

support for RS485 #1094

@xoac

Description

@xoac

Hi,
There exist crate rs485 that define const from libc. The problem is that ioctls change signature depending on system platform (for example it accept c_int when using musl on x86 and c_ulong when use glibc on x86_64). So compilation fill when musl is involved:

rust-musl-builder-armv7 cargo build --examples                                                                                                              18:21:01 
   Compiling rs485 v0.1.0
error[E0308]: mismatched types
  --> /root/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/rs485-0.1.0/src/lib.rs:92:45
   |
92 |         let rval = unsafe { libc::ioctl(fd, TIOCGRS485, &mut conf as *mut SerialRs485) };
   |                                             ^^^^^^^^^^ expected i32, found u32

error[E0308]: mismatched types
   --> /root/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/rs485-0.1.0/src/lib.rs:186:45
    |
186 |         let rval = unsafe { libc::ioctl(fd, TIOCSRS485, self as *const SerialRs485) };
    |                                             ^^^^^^^^^^ expected i32, found u32

It would be nice to add this constants (TIOCGRS485, TIOCSRS485) to libc. I am not sure how to do it properly. For musl target constant can be found here:
http://git.musl-libc.org/cgit/musl/tree/arch

in most cases looks like this:

#define TIOCGRS485	0x542E
#define TIOCSRS485	0x542F

but there are different here:
http://git.musl-libc.org/cgit/musl/tree/arch/mips64/bits/ioctl.h#n61

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions