How do I determine the address of a received J1939 message i

Discuss issues and ideas you have to configuring displays with PowerVision
robertheldibridle
Posts: 6
Joined: Wed Aug 07, 2013 1:20 pm

How do I determine the address of a received J1939 message i

Post by robertheldibridle » Wed May 20, 2015 6:17 pm

Hello,

I can have 4 - 48 devices with the same function on my J1939 can bus. I would like to store all that data in a list, so that I can run some statistics on it, like an average.

I figured out how to populate the list using the demo for the lists. I can add data using a button press. I can also get the data to update certain rows of the table by searching for the address in the table and then updating that row.

What I don't know how to do is get the address of the can message the data is being updated from.

Ideally I would like to trigger an event after the data has been parsed and the message is still available. Is this possible?

Also is there more documentation for using the scripting api.

Thanks
Robert Heldibridle
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: How do I determine the address of a received J1939 messa

Post by stalley » Thu May 21, 2015 9:28 am

Hello Robert,

You have a couple of ways you can filter on the incoming source address.

The easiest is to have a device for each source address. You could use an on change event on each of the parameters to know when to update the list data. Because of how PowerVision works, it is possible that parameters on the same message will be written to the database at different times. Depending on your system requirements, you may need to use different on change events.

The other way you can filter is to use a Free Form Data Message as a Raw Binary MEssage type. I have attached an example. The example is just about filtering with the source address. It shows you how to set the PGN and PGN Mask so that all messages, regardles of source address, with the PGN, will be received by the display. Your script should be able to parse out the source address from the buffer.CanID. I have put a variable on the screen that displays the buffer.CanID so you can see what it looks like.

This will get you an event when all parameters in the message are in the database ready to be used in the configuration.
DEMO - Receive J1939 Messages.zip
(678.03 KiB) Downloaded 40 times
There is a topic with some information about manipulating the J1939 packets here viewtopic.php?f=7&t=1084. It might have some helpful information, but it also has some example configs.

The only documentation we have for using Angel Script is found on the Scripting Syntax Reference when you are in a script. I can sometimes find info online also.
Sara Talley
Software Engineer
Enovation Controls
robertheldibridle
Posts: 6
Joined: Wed Aug 07, 2013 1:20 pm

Re: How do I determine the address of a received J1939 messa

Post by robertheldibridle » Thu May 21, 2015 2:23 pm

So I looked at what you sent. At first I thought that this solved my problem, but it created a new one.

How do I create a free form numeric message for multiple addresses, ie how do I filter on a pgn?

Or how do I create a free form data message that isn't using the multi-packet protocol? You have the standard Multi-Packet Compatible check box checked in the example you gave me. What does that do for a message that is a standard 8 bytes long and not using the bam or cm protocol?

Thanks for your help
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: How do I determine the address of a received J1939 messa

Post by stalley » Thu May 21, 2015 4:36 pm

Hello Robert,

So, you want your cake and eat it too? ;)

To be able to filter on the PGN and to know when all parameters have been written to the database, you will need to use the Free Form Data Message. This means you will need to parse the data.

Or you can use the devices to filter the PGNs and parse the data, but you will have to guess as to when the all the data in the PGN has all be updated.

The check box for Standard Multi-Packet Compatible means that if the data is more than 8 bytes and comes in multipacket transfer, the display can handle it. The display won't use multi-packet if it doesn't see the multipacket transfer messages. Messages with a length of 8 bytes or less cannot (or should not anyway) be sent with the multipacket transport, according to the J1939 standard.
Sara Talley
Software Engineer
Enovation Controls
robertheldibridle
Posts: 6
Joined: Wed Aug 07, 2013 1:20 pm

Re: How do I determine the address of a received J1939 messa

Post by robertheldibridle » Fri May 22, 2015 10:12 am

So, let me summarize where I think I am at with this.

I have multiple devices sending the same pgn with different addresses. I want to create a table to put all the data in. The table will have the address of the device and the data from the device in each row. I would like to update the table in a script.

Option 1. Use the device under the connections tabs. The device will correspond to each unique device and must be hard coded before hand. So if I have 10 devices on the bus, I will need 10 devices in my config. Each variable will have to be added to the table individually as the change event for the data value is the only value I have access to. I would have to map each variable to an element in the table; very time consuming and error prone. Also, I don't know how many devices will be on the bus before hand, could be 1, could be 40. Would have to plan for 40 and create 40 devices.

Option 2. Use the free numeric form can messages.
The free form numeric message doesn't filterer on pgns, but rather on can ids. So this is the same as option 1, only I would update my table for whole messages instead of individual data chunks. This might lead to less processing. Because I can't filter on the pgn alone, I will have to have an event for every possible address. This would lead to more work than option 1.

Option 3. Use the free form can messages
This is for multi packet messages. My data is not in multi message format. I am sending an 8 byte message for each of my pgns. Like you said, can't use multi message for 8 byte data or less in J1939, so this does not apply to my data.

So what I want to do is receive an event after I get and 8 byte, non multi packet message. When I receive the event, I will parse the data and put it into the right row, based on the senders address.

Then all I have to do is create a few screens that look display the data from the table, which you do beautifully.

What is your advice on this, can it be done?
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: How do I determine the address of a received J1939 messa

Post by stalley » Tue May 26, 2015 8:12 am

Hello Robert,

I think you have summed up your options accurately.

I will confirm that for Option 2 there would be a LOT of typing involved. The messages can't be copy and pasted. I don't know about you, but I am not a very good typist, so this could be error prone also.

Option 3 should result in a smaller configuration.

Are you planning a history so you have to store values? The PV780/700/480 all have considerable memory but not unlimited, like any device.

You can do it! We are here if you need help.
Sara Talley
Software Engineer
Enovation Controls