Edit CUPS Filter source file to produce "beep" tone before printing

135 Views Asked by At

I have a Rongta RP326 printer which supports ESC/POS, it literally says that on the bottom of the printer.

I have this printer connected to a Raspberry Pi Model 4B.

The manufacturer of this receipt printer unfortunately does not have ARM linux drivers... but I was able to find this driver that works great: https://github.com/klirichek/zj-58 it has build instructions so though I don't know C and how programs are usually compiled...I was able to follow the instructions and get it compiled and working.

The paper cutting works fine (I haven't tested drawer because I don't have one but it might work fine since I can see printer options for it in printer properties)

What doesn't work is the "beep" that comes through whenever a print job is about to happen on the printer. This printer does support the beep because on Windows and MacOS it works just fine.

Through research I was able to find the ESC/POS command that needs to be sent to the printer for the beep.

However, I do not know any C programming so I'm literally stuck as to what to do and how to bring that ESC/POS command over to C code.

I have stumbled across the resources but unfortunately the block in the road is that I do not know C and I do not know the first step to taking what I'm seeing in the documentation links and transferring it to the filer's source file.

I tried editing the code to add the following lines:

static void sendBeep(int n, int t) {
  if (n >= 1 && n <= 9 && t >= 1 && t <= 9) {
    char beepCommand[] = "\x1B\x42";
    beepCommand[2] = n + '0'; // Convert n to ASCII
    beepCommand[3] = t + '0'; // Convert t to ASCII
    SendCommand(beepCommand);
  }
}

Then inside the "setupJob()" function, I added a line with sendBeep(3, 5);

That didn't work. I later realized that this was for changing the beep tone which I fed from the Rongta RP80 command set doc.

I then tried instead to use the following code:

static void soundBuzzer(int n, int c, int t) {
  if (n >= 0 && n <= 9 && c >= 1 && c <= 9 && t >= 0 && t <= 9) {
    // ESC/POS command to sound the buzzer
    char buzzerCommand[] = "\x1b\x28\x41\x04\x00\x30";
    buzzerCommand[6] = n + '0'; // Convert n to ASCII
    buzzerCommand[7] = c + '0'; // Convert c to ASCII
    buzzerCommand[8] = t + '0'; // Convert t to ASCII
    SendCommand(buzzerCommand);
  }
}

And added soundBuzzer(4, 3, 1); inside the setupJob() function body:

void setupJob() {
  SendCommand(escInit);
  if (settings.CashDrawer1 == 1)
    CashDrawerEject(0,settings.CashDrawer1On,settings.CashDrawer1Off);
  if (settings.CashDrawer2 == 1)
    CashDrawerEject(1, settings.CashDrawer2On, settings.CashDrawer2Off);  
  
  soundBuzzer(4, 3, 1);
}

That didn't make the beep sound either. Each time I've been deleting the filter from CUPS /usr/lib/cups/filter, recompiling it with the updated source, and then adding it back to the directory /usr/lib/cups/filter but can't get any beep still.

Any help in understanding this and getting it to work would be greatly appreciated

P.S I have posted an issue on the github repo for the driver I'm using but the repo seems to be abandoned though it still works fine: https://github.com/klirichek/zj-58/issues/49

0

There are 0 best solutions below