Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

My termios.h differs from yours #2

Closed
gitfoxi opened this issue Sep 8, 2014 · 4 comments
Closed

My termios.h differs from yours #2

gitfoxi opened this issue Sep 8, 2014 · 4 comments

Comments

@gitfoxi
Copy link

gitfoxi commented Sep 8, 2014

It would be nice if bindgen could use the termios.h for the target system but it doesn't look feasible at the present state of the art.

Pyserial seems to solve this problem in a pure-python way by detecting your system and catering to it. This may not be so hard to port since they've already done the hard work.

Some other approaches

rust-term implements a termios_wrapper.c. https://github.com/doy/rust-term/blob/2affde6edab9a75db2b0e0eb748b0a139b1d8842/src/termios_wrapper.c

rustuv (libuv) doesn't quite have everything you need but it almost seems like it should. There's some TTY stuff but it doesn't paper over the control stuff like XON, XOFF

The lack of serial port in libuv has been addressed by a node-serialport project which has a nice wrapper, unfortunately in C++. https://github.com/voodootikigod/node-serialport/blob/644bfab14844c08e7f74aa8125702c611eb1f4dd/src/serialport_unix.cpp

@japaric
Copy link
Contributor

japaric commented Sep 24, 2014

My termios.h differs from yours

This is a bit vague, could you provide more details?

  • What OS are you using?
  • What libc are you using?
  • How are the termios.h different? Are the #define constants different? Are the functions signatures different? Are the fields of the Termios struct different?
  • Could you provide a link to the termios.h you are using?

If the differences are OS-specific, perhaps conditional compilation (example) could solve the issue.

@gitfoxi
Copy link
Author

gitfoxi commented Sep 24, 2014

I was trying on OSX and I think it's a Linux vs BSD thing. Your OS-specific example looks like it will work. I was hoping there would be a better way, like Rust could look at system headers at compile time, but it seems like that's not possible. It's too bad Rust can't break free of the history of slightly incompatible C libraries which has given rise to crazy autotools, configure, cmake and headers full of #ifdef.

OSX termios.h looks similar to this one: http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/termios.h

@japaric
Copy link
Contributor

japaric commented Sep 24, 2014

Rust could look at system headers at compile time, but it seems like that's not possible.

There's an issue in the rust-lang repo about using bindgen to do that, but I think no one is working on it at the moment.

I'll go with the [cfg(..)] solution for now. I was planing to use travis to test that this library works on OSX, but it's not currently possible. And since I don't have access to a OSX/*BSD box at the moment to test the library, I'm considering putting this issue on hold ... unless someone else with access to OSX is willing to test a PR that I can't test.

@gitfoxi
Copy link
Author

gitfoxi commented Sep 24, 2014

If you make it I'll try it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants