Author Topic: Read / Write to a USB Printer  (Read 4841 times)

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Read / Write to a USB Printer
« on: December 09, 2008, 12:46:56 pm »
Hello,

I'm trying to read and write data to a USB printers so I presume the USBpipedemo is the best place to start.

On loading the project and running it, I can see my device in the first combo so I select it, in the second and thrird combos
I select the Pipe [2] IN endpoint and Pipe [1] OUT endpoint repectively.

I presume I then need to check the Active checkbox? When I try this the checkbox immediately unchecks itself.

looking at the code, nrUSB1.Active is never true. Does this mean my printer will not work with this component?
Have you any suggestions? 

  if CheckBox1.Checked then begin
      nrUSB1.Active := True;
      if nrUSB1.Active then begin
        nrUSBPipePair1.PipeIn := TnrUsbPipe(ePipeIn.Items.Objects[ePipeIn.ItemIndex]).Index;
        nrUSBPipePair1.PipeOut := TnrUsbPipe(ePipeOut.Items.Objects[ePipeOut.ItemIndex]).Index;
      end;


Thanks for your assistance

Chris Hedges

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #1 on: December 09, 2008, 12:52:19 pm »
Ok, I've trapped the exception

'USB device open is failed. Driver is unknown.'

doesn't sound good to me :(

The printer is installed but it shows as a HID device. Does this help at all?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Read / Write to a USB Printer
« Reply #2 on: December 09, 2008, 01:00:28 pm »
Hello

Please note that TnrUSBPipePair needs the WinUSB driver for work with your USB device.
The WinUSB driver should be installed instead the your origin USB device driver.

WinUSB driver is released by Microsoft and it can support not all USB devices.

If you want to work with HID device, I recommend to use other nrComm Lib component - TnrHID.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #3 on: December 09, 2008, 02:57:42 pm »
Hi Roman,

I've tried the HIDDemo project but my printer does not appear on the list of devices?
any ideas?

thanks again,

Chris

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Read / Write to a USB Printer
« Reply #4 on: December 09, 2008, 04:37:27 pm »
Hello

You wrote:

Quote
The printer is installed but it shows as a HID device

I'm sorry but I don't understand. Where do you see that printer is installed as HID device?
If you see your printer in HID device list in Windows Device Manager Tree,
then HIDDemod should show printer too.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #5 on: December 09, 2008, 05:20:59 pm »
Yes, I would have thought so too, but it does not unfortunately :(





Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Read / Write to a USB Printer
« Reply #6 on: December 09, 2008, 08:20:29 pm »
Hello Chris

Thank you for your information. It is very interesting :-)

Please, when you will have a time, download the following program:
http://www.deepsoftware.com/download/hiddemo.zip

I have prepared the special debug version of HIDDemo.
Please run and exit this EXE. After that you can find a log file in same folder.
Please show me this LOG file.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #7 on: December 10, 2008, 08:18:19 am »
thanks Roman, here is the log


[10/12/2008 08:17:55] nrComm Lib v8.19 Pro Windows XP [5.1.2600] Service Pack 3
[10/12/2008 08:17:55] Trying:{4D36E96F-E325-11CE-BFC1-08002BE10318}\0003
[10/12/2008 08:17:55] ... added.
[10/12/2008 08:17:55] Trying:{4D36E96B-E325-11CE-BFC1-08002BE10318}\0002
[10/12/2008 08:17:55] ... added.

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Read / Write to a USB Printer
« Reply #8 on: December 10, 2008, 10:43:03 am »
Hello

It seems interesting more and more :-)


Please, if you have time, open Device Manager, select problem device, open device properties and select "Details" tab.
I need following inforamtion:

"Device Instance Id"
"Service"
"Enumerator"
"Bus relations"

You can select needed parameter, click to list box (below) and use Ctrl+C for copy value into clipboard.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #9 on: December 11, 2008, 12:07:45 pm »
As Requested :)

"Device Instance Id"  USB\VID_0A43&PID_0201\0000176935
"Service"                 WinDriver
"Enumerator"            USB
"Bus relations"          blank?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Read / Write to a USB Printer
« Reply #10 on: December 11, 2008, 12:39:14 pm »
Hello

Thank you for information.

It seems like your printer is not HID device at all :-)

I don't understand why Device Manager shows it as HID Devices :-(

Roman Novgorodov
DeepSosftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #11 on: December 12, 2008, 10:25:13 am »
Thanks for your efforts Roman,

I think I will contact the manufacturer, perhaps there is some issue with
their driver or it is written in a non-standerd manner

:)

chedges

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
Re: Read / Write to a USB Printer
« Reply #12 on: January 08, 2009, 02:09:34 pm »
HI Roman,

I have finally got some firmware updates etc to allow my printer to be successfully "seen" by the nrComm HID demos.

I'm now looking for some resources that will explain how I should read and write data to and from the printer (I need to read the printer status).

Do you have any help files or even better a demo that would demonstrate the HID components usage. There appears to be no mention of the HID controls in the help file that ships with the nrComm eval version.

Thanks again,

Chris Hedges

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Read / Write to a USB Printer
« Reply #13 on: January 08, 2009, 07:38:41 pm »
Hi Chris

I glad that you have a small progress with your enigmatic device.

You can use HIDDemo project and see how it can read the incoming HID reports. Please select needed HID device and open it (click checkbox).
After that log will show all incoming bytes at bottom of application window.

If you want to write data, you can use TnrHID.SendChar(), TnrHID.SendString(), TnrHID.WriteReport() TnrHID.WriteFeature()
methods. Please note that a first byte of data is number of HID report.

Roman Novgordov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.