API Reference
Here you will find the methods that you can use to interact with the Relay device.
Setters
Section titled “Setters”listenOnPort
Section titled “listenOnPort”Each device can have different configurations, for Relays port doesn’t matter
Warning
Better don’t use this
machine.listenOnPort = 1;serialFilters
Section titled “serialFilters”usbVendorId usbProductId are the filters that you can use to connect to the device
machine.serialFilters = [{ usbVendorId: 0x04d8, usbProductId: 0x0053}];serialConfigPort
Section titled “serialConfigPort”Warning
This is better don’t use once constructor was called
machine.serialConfigPort = { baudRate: 9600, dataBits: 8, stopBits: 1, parity: "none", bufferSize: 32768, flowControl: "none",}Getters
Section titled “Getters”listenOnPort
Section titled “listenOnPort”Address of the machine
console.log(machine.listenOnPort);serialFilters
Section titled “serialFilters”get the filters that apply when require a serial device
console.log(machine.serialFilters);serialConfigPort
Section titled “serialConfigPort”get the configuration of the serial port
console.log(machine.serialConfigPort);isConnected
Section titled “isConnected”Check if the machine is connected
console.log(machine.isConnected);isDisconnected
Section titled “isDisconnected”Check if the machine is disconnected
console.log(machine.isDisconnected);deviceNumber
Section titled “deviceNumber”Get the number of device, isn’t the same of the address.
Warning
Number of device is util if you have more than one machine in the same pc
console.log(machine.deviceNumber);Get the uuid of the connection
When you create a new instance of the class, the uuid is generated
console.log(machine.uuid);typeDevice
Section titled “typeDevice”Get the type of the device each class has a different type, in this case is relay
console.log(machine.typeDevice);Get the queue of commands that are waiting to be executed
console.log(machine.queue);isDispensing
Section titled “isDispensing”Check if the machine is dispensing
console.log(machine.isDispensing);balance
Section titled “balance”Get the balance of the hoppers
console.log(machine.balance);currentHopper
Section titled “currentHopper”Get the current hopper that is being used
console.log(machine.currentHopper);levels
Section titled “levels”Get the levels of the hoppers
console.log(machine.levels);Methods
Section titled “Methods”softReload
Section titled “softReload”Soft reload the machine
await machine.softReload();sendConnect
Section titled “sendConnect”Send connect to the machine
await machine.sendConnect();sendCustomCode
Section titled “sendCustomCode”Send custom code to the machine
await machine.sendCustomCode({code: ['00', '00', '00', '00', '00', '00', '00', '00', '00', '00']});setMaxCapacity
Section titled “setMaxCapacity”Set the maximum capacity of the hopper
machine.setMaxCapacity({hopper: 1, capacity: 1000});setHopperName
Section titled “setHopperName”Set the name of the hopper
machine.setHopperName({hopper: 1, name: '10 Pesos'});setHopperKey
Section titled “setHopperKey”Set the key of the hopper
machine.setHopperKey({hopper: 1, key: 'Hopper 1'});setHopperCurrency
Section titled “setHopperCurrency”Set the currency of the hopper
machine.setHopperCurrency({hopper: 1, currency: 10});requestStatus
Section titled “requestStatus”Request levels of the hoppers
await machine.requestStatus();readBalance
Section titled “readBalance”Read the balance of the hoppers
await machine.readBalance();clearBalance
Section titled “clearBalance”Clear the balance of the hoppers
await machine.clearBalance();forceInvalid
Section titled “forceInvalid”Force the machine to be invalid, this is useful only to test an invalid sintax error
await machine.forceInvalid();readHopper
Section titled “readHopper”Read the hopper levels
hopper: 1, 2, 3 or 4
await machine.readHopper({hopper: 1});writeHopper
Section titled “writeHopper”Write to the hopper levels
hopper: 1, 2, 3 or 4
quantity: amount of coins to write to the hopper max 32767
await machine.writeHopper({hopper: 1, quantity: 1000});dispenseHopper
Section titled “dispenseHopper”Dispense from the hopper
hopper: 1, 2, 3 or 4
await machine.dispenseHopper({hopper: 1});dispenseChange
Section titled “dispenseChange”Dispense change from the hopper
change: amount of change to dispense in pesos (MXN), max 32767
await machine.dispenseChange({change: 210});configValidator
Section titled “configValidator”Configure the validator of the hoppers
enable: true to enable the validator, false to disable it
await machine.configValidator({ enable: true });disableValidator
Section titled “disableValidator”Disable the validator of the hoppers
await machine.disableValidator();enableValidator
Section titled “enableValidator”Enable the validator of the hoppers
await machine.enableValidator();change1x1
Section titled “change1x1”return change 1 by 1
hopper: 1, 2, 3 or 4
await machine.change1x1({hopper: 1});