Create a LibSerialStream from a C file descriptor
Moved to GitHub
Brought to you by:
crayzeewulf,
wedesoft
I want to use the library with RFCOMM (serial over bluetooth).
In that case, a C file descriptor is provided to communicate with the device.
There is a really simple example on this page:
http://people.csail.mit.edu/albert/bluez-intro/x502.html
(see the example 4-3 for instance).
Would it be possible to add a constructor to LibSerialStream to be able to construct the object from a file descriptor?
Thanks.
Logged In: YES
user_id=645118
Originator: NO
I am not sure what will happen if one tries to call termios functions on a descriptor returned by socket(). Furthermore, the SerialPort implementation is dependent on the fact that the descriptor be opened with specified flags (O_RDWR|O_NOCTTY|O_NONBLOCK). Additionally, keeping the descriptor hidden from users of the class ensures that the descriptor is completely controlled by the class and does not, for example, get closed by someone else while it is in use.
However, this is an interesting idea and worth investigating. I will look into it further and post updates based on what I find.