@enyo-energy/sunspec-sdk 0.0.30 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/sunspec-modbus-client.cjs +38 -35
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/sunspec-modbus-client.js +38 -35
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -230,6 +230,22 @@ class SunspecModbusClient {
|
|
|
230
230
|
}
|
|
231
231
|
// If custom base address provided, try it first (1-based, then 0-based variant)
|
|
232
232
|
if (customBaseAddress !== undefined) {
|
|
233
|
+
console.log(`Detect models for custom base address '${customBaseAddress}' ...`);
|
|
234
|
+
// Try 0-based at custom address
|
|
235
|
+
try {
|
|
236
|
+
const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress, 2);
|
|
237
|
+
if (sunspecId.includes('SunS')) {
|
|
238
|
+
console.log(`Detected 0-based addressing mode (base address: ${customBaseAddress})`);
|
|
239
|
+
return {
|
|
240
|
+
baseAddress: customBaseAddress,
|
|
241
|
+
isZeroBased: true,
|
|
242
|
+
nextAddress: customBaseAddress + 2
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.debug(`Could not read SunS at ${customBaseAddress}:`, error);
|
|
248
|
+
}
|
|
233
249
|
// Try 1-based at custom address (customBaseAddress + 1)
|
|
234
250
|
try {
|
|
235
251
|
const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress + 1, 2);
|
|
@@ -245,52 +261,39 @@ class SunspecModbusClient {
|
|
|
245
261
|
catch (error) {
|
|
246
262
|
console.debug(`Could not read SunS at ${customBaseAddress + 1}:`, error);
|
|
247
263
|
}
|
|
248
|
-
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
// Try 1-based addressing first (most common)
|
|
249
267
|
try {
|
|
250
|
-
const sunspecId = await this.modbusClient.readRegisterStringValue(
|
|
268
|
+
const sunspecId = await this.modbusClient.readRegisterStringValue(40001, 2);
|
|
251
269
|
if (sunspecId.includes('SunS')) {
|
|
252
|
-
console.log(
|
|
270
|
+
console.log('Detected 1-based addressing mode (base address: 40001)');
|
|
253
271
|
return {
|
|
254
|
-
baseAddress:
|
|
255
|
-
isZeroBased:
|
|
256
|
-
nextAddress:
|
|
272
|
+
baseAddress: 40001,
|
|
273
|
+
isZeroBased: false,
|
|
274
|
+
nextAddress: 40003
|
|
257
275
|
};
|
|
258
276
|
}
|
|
259
277
|
}
|
|
260
278
|
catch (error) {
|
|
261
|
-
console.debug(
|
|
279
|
+
console.debug('Could not read SunS at 40001:', error);
|
|
262
280
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
281
|
+
// Try 0-based addressing
|
|
282
|
+
try {
|
|
283
|
+
const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
|
|
284
|
+
if (sunspecId.includes('SunS')) {
|
|
285
|
+
console.log('Detected 0-based addressing mode (base address: 40000)');
|
|
286
|
+
return {
|
|
287
|
+
baseAddress: 40000,
|
|
288
|
+
isZeroBased: true,
|
|
289
|
+
nextAddress: 40002
|
|
290
|
+
};
|
|
291
|
+
}
|
|
274
292
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
console.debug('Could not read SunS at 40001:', error);
|
|
278
|
-
}
|
|
279
|
-
// Try 0-based addressing
|
|
280
|
-
try {
|
|
281
|
-
const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
|
|
282
|
-
if (sunspecId.includes('SunS')) {
|
|
283
|
-
console.log('Detected 0-based addressing mode (base address: 40000)');
|
|
284
|
-
return {
|
|
285
|
-
baseAddress: 40000,
|
|
286
|
-
isZeroBased: true,
|
|
287
|
-
nextAddress: 40002
|
|
288
|
-
};
|
|
293
|
+
catch (error) {
|
|
294
|
+
console.debug('Could not read SunS at 40000:', error);
|
|
289
295
|
}
|
|
290
296
|
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
console.debug('Could not read SunS at 40000:', error);
|
|
293
|
-
}
|
|
294
297
|
const addressesChecked = customBaseAddress !== undefined
|
|
295
298
|
? `${customBaseAddress}, ${customBaseAddress + 1}, 40000, or 40001`
|
|
296
299
|
: '40000 or 40001';
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -9,7 +9,7 @@ exports.getSdkVersion = getSdkVersion;
|
|
|
9
9
|
/**
|
|
10
10
|
* Current version of the enyo Energy App SDK.
|
|
11
11
|
*/
|
|
12
|
-
exports.SDK_VERSION = '0.0.
|
|
12
|
+
exports.SDK_VERSION = '0.0.31';
|
|
13
13
|
/**
|
|
14
14
|
* Gets the current SDK version.
|
|
15
15
|
* @returns The semantic version string of the SDK
|
package/dist/cjs/version.d.cts
CHANGED
|
@@ -227,6 +227,22 @@ export class SunspecModbusClient {
|
|
|
227
227
|
}
|
|
228
228
|
// If custom base address provided, try it first (1-based, then 0-based variant)
|
|
229
229
|
if (customBaseAddress !== undefined) {
|
|
230
|
+
console.log(`Detect models for custom base address '${customBaseAddress}' ...`);
|
|
231
|
+
// Try 0-based at custom address
|
|
232
|
+
try {
|
|
233
|
+
const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress, 2);
|
|
234
|
+
if (sunspecId.includes('SunS')) {
|
|
235
|
+
console.log(`Detected 0-based addressing mode (base address: ${customBaseAddress})`);
|
|
236
|
+
return {
|
|
237
|
+
baseAddress: customBaseAddress,
|
|
238
|
+
isZeroBased: true,
|
|
239
|
+
nextAddress: customBaseAddress + 2
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
console.debug(`Could not read SunS at ${customBaseAddress}:`, error);
|
|
245
|
+
}
|
|
230
246
|
// Try 1-based at custom address (customBaseAddress + 1)
|
|
231
247
|
try {
|
|
232
248
|
const sunspecId = await this.modbusClient.readRegisterStringValue(customBaseAddress + 1, 2);
|
|
@@ -242,52 +258,39 @@ export class SunspecModbusClient {
|
|
|
242
258
|
catch (error) {
|
|
243
259
|
console.debug(`Could not read SunS at ${customBaseAddress + 1}:`, error);
|
|
244
260
|
}
|
|
245
|
-
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// Try 1-based addressing first (most common)
|
|
246
264
|
try {
|
|
247
|
-
const sunspecId = await this.modbusClient.readRegisterStringValue(
|
|
265
|
+
const sunspecId = await this.modbusClient.readRegisterStringValue(40001, 2);
|
|
248
266
|
if (sunspecId.includes('SunS')) {
|
|
249
|
-
console.log(
|
|
267
|
+
console.log('Detected 1-based addressing mode (base address: 40001)');
|
|
250
268
|
return {
|
|
251
|
-
baseAddress:
|
|
252
|
-
isZeroBased:
|
|
253
|
-
nextAddress:
|
|
269
|
+
baseAddress: 40001,
|
|
270
|
+
isZeroBased: false,
|
|
271
|
+
nextAddress: 40003
|
|
254
272
|
};
|
|
255
273
|
}
|
|
256
274
|
}
|
|
257
275
|
catch (error) {
|
|
258
|
-
console.debug(
|
|
276
|
+
console.debug('Could not read SunS at 40001:', error);
|
|
259
277
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
278
|
+
// Try 0-based addressing
|
|
279
|
+
try {
|
|
280
|
+
const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
|
|
281
|
+
if (sunspecId.includes('SunS')) {
|
|
282
|
+
console.log('Detected 0-based addressing mode (base address: 40000)');
|
|
283
|
+
return {
|
|
284
|
+
baseAddress: 40000,
|
|
285
|
+
isZeroBased: true,
|
|
286
|
+
nextAddress: 40002
|
|
287
|
+
};
|
|
288
|
+
}
|
|
271
289
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
console.debug('Could not read SunS at 40001:', error);
|
|
275
|
-
}
|
|
276
|
-
// Try 0-based addressing
|
|
277
|
-
try {
|
|
278
|
-
const sunspecId = await this.modbusClient.readRegisterStringValue(40000, 2);
|
|
279
|
-
if (sunspecId.includes('SunS')) {
|
|
280
|
-
console.log('Detected 0-based addressing mode (base address: 40000)');
|
|
281
|
-
return {
|
|
282
|
-
baseAddress: 40000,
|
|
283
|
-
isZeroBased: true,
|
|
284
|
-
nextAddress: 40002
|
|
285
|
-
};
|
|
290
|
+
catch (error) {
|
|
291
|
+
console.debug('Could not read SunS at 40000:', error);
|
|
286
292
|
}
|
|
287
293
|
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
console.debug('Could not read SunS at 40000:', error);
|
|
290
|
-
}
|
|
291
294
|
const addressesChecked = customBaseAddress !== undefined
|
|
292
295
|
? `${customBaseAddress}, ${customBaseAddress + 1}, 40000, or 40001`
|
|
293
296
|
: '40000 or 40001';
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED