What could be causing the global variable to change when using the function write_ACK_ONLY()
? I'm passing the array rxUartBuffer
to write_ACK_ONLY()
as data = new Array(20)
, but upon checking the Log Output, it seems that the function is also modifying the rxUartBuffer
Code Section
console.log(this.toHexString(rxUartBuffer));
this.write_ACK_ONLY(rxUartBuffer)
console.log(this.toHexString(rxUartBuffer));
Log Output
aa|02|00|01|00|00|0b|00|00|00|00|00|00|00|00|00|00|01|1d|d5|
aa|02|00|01|00|40|0b|00|00|00|00|00|00|00|00|00|00|01|1d|d5|
Code
import {Module} from './module';
import {PCP} from './pcp';
import {Logic} from "./logic";
...
const SerialPort = require('serialport');
const Ready = require('@serialport/parser-ready');
const CRC = require('crc-full').CRC;
var gpio = require('rpi-gpio')
var gpiop = gpio.promise;
gpiop.setup(7, gpio.DIR_OUT);
export class RsBUS{
/*SERIAL*/
private port = new SerialPort('/dev/ttyS0', {
baudRate: 19200, dataBits: 8
});
...
}