Andrew Sutton wrote :
> i'm a bit of an irda newbie, so naturally, i have some questions.
> 
> i'm writing an application that needs to communicate with several irda
> devices over serial cables (cable-connected irda, like a null-modem). i'm
> developing under win2k and using the winsock api to do all the fun
> socket-like irda connection stuff... so here's my question: since i need to
> communicate with several devices - each one connected to an irda enabled
> serial port via a serial cable - how do i specify which com port to open
> when i create the socket? is that even possible, or does the irda stack just
> open all com ports and use service multiplexing to differentiate the
> connected devices?

        Under Windows, you can't. You need to setup the stack on a
specific COM port, and you can set only one COM port. So, you need to
plug all your device sequencially in this COM port.
        If you try to install IrDA phy in the Windows IrDA stack,
usually the IrDA stack get in strange state, and it's usually very
difficult to get it to behave properly again (regedit is your friend).
        Note that getting Microsoft to make any change to the IrDA
stack is *very* difficult, and they are not very active on the subject
(apart from removing some modules such as IrComm and IrLAN).

        On the other hand, Linux has full support for multiple
physical layer, and I've got many setups with 2 IrDA dongles on one
box. In your case, you could setup the Linux-IrDA stack to open all
the Serial ports available on your box like this :
                > irattach /dev/ttyS0 -s 1
                > irattach /dev/ttyS1 -s 1
                > irattach /dev/ttyS2 -s 1
                > irattach /dev/ttyS3 -s 1
        If you got a multiserial board, refer to the doc to know what
tty are available.

        Then, selecting a specific device under Linux is quite
trivial. You perform a discovery (IRLMP_ENUMDEVICES) and you get a
list of all the device discovered, including their nickname, their
IrDA address and their hint bit. So, you can match the nickname, or
can match the int bit, whatever...
        You can also query all present devices for some specific IAS
entry. I've got some sample code doing that (you just use
IRLMP_IAS_QUERY).
        Then, you just use the IrDA address you get when you do an
connect(), as (struct sockaddr_irda *)->sir_addr. The Linux-IrDA stack
will figure by itself which serial port to use...

        Note that you will need to use a fairly recent version of the
Linux kernel (best bet is 2.2.15 or later), because in old versions
IRLMP_ENUMDEVICES and IRLMP_IAS_QUERY are broken.

> any thoughts? answers? they would be very much appreciated...
> 
> thanks,

        Good luck...

        Jean
_______________________________________________
Linux-IrDA mailing list  -  [EMAIL PROTECTED]
http://www.pasta.cs.UiT.No/mailman/listinfo/linux-irda

Reply via email to