BK9050
ptorrent opened this issue · comments
Hello,
I'm trying to connect to BK9050.
Without bareClient actived this is what I got during the connecting process:
04-09-2023 15:23:12.862 > error > ads_24 > { ClientException: Connection failed: Device system manager state read failed
04-09-2023 15:23:12.862 > error > ads_24 > at Socket.socket.once (/node_modules/ads-client/src/ads-client.js:3425:25)
04-09-2023 15:23:12.862 > error > ads_24 > at <anonymous>
04-09-2023 15:23:12.862 > error > ads_24 > name: 'ClientException',
04-09-2023 15:23:12.862 > error > ads_24 > sender: '_connect()',
04-09-2023 15:23:12.862 > error > ads_24 > adsError: true,
04-09-2023 15:23:12.862 > error > ads_24 > adsErrorInfo:
04-09-2023 15:23:12.862 > error > ads_24 > { adsErrorType: 'AMS error',
04-09-2023 15:23:12.862 > error > ads_24 > adsErrorCode: 8,
04-09-2023 15:23:12.862 > error > ads_24 > adsErrorStr: 'Unknown command ID' },
04-09-2023 15:23:12.862 > error > ads_24 > metaData: null,
04-09-2023 15:23:12.862 > error > ads_24 > errorTrace:
04-09-2023 15:23:12.862 > error > ads_24 > [ 'readSystemManagerState(): Device system manager state read failed',
04-09-2023 15:23:12.862 > error > ads_24 > '_sendAdsCommand(): Response with AMS error received' ],
04-09-2023 15:23:12.862 > error > ads_24 > getInnerException: [Function] }
04-09-2023 15:23:12.921 > error > ads_24 > { ClientException: Connection failed: Device system manager state read failed
04-09-2023 15:23:12.921 > error > ads_24 > at Socket.socket.once (/node_modules/ads-client/src/ads-client.js:3425:25)
04-09-2023 15:23:12.921 > error > ads_24 > at <anonymous>
04-09-2023 15:23:12.921 > error > ads_24 > name: 'ClientException',
04-09-2023 15:23:12.921 > error > ads_24 > sender: '_connect()',
04-09-2023 15:23:12.921 > error > ads_24 > adsError: true,
04-09-2023 15:23:12.921 > error > ads_24 > adsErrorInfo:
04-09-2023 15:23:12.921 > error > ads_24 > { adsErrorType: 'AMS error',
04-09-2023 15:23:12.921 > error > ads_24 > adsErrorCode: 8,
04-09-2023 15:23:12.921 > error > ads_24 > adsErrorStr: 'Unknown command ID' },
04-09-2023 15:23:12.921 > error > ads_24 > metaData: null,
04-09-2023 15:23:12.921 > error > ads_24 > errorTrace:
04-09-2023 15:23:12.921 > error > ads_24 > [ 'readSystemManagerState(): Device system manager state read failed',
04-09-2023 15:23:12.921 > error > ads_24 > '_sendAdsCommand(): Response with AMS error received' ],
04-09-2023 15:23:12.921 > error > ads_24 > getInnerException: [Function] }
By setting bareClient to true, it seems able to connect to the device but right after the connection, I got this error:
04-09-2023 15:25:23.175 > error > ads_24 > RangeError: Index out of range
04-09-2023 15:25:23.175 > error > ads_24 > at checkOffset (buffer.js:977:11)
04-09-2023 15:25:23.175 > error > ads_24 > at Buffer.readUInt32LE (buffer.js:1039:5)
04-09-2023 15:25:23.175 > error > ads_24 > at Client._parseAdsData (/node_modules/ads-client/src/ads-client.js:6049:29)
04-09-2023 15:25:23.175 > error > ads_24 > at Client._parseAmsTcpPacket (/node_modules/ads-client/src/ads-client.js:5875:55)
04-09-2023 15:25:23.175 > error > ads_24 > at runCallback (timers.js:810:20)
04-09-2023 15:25:23.175 > error > ads_24 > at tryOnImmediate (timers.js:768:5)
04-09-2023 15:25:23.175 > error > ads_24 > at processImmediate [as _immediateCallback] (timers.js:745:5)
04-09-2023 15:25:23.208 > error > ads_24 > RangeError: Index out of range
04-09-2023 15:25:23.208 > error > ads_24 > at checkOffset (buffer.js:977:11)
04-09-2023 15:25:23.208 > error > ads_24 > at Buffer.readUInt32LE (buffer.js:1039:5)
04-09-2023 15:25:23.208 > error > ads_24 > at Client._parseAdsData (/node_modules/ads-client/src/ads-client.js:6049:29)
04-09-2023 15:25:23.208 > error > ads_24 > at Client._parseAmsTcpPacket (/node_modules/ads-client/src/ads-client.js:5875:55)
04-09-2023 15:25:23.208 > error > ads_24 > at runCallback (timers.js:810:20)
04-09-2023 15:25:23.208 > error > ads_24 > at tryOnImmediate (timers.js:768:5)
04-09-2023 15:25:23.208 > error > ads_24 > at processImmediate [as _immediateCallback] (timers.js:745:5)
This is happending when I try to read this register: group:16416 offset:2 length:1
Do you know why I get this error ?
Thanks for your help !
For your information, I'm using an export of symbols:
<PlcProjectInfo>
<RoutingInfo>
<AdsInfo>
<NetId>192.168.1.232.1.1</NetId>
<Port>100</Port>
</AdsInfo>
</RoutingInfo>
<Symbols>
<Symbol>
<Name>KL6781-0000_1_Channel_1.State</Name>
<Type>UINT</Type>
<IGroup>61472</IGroup>
<IOffset>0</IOffset>
<BitSize>16</BitSize>
</Symbol>
...
I'm trying to subscribe to the symbole name and I got this error "Index out of range".
So I tried to get raw value with groupIndex and offset but same error !
The result of a read is: (buffer is the value, USINT is the datatype from export )
04-09-2023 20:15:58.997 > error > ads_24 > <Buffer 00> USINT
04-09-2023 20:15:58.997 > error > ads_24 > <Buffer 00> USINT
04-09-2023 20:15:59.009 > error > ads_24 > <Buffer 00> USINT
04-09-2023 20:15:59.009 > error > ads_24 > <Buffer 00> USINT
client.readRaw(61472,0,2).then(function(res){
console.error(res,'UINT')
client.convertFromRaw(res, 'UINT').then(function(value){
}).catch(function(err){
})
}).catch(function(err){
})
The issue seems coming from "convertFromRaw"
Could you please show the Node.js code you are using with connection settings?
Quickly looking the port could be also 300 (https://download.beckhoff.com/download/document/io/bus-terminals/bk9000_bk9050_bk9100en.pdf):
Edit: And yes most probably these BK systems have no system manager so bareClient
is the correct/only option.
Thanks for your answer, this is my settings:
var settings = {
localAmsNetId: '192.168.1.110.1.1',
localAdsPort: 32905,
targetAmsNetId: '192.168.1.232.1.1',
targetAdsPort: 300,
allowHalfOpen: true,
bareClient: true,
readAndCacheSymbols: false,
routerAddress: '192.168.1.232',
routerTcpPort: 48898
}
client = new ads.Client(settings)
client.connect().then(function(err){
client.subscribe("KL6781-0000_1_Channel_1.State", (data, sub) => {
console.error('change')
}, cycleTime).then(function(sub){
console.error('success!')
}).catch(function(err){
console.error('failed !',err)
})
})
I don't receive Change / success! / failed! log. Just:
05-09-2023 05:54:09.097 > error > ads_24 > RangeError: Index out of range
05-09-2023 05:54:09.097 > error > ads_24 > at checkOffset (buffer.js:977:11)
05-09-2023 05:54:09.097 > error > ads_24 > at Buffer.readUInt32LE (buffer.js:1039:5)
05-09-2023 05:54:09.097 > error > ads_24 > at Client._parseAdsData (/node_modules/ads-client/src/ads-client.js:6049:29)
05-09-2023 05:54:09.097 > error > ads_24 > at Client._parseAmsTcpPacket (/node_modules/ads-client/src/ads-client.js:5875:55)
05-09-2023 05:54:09.097 > error > ads_24 > at runCallback (timers.js:810:20)
05-09-2023 05:54:09.097 > error > ads_24 > at tryOnImmediate (timers.js:768:5)
05-09-2023 05:54:09.097 > error > ads_24 > at processImmediate [as _immediateCallback] (timers.js:745:5)
I am able to read the value but not decode it. Seems that i'm also able to subscribe to the symbol name, but still same error. However, I feel like I'm only receiving 00 Buffer or 00 00 depending the length.
What happens when you try to read it using indexGroup and indexOffset with readRaw()
?
I'm not too familiar with BK9050 and I don't have any unit to test myself.
I'm able to get the value: Buffer(00 00)
client.connect().then(function(err){
client.readRaw( target.group,target.offset,target.length).then(function(res){
===> OK I've the res
===> crash the process on convertion
client.convertFromRaw(res, target.type).then(function(value){
})
}).catch(function(err){
})
})
Is the value correct? Can you get a value that isn't 0?
I will check it tonight and let you know, not at my desk, thanks for your support
Hello again, I was able to decode value by adding this in ads-client.js line 6049:
try{
switch (packet.ams.adsCommand) {
....
debugD(`_parseAdsData(): ADS data parsed: %o`, ads)
} catch(e){}
values are correct
But with that solutation, cannot read value with readSymbol because of this error and readRaw for BOOL type:
I think that catching the decode error remove some properties needed for decoding value
ClientException: Reading data failed (Cannot read property 'byteLength' of undefined)
line 1442
Others types working fine, UINT etc...
If you want to check a bit, I can give you access to the linux machine. We can pay for your support as well
@ptorrent can you send me email. You can find the address from package.json details for example.
Issues related to this are now fixed in 1.14.3