Pocket PC printing? IRDA, Bluetooth

R

RockDale

I have read all the post but still do not know where should start. My
Pocket PC application which coded by C#.net CF need to print report to
IrDA or bluetooth enabled printer (whichever works). Almost every post
says try the dll from http://www.fieldsoftware.com/. But unfortunately
we can not afford a 3rd party dll. Also some posts talked about this
hyperlink
http://www.innovativedss.com/forums/topic.asp?TOPIC_ID=83, which is no
longer accessable. The printer now we have is Canon iP90, so I am not
sure whether the package HP provided works or not. Anybody has some
sample code /hyperlink to point me the correct direction? Thanks a lot
 
G

Ginny Caughey [MVP]

I haven't worked with your particular printer, but many portable printers
can just take an ASCII stream with perhaps some printer control codes in it.
You can use ther serial class from www.opennetcf.org to send data out a
serial port. When you are testing this sort of thing, you may need to delay
(Sleep) a few milliseconds after each line of text you send to the printer.
You may also need to delay a bit before closing the serial port to get this
to work since printers are generally pretty slow compared to your processor.

Ginny Caughey
..NET Compact Framework MVP
 
R

rockdale.green

Hi, Ginny

Thanks for your reply. I was checking the www.opennetcf.org when I saw
your reply. I still have 2 more questions, how can I set which serial
number to use? I can know the inbound and outbound comm # of bluetooth
by check the configuration of bluetooth. But how can I know which
serial number is used by IrDA? And are IrDA and bluetooth make no
difference to my code since they both use serial port?

Thank you
-rockdale
 
R

rockdale.green

Hi, Ginny

I checked the above hyperlinks and downloaded a regedit freeware to
view my Registry from
http://www.phm.lu/Products/PocketPC/RegEdit/
(I guess there is no regedit on Windows CE, is it?)

HKEY_LOCAL_MACHINE\Drivers\BuildIn\IrDA
Here is the 12 Key names under the above dir
DevConfig
DeviceArrayIndex
DeviceType
Dll
FriendlyName
Index
IoBase
Irq
Order
Prefix
Tsp

But I have no idea which one is the serial # of IrDA. Is it the Index?

Also, can u tell me do I need to use IrClient like below post
suggested?
http://groups-beta.google.com/group...710?q=irda+port&rnum=6&hl=en#5a69a29d86d1f710

Do I need to find my printer ? if so , how. Or I only need to write to
the serial port with the printer control language and my
string-to-be-printed ?

Thank you very much
 
G

Ginny Caughey [MVP]

You shouldn't need to find your printer. Once you know which serial port it
is, you should just be able to write to that port.

I don't have any IrDA printers to test with, but the code sample looks good.
Have you tried it?

Ginny Caughey
..NET Compact Framework MVP
 
R

rockdale.green

Which sample are you talking. I tried the sample code from OpenNetCF
SerialCSharp code.
http://www.opennetcf.org/PermaLink.aspx?guid=0e593c58-7305-46d1-b8f8-9559152d5e1e
Nothing happened.

I can beam a doc file to my printer, it print the doc content with some
##@####@# characters. So I guess my printer is able to accept IrDA
signal.
I have 2 Pocket PC on hand.
I tried to to use the SerialCSharp send text from one PPC to Another ,
but nothing happen.

Or you have other sample code for me to refer. 2 days passed and no
progress, so frustrating.

Thanks
 
G

Ginny Caughey [MVP]

I was referring to the IrDAClient samples in the google link. I don't have a
printer to test them with myself.

Ginny
 
R

rockdale green

The IrDAClient could not find any IrDA devices even I have a IrDA
printer and another Pocket PC near itself.
 
R

rockdale green

Hi, Ginny
Hope you still follow this thread.

Following is my Code to find IrDa device and it works. But as you said,
i do not need to find the printer.
private string FindIrDADevice()
{
string name;
IrDAClient irdaClient = new IrDAClient();
Stream irStream;
IrDADeviceInfo[] irdaDevices;
irdaDevices = irdaClient.DiscoverDevices(2);
if ( irdaDevices.Length > 0 )
{ // get endpoint and connect to IrDA device
try
{
System.Net.IrDAEndPoint endP = new
System.Net.IrDAEndPoint(irdaDevices[0].DeviceID, "IrDA:IrCOMM");
irdaClient.Connect(endP);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString() + " thrown in openConnection");
}
irStream = irdaClient.GetStream();
name = irdaDevices[0].DeviceName.ToString();


}

else
name="No IrDA Devices Found";
irdaClient.Close();
return name;

}


So here is the code to write to serial port;
But nothing happened

private void btnPrint_Click(object sender, System.EventArgs e)
{

Port serialPort = new Port ("COM2:");

serialPort.DetailedSettings.OutCTS = false;
serialPort.DetailedSettings.OutDSR = false;
serialPort.DetailedSettings.DTRControl = DTRControlFlows.disable;
serialPort.DetailedSettings.DSRSensitive = false;
serialPort.DetailedSettings.TxContinueOnXOff = false;
serialPort.DetailedSettings.InX = false;
serialPort.DetailedSettings.OutX = false;
serialPort.DetailedSettings.ReplaceErrorChar = false;
serialPort.DetailedSettings.DiscardNulls = false;
serialPort.DetailedSettings.RTSControl = RTSControlFlows.disable;
serialPort.DetailedSettings.AbortOnError = false;
serialPort.Settings.BaudRate = BaudRates.CBR_9600;
serialPort.Settings.ByteSize = 8;
serialPort.Settings.Parity = Parity.none;
serialPort.Settings.StopBits = StopBits.one;

try
{
serialPort.Open();
}
catch(Exception ex )
{
MessageBox.Show ("Fail to Open Port: " + ex.Message.ToString());
}

String txtTx = "Some text to print";

if(serialPort.IsOpen)
{
byte[] outputData = new byte[1];
for(int i = 0 ; i < txtTx.Length ; i++)
{
outputData[0] = Convert.ToByte(txtTx);
serialPort.Output = outputData;
}
serialPort.Close();
}
}

Any thoughts?
 
G

Ginny Caughey [MVP]

Ok, we'll we're getting closer. Try appending carriage return and line feed
characters to the output data. I"ve worked with some printers that expected
that before they'd print anything. And the other thing to try is to insert
Sleep(500) after writing the data and before closing the port.

HTH,

Ginny
 
R

rockdale green

Thanks for your reply. Yeah, I guess we are closer thanks for your
guidance. I also tried write to comm6 which is the outbound port of
bluetooth on my Pocket PC. I can see the printer power light is
flushing, but still nothing happen. As for the carrige return or what
else, do they have some documentation about this kind of PCL or I have
to trial-and-fail by ourself? I will let u know what happen for carrige
return and sleep.

Thanks again
 
R

rockdale green

Thanks for your reply. Yeah, I guess we are closer thanks for your
guidance. I also tried write to comm6 which is the outbound port of
bluetooth on my Pocket PC. I can see the printer power light is
flushing, but still nothing happen. As for the carrige return or what
else, do they have some documentation about this kind of PCL or I have
to trial-and-fail by ourself? I will let u know what happen for carrige
return and sleep.

Thanks again
 
G

Ginny Caughey [MVP]

You should have some documentation that comes with your printer about the
PCL, but the delay is something I found out by accident. The printers I have
worked with take an input stream that defines the page size, sets the fonts,
etc., and the docs for your printer should provide this. But I found I also
had to delay, sometimes only 10 milliseconds, after sending each line of
text to get it to actually work. You might also need to send the EJECT code,
whatever that is for your printer, before you see anything useful. Now that
you've got the light flickering, it sounds like you've got the right port.
You might need to double check the baud, parity, etc., and remember that all
the data you send to these printers needs to be ASCII and not Unicode.

HTH,

Ginny Caughey
..NET Compact Framework MVP
 
R

rockdale green

Hi, Ginny:

Good news, now I can print with IrDA and BlueTooth. The IrDA failed is
because I used the wrong COM (I used 2 but actually it is 3). I find out
by testing these COMs one by one. For bluetooth, It suddenly works even
I did not add the carriage return and thread.sleep(5000). But I guess
the sleep is necessary to avoid lost data. Although I still have 3 more
questions:

1. I am using OpenNETCF.io.serial but I also find there is another
package OpenNETCF Bluetooth v1.4.50709 (
http://www.opennetcf.org/PermaLink.aspx?guid=3f99525a-d45f-4db1-bd24-2d8
8fe343d3f ). Should I change to this bluetooth or I can still use
current OpenNETCF.IO.Serial? Or they have another bluetooth package
because that one has more funcationality?

2. How can I change the font size of print out, I guess my current print
out uses the printer default font because I did not set any font
parameters.

3. I read from some post that said we can not print picture through this
approach - send stream to serail port. Is that true, if I want print
picture, what should I do.

Well, sorry about these questions, I need to know why so that I can give
them authorized reason when my boss ask "why cannot". Sometimes it is
hard for people to understand the Pocket PC is totally different from
Desktop. :)

Thank you very much

With best regards
-Rockdale
 
G

Ginny Caughey [MVP]

Congratulations! Sometimes working with printers involves some
experimentation.

For your first question, if you've got Bluetooth printing working with the
serial class, I'd stick with that. The documentation for your printer would
be the place to learn how to set different fonts. I haven't tried printing a
picture from a portable printer, but other simple serial devices I have used
(signature captrue devices) print pictures by sending it a bmp file. You
just need to check the printer documentation and see what is supported and
how.

Ginny Caughey
..NET Compact Framework MVP
 
C

chintan dhruva

Hi RockDale,

I read your post on
http://www.developersdex.com/vb/newmessage.asp?p=2916&ID=<1122312077%2
E823025%2E159900%40g47g2000cwa%2Egooglegroups%2Ecom%3E

I am facing a similar problem. I want to add printing feature in my
application and cannot afford third party dll.
I have also downloaded the HP SDK but the function

CreateJob (...) is giving me runtime error system.missingmethodexception
which is present in mPrintWrapper.dll .

I am badly stuck plz help me out with this problem.

Regards,
Chintan
 
C

chintan dhruva

Hi RockDale,

I read your post on
http://www.developersdex.com/vb/newmessage.asp?p=2916&ID=<1122312077%2
E823025%2E159900%40g47g2000cwa%2Egooglegroups%2Ecom%3E

I am facing a similar problem. I want to add printing feature in my
application and cannot afford third party dll.
I have also downloaded the HP SDK but the function

CreateJob (...) is giving me runtime error system.missingmethodexception
which is present in mPrintWrapper.dll .

I am badly stuck plz help me out with this problem.

Regards,
Chintan
 

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