• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

JavaPOS - send packet to device..

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

I am working on integrating a device with my application. Its the Ingenico 6780. I have got all working except for one thing.
I am trying to make the device beep, when I open up certain forms.

From the device manufacturer I have been told that I have to send a packet directly to the device.
I am not completely sure how to do this.

I received the following from the manufacturer.
The OPOS directIO function signature is different from the JPOS one. In OPOS you would send arg0 as 0 and arg1 as the char array holding the packet. So my guess is to do the same for JPOS just set the object reference to null. The array might be in the wrong format however. It is possible that the byte array is correct and just needs to be put into a integer array (byte[0] becomes int[0] and so forth). However it might also be true that the data will have to be further packed to work correctly in JPOS (int[0] = (byte[0] << 32) | (byte[1] << 24) | (byte[2] << 16) | byte[3]; )

I have tried this, and the code I am using is at the end of this post, but it is not working.
controlForm.directIO(0, beep_packet(0xFFFFFF12, 0xFFFFFF02), null);
where beep_packet returns int[].

Am I using the correct function, or should I be using the RAW IO functionality. If you guys have any suggestions on how this might be done, it would be greatly appreciated.


public void sendBeepToDevice(){
try {
// When we run with below line, the application hangs as it's waiting for getting some response from
// Pin Pad
//controlForm.directIO(0x71, beep_packet(0xFFFFFF12, 0xFFFFFF02), controlForm);
controlForm.directIO(0, beep_packet(0xFFFFFF12, 0xFFFFFF02), null);
} catch (JposException e) {
// TODO Auto-generated catch block

public enum beep_duration {

public final int Value;
private beep_duration(int value) {
Value = value;
} //end constructor
} //end beep_duration

public enum beep_frequency {

public final int Value;
private beep_frequency(int value) {
Value = value;
} //end constructor
} //end beep_frequency

public int[] beep_packet(int duration, int frequency) {

ByteArrayOutputStream arr = new ByteArrayOutputStream(12);
int lrc = 0x05 ^ 12 ^ 0x85;


int temp = duration;
for(int i = 0; i < 4; ++i) {
temp >>= 8;
lrc ^= temp;
} //end for

temp = frequency;
for(int i = 0; i < 4; ++i) {
temp >>= 8;
lrc ^= temp;
} //end for

byte[] byteArr = arr.toByteArray();
int[] beep_packetArr = new int[1];
beep_packetArr[0] = (byteArr[0] << 32) | (byteArr[1] << 24) | (byteArr[2] << 16) | byteArr[3];
// Tried the below option to cobert from byte[] to int, but the same result
//beep_packetArr[0] = byteArrayToInt(byteArr,0);
return beep_packetArr;
} //end beep_packet

public int byteArrayToInt(byte[] b, int offset) {
int value = 0;
for (int i = 0; i < 4; i++) {
int shift = (4 - 1 - i) * 8;
value += (b[i + offset] & 0x000000FF) << shift;
return value;
That feels good. Thanks. Here's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic