setting IrDA Attributes

G

Guest

Hello,

How do I set up attributes for an IrDA device. I am trying to use
IrDA:IrCOMM as 9 Wire cooked.

I am using the following code:

private void Send_Click(object sender, System.EventArgs e)
{
try
{
irEndP = new IrDAEndPoint(irDevices[DeviceID].DeviceID,
"IrDA:IrCOMM");
irClient = new IrDAClient( irEndP );
}
catch( SocketException exS )
{
MessageBox.Show( "Create socket error: " + exS.Message );
return;
}

// Get the underlying stream of the client.
Stream irStream = irClient.GetStream();

irStream.Write( stringToByteArray(textBox1.Text), 0, textBox1.Text.Length );

// Display the number of bytes being sent.
statusBar1.Text = "Sending " + textBox1.Text.Length + " bytes";

irStream.Flush();
irStream.Close();
irClient.Close();
}

where irDevices[DeviceID].DeviceID is a previously discovered IrDA device

Thanks

Steve
 
G

Guest

Steve Spencer said:
How do I set up attributes for an IrDA device. I am trying to use
IrDA:IrCOMM as 9 Wire cooked.

I am using the following code:
irEndP = new IrDAEndPoint(irDevices[DeviceID].DeviceID,
"IrDA:IrCOMM");
irClient = new IrDAClient( irEndP );
[...]
Unfortunately Steve, there appears to be no way to select Cooked-mode IrCOMM
for IrDA connections in the Compact Framework. Bit of an omission
Microsoft... :-(

So you'll have to use native code. Or else use the IrCOMM Virtual COM Port
(assuming there is one). You lose some controllability that way: selection
of peers etc.
 
G

Guest

Alan,

thanks for this, you have confirmed my own thoughts.
So you'll have to use native code.
OK, Do you have any sample code that I could follow? Ideally I would like to
have everything as .NET so if you have any examples of this using PInvoke
that would be useful.

Unfortunately, we can only run in IrCOMM and 9pin cooked mode as we are
trying to use an Actisys IR100s serial to IR converter connected to the RS232
port of the hardware device we are trying to communicate with.

Regards

Steve
 
G

Guest

Steve Spencer said:
thanks for this, you have confirmed my own thoughts.

OK, Do you have any sample code that I could follow? Ideally I would like to
have everything as .NET so if you have any examples of this using PInvoke
that would be useful.
My expertise is only in the use of IrDA, and in particular on desktop
Windows, so others may have more useful help here...

Anyway see my programming reference for the complete details of IrDA through
Winsock, at
<http://www.alanjmcf.me.uk/comms/infrared/Microsoft Windows IrDA programming.html>,
sections 3.2, 4.9.3, etc. In short, use setsockopt with option
IRLMP_9WIRE_MODE to set Cooked mode. However that probably takes you deeply
into the native world...

It would be nice if some company would create an 'object' to use with .Net
that provides IrCOMM and IrLPT connectivity...


Also I'll note again, in case you missed it the first time, that there's
normally an IrCOMM Virtual COM Port present on PocketPC. One just uses it
like a normal serial port but it uses IrCOMM to talk to an IrDA peer; it does
all the discovery etc automatically. See
<http://msdn.microsoft.com/library/en-us/wceseril/html/cmconircomm.asp> etc.
I presume one can use it fine from .Net.

Unfortunately, we can only run in IrCOMM and 9pin cooked mode as we are
trying to use an Actisys IR100s serial to IR converter connected to the RS232
port of the hardware device we are trying to communicate with.
Yup, its maybe a bit of a shame that the device can't be set to listen on a
bog-standard (non-IrCOMM) TinyTP socket. :-(
 
G

Guest

Alan,

Thanks for this. I can now access the IR port using the virutal com port. In
fact it makes my code easier because I can now access both Bluetooth and IR
using serial communications on .NET CF.

Cheers

Steve
 
G

Guest

Did you get this to work?
I need to talk to a Microchip MCP215X which supports IRCOMM and "9-wire
cooked mode" so, having read this thread, I tried the virtual COM port:
however I'm still not getting anything past the chip.
Cheers
Nick
 
G

Guest

Nick,

I did get the virtual com port working. On my PDA I found the com port that
is associated with the IR and used the OpenNetCF SmartDevice Framework
(http://www.opennetcf.org/) to open the com port as you would for a standard
RS232 connection. Unfortunately I have not got any further with IR as we
decided it wasn't suitable for our application.

Steve
 
G

Guest

Thanks, Steve, but did you manage to write anything to the virtual COM Port
(and, more to the point, did the hardware see what you wrote)? After reading
your post I tried this (using Output=ByteArray) but the hardware is receiving
what I think I'm sending.
If you did manage to write then could you possibly post the settings you
used for the OpenNETCF.IO.Serial.Port? Or did you discard all your work on
this project in disgust?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top