Using IrDA sockets

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

Hi,

I'm trying to directly use sockets to establish a
connection over IrDA. My current problem is that I don't
know how to create a local endpoint to which I will bind
the socket. I'm assuming that I should use the
IrDAEndPoint implementation. However, I have no idea what
to give as the arguments to this constructor, which takes
and array of bytes and a string. I suspected that the
IrDADeviceInfo class might be useful, but this class has
NO public constructor. Neither class has any public
static instances either. Does anyone know how to do this?

Thanks in advance,
Jon
 
Hi Jon,
I'm trying to directly use sockets to establish a connection over IrDA.
My current problem is that I don't
know how to create a local endpoint to which I will bind
the socket. I'm assuming that I should use the
IrDAEndPoint implementation. However, I have no idea what
to give as the arguments to this constructor, which takes
and array of bytes and a string. I suspected that the
IrDADeviceInfo class might be useful, but this class has
NO public constructor. Neither class has any public
static instances either. Does anyone know how to do this?

There are several ways. Here is one of them.

// Create an instance of IrDAClient
IrDAClient irClient = new IrDAClient();

// Discover upto, say, five devices
IrDADeviceInfo[] irDevices = irClient .DiscoverDevices(5);

// Now you have an array of IrDADeviceInfo objects.
// Use the device id overload to create the end point
IrDAEndPoint endPt = new IrDAEndPoint(irDevices[0].DeviceID, "IrDA:IrCOMM");

This should provide enough hints to use alternate ways to accomplish the
same thing.

Cheers,
Sarat Venugopal
Huelix Solutions
www.huelix.com

*Remove '_ng' and 'n0spam' from the email id to reply directly
 
Hi Sarat,

Thanks for responding to my post. However, I'm still
having problems. I had actually already tried what
suggested (purely a guess because there's no
documentation), and when I test run my code, I get an
ArrayIndexOutOfRangeException on the line:

IrDAEndPoint endPt = new IrDAEndPoint(irDevices
[0].DeviceID, "IrDA:IrCOMM");

which is implied by the fact that my visual studio
debugger shows that the array irDevices is of length 0.
I'm guessing that this is because the IrDAClient has no
connections. Thus I can't get device info unless I
already have an IrDA connection, and even if I did, I'm
not so sure I'd get the device info for the local device.
I want local device info because I want a socket that
accepts incoming connections.

Any more ideas on what I should do?

-Jon
-----Original Message-----
Hi Jon,
I'm trying to directly use sockets to establish a connection over IrDA.
My current problem is that I don't
know how to create a local endpoint to which I will bind
the socket. I'm assuming that I should use the
IrDAEndPoint implementation. However, I have no idea what
to give as the arguments to this constructor, which takes
and array of bytes and a string. I suspected that the
IrDADeviceInfo class might be useful, but this class has
NO public constructor. Neither class has any public
static instances either. Does anyone know how to do
this?

There are several ways. Here is one of them.

// Create an instance of IrDAClient
IrDAClient irClient = new IrDAClient();

// Discover upto, say, five devices
IrDADeviceInfo[] irDevices = irClient .DiscoverDevices(5);

// Now you have an array of IrDADeviceInfo objects.
// Use the device id overload to create the end point
IrDAEndPoint endPt = new IrDAEndPoint(irDevices [0].DeviceID, "IrDA:IrCOMM");

This should provide enough hints to use alternate ways to accomplish the
same thing.

Cheers,
Sarat Venugopal
Huelix Solutions
www.huelix.com

*Remove '_ng' and 'n0spam' from the email id to reply directly


.
 
You are supposed to get IrDADeviceInfo[] array from
IrDAClient.DiscoverDevices as Sarat points out in his code sample.
If you did not, it means that there was no other device in vicinity. In my
experience IrDAClient.DiscoverDevices sometimes did not workk with some
devices, so I resorted to PInvoking the equivalent API functions.

Jon said:
Hi Sarat,

Thanks for responding to my post. However, I'm still
having problems. I had actually already tried what
suggested (purely a guess because there's no
documentation), and when I test run my code, I get an
ArrayIndexOutOfRangeException on the line:

IrDAEndPoint endPt = new IrDAEndPoint(irDevices
[0].DeviceID, "IrDA:IrCOMM");

which is implied by the fact that my visual studio
debugger shows that the array irDevices is of length 0.
I'm guessing that this is because the IrDAClient has no
connections. Thus I can't get device info unless I
already have an IrDA connection, and even if I did, I'm
not so sure I'd get the device info for the local device.
I want local device info because I want a socket that
accepts incoming connections.

Any more ideas on what I should do?

-Jon
-----Original Message-----
Hi Jon,
I'm trying to directly use sockets to establish a connection over IrDA.
My current problem is that I don't
know how to create a local endpoint to which I will bind
the socket. I'm assuming that I should use the
IrDAEndPoint implementation. However, I have no idea what
to give as the arguments to this constructor, which takes
and array of bytes and a string. I suspected that the
IrDADeviceInfo class might be useful, but this class has
NO public constructor. Neither class has any public
static instances either. Does anyone know how to do
this?

There are several ways. Here is one of them.

// Create an instance of IrDAClient
IrDAClient irClient = new IrDAClient();

// Discover upto, say, five devices
IrDADeviceInfo[] irDevices = irClient .DiscoverDevices(5);

// Now you have an array of IrDADeviceInfo objects.
// Use the device id overload to create the end point
IrDAEndPoint endPt = new IrDAEndPoint(irDevices [0].DeviceID, "IrDA:IrCOMM");

This should provide enough hints to use alternate ways to accomplish the
same thing.

Cheers,
Sarat Venugopal
Huelix Solutions
www.huelix.com

*Remove '_ng' and 'n0spam' from the email id to reply directly


.
 
Hi,

I suppose I should describe what I'm trying to do. I want
to make a socket that can accept a connection from the
IrDA port asynchronously, without blocking, and without
starting my own seperate thread. I have done this with a
tcp socket using the BeginAccept method. I want to do the
same thing with an IrDA socket. However, I have no
EndPoint to bind the socket to before its starts
listening. When using a tcp socket, I could simply bind
it to any port on the host machine. Is it even possible
to do what I'm asking? Or are IrDA connections too
different from TCP connections?

Thanks again,
Jon
-----Original Message-----
You are supposed to get IrDADeviceInfo[] array from
IrDAClient.DiscoverDevices as Sarat points out in his code sample.
If you did not, it means that there was no other device in vicinity. In my
experience IrDAClient.DiscoverDevices sometimes did not workk with some
devices, so I resorted to PInvoking the equivalent API functions.

Jon said:
Hi Sarat,

Thanks for responding to my post. However, I'm still
having problems. I had actually already tried what
suggested (purely a guess because there's no
documentation), and when I test run my code, I get an
ArrayIndexOutOfRangeException on the line:

IrDAEndPoint endPt = new IrDAEndPoint(irDevices
[0].DeviceID, "IrDA:IrCOMM");

which is implied by the fact that my visual studio
debugger shows that the array irDevices is of length 0.
I'm guessing that this is because the IrDAClient has no
connections. Thus I can't get device info unless I
already have an IrDA connection, and even if I did, I'm
not so sure I'd get the device info for the local device.
I want local device info because I want a socket that
accepts incoming connections.

Any more ideas on what I should do?

-Jon
-----Original Message-----
Hi Jon,

I'm trying to directly use sockets to establish a connection over IrDA.
My current problem is that I don't
know how to create a local endpoint to which I will bind
the socket. I'm assuming that I should use the
IrDAEndPoint implementation. However, I have no idea what
to give as the arguments to this constructor, which takes
and array of bytes and a string. I suspected that the
IrDADeviceInfo class might be useful, but this class has
NO public constructor. Neither class has any public
static instances either. Does anyone know how to do this?

There are several ways. Here is one of them.

// Create an instance of IrDAClient
IrDAClient irClient = new IrDAClient();

// Discover upto, say, five devices
IrDADeviceInfo[] irDevices = irClient .DiscoverDevices (5);

// Now you have an array of IrDADeviceInfo objects.
// Use the device id overload to create the end point
IrDAEndPoint endPt = new IrDAEndPoint(irDevices [0].DeviceID, "IrDA:IrCOMM");

This should provide enough hints to use alternate ways
to
accomplish the
same thing.

Cheers,
Sarat Venugopal
Huelix Solutions
www.huelix.com

*Remove '_ng' and 'n0spam' from the email id to reply directly


.


.
 
Let me describe what we're trying to do here (different situation): we've
been using a system developed for six years now... it runs on an HP 200LX
handheld and uses a small calculator printer named HP82240B (redeye
infrared). Now we're starting to develop the system upgrade from Clipper to
..Net CF (VB.Net) and we're gonna have to replace the handhelds for new ones
but there's no reason not to reuse the printers.

The problem is that this printer does not communicate using the IRDa, so I
tried to send the characters through the COM port of the Infrared,
unsuccesfully, though; so, does anyone how can I control the infrared port
in a low level way (or any other), time the lightning and shade of the led
and so on? We were able to do that through assembler, connecting a
electronic circuit in the speaker jumper and timing the on 'n off of the
led...

Tks,

Arnaldo.


Alex Feinman said:
You are supposed to get IrDADeviceInfo[] array from
IrDAClient.DiscoverDevices as Sarat points out in his code sample.
If you did not, it means that there was no other device in vicinity. In my
experience IrDAClient.DiscoverDevices sometimes did not workk with some
devices, so I resorted to PInvoking the equivalent API functions.

Jon said:
Hi Sarat,

Thanks for responding to my post. However, I'm still
having problems. I had actually already tried what
suggested (purely a guess because there's no
documentation), and when I test run my code, I get an
ArrayIndexOutOfRangeException on the line:

IrDAEndPoint endPt = new IrDAEndPoint(irDevices
[0].DeviceID, "IrDA:IrCOMM");

which is implied by the fact that my visual studio
debugger shows that the array irDevices is of length 0.
I'm guessing that this is because the IrDAClient has no
connections. Thus I can't get device info unless I
already have an IrDA connection, and even if I did, I'm
not so sure I'd get the device info for the local device.
I want local device info because I want a socket that
accepts incoming connections.

Any more ideas on what I should do?

-Jon
-----Original Message-----
Hi Jon,

I'm trying to directly use sockets to establish a connection over IrDA.
My current problem is that I don't
know how to create a local endpoint to which I will bind
the socket. I'm assuming that I should use the
IrDAEndPoint implementation. However, I have no idea what
to give as the arguments to this constructor, which takes
and array of bytes and a string. I suspected that the
IrDADeviceInfo class might be useful, but this class has
NO public constructor. Neither class has any public
static instances either. Does anyone know how to do this?

There are several ways. Here is one of them.

// Create an instance of IrDAClient
IrDAClient irClient = new IrDAClient();

// Discover upto, say, five devices
IrDADeviceInfo[] irDevices = irClient .DiscoverDevices(5);

// Now you have an array of IrDADeviceInfo objects.
// Use the device id overload to create the end point
IrDAEndPoint endPt = new IrDAEndPoint(irDevices [0].DeviceID, "IrDA:IrCOMM");

This should provide enough hints to use alternate ways to accomplish the
same thing.

Cheers,
Sarat Venugopal
Huelix Solutions
www.huelix.com

*Remove '_ng' and 'n0spam' from the email id to reply directly


.
 
Back
Top