PGN Request

Discuss issues and ideas you have to configuring displays with PowerVision
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

PGN Request

Post by cconner_aie » Thu Nov 10, 2016 1:34 pm

Hello,

I'd like some advice on how to implement PGN requests. I see some used in gauges on the PV380, however I'm not sure how the panel actually sends the request to update the data. For example, I'd like to use PGN 65259 to read back the engine serial and model code. Here is a CAN trace:

Image

I assume you'd set up PGN 65259 in the J1939 library with 0 cycle time and the request box ticked. From there I'm assuming you assign the fields in the parameters box, how would this work with a multi packet message?

Image

Here is the break down of the first two steps of the response message. How would I turn all this spaghetti into KBTA *EG52223000*1FU5796*1? I get the feeling this would need to be handled in a script. I'd also like to to do some string manipulation with this once it's read in so it may make more sense if this was the way I had to go anyway.

Thanks,
Coleby Conner
Controls Engineer, Anderson Industrial Engines
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: PGN Request

Post by stalley » Fri Nov 11, 2016 2:01 pm

Hi cconner_aie,

Is the config you want to do the multi-packet for a monochrome or color display?

General PowerVision Configuration Request Info:
For PGNs defined in the Library, if you check the Request box for the PGN, the request will automatically be sent when a parameter on the PGN is mapped to a Device on the Connections tab. The

If the Request Specific Address box on the Connections tab for the Device where the requested parameter is mapped, there will be an additional request sent with the Destination Address of the Device.

For example, Engine Total Hours of Operation is a common parameter on the Engine Device. By default in PowerVision Configuration Studio, PGN 65253 has the Request box checked. If the Engine Total Hours of Operation is added to the j1939 Mapped Variables on the Engine Device (Source Address = 0), you should see two requests from the display for the xFEE5. One request will be x18EAFF and the other will be x18EA00.

J1939 Multi-Packet:
You should be able to define most PGNs in the Library, map the parameters to a device and read the variables just like other parameters. Not that complicated. All of the transport protocol handling is done in the application, the config doesn't need to do anything. The 65259 is different since the parameters have indeterminate size and they are strings. The Library doesn't have a string type. Four is the longest Byte Length you can enter for an SPN.

The only way to possibly parse is with a Free Form CAN message on a color display using a script.
Check out this viewtopic.php?f=7&t=1181&p=3252&hilit=m ... cket#p3252 post for an example of handling a large multi-packet message.

Hope this will get you started.
Sara Talley
Software Engineer
Enovation Controls
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: PGN Request

Post by cconner_aie » Fri Nov 11, 2016 2:59 pm

Thanks Sara,

I came across that post earlier today and started looking into it, looks like that's exactly what I need.

Looks easy enough to setup the Free From Data Message and I can handle the string manipulation inside the script, so that's great but how would I call it when I wanted that data retrieved? Perhaps I'm missing something easy, I saw that when a Free Form Numeric Message was made it's an option under the J1939 Port Manager Actions through Tx Std/Ext Free Form but I don't see the data message as an option.

Thanks again,
Coleby Conner
Controls Engineer, Anderson Industrial Engines
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: PGN Request

Post by stalley » Mon Nov 14, 2016 8:13 am

Hi Coleby,

If you make the Complete Event on the Message Definition the same as the event that runs the script, it will all magically work. The J1939/CAN application will fire the event when it has received the message you specify in the PGN property. So not really magic, but the configuration doesn't have to set up a recurring timer to check.

Transmitting is a little different. With scripts, using the Free Form Data Message has limited use. Transmitting is when you would need to set up a recurring timer to run your script or transmit as needed.
Sara Talley
Software Engineer
Enovation Controls
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: PGN Request

Post by cconner_aie » Mon Nov 14, 2016 9:25 am

Thanks Sara,

The transmitting is what I'm looking for, this is the message I need to send:

Can ID - 0x18EA00D0
Data - 0xEBFE00

If I understand the process flow correctly this should work correct?

CANPort1 Free Form Numeric Message
Image

Actions and variables
Image

FFMsg_PGNRequest_Byte1:
- Enumeration Values:
- CI = 235 (0xEB)
- Calculation Events:
Image

FFMsg_PGNRequest_Byte2:
- Enumeration Values:
- CI = 254 (0xFE)
- Calculation Events:
Image

FFMsg_PGNRequest_Byte3:
- Enumeration Values:
- CI = 0 (0x00)
- Calculation Events:
Image

And then the action to call the request:
Image

This seems like it should work, but it's all very convoluted in my opinion. I can see the benefit of keeping this request flexible and will probably use it in the future, but for this specific instance I'd love to wrap this all up in a script. I found an example in the function reference, but I don't see any detailed documentation on the data types for CANMessageInfo and CANMessageBuffer. Can you comment on the snippet below and correct any mistakes?

Code: Select all

void $CI_Req$ () 
{
	/* --- PGN TO REQUEST PGN 'CI' --- */
	/* MESSAGE THAT NEEDS TO GO OUT    */
	/* CAN ID = 0x18EA00D0             */
	/* DATA = 0xEBFE00				   */
	/* ------------------------------- */

	CANMessageInfo info;
    
	// only need to send one packet for pgn request
	info.MessageType = CANMessageInfoType.SinglePacket;
	
	// engine source address is 0x00, but reads on 0xD0,
	// so this would need to be set to 0x00 correct?
    info.DestinationAddress = 0x00;
								
	// is this required on single packets?
	// it was used on the example where a MessageType was set
	// to MultiPacket	
    info.RtsCtsMaxPackets = 1000;
    
    CANMessageBuffer buffer;

    buffer.CanID = 0x18EA00D0;
    buffer.Size = 3;
    buffer.WriteInt32(1, 235);	// byte 1 = 0xEB
	buffer.WriteInt32(2, 254);	// byte 2 = 0xFE
	buffer.WriteInt32(3, 0);	// byte 3 = 0x00

    int port = 0;
    SendCANMessage(0, buffer, info);
}
Thanks,
Coleby Conner
Controls Engineer, Anderson Industrial Engines
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: PGN Request

Post by stalley » Mon Nov 14, 2016 1:32 pm

Hey Coleby,

You can totally eliminate the Free Form message and setting up the message on your event by using the script to transmit the request.

The examples in Function Reference tab shows the valid types for the structure/object members.

Your script looks fine, except... the index to the buffer is zero based and you want to use the WriteInt8() method since you are only writing one byte.
Sara Talley
Software Engineer
Enovation Controls
cconner_aie
Posts: 93
Joined: Thu Jun 11, 2015 10:12 am

Re: PGN Request

Post by cconner_aie » Mon Nov 14, 2016 1:33 pm

Awesome,

Thanks for your help clearing all that up.

Thanks!
Coleby Conner
Controls Engineer, Anderson Industrial Engines