Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Fun project, concept: playseat, play AAA simracing PC games in VR with Quest2 from inside the car

This site may earn commission on affiliate links.
Hi to all, the idea:
Parking car near a PC Windows in VR streaming mode to an Oculus Quest 2.
Develop on PC a program that read car data, at least steering wheel angle and pedals and emulate a joystick (this is easy, i done a prototype with ViGEm Bus Driver).

I'm stuck at read car data step.
- ScanMyTesla log the data i need in "All" tab, but i don't understand how to extract in realtime and send to PC for joystick emulation.
It have a Teslalogger integration, BUT steering wheel are not in the 'filters' list.
It would be nice if there was a support of standard like MQTT (@amund7), there are a lots of data analyzer and presentation around (Influx, Grafana, Home Assistant) that can integrate easy ScanMyTesla with MQTT, imho.
- I try to develop an ODB.Net program, but i don't have knowledge how to decode AT commands and fix problem (current status: i have C# code that connect, but i don't know how to decode HEX data i receive)

Any suggestion how to proceed? (i'm available to funding with a donation a development)
Thx
 
We could add steering wheel to the Teslalogger list, but Teslalogger does a lot of data compression and discarding to not overfill the Raspberry Pi with too much similar data. So I don't think that would work for what you're trying to achieve.

Look up JWardell's DBC file, there all the definitions are. What Scan My Tesla does is;

AT commands to set filters. If you're on ELM327 it's a bit complicated, you need to build a bitmask that includes the can IDs you want to recieve. If it's just one, you just need to set that one, easy.

then ATMA to stream that data, repeat when it finishes (you can look for the '>' character)

The first 3 hex letters are the can ID, the rest is payload. You will need to do a bit of bit shifting and masks to extract the data you want.

Just worried that you'll eventually touch the gear selector and blast through your garage door :D (Maybe plug the car in the charger to prevent that?)
 
  • Like
Reactions: Clodo76
AT commands to set filters. If you're on ELM327 it's a bit complicated, you need to build a bitmask that includes the can IDs you want to recieve. If it's just one, you just need to set that one, easy.
I'm stuck here, i'm a newbie about ELM327 and canID.

These are the info i found in the JWardell DBC file:
Code:
BO_ 297 ID129SteeringAngle: 8 VehicleBus
 SG_ SteeringSensorC129 : 56|8@1+ (1,0) [0|255] ""  Receiver
 SG_ SteeringSensorB129 : 48|8@1+ (1,0) [0|255] ""  Receiver
 SG_ SteeringSensorA129 : 46|2@1+ (1,0) [0|3] ""  Receiver
 SG_ SteeringSpeed129 : 32|14@1+ (0.5,-4096) [-4096|4095.5] "D/S"  Receiver
 SG_ SteeringAngle129 : 16|14@1+ (0.1,-819.2) [-819.2|819.1] "Deg"  Receiver
[..]
CM_ SG_ 297 SteeringSpeed129 "Steering Speed";
CM_ SG_ 297 SteeringAngle129 "Steering Angle";
[..]
 SG_ ESP_steeringAngleQF : 27|1@1+ (1,0) [0|1] ""  Receiver

I need "SteeringAngle", i'm trying to understand/study how to encode in ATCF * or ATCM * commands.

Anyway, thanks for your reply & info, light in the dark for me :D
 
297 decimal = 129 hex (don't ask why it's being mixed, it's DBC format standard I think)

If you now say ATCF 129, then ATCM 7FF. I forget which is which, but I don't think it matters. 7FF because that's 11 bit which is the number of ID bits in this type of bus.

ATMA after this should give you only the ID 129 messages.

now you need to shift and mask the bits so that it starts at bit 16 and gets only the 14 bits after that. Then multiply by 0.1

In case you are not up to speed on the DBC syntax,
16|14 means, start bit 16, 14 bit signal
0.1,-819.2 means multiply by 0.1, subtract 819.2
1+ means signed... ? or unsigned... can't remember off the top of my head, sorry. But with the huge negative offset I suppose you interpret those initial 14 bits as unsigned

Hope that helps!
 
  • Like
Reactions: Clodo76
I'm trying to write a C#/WinForms program, i reach the step to connect serial,
but i don't understand your "ATMA after this should give you only the ID 129 messages", plz see the log below.
The bits that i need to shift/read are somewhere in "D49FA4095609FC08" ?
Thx, sorry i'm a really newbie about this stuffs.

Code:
Sending:ATZ
Received:ATZ
Sending:ATE0
Received:ELM327 v2.2
Sending:ATL0
Received:ATL0
Received:OK
Sending:ATH0
Received:ATH0
Received:OK
Sending:ATS0
Received:ATS0
Received:OK
Sending:ATSP0
Received:ATSP0
Received:OK
Sending:ATCF 129
Received:ATCF 129
Received:OK
Sending:ATCM 7FF
Received:ATCM 7FF
Received:OK
Sending:ATMA
Received:ATMA
Received:SEARCHING...
Received:D49FA4095609FC08<DATA ERROR
Received:D49FA4095609FC08<DATA ERROR
Received:D49FA4095609FC08<DATA ERROR
Received:4B69A4095609FC08<DATA ERROR
Received:4B69A4095609FC08<DATA ERROR
Received:489212587E20FC08<DATA ERROR
Received:489212587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497D98587E20FC08<DATA ERROR
Received:497DA4B024E7FC08<DATA ERROR
Received:497DA4B024E7FC08<DATA ERROR
Received:668FA4B024E7FC08<DATA ERROR
Received:668FA4B024E7FC08<DATA ERROR
Received:668FA4B024E7FC08<DATA ERROR
Received:668FA4B024E7FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08<DATA ERROR
Received:497DA4587E20FC08
Received:BUFFER FULL
 
No, the first 3 bytes are the can ID's.

To be clear, does the same device and wiring work with scan my tesla? If so, we know the adapter works for this task, and your wiring is correct.

If so, try this: Do an ATMA first. That lets the obd2 adapter auto detect the bus speed and type. It may be that ATCM and ATCF doesn't register before you do that. After that the bytes you see are straight forward. In your example, D49 should be the CAN ID, after that comes the payload. There is an AT command to get rid of the 'DATA ERROR' too, the reason is the Tesla data is somewhat out of spec I think, the packets have different payload lenghts. That command is ATCAF0

I checked my code, I send ATH1. So I think in your case, you are actually turning off the header / CAN ID. Try with ATH1 instead of ATH0. Then you should only get packets starting with 129. Of course that won't be necessary if you only want that sincle packet. But I think some other packets come in in any case, one called 7FF or something like that, so without the ID's you won't be able to pick out the right ones.
 
Current situation (please be patience, difficult to explain for me):
At serial connection, i do
  • ATCAF0 // rid of the 'DATA ERROR'
  • ATH1 // With CAN/ID
  • ATS0 // Without spaces in response
  • ATMA
  • when i receive "BUFFER FULL", i run another ATMA.
(no ATCM or ATCF commands until all works)

Now, Model3CAN.dbc say about "Acceleration Pedal"
# BO_ 280 ID118DriveSystemStatus: 8 VehicleBus
# SG_ DI_accelPedalPos : 32|8@1+ (0.4,0) [0|100] "%" Receiver
and works, when i receive an ID 118(hex), i pick the payload, i pick 8 bits from 32 bits offset, multiply *0.4, add 0, i obtain a value in range 0..100% that match the real pedal (and also ScanMyTesla measurement).
IT WORKS!!!!

.... BUT, i don't yet find a solution for "Steering Angle".
Model3CAN.dbc say
# BO_ 297 ID129SteeringAngle: 8 VehicleBus
# SG_ SteeringSensorC129 : 56|8@1+ (1,0) [0|255] "" Receiver
# SG_ SteeringSensorB129 : 48|8@1+ (1,0) [0|255] "" Receiver
# SG_ SteeringSensorA129 : 46|2@1+ (1,0) [0|3] "" Receiver
# SG_ SteeringSpeed129 : 32|14@1+ (0.5,-4096) [-4096|4095.5] "D/S" Receiver
# SG_ SteeringAngle129 : 16|14@1+ (0.1,-819.2) [-819.2|819.1] "Deg" Receiver
I move the steering wheel to around 46 degree, i open ScanMyTesla, and SteeringWheelAngle jump between 46.0 and 46.1 degree (correct).
i run my program, and i receive two kind of payload for CANID 129 (binary below):
Code:
                <16 bit start>
                <14-bit len  >
1001111100101000110011000110000100000000001000001111111100111111
0001000000101011110011010110000100000000001000001111111100111111
so data in binary that i read are
11001100011000 binary = 13080 decimal, *0.1 -819.2 = 488.8 deg
11001101011000 binary = 13144 decimal, *0.1 -819.2 = 495.2 deg
but ScanMyTesla report
46.0 deg, +819,2 / 0.1 = 8652 decimal, 10000111001100 binary
46.1 deg, +819,2 / 0.1 = 8653 decimal, 10000111001101 binary
  • The fact i read "Acceleration Pedal" mean i correctly parse payload
  • About "SteeringWheelAngle", i start receive CANID 129 messages when i touch the steering wheel, so is ok
  • i receive two kind of values, like the ScanMyTesla jump between two values.
This is my progress about this. I'm in a trial-error phase, for my zero knowledge about CANBUS.
I never would have gotten this far without your help, so thanks again, even if you don't reply (i understand the mess :p).
I will release the source-code on Github when i reach a working status, maybe helpful for other projects.