Menu

#2 Create a LibSerialStream from a C file descriptor

open
None
5
2008-07-28
2008-07-27
Anonymous
No

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.

Discussion

  • Crayzee Wulf

    Crayzee Wulf - 2008-07-28

    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.

     
  • Crayzee Wulf

    Crayzee Wulf - 2008-07-28
    • assigned_to: nobody --> crayzeewulf
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.