CAN packet triggering an Event

Discuss issues and ideas you have to configuring displays with PowerVision
ssirpatil
Posts: 7
Joined: Wed Sep 08, 2010 4:12 pm

CAN packet triggering an Event

Post by ssirpatil » Thu Jan 27, 2011 3:31 pm

Hello,

How can I make an incoming CAN packet trigger an event ? This could be a J1939 packet or a free form CAN packet.

I tried using a variable, with the variable "fire on change" tied to an event. This works fine as long as the data is changing. If the incoming data is same in a set of packets, events are not triggered.
jpratt
Enovation Controls Development
Enovation Controls Development
Posts: 222
Joined: Mon Jun 21, 2010 11:18 am

Re: CAN packet triggering an Event

Post by jpratt » Fri Jan 28, 2011 4:57 pm

Currently i believe that the event only fires when the value actually is changed to a new value. I have forwarded this on to look into for future releases.
Jake Pratt
Software Development Manager
ssirpatil
Posts: 7
Joined: Wed Sep 08, 2010 4:12 pm

Re: CAN packet triggering an Event

Post by ssirpatil » Tue Feb 01, 2011 12:16 pm

I tried to work around this and was able to create a timer and poll the data.

Now the other part of the problem. How can I monitor the CAN bus and detect bus failure. In my case there is only one other device on the bus. This device sends 4 different CAN packets ( 4 different PGNs). I need a way to detect bus / device failure ( incoming packets stop) where the incoming packets data does not change. Any suggestions to try ?

I tried using a variable that is tied to CAN data and use the "Fire on change" event to run a script. In this script, I process the data and at the end write back to this variable using smWrite() and set the value to 0 and also status as invalid. So that the next CAN packet will fill in the data and set it as valid , hoping this would cause an event. This did not work. I dont know the mechanism of CAN variable update and how this interacts with smWrite() function call.

BTW, the prototype of smWrite() in the scripting guide needs to be updated.
I believe the correct one is

Code: Select all

smWrite(uint handle, double value, uint timeoutMs, bool valid)
dwills
Enovation Controls Development
Enovation Controls Development
Posts: 26
Joined: Fri Jul 30, 2010 8:27 am

Re: CAN packet triggering an Event

Post by dwills » Thu Feb 03, 2011 9:45 am

You should be able to monitor for bus failure by using the smRead function. It will return false if the value in the database is invalid. A simple script can be run once every second or two and read the values of interest in the database. If all of the values are false, then the bus has failed. Of course, you may want to have the script see multiple failures before declaring a communication problem.