Core Scripting Functions Documentation

Below are the available functions for the "Message" and "ScriptBlock" classes that are used in CANCapture's script function blocks.

Currently CANCapture supports the callback events that are included in the default example (OnStartCapture, OnStopCapture, and OnReceiveMessage). Each callback populates a "Message" object and/or a "ScriptBlock" object, which has been pre-filled with the appropriate data.  


Message Class - this object represents a physical CAN packet that has been received by the script-block. Each time a new message is received, the callback event "OnReceiveMessage" is called and it is passed a "Message" object that represents the CAN packet that was just received.


uint SetPGN (uint PGN_value)
uint GetPGN ()

Gets or sets the J1939 PGN according to the SAE J1939 protocol. The message should also be set to 29-bit using the function Set11Bit(0).

void SetPriority (uint8 priority)
uint8 GetPriority ()

Gets or sets the J1939 priority according to the SAE J1939 protocol

void SetDataPageBit (uint8 dataPage)
uint8 GetDataPageBit ()

Gets or sets the data page bit of the CAN packet ID

void SetReservedBit (uint8 reservedBit)
uint8 GetReservedBit ()

Gets or sets the reserved bit of the CAN ID

void SetPF (uint8 PDUF)
uint8 GetPF ()

Gets or sets the PDU-F from the 29-bit CAN ID according to the J1939 protocol.

void SetSA (uint8 SA)
uint8 GetSA ()

Gets or sets the Source address for the 29-bit CAN ID according to the J1939 protocol.

void SetPS (uint8 PDUS)
uint8 GetPS ()

Gets or sets the PDU-S for the 29-bit CAN ID according to the J1939 protocol

void SetDataLength (uint8 DLC)
uint8 GetDataLength ()

Gets or sets the data length code for the CAN packet

void SetData (int byte_index, uint8 byte_value)
uint8 GetData (int byte_index)

Gets or sets the values for a given CAN data byte. The variable "byte_index" is based on zero and should be in the range of 0 to 7.

double GetTimeStamp ()
Gets the hardware timestamp that was received in hardware (if applicable) relative to the time when "Start Capture" was pressed.

void SetID (uint32 can_id)
uint32 GetID ()

Gets or sets the 29-bit or 11-bit ID depending on whether the CAN packet is set for 11 or 29-bit.

uint8 Is11Bit ()
void Set11Bit (uint8 is11bit)
\
Gets or sets whether or not the CAN packet is 29-bit or 11-bit

uint8 IsRemoteFrame()
void SetRemoteFrame(uint8 EnableRemoteFrame)

Gets or sets the CAN packet to be marked as a remote frame. If the message is not a remote frame, then it is a data frame.


ScriptBlock Class - this object represents the physical script block that received the CAN packet and functions related to it. Each callback function/event in CANCapture will receive a "ScriptBlock" object that represents the block that the event corresponds to.


void SendMessage(uint8 port, Message &msg)
This function is used to transmit a message from the respective ScriptBlock and onto the flowchart workspace.  The variable "port" must be either 1, 2, or 3, which corresponds to the output ports that are enabled on block from within the workspace chart.  The top-right port is 1, the middle-right port is 2, and the bottom-right port is 3.  The variable "msg" corresponds the the CAN message that will be sent.

void PrintOutputText(string &str, bool red, bool green, bool blue, bool bold)
Prints a text string to the output window for the respective script block.  Each script block has an output window that is used for displaying compile/syntax errors as well as any text that the script desires.  The variables "red", "green", "blue", and "bold" set the style for the text that gets printed.

void ClearOutputText()
Clears all text from the output window that corresponds to the respective script block.

Tags: 
CANCapture and ECOM Knowledgebase