• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printer file concurrent access

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

I'm developing system,that often prints reports, and always is checking the status of printer (Low on paper, Out of paper etc...). I've implemented class, that queries printer file (/dev/usb/lp0) for status as written in printers (Swecoin TTP2030) manual, here is a code:



And out of my system this code works great. But when I integrate it in system, it starts to raise a lot of IOExceptions. I noticed that it happens when printer prints something, and in this moment I try to get status. Some times I get exception (File not found), and in this case I can check printer file like that - file.canWrite() But sometimes I can get exception (Device or resource busy) or (Input/Output error), and in this case file.canWrite() won't help. The worst thing is, that printer status enquirer not only throws exceptions, it can lock printer's file for some time. It still prints, but unavailable for enquirer.

Does exist a way to enquiry printer file while it's printing? Or maybe exists a way how to check if printer file is available. Please help!

P.S.: System is Ubuntu 12.10
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how to solve your problem but surely since the printer device is a serial device and not a block device one should not use RandomAccessFile !

PS. I print on Linux but I use the printer API and have few problems. I suspect you need more control than the printer API gives you.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
Nikolai Ghershun
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your fast answer.

Richard Tookey wrote:PS. I print on Linux but I use the printer API and have few problems. I suspect you need more control than the printer API gives you.



Richard, can you please describe in more details, what API you use, how, and what problems you are facing?

And also how to query serial device other way (not RandomAccessFile), because I tried simple input/output streams and they didn't work.

Thanks,
Nikolai.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The general approach for interfacing with a printer would be the javax.print package.
 
reply
    Bookmark Topic Watch Topic
  • New Topic