unable to transmit J1939 mesage with more than 8 bytes of data

embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Wed Jul 05, 2017 3:45 pm

Hi, not sure if this is a bug or known limitation but I cant seem to find mention of it, I have just found a strange thing.

I cant seem to transmit a message fo more than 8 bytes.

Using Powervision OEM 2.8.10599 with a PV780, running Windows 10 Home 64 bit, I can specify a J1939 message in the Library section that has 28 bytes of data with 33 SPNs.

Then in the Connections tab, If I go to Transmit Device, none of the SPNs from the PGN are available.

I can add them as a recieved device OK.

If I delete SPN's 33 down to 9, leaving only 8, at 1 byte each, and look again the Tranmit device area, they are available to select.

This leads on to ...how can I send a multipacket PGN with 28 bytes of data?

Many thanks.
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Wed Jul 05, 2017 5:07 pm

I did not know, but the Transmit Device does not support multipacket messages. Multipacket messages can be transmitted easily with scripting on the color displays.
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Wed Jul 05, 2017 5:11 pm

Are you able to provide a small demo of a multipacket script, sending variables that have been calculated outside of the script?
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Thu Jul 06, 2017 1:38 pm

Here is a sample of a script that transmits a multipacket message. There is some commented out code to read configuration variables that shows how it would be done.

Code: Select all

//---------------------------------------------------------------------------------------------
// Murphy Scripting
// - Leave EventName as $Multipacket Transmit$ for main script method
//---------------------------------------------------------------------------------------------
void $Multipacket Transmit$ () 
{
	uint32 word1, word2;
	uint8 extra;
	
	//smRead(VariableIDs.J1939_Engine_Word_One, word1);
	//smRead(VariableIDs.J1939_Engine_Word_Two, word2);
	//smRead(VariableIDs.J1939_Engine_Extra_Byte, extra);
	word1 = 0x01234567;
	word2 = 0x89abcdef;
	extra = 0x88;
	
	CANMessageInfo info;
	info.MessageType = CANMessageInfoType.MultiPacket;
	info.DestinationAddress = 0xFF;
	info.RtsCtsMaxPackets = 3;
	
	CANMessageBuffer buffer;
	buffer.CanID = 0x18FF01F2;
	buffer.Size = 9;
	buffer.WriteInt32(0, word1);
	buffer.WriteInt32(4, word2);
	buffer.WriteInt8(8, extra);
	
	int port = 0;
	SendCANMessage(port, buffer, info);
}
multipacket2.JPG
multipacket2.JPG (63.9 KiB) Viewed 177 times
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Thu Jul 06, 2017 2:38 pm

Thanks Boyce,

that covers managing the values of the data in the script, how would I reference a numeric value from outside of the script, say somethng that has been calulated from another incoming message that is already being displayed, like engine speed for example.?

I must apologise as scrpting is not my strong point.
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Thu Jul 06, 2017 2:48 pm

That's what I was referring to as the commented out lines. The smReads can read the variable values including J1939 parameters. Say you want to access Engine Speed you could read the value:

Code: Select all

	double speed;
	smRead(VariableIDs.J1939_Engine_Engine_Speed, speed);
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Thu Jul 06, 2017 3:04 pm

ok thanks, might be an silly/obviouos one, but can I perform maths of them in the script like:

Byte1=J1939.EngineSpeed * 1.1 / (NewUserVariable * -1)

?
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Thu Jul 06, 2017 3:29 pm

Yes, but you first read the configuration variables into script variables. Script variables can't have a "." in the name so they would be changed to J1939_EngineSpeed. The J1939_EngineSpeed would be read like shown before. The NewUserVariable, assuming that is a Numeric Variable in the configuration, would be read into the script similarly:

// read the configuration variable NewUserVariable into the script variable newUserVariable
double newUserVariable;
smRead(VariableIDs.NewUserVariable, newUserVariable);

The configuration variable could be updated from a script variable after a calculation like this:

int Byte1;
Byte1 = J1939_EngineSpeed * 1.1 ...
// write the script variable Byte1 to the configuration variable such as FreeFormCAN.Byte1:
smWrite(VariableIDs.FreeFormCAN_Byte1, Byte1);
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Fri Jul 07, 2017 3:49 am

thanks Boyce,

I think I get that for a full byte :)

what if the referenced variable was not a full byte , or more than 1 byte? how would I reference in the script how to build up the complete byte structure if it was formed from bits and nibbles?

thanks, Dave.
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Fri Jul 07, 2017 8:43 am

In that sample I could have used unsigned integer types in the script:
uint8 byte1;
uint16 halfword1;
uint32 word1;

In the script you can do bitwise operations on any of the unsigned integer types. When the script variable is written to the configuration numeric variable it is promoted to a double for the function call but saved in the configuration in the type of the configuration variable.

void smWrite( uint variableID, double variableValue );

Numeric variables in the configuration can be defined as Double, Float, Int32, Int16 or Int8.
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Fri Jul 07, 2017 12:53 pm

Thanks Boyce, I think Im getting closer.

What would I need to define to send a nibble, then how do i reference whether its the upper or lower nibble?

Cheers, Dave.
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Fri Jul 07, 2017 1:36 pm

You really can't. CAN messages are transmitted with a length in bytes.
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Fri Jul 07, 2017 2:06 pm

sorry, I didnt make myself clear.

if i wanted to send 20 bytes for example, the first 18 of which were full bytes, then the next byte was built of 2 nibbles, and the last byte was 8 individual bits.

thanks again for the support. I'll post up the script once its working for others to benefit from as this has been a learing curve.. :)
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.
boyce
Enovation Controls Development
Enovation Controls Development
Posts: 322
Joined: Wed Sep 08, 2010 5:09 pm

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by boyce » Fri Jul 07, 2017 2:57 pm

Okay, the nibbles would have to be or'ed together and written out to the byte.

uint8 nibblehi = 0x04;
uint8 nibblelo = 0x05;
uint8 nibbles = (nibblehi << 4) | nibblelo;
buffer.WriteInt8(9, nibbles);
multipacket3.JPG
multipacket3.JPG (66.49 KiB) Viewed 158 times
Boyce Schrack
Enovation Controls
embtechnicalservices
Posts: 52
Joined: Fri Jan 15, 2016 10:14 am

Re: unable to transmit J1939 mesage with more than 8 bytes of data

Post by embtechnicalservices » Fri Jul 07, 2017 5:42 pm

Boyce, thankyou very much. please find below screen grabs and copy of the code that is sending a 28 byte multipacket J1939 message made up from variables pulled from powervision. I would have never worked out the nibble bits. Perhaps some examples of these along with words and bits could make their way to the next user guide?

For refernce I gave the first 6 values AA BB CC DD EE FF so I could see the placment in the transmitted response, and the rest are some ransom value. The last 2 'reserved' were packed with AB, CD, again so I could check where they appeared.

Code: Select all

//---------------------------------------------------------------------------------------------
// Murphy Scripting
// - Leave EventName as $Send Torque Curve$ for main script method
//---------------------------------------------------------------------------------------------
void $Send Torque Curve$ () 
{
   // List of the bytes & nibbles needed to fill and thieir definition ( in groups of 8 bytes for ease)
   uint8 byte0, byte1, byte2, byte3, byte4, byte5, byte6, byte7;
   uint8 byte8, byte9, byte10, byte11, byte12, byte13, byte14, byte15;
   uint8 byte16, byte17, byte18, byte19, byte20, nibblehi21, nibblelo21, nibblehi22, nibblelo22, nibblehi23, nibblelo23;
   uint8 nibblehi24, nibblelo24, nibblehi25, nibblelo25, byte26, byte27;

   //Define the Variable in Powervision to be placed in each byte defined above.
   smRead(VariableIDs.Engine_Speed_at_Point_01, byte0);            //Full Byte 
   smRead(VariableIDs.Engine_Torque_at_Point_01, byte1);           //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_02, byte2);            //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_02, byte3);           //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_03, byte4);            //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_03, byte5);           //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_04, byte6);            //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_04, byte7);           //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_05, byte8);            //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_05, byte9);           //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_06, byte10);           //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_06, byte11);          //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_07, byte12);           //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_07, byte13);          //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_08, byte14);           //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_08, byte15);          //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_09, byte16);           //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_09, byte17);          //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_10, byte18);           //Full Byte
   smRead(VariableIDs.Engine_Torque_at_Point_10, byte19);          //Full Byte
   smRead(VariableIDs.Engine_Speed_at_Point_11, byte20);           //Full Byte
   smRead(VariableIDs.Fractional_Torque_at_Point_01, nibblehi21);  //Upper Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_02, nibblelo21);  //Lower Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_03, nibblehi22);  //Upper Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_04, nibblelo22);  //Lower Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_05, nibblehi23);  //Upper Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_06, nibblelo23);  //Lower Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_07, nibblehi24);  //Upper Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_08, nibblelo24);  //Lower Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_09, nibblehi25);  //Upper Nibble
   smRead(VariableIDs.Fractional_Torque_at_Point_10, nibblelo25);  //Lower Nibble  
   smRead(VariableIDs.Reserved0x27, byte26);                                 //Full Byte
   smRead(VariableIDs.Reserved0x28, byte27);                                 //Full Byte
   
   // List of how the nibbles combine back into bytes
   uint8 byte21 = (nibblehi21 <<4) | nibblelo21;
   uint8 byte22 = (nibblehi22 <<4) | nibblelo22;
   uint8 byte23 = (nibblehi23 <<4) | nibblelo23;
   uint8 byte24 = (nibblehi24 <<4) | nibblelo24;
   uint8 byte25 = (nibblehi25 <<4) | nibblelo25;
   
             
   //Setup the mode inc the multipacket tx
   CANMessageInfo info;
   info.MessageType = CANMessageInfoType.MultiPacket;
   info.DestinationAddress = 0xFF;
   info.RtsCtsMaxPackets = 3;
   
   //setup the header and the message structure
   CANMessageBuffer buffer;
   buffer.CanID = 0x1FF08;              //TX ID
   buffer.Size = 28;                    //Number of bytes to send
   //     Write 8 bits, (byte number, contents);
   buffer.WriteInt8(0, byte0);
   buffer.WriteInt8(1, byte1);
   buffer.WriteInt8(2, byte2);
   buffer.WriteInt8(3, byte3);  
   buffer.WriteInt8(4, byte4); 
   buffer.WriteInt8(5, byte5); 
   buffer.WriteInt8(6, byte6); 
   buffer.WriteInt8(7, byte7); 
   buffer.WriteInt8(8, byte8); 
   buffer.WriteInt8(9, byte9); 
   buffer.WriteInt8(10, byte10); 
   buffer.WriteInt8(11, byte11); 
   buffer.WriteInt8(12, byte12); 
   buffer.WriteInt8(13, byte13); 
   buffer.WriteInt8(14, byte14); 
   buffer.WriteInt8(15, byte15); 
   buffer.WriteInt8(16, byte16);
   buffer.WriteInt8(17, byte17);
   buffer.WriteInt8(18, byte18);
   buffer.WriteInt8(19, byte19);
   buffer.WriteInt8(20, byte20);
   buffer.WriteInt8(21, byte21);
   buffer.WriteInt8(22, byte22);
   buffer.WriteInt8(23, byte23);
   buffer.WriteInt8(24, byte24);
   buffer.WriteInt8(25, byte25);
   buffer.WriteInt8(26, byte26); 
   buffer.WriteInt8(27, byte27);
                   
   //Send the whole lot out 
   int port = 0;
   SendCANMessage(port, buffer, info);
}
then with fildter applied in CAN capture you get this segmented data...

Image

or with no filter, the full multiplex string....
Image

I'm off for a beer after that small triumph. thanks again :)
http://www.emb-technical-services.co.uk
Image
Windows 10 Home x64 - PowerVision 2.9.21075 OEM
i7-7700HQ ,16GBRAM, 500GBSSD, DELL Inspion 7567, 4K UHD Display.