2nd iteration for fixes
This commit is contained in:
@@ -103,6 +103,7 @@ const serialProtocol = {
|
|||||||
sourceHost: 0xFF, // SRC host/GUI
|
sourceHost: 0xFF, // SRC host/GUI
|
||||||
endOfFrame: 0x0D, // EOF
|
endOfFrame: 0x0D, // EOF
|
||||||
addressAny: 0x00, // DST = qualsiasi dispositivo (usato per discovery)
|
addressAny: 0x00, // DST = qualsiasi dispositivo (usato per discovery)
|
||||||
|
defaultDestinationAddress: 0x00, // DST UART usato da DataCOM: l'Addr del registro 1 e' il CAN Rx ID
|
||||||
headerLength: 5, // SOF + DST + SRC + 0x00 + DLEN
|
headerLength: 5, // SOF + DST + SRC + 0x00 + DLEN
|
||||||
tailLength: 3, // CHK_HI + CHK_LO + EOF
|
tailLength: 3, // CHK_HI + CHK_LO + EOF
|
||||||
// Comandi (scritti nel registro 2)
|
// Comandi (scritti nel registro 2)
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class MPPTReader extends EventEmitter {
|
|||||||
// Buffer di ricezione e transazione pendente (protocollo sincrono: 1 alla volta)
|
// Buffer di ricezione e transazione pendente (protocollo sincrono: 1 alla volta)
|
||||||
this.rxBuffer = Buffer.alloc(0);
|
this.rxBuffer = Buffer.alloc(0);
|
||||||
this.pendingTransaction = null;
|
this.pendingTransaction = null;
|
||||||
|
// Indirizzo DST usato sul protocollo UART. Il registro Addr identifica il CAN Rx ID;
|
||||||
|
// DataCOM e il test Python interrogano l'MPPT con DST=0x00.
|
||||||
|
this.uartDestinationAddress = serialProtocol.defaultDestinationAddress;
|
||||||
|
|
||||||
// Istanzia gli MPPT configurati (indicizzati per nome logico)
|
// Istanzia gli MPPT configurati (indicizzati per nome logico)
|
||||||
this.mppts = new Map();
|
this.mppts = new Map();
|
||||||
@@ -93,7 +96,8 @@ class MPPTReader extends EventEmitter {
|
|||||||
this.log(
|
this.log(
|
||||||
`[reader] configurazione: device=${this.device}, baudRate=${this.baudRate}, ` +
|
`[reader] configurazione: device=${this.device}, baudRate=${this.baudRate}, ` +
|
||||||
`pollIntervalMs=${this.pollIntervalMs}, timeoutMs=${this.timeoutMs}, retries=${this.retries}, ` +
|
`pollIntervalMs=${this.pollIntervalMs}, timeoutMs=${this.timeoutMs}, retries=${this.retries}, ` +
|
||||||
`dtr=${this.dtr}, rts=${this.rts}, mppts=${JSON.stringify(Array.from(this.mppts.values()).map((mppt) => ({
|
`dtr=${this.dtr}, rts=${this.rts}, uartDestinationAddress=${this.uartDestinationAddress}, ` +
|
||||||
|
`mppts=${JSON.stringify(Array.from(this.mppts.values()).map((mppt) => ({
|
||||||
name: mppt.name,
|
name: mppt.name,
|
||||||
address: mppt.address,
|
address: mppt.address,
|
||||||
})))}`
|
})))}`
|
||||||
@@ -263,7 +267,7 @@ class MPPTReader extends EventEmitter {
|
|||||||
for (const regAddr of pollRegisters) {
|
for (const regAddr of pollRegisters) {
|
||||||
try {
|
try {
|
||||||
this.log(`[reader] leggo MPPT ${mppt.name} address=${mppt.address} registro=${regAddr}`);
|
this.log(`[reader] leggo MPPT ${mppt.name} address=${mppt.address} registro=${regAddr}`);
|
||||||
const rawValue = await this._readRegister(mppt.address, regAddr);
|
const rawValue = await this._readRegister(this.uartDestinationAddress, regAddr);
|
||||||
this.log(`[reader] letto MPPT ${mppt.name} address=${mppt.address} registro=${regAddr} raw=${rawValue}`);
|
this.log(`[reader] letto MPPT ${mppt.name} address=${mppt.address} registro=${regAddr} raw=${rawValue}`);
|
||||||
mppt.updateRegister(regAddr, rawValue);
|
mppt.updateRegister(regAddr, rawValue);
|
||||||
updated = true;
|
updated = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user