Sending Free CAN Standard Message

Discuss issues and ideas you have to configuring displays with PowerVision
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Sending Free CAN Standard Message

Post by MuratE » Wed Mar 11, 2015 7:24 am

Hi All,

I am new with your tools. I have PV780 (both of touch and non-touch version) displays. I can send free CAN messages via script. But I could not figure out yet without script. Can you please view my configuration in attachment (it is PV780-touch)? In this configuration "Message1" and "Message2" are sent through script. For "Message3" I created an event (My Event) and I added it to "Complete Event" at "Connection" Tab.

When I add an action:
(J1939->Tx Std Free Form(FFCAN.Standard_Send))
for "My Event" it sends message continuously and I can not stop it. If I do not add any actions it does not give any response when I push the button on the display.

I would like to know your recommendations for sending free CAN messages without script.

Thanks in advance.

Murat
Attachments
J1939_Message.zip
(678 KiB) Downloaded 24 times
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Wed Mar 11, 2015 9:15 am

Hello,

The short answer to your question is that the Complete Event, My Event, is fired after a send or a receive. In other words, when a transmit message process has finished, the event will be fired.

You can re-create your My Event under the Programming tab, add the action J1939 Port Manager (J1939)->Tx Std Free Form on the event.

You will still have to re-attach the My Event to your keys/touches.

You could also use the My Event to do processing after the message has been transmitted and create a different event for the transmit.

Good job getting the messages transmitted using the new CAN message buffer, we have several questions about it. Thanks for a good example for the forum, I can just point them to yours!
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Wed Mar 11, 2015 12:49 pm

Hi Sara,

Thanks for your interest.
The short answer to your question is that the Complete Event, My Event, is fired after a send or a receive. In other words, when a transmit message process has finished, the event will be fired.
As far as I understand from your answer, there should be an event before "My Event". But there is no message transmitting before "My Event". What should I do?

By the way, I am testing and try different combination with PV780, I try to send free CAN message with PV780 in "J1939_Message" example. So there is no message traffic in this example.
You can re-create your "My Event" under the Programming tab, add the action J1939 Port Manager (J1939)->Tx Std Free Form on the event.
When I add action to My Event as you mention above, message transmitting does NOTstop and I have to switch power off. My intention is to send message one-shot when I push/touch the button.

Murat
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Wed Mar 11, 2015 1:11 pm

Hi Murat,

You are using two separate events? One to transmit/send when you press a button and one to know when the send has finished.

The Complete Event is an optional feature. Most configs I've done don't use it, but it is useful if you need to be sure to get something done as soon as the transmit has finished.

I tried the config you sent and it worked great with the two separate events.
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Thu Mar 12, 2015 5:01 am

Hi Sara,
You are using two separate events? One to transmit/send when you press a button and one to know when the send has finished.
Actually, I use three separate events. Two of them (SendCANMessage and SendCANMessage2, Message1 and Message2 on display) with script and I try to find a solution for Message3 without script.

I think I could not express my problem well. I try to ask my question in a different way. For instanse, I want to send standard CAN Message.

Code: Select all

Message ID: 0x95
Message_Content[8] = {0, 10, 20, 30, 40, 50, 60, 70}
If I send this message via script I can use these codes(by the way if you have better method for sending numeric message array I would like to know. Because it is onerous task to write arrays element to buffer separately):

Code: Select all

void $SendWithScript$ () 
{
      CANMessageInfo info;
      info.MessageType = CANMessageInfoType.SinglePacketRaw;
      info.DestinationAddress = 0xFF;
      info.RtsCtsMaxPackets = 0xFF;

      CANMessageBuffer buffer;

      buffer.CanID = 0x95;
      buffer.Size = 8;
      buffer.WriteInt8(0, 0); 
      buffer.WriteInt8(1, 10); 
      buffer.WriteInt8(2, 20); 
      buffer.WriteInt8(3, 30);
      buffer.WriteInt8(4, 40);
      buffer.WriteInt8(5, 50);
      buffer.WriteInt8(6, 60);
      buffer.WriteInt8(7, 70);

      int port = 0;
      SendCANMessage(0, buffer, info);
}
I tested the codes above and they work without any problem. At this point, I try to find send below message without script when I touch/push to display. How do I send below message when I touch/push button without script? This button can be "Message3" button in my example configuration.

Code: Select all

Message ID: 0x95
Message_Content[8] = {0, 10, 20, 30, 40, 50, 60, 70}
Murat
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Thu Mar 12, 2015 6:48 am

Hi Murat,

Did you look at the config that I posted? Does it behave as you expect? Did you try it?

The two events I mentioned previously were just related to transmitting the one message without using a script.

I'm checking on how to do just one write instead of eight to the message buffer. There has been talk about various methods. I want to find the one that works.
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Thu Mar 12, 2015 10:01 am

Hi Sara,
Did you look at the config that I posted? Does it behave as you expect? Did you try it?
Yes I did. It behaves as I expected for "Message1" and "Message2" button. Because events which are assigned to these buttons trigger the script functions (SendCANMessage and SendCANMessage2, you can see them below)

Code: Select all

void $SendCANMessage$ () 
{
    CANMessageInfo info;
	info.MessageType = CANMessageInfoType.SinglePacketRaw;
	info.DestinationAddress = 0xFF;
	info.RtsCtsMaxPackets = 0xFF;
	
	CANMessageBuffer buffer;

	buffer.CanID = 0x15;
	buffer.Size = 8;
    buffer.WriteInt8(0, 0xFF); 
    buffer.WriteInt8(1, 11); 
    buffer.WriteInt8(2, 22); 
    buffer.WriteInt8(3, 33); 
    buffer.WriteInt8(4, 44); 
    buffer.WriteInt8(5, 55); 
    buffer.WriteInt8(6, 66); 
    buffer.WriteInt8(7, 77); 
    buffer.WriteInt8(8, 88); 
    buffer.WriteInt8(9, 99);
	buffer.WriteInt8(10, 110); 
   	
	int port = 0;
	SendCANMessage(0, buffer, info);

}

void $SendCANMessage2$()
{
	CANMessageInfo data;
	data.MessageType = CANMessageInfoType.SinglePacketRaw;
	data.DestinationAddress = 0xFF;
	data.RtsCtsMaxPackets = 0xFF;
	
	CANMessageBuffer buffer1;
	buffer1.CanID = 0x23;
	buffer1.Size = 8;
	buffer1.WriteInt8(0, 100);
	buffer1.WriteInt8(1, 101);
	buffer1.WriteInt8(2, 102);
	buffer1.WriteInt8(3, 103);
	buffer1.WriteInt8(4, 104);
	buffer1.WriteInt8(5, 105);
	buffer1.WriteInt8(6, 106);
	buffer1.WriteInt8(7, 107);
	buffer1.WriteInt8(8, 108);
	buffer1.WriteInt8(9, 109);
	
	int port1 = 0;
	SendCANMessage(port1, buffer1, data);
}
But "Message3" is not what I expect. When I touch "Message3" button, I expect that event sends CAN message (Message ID 0x95 and data = 0 for all 8 bytes). But it does not send any message.
The two events I mentioned previously were just related to transmitting the one message without using a script.
What do you mean by without using script? The two events trigger the script functions which I added above code block, right? As far as I understand scripts work with events. When you fire an event it runs the script. Please correct me if I am wrong.

Is it possible to run script without any event?

Murat
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Thu Mar 12, 2015 10:33 am

Hello Murat,

I am so sorry! I sent the wrong config in the previous post. The config in the zip of that previous post was just your config. :oops:

The config attached to this post should have an event, SendMy, that I added. The SendMy is being used instead of the My Event. My Event is still there as the Complete Event, but is not really used any where. The two events I have been referencing are the My Event and the SendMy event, but since I sent the wrong config, you could not see this. I apologize.
J1939Message_3xst.zip
(678.04 KiB) Downloaded 25 times
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Mon Mar 16, 2015 8:00 am

Hi Sara,

Thanks for your help. And I am sorry for my late reply.
I am so sorry! I sent the wrong config in the previous post. The config in the zip of that previous post was just your config. :oops:
It is OK, not problem.

Attached configuration works as I expected. Thanks.

Can you please add a "Complete Event" to this configuration as an example? It can complete any event.

Murat
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Mon Mar 16, 2015 8:58 am

Hi Murat,

The Complete Event for transmitting Free Form Messages does not provide useful information. It will always be fired when the Tx send is fired.

The Complete Event is useful for receiving Free Form Messages to know when all of the data in a message has been updated. Data from a particular message may be designed to all work together, so the config needs to be sure that all of the data for that message has been received.

The standard J1939 is different, we don't care if all the data of a PGN is in sync. The Complete Event adds flexibility to the configuration tool so that the displays can properly process incoming data on a particular message together instead of individual SPNs, as for J1939, when needed.

The Complete Event is not always needed because most of the time the configuration does not need for all of the data in a message to be updated together.

I'm not confident that I have explained this very well. I will do my best to clarify, if you need.
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Tue Mar 17, 2015 7:20 am

Hi Sara,

Thanks for your detailed explanation.
The Complete Event for transmitting Free Form Messages does not provide useful information. It will always be fired when the Tx send is fired.
I only try to force my ability for using PV780 's opportunities. For this reason, I intend to test Complete Event with different Tx/Rx combination. I keep on testing Complete Event. I will inform you about my result.

By the way, is there something new to send numeric array with different method? I mentioned this issue in my previous message:

Code: Select all

Message ID: 0x95
Message_Content[8] = {0, 10, 20, 30, 40, 50, 60, 70}
If I send this message via script I can use these codes(by the way if you have better method for sending numeric message array I would like to know. Because it is onerous task to write arrays element to buffer separately):
Murat
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Wed Mar 18, 2015 8:46 am

Hi Murat,

There are not any built in functions for writing to multiple bytes in a CANMessageBuffer. This is left to developers, because different systems may operate different.

Something to consider is Endian-ness of the CAN. With J1939, a two byte parameter starting in byte 4, bit 1, 0x2D1, will be:

Byte 4 {xD1}
Byte 5 {x02}

I will add though that WriteInt16() works properly on the CAN.

Another item to consider is signed/unsigned data. J1939 always transmits unsigned data, but the specification for signed data will have an offset. Both transmitting and receiving devices apply the offset. There are some conversion script functions at this post, viewtopic.php?f=7&t=992&p=2649&hilit=signed#p2649. This is also a discussion of receiving data larger than int32. The conversion functions are at the bottom of all posts in the thread.

Since the CANMessageBuffer is very similar to the List, I thought we might be able to use some of the List functions, but they don't get the result I hoped.
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Thu Mar 19, 2015 11:56 am

Hi Sara,

Thanks for your help.

Excuse my ignorance, but I still have questions from our sample J1939Message_3xst configuration :

Image

Can you please explain FastPacket, MultiPacket, SinglePacket, SinglePacketRaw functions in the above picture?

And I will be glad if you can also explain below lines functions in the code.

Code: Select all

info.DestinationAddress = 0xFF;
info.RtsCtsMaxPackets = 0xFF;

Code: Select all

int port = 0
Note: You can assume that all these questions are for Free Can Messages.

And can you please view attached configuration?

I try to writeSendCANMessage4 buffers with loop and array as the code below:

Code: Select all

int8[] testArray = {10, 11, 12, 13, 14, 15, 16, 17};


void $SendCANMessage$()
{
    CANMessageInfo info;
	info.MessageType = CANMessageInfoType.SinglePacketRaw;
	info.DestinationAddress = 0xFF;
	info.RtsCtsMaxPackets = 0xFF;
	
	CANMessageBuffer buffer;

	//buffer.CanID = 0x12345678;
	buffer.CanID = 0x15;
	buffer.Size = 8;
    buffer.WriteInt8(0, 0xFF); 
    buffer.WriteInt8(1, 11); 
    buffer.WriteInt8(2, 22); 
    buffer.WriteInt8(3, 33); 
    buffer.WriteInt8(4, 44); 
    buffer.WriteInt8(5, 55); 
    buffer.WriteInt8(6, 66); 
    buffer.WriteInt8(7, 77); 
    buffer.WriteInt8(8, 88); 
    buffer.WriteInt8(9, 99);
	buffer.WriteInt8(10, 110); 
   	
	int port = 0;
	SendCANMessage(0, buffer, info);

}

void $SendCANMessage2$()
{
	CANMessageInfo data;
	data.MessageType = CANMessageInfoType.SinglePacketRaw;
	data.DestinationAddress = 0xFF;
	data.RtsCtsMaxPackets = 0xFF;
	
	CANMessageBuffer buffer1;
	buffer1.CanID = 0x23;
	buffer1.Size = 8;
	buffer1.WriteInt8(0, 100);
	buffer1.WriteInt8(1, 101);
	buffer1.WriteInt8(2, 102);
	buffer1.WriteInt8(3, 103);
	buffer1.WriteInt8(4, 104);
	buffer1.WriteInt8(5, 105);
	buffer1.WriteInt8(6, 106);
	buffer1.WriteInt8(7, 107);
	buffer1.WriteInt8(8, 108);
	buffer1.WriteInt8(9, 109);
	
	int port1 = 0;
	SendCANMessage(port1, buffer1, data);
}

void $SendCANMessage4$()
{
	CANMessageInfo message4;
	message4.MessageType = CANMessageInfoType.SinglePacketRaw;
	message4.DestinationAddress = 0xFF;
	message4.RtsCtsMaxPackets = 0xFF;
	
	CANMessageBuffer buffer4;
	buffer4.CanID = 0x88;
	
	for(int i = 0; i < 8; i++)
	{
		buffer4.WriteInt8(i, testArray[i]);
	}
	
	int port4 = 0;
	SendCANMessage(port4, buffer4, message4);
}
But its only sends message ID. Is it possible to write to buffer with array?

Code: Select all

for(int i = 0; i < 8; i++)
	{
		buffer4.WriteInt8(i, testArray[i]);
	}
Here is the output of 4 message event, first digit is message ID, others are message content.

Code: Select all

15	255	11	22	33	44	55	66	77	
23	100	101	102	103	104	105	106	107	
95	0	0	0	0	0	0	0	0	
88
Murat
Attachments
J1939Message_3xst_Test.zip
(678.65 KiB) Downloaded 15 times
Eppur Si Muove
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Sending Free CAN Standard Message

Post by stalley » Fri Mar 20, 2015 11:24 am

Hello Murat,

I appreciate your interest in PowerVision Configuration Studio and how it works. I would recommend reviewing the reference manuals available here. These do not have all the details, hopefully the forum and your own development can provide the details you need for your system.

The other information you need is the J1939, NMEA 2000 and CANOpen specifications. PowerVision Configuration Studio tries to provide tools for all three protocols. J1939 has received the most focus.

The SendCANMessage() in scripts uses the J1939 extended frame send. Standard Frame send can be done with the action.

You were very close to getting your transmit message to work. After I gave the data buffer a size, it worked.

I am attaching an updated config that uses the four types of messages of the CANMessageInfoType. It has some brief explanations in the scripts about the fields used and when.

A brief explanation:
  • SinglePacketRaw gives you complete control over the Protocol Data Unit. (Same as NOT checking Update Device Address on outbound messages.)
    SinglePacket will add the devices CAN source address to the PDU. (Same as checking Update Device Address on outbound messages.)
    Multipacket is same as J1939 Transmit Protocol-Connection Mode or Data Transfer, it depends on the destination address.
    Fast Packet is NMEA 2000 fast packet protocol.
J1939Message_MessageTypes.zip
(679.34 KiB) Downloaded 42 times
Sara Talley
Software Engineer
Enovation Controls
MuratE
Posts: 25
Joined: Mon Jan 05, 2015 5:57 am

Re: Sending Free CAN Standard Message

Post by MuratE » Wed Mar 25, 2015 10:26 am

Hi Sara,

Thank you very much for your detailed explanation. I did what I wanted to do with your help.

Murat
Eppur Si Muove