IrDA question again.

G

Guest

Hello all.
So slowly but surely I'm inching along with the project I'm currently
working on. Of course time is now running out quick and I have every part of
the application done except for the IrDA printing. I need to make sure once
and for all that the IrDA port on the printer is working correctly and it's
not something in any of my code.

Can someone supply me with the most basic stripped down code to; open the
IrDA port on the ce.net 4.2 device, establish connection to the printer and
send it a single string of text.

From my understanding of this Zebra Cameo 2 printer that should be all
that is required to print to it. Of course my code is a bit more complex than
what I requested above but I'm not 100% sure that my code is correct and this
is an easier route than posting my code for everyone to analyze. :)

Thanks a lot!

Regards,
-Tony Kirk
 
G

Guest

:
[...]
Can someone supply me with the most basic stripped down code to; open the
IrDA port on the ce.net 4.2 device, establish connection to the printer and
send it a single string of text.
http://groups.google.co.uk/group/mi...ompactframework&rnum=1&hl=en#1251d23396df97c0
and the earlier thread it links to. :-(

There's some possibility that the printer might support 9-wire (i.e. Cooked)
IrCOMM as well as IrLPT, if so then one could also use the IrCOMM Virtual COM
Port...
 
G

Guest

I guess all of us here trying to get IrDA printing working are going off the
same code from the same places :) Below is the portion of code that I'm using
to try to get a connection. While trying to set up a new endpoint connection
I've used every service name I could find in every description I've read on
how to connect to a printer using IrDA. None of them work. I can actually see
the printer. When I print out the device name, ID, character set, etc I
actually get the correct info for the Zebra printer. But then I get an error
that says;

"No connection could be made because the target machine actively refused it."

The answer to my next question is usually no, but I have to try. Is there
any way I can get *any* more information about that? An additional error or a
description somewhere for the possibilties of why that might be? I'm not sure
if the printer is wanting something else from me when I try to connect or if
the printer's IrDA port is broken.

Here is my code. You've seen it before :)

'--- BEGIN CODE ---
Dim irdaClient As New System.Net.Sockets.IrDAClient()
Dim irStream As System.IO.Stream
Dim irdaDevices() As System.Net.Sockets.IrDADeviceInfo
irdaDevices = irdaClient.DiscoverDevices(10)

If irdaDevices.Length > 0 Then
Try
Dim endP As New System.Net.IrDAEndPoint(irdaDevices(0).DeviceID(),
"IrDA:IrCOMM")
irdaClient.Connect(endP)
Catch ex As Exception
MessageBox.Show(ex.Message.ToString & " : thrown in cmdPrint_Click()")
End Try
irStream = irdaClient.GetStream
msgbox(irdaDevices(0).DeviceName().ToString())
Else
msgbox("No IrDA Devices Found")
End If
'--- END CODE ---


Regards,
-Tony


Alan J. McFarlane said:
:
[...]
Can someone supply me with the most basic stripped down code to; open the
IrDA port on the ce.net 4.2 device, establish connection to the printer and
send it a single string of text.
http://groups.google.co.uk/group/mi...ompactframework&rnum=1&hl=en#1251d23396df97c0
and the earlier thread it links to. :-(

There's some possibility that the printer might support 9-wire (i.e. Cooked)
IrCOMM as well as IrLPT, if so then one could also use the IrCOMM Virtual COM
Port...
 
A

Alan J. McFarlane

I guess all of us here trying to get IrDA printing working are going
off the same code from the same places :) Below is the portion of
code that I'm using to try to get a connection. While trying to set
up a new endpoint connection I've used every service name I could
find in every description I've read on how to connect to a printer
using IrDA. None of them work. I can actually see the printer. When I
print out the device name, ID, character set, etc I actually get the
correct info for the Zebra printer. But then I get an error that says;
[/QUOTE]
Well if you've read previous posts of mine you'll have read that its not
possible to do this. You can try different service names until the cows
come home but it'll not work. As I've noted many times, IrLPT uses
IrLMP mode, but IrDAClient always uses TinyTP!

So, when you ask IrDAClient to connect, it looks in the peer's IAS
database for a tuple of the form (serviceName, type=TinyTP, port#=?),
but there's no such entry, the only entry is one of the form ("IrLPT",
type=IrLMP, port#=X).

If you take the example IrLPT client from my website and compile and run
it (verbatim on your PC, or modified to suit PocketPC) I bet it'll
connect straight away... *It* uses IrLMP mode i.e. IRLMP_IRLPT_MODE.
(http://www.alanjmcf.me.uk/comms/infrared/irdaWinsockCliIrLpt.c.html)

At the moment your only options are to create some native code to do
this, or to use some third-party library.

(If the printer happens to support IrCOMM 9-wire mode, which is not
likely, then that requires the mode called IRLMP_9WIRE_MODE, which
IrDAClient doesn't support either. Why do I feel I've explained all of
this before...)
--
Alan J. McFarlane
http://www.alanjmcf.me.uk/
Please follow-up in the newsgroup for the benefit of all.

Alan J. McFarlane said:
:
[...]
Can someone supply me with the most basic stripped down code to;
open the IrDA port on the ce.net 4.2 device, establish connection
to the printer and send it a single string of text.
http://groups.google.co.uk/group/mi...ompactframework&rnum=1&hl=en#1251d23396df97c0
and the earlier thread it links to. :-(

There's some possibility that the printer might support 9-wire (i.e.
Cooked) IrCOMM as well as IrLPT, if so then one could also use the
IrCOMM Virtual COM Port...
 
A

Alan J. McFarlane

I've had a chat with Peter Foot and it turns out that there now is a
way! :) He has created a library called 32feet.NET, which implements
equivalents to the IrDAClient and all the related objects from the
Compact Frameworks but works on desktop too. He also follows the
pattern of TcpClient in v2 and provides access to the underlying socket,
and one can then set socket options on it. Get the library from,
http://32feet.net/

So take any IrDAClient code, change the 'using' to
InTheHand.Net.Sockets, add a reference to the library, then add code
that does:
cli.Client.SetSocketOption(
(SocketOptionLevel)IrDASocketOptionLevel.IrLmp,
(SocketOptionName)IrDASocketOptionName.IrLptMode,
true);

I've put a sample (command-line) IrLPT client using the library up on my
website, at
http://www.alanjmcf.me.uk/comms/infrared/irdaDotNetCliIrLpt.cs.html

I've no CE device, so I've only tested it on XP, so reports from other
platforms are very welcome.

(BTW it you've problems with the library's installer, before canceling
the install, quickly copy the Assembly folder to reference in the your
project).


[...]
Can someone supply me with the most basic stripped down code to;
open the IrDA port on the ce.net 4.2 device, establish connection
to the printer and send it a single string of text.
[/QUOTE][/QUOTE] [...]
Well if you've read previous posts of mine you'll have read that its
not
possible to do this. You can try different service names until the
cows
come home but it'll not work. As I've noted many times, IrLPT uses
IrLMP mode, but IrDAClient always uses TinyTP! [...]
If you take the example IrLPT client from my website and compile and
run it (verbatim on your PC, or modified to suit PocketPC) I bet it'll
connect straight away... *It* uses IrLMP mode i.e. IRLMP_IRLPT_MODE.
(http://www.alanjmcf.me.uk/comms/infrared/irdaWinsockCliIrLpt.c.html)

At the moment your only options are to create some native code to do
this, or to use some third-party library.
[/QUOTE]
As above, set socket option IrDASocketOptionName.IrLptMode.
(If the printer happens to support IrCOMM 9-wire mode, which is not
likely, then that requires the mode called IRLMP_9WIRE_MODE, which
IrDAClient doesn't support either. Why do I feel I've explained all
of this before...)
Ditto, but with socket option IrDASocketOptionName.NineWireMode.
 

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