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
Hi all,
I have connected a YDTA-01N tankadapter on my tanksensor.
The divice seems to work OK, on the SD card it's writing the correct tank content (80% ~ 88 liter)

I connected the sensor to the N2K network.
The Shipmodule miniplex 3E N2K is getting the input from the tankmodule and from the logfile I can see for example:


The miniplex send this to UPD 10120

in the SK log I find:

Aug 17 11:54:21 2021-08-17T09:54:21.871Z canboatjs:fromPgn parsed pgn {"prio":0,"pgn":127505,"dst":255,"src":391,"input":["$MXPGN,01F211,68BB,FF0000044C4EA800*60"],"fields":{"Level":0,"Capacity":282370355.6,"Reserved1":"0"},"description":"Fluid Level","timestamp":"2021-08-17T09:54:21.871Z"}

So it look like the data is recieved in SK, however not the values like 80% and/or 88Liter

Now I have some questions:
1) How is propriatarie MXPGN recognized as N2000?
2) How is the data being read from the MXPGN sentence?

Thanks in advance
src could never get higher than 255 but that doesn't matter.

If you change the direction of the 8 data bytes (00 A8 4E 4C 04 00 00 00 FF)
00 -> instance 0 and type of tank fuel
A8 4E = 168 + 78*256 = 20136 (this must be multiplied with 0,004) -> 80,544 % level
4C 04 00 00 = 76+1024 = 1100 (multiplied with 0,1) -> 110 liter capacity

8 - length = 8
BB - src = 187

Are you shure you have the latest version of Signal K?
File /usr/lib/node_modules/signalk-server/node_modules/@canboat/canboatjs/lib/stringMsg.js changes the data byte direction. This fix was done on Mar 3, 2021.
Thanks E-sailing.
Got a simulair answer from Shipmodule support in meantime as well.
But always good to share some knowledge here.

I have SK version 1.40

I found the file it was timestamped 10/26/1985 09:15 so I asume the date is not valiid

The MXPGN code in my server is:
// $MXPGN,01F801,2801,C1308AC40C5DE343*19
exports.isMXPGN = startsWith('$MXPGN,')
exports.parseMXPGN = (input) => {
 const [ prefix, pgn, attr_word, data ] = input.split(',')

 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);
 let src, dst;
 send ? dst = addr: src = addr;
 return buildMsg(
   buildCanId(0, parseInt(pgn, 16), 255, parseInt(src, 16)),
   Buffer.from(rmChecksum(data), 'hex'),
   { coalesced: true, prefix },

exports.encodeMXPGN = ({ prefix = '$MXPGN', pgn, prio, src, data }) => {
 if (src > 255) src = 255;
 if (!prio) prio = 3;
 if (!src) src = 255;
 const dataLength = hexByte(128 + (prio * 16) + (byteString(data, '').toUpperCase().length / 2)).toUpperCase()
   const attribWord = dataLength + hexByte(src).toUpperCase()

   var buff = Buffer.from(byteString(data, ''), 'Hex');
   for (var i = 0, j = buff.length - 1; i < j; ++i, --j) {
       var t = buff[j]

       buff[j] = buff[i]
       buff[i] = t

   const sentence = [prefix, toPaddedHexString(pgn, 6), attribWord, buff.toString('Hex').toUpperCase()].join(',')
 return sentence + compute0183Checksum(sentence)

The only reference I found on MXPGN in gethub is this commit

As far as I see I have this commit installed.
If you have checked that you have the latest firmware on your shipmodul, you can try the original series (comment out two lines of the code).
  for (var i = 0, j = buff.length - 1; i < j; ++i, --j) {
      var t = buff[j]

      //buff[j] = buff[i]
      //buff[i] = t
I was having a look again in this issue tonight.
I do not understand the code.

I tried to comment-out the 2 buf lines, but it still does not give the correct result.
Actually I do not see difference in the output

Currently I have this in the log:

canboatjs:fromPgn parsed pgn {"prio":0,"pgn":127505,"dst":255,"src":391,"input":["$MXPGN,01F211,68BB,FF0000044C42B600*1A"],"fields":{"Level":0,"Capacity":305779814.8,"Reserved1":"0"},"description":"Fluid Level","timestamp":"2021-10-08T20:29:06.326Z"}

As you explained before the correct translation should be:
LEVEL: 42B6=17078x0.004= 68.312%
Capacity: 044C = 1100 = 110l lit

Is there a way I can add more detailed logging in this function in order to see what happens exactly?

Thanks for your help!
Boat is on the dry so started to use the http://localhost:3000/admin/#/serverConfiguration/datafiddler to further investigate.

I added logging to stringMSG.js
I found exports.encodeMXPGN code mentioned above is not used.
Only exports.parseMXPGN is being used.

Also I tried to reverse the HEX words manualy so tested:

Then I get at least some valid data:
"values": [
    "path": "tanks.fuel.0.currentLevel",
    "value": 1.7234399999999999
    "path": "tanks.fuel.0.capacity",
    "value": 127533.056

this looks better however values not yet correct.

==> which piece of code should reverse the HEX words?
==> where are the values calculated

to be continued.
Tips are welcome Tongue

Forum Jump:

Users browsing this thread: 1 Guest(s)