Is it possible to code a device driver in Java?

后端 未结 13 1245
猫巷女王i
猫巷女王i 2020-12-04 20:04

Introduction

I heard something about writing device drivers in Java (heard as in \"with my ears\", not from the internet) and was wondering... I always thought dev

13条回答
  •  情深已故
    2020-12-04 21:08

    A device driver could be a lot of things

    I actually write device drivers in java for a living: drivers for industrial devices, such as scales or weighing devices, packaging machines, barcode scanners, weighing bridges, bag and box printers, ... Java is a really good choice here.

    Industrial devices are very different from your home/office devices (e.g. scanners, printers). Especially in manufacturing (e.g. food), companies opt more and more for a centralized server which runs an MES application (e.g. developed in Java) The MES server needs to interface with the devices of the production line, but also contains business logic. Java is a language that can do both.

    Where your home/office devices are often built-in to your computer or connected with an USB cable, these industrial devices usually use Ethernet or RS232 connectors. So, in essence, pretty much every language could do the job.

    There is not much standardisation in this area yet. Most vendors prefer to create their own protocol for their devices. After all they are hardware builders, not software geniuses. The result is that there is a high diversity of protocols. Some vendors prefer simple plain-text protocols, but others prefer complex binary protocols with CRC codes, framing, ... Sometimes they like to stack multiple protocols (e.g. a vendor specific handshaking algorithm on top of an OPC layer). A strong OOP language has a lot of advantages here.

    E.g. I've seen java print at a continuous speed of 100ms/cycle. This includes generating a unique label, sending it to the printer, receiving a confirmation, printing it on paper and applying it to the product using air pressure.

    In summary, the power of java:

    • It is useful for both business logic as complex interfacing.
    • It is just as reliable in communication with sockets as C.
    • Some drivers can benifit from Java's OOP power.
    • Java is fast enough.

提交回复
热议问题