kybarg / ssp

Node.JS implementation of Encrypted Smiley ® Secure Protocol (eSSP, SSP)
MIT License
5 stars 1 forks source link

Error after READ_NOTE #7

Closed kolucciy closed 1 week ago

kolucciy commented 2 weeks ago

Hi, for some reason straight after READ_NOTE event I get ERROR with empty object. Any idea what it might be? If I test using ITL Validator Manager v 5.1.exe everything seems to be working as expected.

kybarg commented 2 weeks ago

@kolucciy please provide code example, also device model and protocl varsion you use

kolucciy commented 2 weeks ago
this.eSSP = new SSP({
      id: 0x00,
      debug: true,
      fixedKey: "0123456701234567",
});

this.serialPortConfig = {
      baudRate: 9600, // default: 9600
      dataBits: 8, // default: 8
      stopBits: 2, // default: 2
      parity: 'none', // default: 'none'
};

this.device = 'COM1';

async open() {
      await this.eSSP.open(this.device, this.serialPortConfig);
      await this.eSSP.command('SYNC');
      await this.eSSP.command('HOST_PROTOCOL_VERSION', { version: 6 });
      await this.eSSP.initEncryption();
      const serialNumberResult = await this.eSSP.command('GET_SERIAL_NUMBER');
      //console.log('ESSP SERIAL NUMBER:', serialNumberResult.info.serial_number);
      await this.eSSP.command('UNIT_DATA');
      const setupResult = await this.eSSP.command('SETUP_REQUEST');
      for (let i = 0; i < setupResult.info.channel_value.length; i++) {
        this.channels[i + 1] = {
          value: setupResult.info.expanded_channel_value[i],
          country_code: setupResult.info.expanded_channel_country_code[i],
        };
      }
      //console.log('ESSP channels', this.channels);
      const ch = Array(this.channels.length).fill(1);
      await this.eSSP.command('SET_CHANNEL_INHIBITS', { channels: ch });
      await this.eSSP.enable();
      this.emit('connected');
      this._startPolling();
}

async _startPolling () {
      this.eSSP.state.enabled = true
      if (!this.eSSP.state.polling) return this.eSSP.poll(true);
}

this.eSSP.on('READ_NOTE', (result) => {
      const denomination = this.channels[result.channel].value;
      if (denomination > 0) {
        console.log('ESSP READING NOTE', denomination)
      }
});

this.eSSP.on('NOTE_STACKED', () => {
      console.log('ESSP NOTE_STACKED');
});

this.eSSP.on('NOTE_STORED_IN_PAYOUT', () => {
      console.log('ESSP NOTE_STORED_IN_PAYOUT');
});

this.eSSP.on('ERROR', (err) => console.error(`ESSP Error: ${JSON.stringify(err)}`));

// Open the connection to the device
this.open();
kolucciy commented 2 weeks ago

Its NV9 Spectral dispenser

kybarg commented 2 weeks ago

@kolucciy and what error do you get?

kolucciy commented 2 weeks ago

That's what I have in the log:

...
ESSP READING NOTE 20
ESSP Error: {}

it should be:

...
ESSP READING NOTE 20
ESSP NOTE_STACKED

or

...
ESSP READING NOTE 20
ESSP NOTE_STORED_IN_PAYOUT

depending on the note insterted.

kybarg commented 1 week ago

In order to help i need more infromation

  1. device and protocol version
  2. code example
  3. raw logs (set DEBUG=ssp env varibale)
kybarg commented 1 week ago

@kolucciy also try viewing error without JSON.stringify as error might not have toString method

kolucciy commented 1 week ago

The issue can be closed, it was not related to the library, it was my code issue, sorry.