jCOM Series by Copperhill Technologies Embedded Network Solutions SAE J1939 – NMEA 2000 – ISOBUS – MilCAN – CAN Contact Us: [email protected]For more information see http://copperhilltech.com JCOM.J1939 PROTOCOL &PROGRAMMING INTERFACE The jCOM.J1939 gateway series by Copperhill Technologies represent high- performance, low-latency vehicle network adapters. They allow any host device with a serial COM port (USB or UART) to monitor SAE J1939 data traffic and communicate with the SAE J1939 vehicle network. The gateways support the full SAE J1939 protocol according to J1939/81 Network Management (Address Claiming), J1939/21 Transport Protocol (TP), and J1939/16 (Automatic CAN baud rate detection). The jCOM.J1939 Gateway Protocol is designed to establish a data exchange between a jCOM.J1939 Series gateway and a host system (e.g. a PC or embedded system such as the Raspberry Pi) per means of serial communication (UART, USB). The protocol enables the host system to take advantage of the gateway’s capabilities by providing a set of commands from the host and responses from the gateway. JCOM.J1939 GATEWAY OPERATING MODES The jCOM.J1939 gateways supports two operating modes to cover all possible scenarios. The operating mode can be set by the host system per command through the serial port (USB or UART) as described in the next chapter. The modes are: 1. Listen-Only (Default): This mode supports a mere J1939 data-monitoring mode, which does not require the use of a NAME and source address, i.e. there is no address claim process. 2. Communication: This mode allows full communication, i.e. bidirectional data transfer, between the host system and the J1939 vehicle network. A jCOM.J1939 gateway works per default as a mere monitoring device in Listen-Only mode, however, the gateway will, also per default, not report any data unless the host system (e.g. a PC under Windows/Linux) sets the corresponding filters (ADDFILTER command).
18
Embed
COM.J1939 PROTOCOL PROGRAMMING Icopperhilltech.com/content/jCOM1939-Protocol.pdf · SAE J1939 – NMEA 2000 – ISOBUS – MilCAN – CAN ... J1939 vehicle network is only possible
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
JCOM.J1939PROTOCOL&PROGRAMMINGINTERFACEThe jCOM.J1939 gateway series by Copperhill Technologies represent high-performance, low-latencyvehiclenetworkadapters.TheyallowanyhostdevicewithaserialCOMport(USBorUART)tomonitorSAEJ1939datatrafficandcommunicatewiththe SAE J1939 vehicle network. The gateways support the full SAE J1939 protocolaccording to J1939/81 NetworkManagement (Address Claiming), J1939/21 TransportProtocol(TP),andJ1939/16(AutomaticCANbaudratedetection).ThejCOM.J1939GatewayProtocolisdesignedtoestablishadataexchangebetweenajCOM.J1939Seriesgatewayandahostsystem(e.g.aPCorembeddedsystemsuchastheRaspberryPi)permeansofserialcommunication(UART,USB).Theprotocolenablesthehost system to take advantageof the gateway’s capabilities byproviding a set ofcommandsfromthehostandresponsesfromthegateway.
1. Listen-Only(Default):ThismodesupportsamereJ1939data-monitoringmode,whichdoesnotrequiretheuseofaNAMEandsourceaddress, i.e. there isnoaddressclaimprocess.
2. Communication: This mode allows full communication, i.e. bidirectional datatransfer,betweenthehostsystemandtheJ1939vehiclenetwork.
A jCOM.J1939 gatewayworks per default as ameremonitoring device in Listen-Onlymode,however,thegatewaywill,alsoperdefault,notreportanydataunlessthehostsystem (e.g. a PC under Windows/Linux) sets the corresponding filters (ADDFILTERcommand).
2
Afullcommunication,i.e.bidirectionaldatatransfer,betweenthehostsystemandtheJ1939vehiclenetworkisonlypossibleafterthehostsysteminitiatestheJ1939AddressClaimprocessbysendingthecorrespondingcommand(SETPARAM).All operatingmodes allow the reception of up to 1785 bytes permessage,while theCommunication operatingmodealso allows the transmissionof up to 1785bytes permessage(BAMorRTS/CTSSession).The Communication operating mode engages the full Address Claim procedure,requiringaNAME,apreferred sourceaddress (SA), andanoptionaladdress range (incasethepreferredSAisalreadytaken).The transmission of J1939messages in theCommunication operatingmode is always“real-time,” i.e. themessage is being transmitted as soon as possible (as soon as thegatewayproceedsduringthebusarbitrationprocess).
MESSAGEFORMATThe jCOM.J1939 protocol defines two special tokens, START and ESC. START has thevalueof192decimalandESChasthevalueof219decimal.DataissenttoandfromthejCOM.J1939gatewayusingtheindustrystandardmethodofbytestuffing.BytestuffingistheprocessofinsertingadditionaltokenswhentheSTARTorESCtokensarepartofthedatafield.All messages start with a START token, and due to byte stuffing, a START token canneverappear inanyotherpartof themessage. If thevalueof192 iscontained inthemessagelength,datafield,orchecksum,anESCtokenisinsertedintothedatastreamfollowedbya220,thisindicatesavalueof192.IfanESCtokenappearsinthemessagelength,datafield,orchecksum,anESCtokenisinsertedintothestreamfollowedbya221,thisindicatesavalueof219.Allmessagesmustbebytestuffed, following theSTARTtoken,by the transmitterandunstuffedbythereceiver.Code Dec / Hex Description START 192 / 0xC0 Start of Message ESC 219 / 0xDB Stuffing Byte START_STUFF 220 / 0xDC Stuffing Byte ESC_STUFF 221 / 0xDD Stuffing Byte DATA_START ESC+START_STUFF Data = 219, 220 / 0xDB, 0xDC DATA_ESC ESC+ESC_STUFF Data = 219, 221 / 0xDB, 0xDD Tosendapacket,thetransmittingdevicestartsbysendingaSTARTcharacterfollowedbythesizeofthedatatofollow,alongwiththedataandthechecksumofthepacket.Themessagelengthisa2-bytefield(MSBfirst,followedbyLSB)equaltothesizeofthedatafieldpluschecksum,bothbeforebytestuffing.The checksum is a 2’s complement checksum over the length and data fields and iscalculatedbeforebytestuffinghasbeenadded.
4
WHATISA2’SCOMPLEMENTCHECKSUM?Achecksumisatechniquetocheckdatafortransmissionerrorsortampering.Ifthelastfew bytes are the sum of all the preceding bytes, then any errors are likely to bedetected. Inthiscase,thechecksumisthesumofallbytesbetweenthedata lengthfield(MSB)andthe lastbyteoftheactualdatafield, ignoringanycarry,meaningthechecksumisalways8bitslong(0to255).Aone’scomplementisjustacomplement:~xAtwo’scomplementisacomplementandincrement,ignoringcarry:(~x)+1
MESSAGESThischapterdescribesthecommandssenttoandreceivedfromthegateway.Note: All message definitions are documented in their unstuffed representation. Allhighlightedsectionsrepresentthedatafield.Everymessageispartofthedatafield,anditstartswithamessageidentifier.Thisisaneight-bitvaluethattellsthereceiverwhattypeofmessagefollows.Thisisfollowedbyone or more additional data field(s), depending on the message. The messageidentifiers, data fields, responses, etc. are documented for each message in thefollowingchapters.TheavailablemessagesandtheirmessageIDsare:Message ID Meaning Source AcknowledgeACK 0 Acknowledgement Gateway -ADDFILTER 1 AddFilter Host ACKDELFILTER 2 DeleteFilter Host ACK
5
TXDATA 3 TransmitData Host ACKRXDATA 4 ReceiveData Gateway -RESET 5 ResetjCOM.J1939.USB Host ACKHEART 6 Heartbeat Gateway -SETPARAM 7 SetProtocolParameters Host ACKREQINFO 8 RequestInformation Host REPSTATUSor RXDATAor VERSIONREPSTATUS 9 ReportProtocolStatus Gateway -FLASH 10 Startsflashprogrammer Host ACKSETACK 11 SetAcknowledgement Host ACKSETHEART 12 SetHeartbeatFrequency Host ACKVERSION 13 ReportHW/SWVersion Gateway -SETPARAM1 14 SetProtocolParameters Host ACK WithREPSTATUSresponseSETMSGMODE 15 SetMessageMode Host ACKTXDATAL 16 TransmitDataLoopback Host ACKTXDATAP 17 PeriodicDataTransmission Host ACKTXDATAPL 18 TXDATAPwithLoopback Host ACKNote:ThislistofmessagesissortedbymessageID.Theoriginalprotocolincludedonlythefirst10messagesandfurthermessageswereaddedovertime.Inordertomaintaina strict backwards compatibility, the function of a message, once established, willremain unchanged. Any additional or modified functionality is accomplished throughnew messages (as an example, see the original TXDATA and the added TXDATALmessages).
• ToenableSAEJ1939requestmessages(PGN=0xEAxx),itissufficienttousethebase PGN 0xEA00 (59904) or any PGN in the range from 0xEA00 to 0xEAFF,whichwillenabletheentirerange.
• ThegatewaywillnottransmitanydataduringtheAddressClaimprocess(appliesonly to the Communication operating mode), which can last up to severalhundredsofmilliseconds.
• AJ1939messagecanbebetween0and1785byteslong.Ifamessageislongerthan 8 bytes, the jCOM.J1939 gateway will, depending on the destinationaddress, manage the transmission per broadcast (BAM) or peer-to-peer(RTS/CTS)session.
• The jCOM.J1939 gateway will allow you the use of a random source address,provided that the address claim process was finished successfully. It is highlyrecommended using the negotiated source address (obtained through theREPSTATUS message). Nevertheless, this feature is provided for maximumflexibility.
This message is designed (and handles data transmission exactly) like the regularTXDATAmessage.However,whenthegatewayreceivestheTXDATALmessage,thedata
9
will be reflected back to the host system (which is amandatory feature for gatewayapplications).MessageIdentifier: 16TotalLength: Variable(19with8databytes)Response: ACKIndex Code Value0 MSG_TOKEN_START 1921 LengthMSB xx2 LengthLSB xx3 MSG_ID_TX 164 PGNMSB xx5 PGN2ND xx6 PGNLSB xx7 DestinationAddress xx8 SourceAddress xx9 Priority 0…710 DataFieldStart xx::nn CHKSUM xx
TXDATAP,TXDATAPL–TransmitDataPeriodically
These twomessagesaredesignedandhandledata transmissionsimilar to the regularTXDATA message. They are, however, extended by a message frequency (inmilliseconds). When the gateway receives the TXDATAPL message, the data will bereflected back to the host system (which is a mandatory feature for gatewayapplications).Note:
• Themessage frequency (inunitsofmilliseconds) is submittedusing twobytes,thusallowingamaximumtimeof65.536seconds.
This message requests a gateway reset, causing a re-initialization of all SAE J1939protocolparameters,whichincludessettingtheoperatingmodetoListen-Only.The purpose of the RESET command is for synchronizing the gateway with the hostsystem. The gateway’s settings will not be affected by a host system power-down,meaning all filter settings plus negotiated addresswill remain active. To prevent anysynchronization issues, it is therefore recommended to issue the RESET command assoonasthehostsystempowersdownorstartsup.CAN Baud Rate Switching – The RESET command also allows initializing the gatewaywithaCANbaudrateof250kbpsor500kbps.Todoso,modifythe“ResetKey3”valueasshowninthemessageformatdescriptionbelow.Note:
• The gateway-reset command does not affect the heartbeat frequency or ACKmessagesettings.
Thismessageisperdefaultbeingtransmittedwithaonesecondfrequency; it isbeingusedasaso-called“watchdog”functiontomonitortheserialconnectionfunctionality.Themessage contains the hardware and software versions in a form of A.BB.CC (forinstance,1.02.03):
• A -MajorUpdate• BB -MinorUpdate• CC -BugFix
Following the hardware and software versions are two error counters that allow aninsightintothequalityoftheserialconnection:
• ChecksumError• ByteStuffingError
Pleasebeaware that the rangeof thesecounters is from0 to255,where,atacountgreaterthan255,thecounterwillstartatzeroagain.However,actionshouldbetakenassoonasacertain(project-specific)counthasbeenreached.The heartbeat message frequency can be adjusted through the SETHEART message,whichalsoallowssuppressingtheheartbeat.MessageIdentifier: 6TotalLength: 13bytesResponse: -Index Code Value0 MSG_TOKEN_START 1921 LengthMSB 02 LengthLSB 103 MSG_ID_HEART 64 HW_VERSIONMAJOR xx5 HW_VERSIONMINOR xx6 HW_VERSIONBUGFIX xx7 SW_VERSIONMAJOR xx8 SW_VERSIONMINOR xx9 SW_VERSIONBUGFIX xx
13
10 ERRCNT_CHECKSUM xx11 ERRCNT_STUFFING xx12 CHKSUM xx
SETPARAM,SETPARAM1–SetProtocolParameters
ThismessagesetstheNAMEofthecontrolapplication(CA)accordingtoSAEJ1939/81(Address Claim Process), sets a preferred source address and address range for theaddressclaimprocessandstartstheAddressClaimprocess.WithusingtheSETPARAM1command,assoonastheaddressclaimprocessisfinished(successfulornot),thegatewaywillsendaREPSTATUSmessage,reportingtheaddressclaimstatusandthenegotiatedaddress.Theparametersinthismessageare:
• The Address Claim process is initiated by overwriting the Listen-Only mode(gatewaydefault)toCommunicationmode.
SettingtheaddressrangeornotwillimpacttheAddressClaimprocess:1. Full SAE J1939/81 compliant address claim with source address and alternativeaddressrange:Theusercansetapreferredsourceaddress,but,incasetheaddressisalreadyusedinthe vehicle network, an alternative address range is available for the address claimprocess.2.FullSAEJ1939/81compliantaddressclaimwithonlyonesourceaddress:Setting both address range parameters to 254 but submitting a source address (i.e.settingthecontrolapplicationasnon-arbitrary-address-capable)willresettheArbitraryAddressCapableflagintheNAME.Note:
14
• SETPARAM, SETPARAM1will be rejected (i.e. no ACKwill be sent) in case theoperatingmodeissetotherthanthedefinedvalues.
• The SETPARAM1 command (ID = 14) function is identical to the originalSETPARAMcommand,butinadditionitinitiatestheREPSTATUSmessage,whichisbeingtransmittedassoonastheAddressClaimprocessisfinished.Thisallowsthehost’sprogramtowaitfortheREPSTATUSmessagetoobtainthenegotiatedsourceaddress.
MessageIdentifier: 7/14TotalLength: 17bytesResponse: ACKIndex Code Value0 MSG_TOKEN_START 1921 LengthMSB 02 LengthLSB 143 MSG_ID_SET 7/144 NAMELSB xx5 NAME xx6 NAME xx7 NAME xx8 NAME xx9 NAME xx10 NAME xx11 NAME MSB xx12 SourceAddress (SA) xx13 SARangeBottom xx14 SARangeTop xx15 OperatingMode xx16 CHKSUM xx
REQINFO–RequestInformationfromJ1939Gateway
This message, sent from the host system to the jCOM.J1939gateway, requests thetransmission of the report message REPSTATUS or the version message VERSIONaccordingtotheRequestID.RequestID: REPSTATUS(ID=9) VERSION(ID=13)Note:
This message reports the address claim status and the negotiated source address.REPSTATUSisusuallyaresponsetotheREQINFOmessage,butisalsotransmittedwhenthesource(node)addresschangedduetoanaddresschallengeduringoperation.ThereportedSTATUSwillbe:
The reported SA will be NULLADDRESS (254) when the address claim process is inprogress, the address claim failed, or the operating mode is Listen-Only. In case thesourceaddressis254,checktheJ1939ProtocolStatus.MessageIdentifier: 9TotalLength: 7bytesResponse: -Index Code Value0 MSG_TOKEN_START 1921 LengthMSB 02 LengthLSB 43 MSG_ID_RS 94 Status xx5 SourceAddress xx6 CHKSUM xx
• The ACK message will be active per default, unless overwritten by the hostsystem.
MessageIdentifier: 11TotalLength: 6bytesResponse: ACK(onlywhenactivated)Index Code Value0 MSG_TOKEN_START 1921 LengthMSB 02 LengthLSB 33 MSG_ID_SETACK 114 ACTIVE xx(0-inactive,1-active)5 CHKSUM xx
17
SETHEART–SetHeartbeatFrequency
Thismessageallowsthesettingoftheheartbeatfrequencyinunitsofmilliseconds.Themessage frequency is assigned by two bytes, allowing a range of 100 – 5000milliseconds, i.e. a time of less than 100millisecondswill be corrected to 100, and atimeofmorethan5000willbecorrectedto5000.Note:
8 SW_VERSIONMINOR xx9 SW_VERSIONBUGFIX xx10 CHKSUM xx
SETMSGMODE–SetMessageMode
The message mode defines the type of data (PGNs) that is being passed from thegatewaytothehostsystem.Thiscommand isonlynecessary forgatewayapplicationswheretheuserneedstoseeallPGNsincludingthoseforprotocolcontrol.Thesettingsare: