Cash Box

iMin’s desktop series models all support direct access to the cash box. The cash box uses the RJ12 interface. Developers can control the cash box by sending data to the RJ12 interface; Developers can open the money box by sending instructions directly. The money box has two operations: opening the money box and checking the status of the money box.

Link Cash Box SDK downloads

  • Open the cash box

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    public void cmdGpioPwrOn() {
        String cmd = "echo 1 > /sys/class/neostra_gpioctl/dev/gpioctl " + "\n";
        try {
            Process exeEcho = Runtime.getRuntime().exec("sh");
            exeEcho.getOutputStream().write(cmd.getBytes());
            exeEcho.getOutputStream().flush();
            Log.i(TAG, " " + cmd);
        } catch (Exception e) {
            Log.i(TAG, "cmdGpioPwrOn faild");
            ((Button) findViewById(R.id.btn_Fail)).setVisibility(View.VISIBLE);
        }
    }
  • Check cash box status

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public void readStatus() {
        String cmd = "cat /sys/class/neostra_gpioctl/dev/gpioctl_sns" + "\n";
        ExeCommand exeCommand = new ExeCommand();
        status = exeCommand.run(cmd, 10000).getResult();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                selectStatusCount++;
                if (selectStatusCount == 1) {
                    statusValue = status.trim();
                }
                //0 is open ,1 is close
                if (!TextUtils.isEmpty(status) && status.trim().equals("0")) {
                    String value = String.format(getString(R.string.rj12_status), getString(R.string.open), getString(R.string.close));
                    int index = value.indexOf(getString(R.string.open), 0);
                    int lastIndex = getString(R.string.open).length();
                    SpannableStringBuilder ssb = new SpannableStringBuilder(value);
                    ssb.setSpan(new ForegroundColorSpan(Color.GREEN), index, lastIndex + index, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
                    statusText.setText(ssb);
                    if (!TextUtils.isEmpty(statusValue) && (!statusValue.equals("0") || isClose)) {
                        isOpen = true;//If the first entry is closed, it means that the money box was opened
                    }
                } else {
                    String value = String.format(getString(R.string.rj12_status), getString(R.string.close), getString(R.string.open));
                    int index = value.indexOf(getString(R.string.close), 0);
                    int lastIndex = getString(R.string.close).length();
                    SpannableString ssb = new SpannableString(value);
                    ssb.setSpan(new ForegroundColorSpan(Color.RED), index, lastIndex + index, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
                    statusText.setText(ssb);
                    if (!TextUtils.isEmpty(statusValue) && (statusValue.equals("0") || isOpen)) {
                        isClose = true; //If the first entry is opend, it means that the money box was closed
                    }
                }
                if (isOpen && isClose) {
                    ((Button) findViewById(R.id.btn_Pass)).setVisibility(View.VISIBLE);
                }
            }
        });
        exeCommand.closeStream();
    }