Free 7 Day Trial RV GPS App RV Trip Planner Campground Reviews RV Maintenance Free 7 Day Trial ×


Reply
 
Thread Tools Display Modes
 
Old 01-26-2020, 01:36 PM   #41
Bus Geek
 
Join Date: May 2009
Location: Columbus Ohio
Posts: 15,804
Year: 1991
Coachwork: Carpenter
Chassis: International 3800
Engine: DTA360 / MT643
Rated Cap: 7 Row Handicap
I dont do the Heavy hitting of the J1939 data bus.. lots of timing and handshake to deal with... I use the BB-electronics box because it handles all the data coms to the J1708 / J1939. and I just get serial data that I requested.. the BB box throws some extra things in like time stamping. and can push out Hex or just character representations.. I run the interface in 460,800 baud. as my J1939 is only 250k .. running it in Hex you'll eventiually crash the buffer.. i just did it for ease of experimentation...



a sample of the data my Adapter sent to me over the serial port..


Code:

01 05 02 29 81 28 8D 0D 67 80 10 18 08 C0 00 00 FF F7 D4 14 03 2C 

01 05 02 29 81 2A 1D 0D 67 80 60 18 08 F5 03 FF FF FF FF FF FF 5F 

01 05 02 29 81 2B AD 0D C7 80 28 18 08 7D 00 00 7D 4E 20 4E 43 1F 

01 05 02 29 81 2D 74 0D C7 F2 50 18 08 0F 1F 4C FF FF FF FF FF FE 

01 05 02 29 81 42 00 0D 67 80 20 00 08 F1 FF FF FE 15 FF FF FF 0F 

01 05 02 29 81 43 6B 0D 67 80 18 00 08 FD 00 16 FF FF FF FF FF 82 

01 05 02 29 81 44 D5 0D C7 80 00 78 08 F1 FF FF FF FF FF FF FF 89 

01 05 02 29 81 46 43 0D C7 F7 88 00 08 FF FF FF FF FF FF FF FF 8E 

01 05 02 29 81 47 AB 0D 67 80 10 18 08 C0 00 00 FF F7 D4 14 03 69 

01 05 02 29 81 65 92 0D 67 80 10 18 08 C0 00 00 FF F7 CE 14 03 68 

01 05 02 29 81 67 2A 0D 67 80 60 18 08 F8 03 FF FF FF FF FF FF AC 

01 05 02 29 81 6F 09 0D 67 80 20 00 08 F1 FF FF E8 15 FF FF FF 2F 

01 05 02 29 81 84 2C 0D 67 80 10 18 08 C0 00 00 FF F7 CE 14 03 21
01 05 02 29 81 9F A9 0D 67 80 20 00 08 F1 FF FF FC 15 FF FF FF 13 

01 05 02 29 81 A2 B5 0D 67 80 10 18 08 C0 00 00 FF F7 C6 14 03 C0
a REALLY RUDE CRUDE PHP script to parse it and print it out on the screen.. (runs in php-cli in linux).


Code:

#!/usr/bin/php
<?php
## saved data from the HDV
$rr = file_get_contents("j1939-raw-cruiser30-s.txt");
# every message starts with 01 05 02 hex so we break apart our message there and get our data.
$ggg = explode("01 05 02",$rr);
## hex data provided by my HDV100 serial to J1939 device.
##     [13090] =>  0D 48 7A 2F 0D 67 80 60 18 08 00 FB FF FF FF FF FF FF 6F
##     [13091] =>  0D 48 97 30 0D 67 80 10 18 08 C0 00 00 FF F7 00 00 03 01
#                 | timestamp |DL| PGN ID    | SPN DATA & node ID       |CS|
#                                |  data specified by DL(data length    |

# timestamp - 4 byte HDV originated time.
# DL - number of data bytes (includng PGN ID) in Hex (0D = 13)
# PGN ID - 18 bits
foreach ($ggg as $raw1939) {
  # get rid of any mis spaces at begin or end of string
  $rawbreak = trim($raw1939);
  # echo "|".$rawbreak."|\n";
  ## get our data length.
  $hexdl = substr($rawbreak,12,2);
  # make it decimal
  $decdl = base_convert($hexdl,16,10) * 3;
  ## get the data minus the 4 PGN ID bytes
  $rawhexdata = trim(substr($rawbreak,30,($decdl - 16)));
echo "RAW: $raw1939\n";

  # to get the PGN ID we need to be after the Data length and timestamp and just the 4 bytes (32 raw bits)
  # which contains the PGN ID.
  $rawpgn = substr($raw1939,15,12);
  # delete the spaces in the record format
  $drr= str_replace(" ","",trim($rawpgn));
  $rawpgn = $drr;
  # convert the 4 byte Hex number to Binary.
  $binpgn = base_convert($rawpgn,16,2);
  # base convert leaves out the leading 0, so we add it if the value doesnt start with a 1.
  # for a total of 32 bits to work with.
  $binpgn = str_pad($binpgn,32,'0',STR_PAD_LEFT);
  echo $binpgn."\n";
  # echo "67 - ".base_convert("67",16,2)."\n";
  # echo "C7 - ".base_convert("C7",16,2)."\n";
# below is the Binary breakout of the first 4 bytes after DL.

#     67       80       60       18
#  01100111 10000000 01100000 00011000
#  011 0 0 111 10000 01100000 00011 000
#     |   PGN here 18 bits   |       |Ign|

#     67       80       10       18
#  01100111 10000000 00010000 00011000
#  011 0 0 111 10000 00010000 00011   000
#     |   PGN here 18 bits   |       |Ign|
# 001111000000000011 - this is the binary of the 18 PGN ID bits
# DECIMAL IS 61443
# get the 18 bits we need from the 4 byte (32 bit) piece
$binpgnbreak = substr($binpgn,3,18);
# turn it to decimal since PGNs are listed in the book as decimal numbers.
$sourcebrak = substr($binpgn,24,5);
$decsrc = base_convert($sourcebrak,2,10);
$decpgn = base_convert($binpgnbreak,2,10);
# echo $binpgnbreak." - ".$decpgn."\n";
/*

Electronic Engine Controller # 2 – EEC 2
Transmission Rate : 50 ms
Data Length: 8 bytes
Data Page: 0
PDU format: 240
PDU specific: 3
Default priority: 3
PGN: 61,443 (0x00F003)
Byte: 1 Status_EEC2
    Bits: 8-5 Not Defined (Transmitted as 1111)
    Bits: 4-3 AP Kickdown Switch (SPN 559)
        00: Kickdown Passive01: Kickdown Active
        11: Not Configured
    Bits: 2,1 AP Low Idle Switch (SPN 558)
        00: Not In Low Idle Condition
        01: In Low Idle Condition
        10: Error Detected
        11: Not Configured
Byte: 2 Accelerator Pedal Position (TPS) (SPN 91)
    Resolution: 0.4% / Bit, 0% offset
Byte: 3 Percent Load At Current Speed (SPN 92)
    Resolution: 1% / Bit, 0% offset
Byte: 4 Remote Accelerator–N/A
Bytes: 5-8 Not Defined


Electronic Transmission Controller #1 ETC1
Reception Rate : 10 ms
Data Length: 8 bytes
Data Page: 0
PDU format: 240
PDU specific: 2
Default priority: 3
PGN: 61442 (0x00F002)
Byte :  1 - Status_ETC1
   Bits: 8,7 - Not Defined
   Bits: 6,5 - Shift in Progress (SPN 574)
     00: - shift is not in process
     01: - shift in process
     11: - N/A
   Bits: 4,3 - Torque Converter Lockup Engaged (SPN 573)
     00: - Torque Converter Lockup Disengaged
     01: - Torque Converter Lockup Engaged
   Note:  Rel 38.0 or later
   Bits: 2,1 - Driveline Engaged
     00: - Driveline Disengaged
     01: - Driveline Engaged
     11: - N/A
Byte:  2,3 - Output Shaft Speed (SPN 191)
   Resolution: - 0.125 rpm / Bit, 0 rpm offset
Byte:  4 - Percent Clutch Slip - N/A
Byte:  5 - Command_ETC1
   Bits: 8-5 - Not Defined
   Bits: 4-3 - Progressive Shift Disabled (SPN 607)
     00: - Progressive Shift Is Not Disabled
     01: - Progressive Shift Is Disabled
     11: - N/A
   Bits: 2,1 - Momentary Engine Overspeed Enable (SPN 606)
     00: - Momentary Engine Overspeed Is Disabled
     01: - Momentary Engine Overspeed Is Enabled
     11: - N/A
Bytes: 6,7 - Input Shaft Speed - N/A
Byte:  8 - Source Address of Controlling Device for Transmission
   Control N/A
*/
## now lets try to break apart a PGN because its
## Transmission related info from the ECM.
switch ($decpgn) {
  case "61440":
    ## the SPN's in this PGN use 8 bytes per the spec.
    echo "SOURCE:  $decsrc   GOT 61440 - $rawhexdata\n";
    # grab byte 1 - supported by Navistar.
    # last 6 bits are of use.
    $byte1 = substr($rawhexdata,0,2);
    $byte1 = str_pad(base_convert($byte1,16,2),8,'0',STR_PAD_LEFT);
    echo "SPN: 572 Trans Retarder shift assist: ".substr($byte1,0,2);
    echo "  SPN: 571 Trans retarder brake switch: ".substr($byte1,2,2);
    echo "  SPN: 900 Retarder mode: ".substr($byte1,4,4)."\n";
    break;
    break;
  case "61442":
    ## the SPN's in this PGN use 8 bytes per the spec.
    echo "SOURCE:  $decsrc   GOT 61442 - $rawhexdata\n";
    # grab byte 1 - supported by Navistar.
    # last 6 bits are of use.
    $byte1 = substr($rawhexdata,0,2);
    $byte1 = str_pad(base_convert($byte1,16,2),8,'0',STR_PAD_LEFT);
    echo "SPN: 574 Trans Shift in Progress: ".substr($byte1,2,2);
    echo "  SPN: 573 Trans TCC Lock call: ".substr($byte1,4,2);
    echo "  SPN: 560 Trans Engaged status: ".substr($byte1,6,2)."\n";
    break;
  case "61443":
    ## the SPN's in this PGN use 8 bytes per the spec.
    # FD 00 3D FF FF FF FF FF
    # 11110001 00000000 00111101 11111111 11111111 11111111 11111111 11111111
    echo "SOURCE:  $decsrc   GOT 61443 - $rawhexdata\n";
    # grab byte 1 - supported by Navistar.
    # last 4 bits are of use.
    $byte1 = substr($rawhexdata,0,2);
    $byte1 = str_pad(base_convert($byte1,16,2),8,'0',STR_PAD_LEFT);
    echo "SPN: 559 Trans KickDown call: ".substr($byte1,4,2);
    echo "  SPN: 558 Engine Low Idle status: ".substr($byte1,6,2);
    # TPS
    $byte2 = substr($rawhexdata,3,2);
    $byte2 = base_convert($byte2,16,10);
    echo "  SPN: 91 TPS: ".($byte2 * 0.4);

    # engine load
    $byte3 = substr($rawhexdata,6,2);
    $byte3 = base_convert($byte3,16,10);
    echo "  SPN: 92 Engine Load: ".$byte3."\n";
    break;
  case "61444":
    # F1 FF FF 04 10 FF FF FF #
    #  11110001 11111111 11111111 00000100 00010000
    ## the SPN's in this PGN use 8 bytes per the spec
    echo "SOURCE:  $decsrc   GOT 61444 - $rawhexdata\n";

    # grab byte 1 - supported by Navistar.
    # last 4 bits are of use.
    $byte1 = substr($rawhexdata,0,2);
    ## pad the Binary numbers with 0's or the Bin to Hex / decimal converter gets lost
    $byte1 = str_pad(base_convert($byte1,16,2),8,'0',STR_PAD_LEFT);
    echo "SPN: 899 Engine control mode: ".substr($byte1,4);
    ## bytes 2 and 3 unsupported. they are sent as FF in all of my captures

    ## bytes 4 and 5 are the engine RPM data.
    $byte4 = substr($rawhexdata,9,2);
    $byte5 = substr($rawhexdata,12,2);
    ## get a decimal number for our hex. bytes need reversed per spec
    $rpmdec = base_convert($byte5.$byte4,16,10);
    echo "  SPN: 190 Engine RPM Raw: $rpmdec  Real RPM:".$rpmdec*.125."\n";
    break;
  case "61445":
    echo "SOURCE:  $decsrc   GOT 61445 - $rawhexdata\n";
    $byte1 = substr($rawhexdata,0,2);

    echo "SPN: 524 Trans Sel Gear:".base_convert($byte1,16,10);

    ## bytes 2 and 3 are gear ratio.
    $byte2 = substr($rawhexdata,3,2);
    $byte3 = substr($rawhexdata,6,2);
    $tratio = base_convert($byte3.$byte2,16,10) * .001;
    echo "  SPN: 526 Trans Ratio:".$tratio;
    $byte4 = substr($rawhexdata,9,2);
    echo "  SPN: 523 Trans run Gear:".base_convert($byte4,16,10);
    $byte5 = chr(base_convert(substr($rawhexdata,12,2),16,10));
    $byte6 = chr(base_convert(substr($rawhexdata,15,2),16,10));
    echo "  SPN: 162 Trans Req Range:".$byte6.$byte5;

    $byte7 = chr(base_convert(substr($rawhexdata,18,2),16,10));
    $byte8 = chr(base_convert(substr($rawhexdata,21,2),16,10));
    echo "  SPN: 163 Trans run Range:".$byte8.$byte7."\n";

    break;
  case "61452":
    echo "SOURCE:  $decsrc   GOT 61452 - $rawhexdata\n";
    $byte1 = substr($rawhexdata,0,2);
    $byte2 = substr($rawhexdata,3,2);
    $tccratio = base_convert($byte2.$byte1,16,10) * .001;
    echo "SPN: 3030 TCC Ratio: $tccratio\n";
    break;
  default:
    echo "SOURCE:  $decsrc   GOT Uncaught PGN - $decpgn - $rawhexdata    FULL: $raw1939   BIN: $binpgn\n";
    break;
}
}
# print_r($ggg);

#  01100111 10000000 00010000 00011000
#                    00010111
#     C7      F7       88       00
# 11000111 11110111 10001000 00000000
# 11000111 11110111 10001111 11111000
#                      143     248
#                       8F      F8
#                C7 F7 8F F8 08 FF 00 00 FF FF FF FF FF
# 38 99 80 8A 0D C7 F7 88 00 08 FF FF FF FF FF FF FF FF 36
#|  TS       |DL|           |ML|   00 00               |
?>

I attached a sample of the test file.. and a PDF with some of the 1939 SPECs.. the forum only let me put small files up./


DDEC IV CAN bus J1587 J1922 J1939.pdf

j1939-raw-cruiser30-s.txt


-Christopher

cadillackid is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


» Featured Campgrounds

Reviews provided by

Powered by vBadvanced CMPS v3.2.3

All times are GMT -5. The time now is 09:13 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2021, vBulletin Solutions, Inc.