Order of execution - Events and J1939 message sending

Discuss issues and ideas you have to configuring displays with PowerVision
andymartyn
Posts: 25
Joined: Wed Oct 29, 2014 4:51 am

Order of execution - Events and J1939 message sending

Post by andymartyn » Tue Mar 24, 2015 6:34 am

I am having a problem when sending 2 J1939 messages at approximately the same time (give or take a few milliseconds or less) with data being not what I expect

I have 2 state machines, using the same message. I configure parameters (calculate events) and then use the J1939 app to send a freeform extended message. The problem seems to be either that the order of calling events is not sequential and the events in one event occur during the processing of the other. Or the sending of J1939 doesn't act immediately and when it is called it takes the current values of the mapped variables rather than those that were set at the point th e message was queued.

Is this accurate? That when raising an event in one state machine, another event in another state machine can occur, overwriting the data I expect or is it to do with the J1939 sending?

State 1
CCM->Fire Event(Calculate Drivetrain Switchpack Indicator.Bank 1)
CCM->Fire Event(Calculate Drivetrain Switchpack Indicator.Center Blink Rate Fast)
J1939->Tx Ext Free Form(FFCAN.Switchpack Indicator Message)

This should send: 01 40 F0 FF FF FF FF FF

State 2
CCM->Fire Event(Calculate Drivetrain Switchpack Indicator.Bank 2)
CCM->Fire Event(Calculate Drivetrain Switchpack Indicator.Center Blink Rate Medium)
J1939->Tx Ext Free Form(FFCAN.Switchpack Indicator Message)

This should send: 02 30 F0 FF FF FF FF FF

Instead I get 2 of these:
02 30 F0 FF FF FF FF FF
02 30 F0 FF FF FF FF FF

Scripting seems to work, the SendCANMessage() might be instant here? Or is acting as a single event so won't be interrupted?

Any clarification on how this works appreciated

Regards,
Andy
stalley
Enovation Controls Development
Enovation Controls Development
Posts: 618
Joined: Tue Mar 18, 2014 12:57 pm

Re: Order of execution - Events and J1939 message sending

Post by stalley » Tue Mar 24, 2015 8:51 am

Hello,

There are various parts to the system, but the major parts involved in this situation are the CCM (Central Control Machine), NVMgr (database manager, it also handles storage of variables and lists) and the J1939 protocol manager.

The writes to the variables (database) will happen, then the transmits will happen in both scripts and state machines. You have just been lucky with the script. The J1939 protocol manager is just going to use what the variable is at the time, the message data is not buffered up at the time of firing the transmit event.

In situations similar to yours with a state machine, I usually put a delay timer before updating the variables again for subsequent transmits of the same parameters. Are your messages going to different devices or the same? If going to the same device, you should only transmit at a certain rate anyway.

There is an event on the Free Form message definition, Complete Event, it is really for receiving Free Form messages. It insures that all of the data received for the message has completed writing. On sending, I think the Complete Event will be fired as soon as the Transmit Event is fired and doesn't mean that the message has been sent.
Sara Talley
Software Engineer
Enovation Controls