The Java Fiscal Device API is a medium-level API to communicate with fiscal devices such as fiscal printers. It handles the communication protocol, the formatting and parsing of the protocol packets, and provides event-based notification for certain events such as out-of-paper events. It was made for Hasar printers (in use in Argentina and other countries) but also works fine with Epson printers after some small protocol differences were accommodated.
You can download the whole thing from here. It is provided under the GNU GPL license, see the included LICENSE.txt file for details.
com.taliter.fiscal.device.FiscalDeviceSource com.taliter.fiscal.device.FiscalDevice com.taliter.fiscal.device.FiscalPacket com.taliter.fiscal.device.FiscalDeviceEventHandlerand these classes encapsulate all the configuration options:
com.taliter.fiscal.device.hasar.HasarConstantsdefines some useful constants for Hasar printers. The documentation for these is written in spanish. If you are using another brand of printer it is up to you to check with the printer's manual, these constants may or may not be useful to you. Beware that some commands may produce irreversible changes to your printer, even to the point of rendering it useless, so read the manual carefully.
You may want to take a look into package
It contains tools that provide protocol and port speed autodetection,
as well as event and communication loggers that can assist you during development.
Finally, if you have not had enough, there is this pityful sample lying around.