Decode PGN

Hi,
next year I will write my Bachelothesis about AOG. I did some testing in the field over the last days and collected a lot of data. I logged the communication going on between AOG and AgIO, but I have some problems in decoding the data bytes:

80817ffe08470001e7ff7f010033

I am able to get the correct speed (7.1), but no wheel angle, its obviously always 0 using characters 14 and 15. I also need the distance byte to compare that to actual measurements I took in the field but get no useful numbers.

Id also like to decode actual steer angle and roll:

80817ffd0857ff07045500052b6a

I get 0.87 deg as steer angle, is that correct?
Could someone give me a hint?

Greetings
Bennet

There is a file in the support folder explaining the messages.
Also best is to look in the arduino code how it works.
The message is:
0x80, 0x81, Src, PGN, Length, [Data Bytes: Speed(2bytes), status, StearAngle(2bytes), ***, sections(2bytes)], CRC

So what I understand:
HEX to signed int: https://cryptii.com/pipes/integer-encoder
80
81
Src=7F
PGN=FE
lenght=08
Speed= 47 00 = Hi 00 and Lo 47 would give 71 =>7.1 km/h
status=01 = 0000 0001
SteerAngleSetPoint= E7 FF = Hi FF and Lo E7 would give signed -25=> -0.25 deg
Tram= 7F = 0111 1111
sections= 01 00 = 0000 0000 0000 0001
CRC= 33

The other one:
80
81
Src=7F
PGN=FD
lenght=08
ActSteerAngle= 57 FF = Hi FF Lo 57 would -169 => -1.69 deg
Heading= 07 04 = Hi 04 Lo 07 would give 1031 => 103.1 deg
Roll= 55 00 = Hi 00 Lo 55 would give 85 => 8.5 deg? not sure
swich = 05 = 0000 0101
ActPWM = 2B => 43
CRC= 6A

2 Likes

I wrote a Python program to read data from AgIO. If you are familiar with Python here is an example.
https://github.com/salmiac/pi-steer/blob/main/pi-steer/sniff-aog.py

Now I’ve got a python script too, didnt write it myself but works great. I can just decode the .cvs output of wireshark like I wanted to. Needs to be modified to decode other stuff, but that shouldnt be to complicated…

#!/usr/bin/python3

import sys

def get_speed(input_str):
  return int.from_bytes(bytearray.fromhex(input_str[10:12] + ' ' + input_str[12:14]), byteorder='little', signed=False)

def get_was(input_str):
  return int.from_bytes(bytearray.fromhex(input_str[16:18] + ' ' + input_str[18:20]), byteorder='little', signed=True)

def get_distance(input_str):
  return int.from_bytes(bytearray.fromhex(input_str[20:22]), byteorder='little', signed=False)

def to_csv(input_str):
  speed_str = str(get_speed(input_str))
  was_str = str(get_was(input_str))
  distance_str = str(get_distance(input_str))
  return '"' + speed_str + '","' + was_str + '","' + distance_str + '"'

first = True

file_name = sys.argv[1]

file = open(file_name,"r",encoding='latin-1')
for line in file:
  line_rstrip = line.rstrip()
  
  if first:
    first = False
    print(line_rstrip + ',"speed","WAS","distance"')
    continue
  
  data_line = line_rstrip.split('","')[6]
  
  if not data_line.startswith('80817ffe'):
    continue
  
  csv_line = to_csv(data_line)
  print(line_rstrip + ',' + csv_line)
file.close()

Back again working on these messages: Decoding worked just fine, I am just asking myself if the messages are related to any “real world” standard. Would be nice to be able to refer to something like sae
Greetings
Bennet