February 18, 2021  The NMEA 2000 Bridge update

The new firmware offers easy and codeless configuration of user programs, including encrypted and locked programs.

Engine and transmission warinings in Cloud Service

The Bridge allows execution of user programs to process CAN messages in real time. If your tank adapter or gateway does not allow changing the tank number or fluid type, it can be solved with 5-lines of code and the Bridge. At the same time, the Bridge allows creation of really big and powerful programs, to prototype or emulate devices, or even to create your own.

In 2019 we added optional encryption of user programs. This protects intellectual property, ensures compliance with NDA agreements, and makes sure that the program will not be modified by end user. However, a new problem is introduced here: what to do, if the user or installer needs to configure the program? Of course, it is possible to create a handler for PGN 126208 "NMEA Group Function" or for a proprietary PGN, but today we offer a more elegant solution.

# PGN 127505 "Fluid Level" with 100% full diesel tank
SLOT1 = 0111F219 FF 08 00A861FFFFFFFFFF

	# Check new tank level settings
	if (param(SLOT2) == 1) # Is only one byte read?
		load(SLOT2)    # Copy slot to work buffer
		A = get(0,INT8)*250 # % to N2K resolution
		set(DATA+1,INT16,A) # Update % in SLOT1
	# Send fluid level message

The program above turns the Bridge into an emulator of a fuel tank sensor, which sends the tank level every second to NMEA 2000 network. The new function param() reads the string starting with YD:PARAM from the "Installation Description String 2" of the Bridge, which can be entered with the help of any NMEA 2000 PC gateway. This field is stored in device's memory and used by installers to leave a note regarding the product installation.

For example, enter "YD:PARAM 5" to the Bridge's properties and the Bridge will parse entered data and display the answer "YD:PARAM 05 OK" to confirm that the command is accepted (see the screenshot of CAN Log Viewer above). On the right of the screenshot you see that the level of diesel tank 0 was changed to 5%.

If the string is correct, the param() call will save the entered bytes to the specified memory slot, which can be loaded to the work buffer with the load() function. This function returns the number of bytes read (only one in our example). If the field is empty or command is incorrect, the slot will not be modified and the value returned will be 0.

In the next lines of the program, we convert the entered number (new tank level in percent) to NMEA 2000 resolution and update the message template stored in SLOT1. Please, refer the manual if you read the code above with difficulties.

You can enter from one to 30 bytes (hexadecimal). If all 30 bytes are entered, the Bridge will not add "OK" due to limitation of space in the field. Any of the commands below:

   YD:PARAM 5 6 7 1A f	
   YD:PARAM 05 06 07 1a 0F	
   YD:PARAM 0506071A0F

will have the same result:

   YD:PARAM 0506071A0F OK

You can enter bytes with spaces, or without, with a leading zero or not, in upper or in lower register. In case of a mistype, you'll get a "YD:PARAM ERR" response.

The slot can hold up to 229 bytes, and this configuration method allows you to set only the first 30 bytes; all other bytes in the slot will be cleared in case of successful param() call (with non-zero return value).

The firmware update 1.37 for the Bridge is available in the Downloads section.


Next articles:

Previous articles:

See also: recent news, all news...