SAE J1939
1. Overview
This document describes the functionality and communication of the Grayhill Touch Encoder using the SAE J1939 protocol.
The following documents are referenced within this document.
SAE-J1939
SAE-J1939/11
SAE-J1939/21
SAE-J1939/71
SAE-J1939/81
2. J1939 Communications
2.1 Message Header Description
The figure below illustrates the format of the CAN message ID. A brief description of each field follows.
Priority (P) | Reserved (R) | Data Page (DP) | PDU Format (PF) | PDU Specific (PS) | Source Address (SA) |
---|---|---|---|---|---|
3 bits | 1 bit | 1 bit | 8 bits | 8 bits | 8 bits |
- Priority
This 3-bit field is used to define the priority during arbitration. 0 is the highest priority and is usually associated with high-speed control messages. Low priority is used for non-critical configuration and information messages. The lowest priority value is 7.
- Data Page (DP)
This 1-bit field defines on which data page (0 or 1) the message is defined in the J1939 specification. Page 0 contains the messages that are presently defined, while Page 1 is for future expansion according to J1939.
- Protocol Data Unit Format (PF)
This 8-bit field determines the format of the message and is one of the fields which determine the Parameter Group Number of the message (see 2.1.6). If the value is between 0 and 239, the message is a PDU 1 format message. These messages are sent to specific addresses. If the value is between 240 and 255, the message is a PDU 2 format message. These messages are not sent to a specific address, but are instead broadcast to the entire network.
- Protocol Data Unit Specific (PS)
The PDU Specific (PS) field is the Destination Address (DA) in a PDU 1 Format. In a PDU 2 format the PS becomes the Group Extension (GE). This field is 8 bits long.
- Source Address (SA)
This 8-bit field is the source address of the device that sent the message.
- Parameter Group Number (PGN)
J1939 defines allowable messages by their Parameter Group Number (PGN). The Parameter Group Number is an 18-bit value that uniquely defines the message purpose. It is composed of the Reserved bit, DP, PF and PS, all of which are described above.
2.2 J1939 Bit Field Location and Byte Ordering
The first data byte is sent first and is referenced as Byte 1. The LSB of the data bytes are on the right and are referenced as Bit 1.
All multibyte data fields are specified in little-endian byte order unless stated otherwise.
The convention used to locate a parameter in the data field is the same as specified in SAE-J1939/71. The format used is "R.x" where R is the byte number and x is the starting bit number within the byte. The length is the number of bits starting at this point.
Example: Location 4.3 with a length of 3 bits would have the value of 1 as illustrated below.
Example: Location 4.3 with a length of 3 bits would have the value of 6 as illustrated below.
2.3 Grayhill Touch Encoder Source Address
The source address of the Grayhill Touch Encoder is set to 242 (0xF2
) at the factory. This may be modified dynamically with the proprietary Source Address Command. The source address value is stored in non-volatile memory. Touch Encoder assumes this value at startup but the actual source address is the result of Dynamic Addressing. Multiple Touch Encoder devices can coexist in the same system.
2.4 GUIDE
The following sections describe the different commands and reports that are available for the user interface (GUIDE). Each UI screen of a given GUIDE project has a screen ID associated with it. Each screen contains a set of variables, each with an ID associated with it, that influence the appearance and behavior of UI elements. As presented in the upcoming sections, these IDs are used to identify a particular screen or a variable.
Any variable of any screen can be modified or read using SET or GET commands respectively. Also, by the means of issuing an appropriate SET or GET command, the current screen can be changed or polled. A change of a variable value or current screen, whether resulting from a SET command or user input, triggers a notification message identical to a GET command response as if the corresponding GET command was issued.
Each screen also contains a tree of visual elements that make up the user interface and receive various types of events. Event occurrence at a particular element results in an event notification message. In the same fashion as screens and variables, visual elements are identified by their IDs.
All GUIDE commands use the Proprietary A PGN (0x0EF00
). The GUIDE command response messages and notification messages use the Proprietary B PGN 0x0FF11
*.
* The PGN can be reassigned using a configuration message.
2.4.1 Screen GET
The Screen GET request is used for retrieving the ID of the currently active screen on the TE.
Screen GET Request
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Device Command | 0x0A - GUIDE (GET) |
2.1 | 1 Byte | GUIDE Command | 0x01 - Screen Request |
Screen GET Response
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command | 0x01 - Screen Request |
2.1 | 1 Byte | Screen ID (current) | 0x01...0xFF |
2.4.2 Screen SET
The Screen SET request is used for changing the currently active screen on the TE. A Screen Change Notification will be sent by the TE on a successful Screen SET.
Screen SET Request
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Device Command | 0x0B - GUIDE (SET) |
2.1 | 1 Byte | GUIDE Command | 0x01 - Screen Request |
3.1 | 1 Byte | Screen ID (requested) | 0x01 ... 0xFF |
2.4.3 Screen Change Notification
A Screen Change notification is sent by the device if the current screen has changed by the means of user input or the Screen SET request. Additionally, the Screen SET request with screen id equal to the id of the active screen also results in the notification being sent even though no screen transition takes place. This way, the notification resulting from the Screen SET indicates the request was processed successfully. The Screen Change notification is identical to the Screen GET response.
2.4.4 Variable GET
The Variable GET request is used for retrieving the current value of a variable on one of the TE screens.
Variable GET Request
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Device Command | 0x0A - GUIDE (GET) |
2.1 | 1 Byte | GUIDE Command | 0x02 - Variable Req. |
3.1 | 1 Byte | Screen ID* (requested) | 0x00...0xFF |
4.1 | 1 Byte | Variable ID* (requested) | 0x00...0xFF |
Variable GET Response
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command | 0x02 - Variable Req. |
2.1 | 1 Byte | Screen ID | 0x00...0xFF |
3.1 | 1 Byte | Variable ID | 0x00...0xFF |
4.1 | 1-? Bytes | Value* | Variable Value** |
2.4.5 Variable SET
The Variable SET request is used for setting the value of a variable on one of the TE screens. A Variable Change Notification will be sent by the TE on a successful Variable SET.
Variable SET Request
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Device Command | 0x0B - GUIDE (SET) |
2.1 | 1 Byte | GUIDE Command | 0x02 - Variable Req. |
3.1 | 1 Byte | Screen ID | 0x00...0xFF |
4.1 | 1 Byte | Variable ID | 0x00...0xFF |
5.1 | 1-? Bytes | Value* | New Value** |
2.4.6 Variable Change Notification
A Variable Change notification is sent by the device if a variable has changed by the means of user input or Variable SET request. Also, in the fashion similar to the Screen Change Notification, this notification is sent as a response to the Variable SET request even when no value change occurred. This way, the notification resulting from the Variable SET indicates the request was processed without error.
The Variable Change notification is similar to the Variable GET response, except for the following:
The message is truncated at 8 bytes to fit a single CAN frame. If the host wishes to read out the variable's value, it can issue a Variable GET command to do so.
The GUIDE Command field contains the value indicating the variable type:
0x03
for integer variables,0x04
for string variables.
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command (Variable Type) | 0x03 - Integer Variable |
0x04 - String Variable | |||
2.1 | 1 Byte | Screen ID | 0x00...0xFF |
3.1 | 1 Byte | Variable ID | 0x00...0xFF |
4.1 | 1-5 Bytes | Value | Variable Value* |
2.4.7 Event Notification
Event notifications inform the host of various events taking place in the visual element tree. The possible event types include user input of different classes, gestures and changes in the tree of visual elements. Since each event type is associated with different properties, the event data in an event notification message varies. Also, some types have multiple variants due to the fact that event types are only logical groupings of events. Every event notification provides the id of the element, however, as each event occurs in context of a visual element.
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command (Event Type) | 0x10 - Knob Event |
0x11 - Touch Event | |||
0x12 - Gesture Event | |||
0x13 - Scene Event | |||
2.1 | 1 Byte | Element ID | 0x00...0xFF |
3.1 | Variable | Event Data | Refer to Guide Event Notification Data |
2.5 Configuration and Control Message
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Configuration and Control Command | Refer to Configuration and Control Commands |
2.1 | 7 Bytes | Configuration and Control Data | Refer to Configuration and Control Commands |
3. Guide Event Notification Data
This section enumerates possible variants of the GUIDE event notification message, as described in Event Notification.
3.1 Knob Event
Data Length – 5 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command | 0x10 - Knob Event |
2.1 | 1 Byte | Element ID | 0–255 |
3.1 | 1 Byte | Reserved | 0 |
3.1 | 2 Bytes | Relative | -32768–32767 |
3.2 Touch Event
Data Length – 8 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command | 0x11 - Touch Event |
2.1 | 1 Byte | Element ID | 0–255 |
3.1 | 1 Byte | Touch Event Type | 0 - Down |
1 - Move | |||
2 - Up | |||
3 - Enter | |||
4 - Leave | |||
3.4 | 3 Bits | Contact ID | 0–7 |
3.7 | 5 Bits | Reserved | 0 |
4.1 | 2 Bytes | x (local coordinate space) | -32768–32767 |
6.1 | 2 Bytes | y (local coordinate space) | -32768–32767 |
3.3 Gesture Event
Data Length – 7 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command | 0x12 - Gesture Event |
2.1 | 1 Byte | Element ID | 0–255 |
3.1 | 1 Byte | Gesture Type | 0 - Tap |
1 - Axis-aligned swipe | |||
4.1 | 4 Bytes | Gesture Data | Refer to the following subsections |
3.3.1 Tap Event Data
Byte 1 | Byte 2 | Byte 3 | Byte 4 |
---|---|---|---|
xl | xh | yl | yh |
xl - x coordinate low byte
xh - x coordinate high byte
yl - y coordinate low byte
yh - y coordinate high byte
NOTE: The tap coordinates are provided in target element's local coordinate space.
3.3.2 Axis-Aligned Swipe Event Data
Byte 1 | Byte 2 | Byte 3 | Byte 4 |
---|---|---|---|
dd | xx | xx | xx |
dd - Swipe direction. Valid values are 0, 1, 2, 3, to be interpreted as up, down, left, right respectively.
xx - Don't care.
3.4 Scene Event
Data Length – 7 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | GUIDE Command | 0x13 - Scene Event |
2.1 | 1 Byte | Element ID | 0–255 |
3.1 | 1 Byte | Occurrence Type | 0 - Input focus change |
1 - Visibility change | |||
4.1 | 4 Bytes | Data | Refer to the following subsections |
3.4.1 Input Focus Change Event Data
Byte 1 | Byte 2 | Byte 3 | Byte 4 |
---|---|---|---|
vv | xx | xx | xx |
vv - Specifies whether input focus was gained (value 1) or lost (value 0).
xx - Don't care.
NOTE: This event is sent in pairs: for the element losing focus and for the element gaining focus.
3.4.2 Visibility Change Event Data
Byte 1 | Byte 2 | Byte 3 | Byte 4 |
---|---|---|---|
vv | xx | xx | xx |
vv - Specifies whether the element was hidden (value 0) or shown (value 1).
xx - Don't care.
4. Configuration and Control Commands
Changing of the configuration and how the Touch Encoder behaves is done with the Configuration and Control message described in Section 2.5. The first byte serves as the command byte. Where applicable, changes take effect immediately and are stored in non-volatile memory unless otherwise noted.
The Control Data message uses Proprietary A PDU1 format (PF = 239). The header information for these commands is as follows:
4.1 Modify GUIDE Response PGN
By default, GUIDE notifications are sent using the PGN of 0x0FF11
. This value may not be desirable as each message will possibly be received and processed by many nodes. Moreover, if a message does not fit a single CAN frame, it will be segmented in accordance with J1939 BAM, incurring significant latency. To combat such inefficiencies, it is possible to assign a different value for the GUIDE notification PGN. For instance, one may choose to specify a PGN that will target only a specific node.
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Device Command | 0xD9 - GUIDE (PGN Config) |
2.1 | 3 Bytes | PGN | 0x00...0x3FFFF |
4.2 Modify Message Priority (COMING SOON)
Data Length – 8 bytes
Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 |
---|---|---|---|---|---|---|---|
0xD2 | dd | xx | xx | xx | xx | 0x55 | 0xAA |
dd – The new priority. Valid Range: 0..7
xx – Don't Care. Should be 0xFF
following J1939 convention
0x55 – Low byte of 16 bit key
0xAA – High byte of 16 bit key
Applies to all messages sent by the Touch Encoder.
4.3 Modify Source Address
Data Length – 8 bytes
Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 |
---|---|---|---|---|---|---|---|
0xE0 | dd | xx | xx | xx | xx | 0x55 | 0xAA |
dd – The new source address. Valid Range: 0..253
xx – Don&##39;t Care. Should be 0xFF following J1939 convention
0x55 – Low byte of 16 bit key
0xAA – High byte of 16 bit key
4.4 Backlight Intensity
Data Length – 8 bytes
Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 |
---|---|---|---|---|---|---|---|
0x80 | xx | dd | xx | xx | xx | xx | xx |
dd – Has a value between 0 and 100 and is the percentage of backlight intensity
xx – Don't Care. Should be 0xFF following J1939 convention
4.5 Raw Input Event Report Enable/Disable
Raw Input Event (RIE) reports can be enabled/disabled using this command. In order to use the default RIE Report PGN (0x18FF0E), the user can simply send the 2-byte message shown below. In order to define a new PGN for the RIE Reports, the user should use the longer 5-byte message. For more information on RIE Reports, refer to Raw Input Event Reports.
Data Length – 2 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Command | 0x08 - RIE Reports Enable/Disable |
2.1 | 1 Byte | Control | 0x01 - RIE Reports enabled |
0x00 - RIE Reports disabled |
Data Length – 5 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Command | 0x08 - RIE Report Enable/Disable |
2.1 | 1 Byte | Control | 0x01 - RIE Reports enabled |
0x00 - RIE Reports disabled | |||
3.1 | 3 Bytes | PGN | PGN value to use for RIE Reports |
4.6 Enter Suspend Mode
The device can be instructed to enter a low-power mode by issuing the following single-byte command.
Data Length – 1 byte
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Command | 0xF0 - Set Device to Suspend Mode |
Note: Issuing any other host command (e.g. Backlight Intensity), causes the device to wake up from suspend.
4.7 Live Update Request
Data Length – 8 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Command | 0x55 - Live Update Request |
2.1 | 1 Byte | Component type | 0 - package |
3 - project | |||
3.1 | 3 Bytes | Upload Size | File size in bytes |
6.1 | 3 Bytes | PGN | PGN value to use for the update session |
Example: The following message requests the update of Touch Encoder project. The origin (0x21) obligates itself to upload a file of size equal to 2212495 bytes (roughly 2.11MB) over PGN 0x13300. The file, once successfully submitted, will be used to update the TE project.
To learn more about the live update procedure, see our Live Update guide.
4.8 Configure NAME
Certain fields of the Touch Encoder NAME are configurable. The following command allows to set a single field at a time. The field to be set is identified by Selector. The value is taken directly and applied to the selected field up to the maximum bit length of the field. The changes take effect upon the next power cycle. For more information on the NAME field, refer to SAE-J1939/81.
Service Tool Authentication is required to execute this command.
Data Length - 5 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Command | 0xE1 - Set NAME Field |
2.1 | 4 Bits | Selector | 1 - Industry Group |
2 - Vehicle System Instance | |||
3 - Vehicle System | |||
5 - Function | |||
6 - Function Instance | |||
7 - ECU Instance | |||
2.5 | 4 Bits | Reserved | 0 |
3.1 | 3 Bytes | Value | Value appropriate for the selected field (see SAE-J1939/81) |
4.9 Service Tool Authentication Request
This command initiates a service tool authentication session.
Data Length - 5 bytes
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | Command | 0x01 - Service Tool Auth |
2.1 | 1 Byte | Clearance | 1 - Service Tool |
3.1 | 3 Bytes | PGN | PGN value to use for the authentication session |
To learn more, refer to Service Tool Authentication.
5. Raw Input Event Reports
The Touch Encoder can optionally be set to send out "raw input event" (RIE) reports whenever a new input event is available and is being processed by the Touch Encoder. Input events are generated when any of the TE's user input devices show a change in their state. Each input device (encoder, touch sensor) generates a different type of RIE report. The following sections describe the different RIE report types being generated when RIE reports are enabled.
By default, RIE reports use PGN 0x18FF0E (Proprietary B PDU2 Format).
5.1 RIE Report Types
Touch RIE
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | RIE Type | 0x00 - Touch |
2.1 | 1 Bit | Tip Switch | 0-touch not detected |
1-touch detected | |||
2.2 | 3 Bits | Contact ID | Contact ID |
2.5 | 3 Bits | Contact Count | Contact Count |
2.8 | 1 Bits | Reserved | 0 |
3.1 | 2 Bytes | Contact X-coordinate | 16-bit signed integer data |
5.1 | 2 Bytes | Contact Y-coordinate | 16-bit signed integer data |
7.1 | 2 Bytes | Contact Time Stamp | 0x0000...0xFFFF |
Note: The Contact X and Y-coordinates are in the screen coordinate space.
Encoder RIE
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 1 Byte | RIE Type | 0x01 - Encoder |
2.1 | 2 Bytes | Encoder Raw Value | 0x0000...0xFFFF* |
* Note: The maximum value for the encoder raw value is limited by the number of detents of the encoder hardware. Default encoder value range: 0...31.
6. Other J1939 Messages
The following messages are defined in the J1939 documents and are implemented in the Touch Encoder.
6.1 Address Claimed
Start | Length | Field Name | Values |
---|---|---|---|
1.1 | 21 Bits | Identity Number | Device-unique value |
3.6 | 11 Bits | Manufacturers Code | 294 (Assigned to Grayhill by SAE) |
5.1 | 3 Bits | ECU Instance | 0 (Default) |
5.4 | 5 Bits | Function Instance | 0 (Default) |
6.1 | 8 Bits | Function | 60 (Cab Display)* |
7.1 | 1 Bit | Reserved | 0 (Defined by SAE) |
7.2 | 7 Bits | Vehicle System | 0 (Default) |
8.1 | 4 Bits | Vehicle System Instance | 0 (Default) |
8.5 | 3 Bits | Industry Group | 0 Global (Default) |
8.8 | 1 Bit | Arbitrary Address Capable | 1 Capable (Default) |
* Refer to J1939 base document for the Function value based on the Industry Group and Vehicle System combinations
6.2 PGN Request
Start | Length | Field Name | Values |
---|---|---|---|
1 | 1 Byte | Byte 1 of PGN being requested (LSB) | 0 to 255 |
2 | 1 Byte | Byte 2 of PGN being requested | 0 to 255 |
3 | 1 Byte | Byte 3 of PGN being requested (MSB) | 0 |
The following are the supported PGN&##39;s that can be requested from the Touch Encoder. If the request is unsupported, the device responds with a NACK (Refer to J1939-21).
6.2.1 ECU Identification Information (COMING SOON)
Start | Length | Field Name | Values* |
---|---|---|---|
1 | <=64 | ECU Part Number | Ex. "3KYY1001-1" |
Variable | <=64 | ECU Serial Number | Ex. "123456" |
Variable | <=64 | ECU Location | Ex. "CAB" |
Variable | <=64 | ECU Type | Ex. "KEYPAD" |
* All fields "*" ASCII delimited
6.2.2 Software Identification
Start | Length | Field Name | Values |
---|---|---|---|
1 | 1 Byte | Number of software fields | 2 (FW & bootloader only) |
3 (TE Project version available) | |||
2 | 5-N Bytes | Firmware version ## (Major.Minor.Patch) (ASCII) | Ex. "4.3.1" |
Variable | 5-N Bytes | Bootloader version ## (Major.Minor.Patch) (ASCII) | Ex. "7.5.3" |
Variable | 0-N Bytes | TE Project version ## (Major.Minor.Patch) (ASCII) (optional) | Ex. "1.0.1" |
* All fields "*" ASCII delimited
6.3 Acknowledgement Message
Start | Length | Field Name | Values |
---|---|---|---|
1 | 1 Byte | Control Byte | 0 = Positive Acknowledgement |
1 = Negative Acknowledgement | |||
2 = Access Denied | |||
3 = Cannot Respond | |||
2 | 1 Byte | Group Function | Group Function Value* where applicable or 0xFF |
3-5 | 3 Bytes | Reserved by SAE | |
6-8 | 3 Bytes | Parameter Group being Acknowledged |
*Group Function Value is context-dependent. Typically, if the acknowledgement is sent in response to a Configuration and Control Message, the Group Function Value equals the value of the command field (byte 1).