SignalK / node-red-embedded

Node red nodes for use with the signalk-node-red plugin
Apache License 2.0
12 stars 2 forks source link

signalk-send-nmea2000 #8

Closed okbayou closed 5 years ago

okbayou commented 5 years ago

I am having trouble getting this to work. I put together a JSON string in a function block and wired it to signalk-send-nmea2000 in node red. The actisense nmea reader on the network picked up the pgn 127489 but there is no data. Node red says it is sending and the reader is constantly updating but the data is all FF in hex.

in the function block: const pgn = { "pgn": 127489, "engineInstance": 0, "oilPressure": 0, "oilTemperature": oilTemperature, "temperature": temperature, "alternatorPotential": 12, "fuelRate": 0, "totalEngineHours": 1234, "coolantPressure": 0, "fuelPressure": 0, "reserved": 0, "discreteStatus1": 0, "discreteStatus2": 0, "percentEngineLoad": 0, "percentEngineTorque": 0 } msg.payload = pgn; return msg;

In the debug block: 1/6/2019, 5:07:43 PMnode: 9cc66d62.0e579 msg.payload : Object object pgn: 127489 engineInstance: 0 oilPressure: 0 oilTemperature: "70.81" temperature: "71.60" alternatorPotential: 12 fuelRate: 0 totalEngineHours: 1234 coolantPressure: 0 fuelPressure: 0 reserved: 0 discreteStatus1: 0 discreteStatus2: 0 percentEngineLoad: 0 percentEngineTorque: 0

What am I doing wrong?

sbender9 commented 5 years ago

Two issues here. The keys you're using are wrong, please see https://github.com/canboat/canboat/blob/master/analyzer/pgn.h for the names you should use.

You also need to make sure your values are numbers instead of strings and they should be in Kelvin.

Just leave out any values that you don't know so that you don't get bad data on the network.

You're code should look something like:

const pgn = {
   "pgn": 127489,
  "Engine Instance": 0,
  "Oil temperature": Number(oilTemperature),
  "Temperature": Number(temperature)
}
msg.payload = pgn;
return msg;

But I would recommend sending signalk deltas instead. This way the data will get into signalk and then you can use the signalk-to-nmea2000 plugin to send them out on the n2k network.

okbayou commented 5 years ago

Okay, I changed the code in the function block to this:

const pgn = { "pgn": 127489, "Instance":0, "Oil pressure":0, "Oil temperature": Number(oilTemperature), "Temperature": Number(temperature), "Alternator Potential": alternatorPotential, "Fuel Rate":0, "Total Engine hours":0, "Coolant Pressure":0, "Fuel Pressure":0, // "Reserved", "Discrete Status 1":0, "Discrete Status 2":0, "Percent Engine Load":0, "Percent Engine Torque":0 } msg.payload = pgn; return msg; The Debug msg.payload looks like this: 1/6/2019, 8:53:02 PMnode: 9cc66d62.0e579 msg.payload : Object object pgn: 127489 Instance: 0 Oil pressure: 0 Oil temperature: 294.65 Temperature: 294.83 Alternator Potential: 13.3 Fuel Rate: 0 Total Engine hours: 0 Coolant Pressure: 0 Fuel Pressure: 0 Discrete Status 1: 0 Discrete Status 2: 0 Percent Engine Load: 0 Percent Engine Torque: 0

The node-red says it is sending but nothing is happening on NMEA reader on the network.

okbayou commented 5 years ago

copy of the node: [{"id":"7846814e.09bc5","type":"tab","label":"NMEA 2000","disabled":false,"info":""},{"id":"2775bb2c.2ee0b4","type":"link in","z":"7846814e.09bc5","name":"Boat values","links":["7dd4f33f.e7ac9c"],"x":126,"y":58,"wires":[["b5e8a5f9.fad798"]]},{"id":"b5e8a5f9.fad798","type":"function","z":"7846814e.09bc5","name":"Engine data","func":"var boat = msg.payload;\nflow.set('boat',boat);\nvar temperature = (((boat.temperature-32)0.5555)+273.15);\nvar oilTemperature = (((boat.oilTemperature-32)0.5555)+273.15);\nvar alternatorPotential = Number(boat.alternatorPotential);\noilTemperature = oilTemperature.toFixed(2);\ntemperature = temperature.toFixed(2);\n// F_K_convert \n// (F-32)X.5555+273.15\n\nconst pgn = {\n \"pgn\": 127489,\n \"Instance\":0, \n \"Oil pressure\":0, \n \"Oil temperature\": Number(oilTemperature),\n \"Temperature\": Number(temperature),\n \"Alternator Potential\": alternatorPotential, \n \"Fuel Rate\":0, \n \"Total Engine hours\":0, \n \"Coolant Pressure\":0, \n \"Fuel Pressure\":0,\n// \"Reserved\", \n \"Discrete Status 1\":0,\n \"Discrete Status 2\":0,\n \"Percent Engine Load\":0,\n \"Percent Engine Torque\":0\n}\nmsg.payload = pgn;\nreturn msg;\n","outputs":1,"noerr":0,"x":260,"y":55,"wires":[["9cc66d62.0e579","50b5fb1.4895304"]]},{"id":"9cc66d62.0e579","type":"debug","z":"7846814e.09bc5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":534,"y":128,"wires":[]},{"id":"50b5fb1.4895304","type":"signalk-send-nmea2000","z":"7846814e.09bc5","name":"","nmea2000Event":"","nmea2000JsonEvent":"nmea2000JsonOut","x":513,"y":59,"wires":[]}]

okbayou commented 5 years ago

disregard, I restarted the NMEA 2000 reader and everything is working now, Thanks Scott and all those who support this endeavor. - Al