This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tank Adapter YDTA-01N to SK via Shipmodule Miniplex
#7
I finally found the solution (as a non developer)

The solution by e-sailing was in the right direction but not correct.

1) the problem is in the reading, exports.parseMXPGN  and not in exports.encodeMXPGN which is I assume the sending part.
2) the code for reversing the Bytes is not working.

I found a function on internet

Code:
const changeEndianness = (string) => {
 const result = [];
 let len = string.length - 2;
 while (len >= 0) {
   result.push(string.substr(len, 2));
   len -= 2;
 }
 return result.join('');
}

So added it in the stringMsg.js
And updated like:

Code:
exports.parseMXPGN = (input) => {
 console.log('MXpgn parse input' + input)
 const [ prefix, pgn, attr_word, data ] = input.split(',')
 
 console.log('MXpgn parse data ' + data)

 var buff = changeEndianness(rmChecksum(data));
 
 const send_prio_len = (parseInt(attr_word.substr(0,2), 16).toString(2)).padStart(8, '0');
 const addr = (parseInt(attr_word.substr(2,2), 16));
 const send = parseInt(send_prio_len.substr(0,1), 2);
 const prio = parseInt(send_prio_len.substr(1,3), 2);
 const len = parseInt(send_prio_len.substr(4,4), 2);
 console.log('stringMsg:MXpgn parse: attr_word ' + attr_word)
 console.log('stringMsg:MXpgn parse: ' + addr + ' ' + send + ' ' + prio + ' ' + len)
 let src, dst;
 send ? dst = addr: src = addr;
 
 return buildMsg(
   buildCanId(0, parseInt(pgn, 16), 255, parseInt(src, 16)),
   'MXPGN',
   Buffer.from(buff, 'hex'),
   { coalesced: true, prefix },
 )
}


For incomming messages it's working fine now.
I did not test for outgoing yet, but I expect the same function should be used.

I will propose this change in github.
Reply


Messages In This Thread
RE: Tank Adapter YDTA-01N to SK via Shipmodule Miniplex - by Sjoerd02 - 2022-03-22, 10:09 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)