SimHub icon indicating copy to clipboard operation
SimHub copied to clipboard

Some problems in OMSI2

Open xuezhe8973 opened this issue 2 years ago • 4 comments

Hi,i bought a dashboard from a car, and now it can show parkbrake、highbeam、left and right signal、and all of the gauges are OK in Ets2 or in BEAMNG, but some of the data can not be find in the protocol message such as highbeam and parkbrake even the left and right signal also can not be collected. Now i have no idea to drive them, can anyone show some suggestions.(The following code is one of my solution, but the signal shows no respond).And every game has its own name for the same data, why not rename it for shorten the code.

This is in the Protocol message Binding

var DL_FULLBEAM = 2 var DL_HANDBRAKE = 4 var DL_ABS = 1024

if ($prop('TurnIndicatorLeft')) var left1=1; else left1=0; if ($prop('TurnIndicatorRight')) var right1=1; else right1=0; if ($prop('GameRawData.AI_Blinker_L')) var omsileft=1; else omsileft=0; if ($prop('GameRawData.AI_Blinker_R')) var omsiright=1; else omsiright=0; if ($prop('GameRawData.lights_blinkgeber')) var omsiblink=1; else omsiblink=0; if ($prop('EngineStarted')) var battery=1; else battery=0; if ($prop('GameRawData.ShowLights') & DL_FULLBEAM) var fullBeam=1; else fullBeam=0; if ($prop('GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh')) var highbeam=1; else highbeam=0;  if ($prop('GameRawData.lights_fern')) var omsibeam=1; else omsibeam=0; if ($prop('GameRawData.ShowLights') & DL_HANDBRAKE) var handbrake=0; else handbrake=1; if ($prop('GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake')) var ETpark=1; else ETpark=0; if ($prop('GameRawData.ShowLights') & DL_ABS) var abs=1; else abs=0; return (omsiblink + ';' + left1 + ';' + omsileft + ';' + right1 + ';' + omsiright + ';' + battery + ';' + fullBeam + ";" + highbeam + ';' + omsibeam + ';' + handbrake + ';' + ETpark + ';' + abs)

This is in the Arduino(Due to the different work mode for my dash, i use the base control instead of use pinmode

#ifndef SHCUSTOMPROTOCOL_H #define SHCUSTOMPROTOCOL_H

#include <Arduino.h>

class SHCustomProtocol { private:

public: // Called when starting the arduino (setup method in main sketch) void setup() { }

// Called when new data is coming from computer void read() { // EXAMPLE 1 - read the whole message and sent it back to simhub as debug message // Protocol formula can be set in simhub to anything, it will just echo it // ------------------------------------------------------- //String message = FlowSerialReadStringUntil('\n'); //FlowSerialDebugPrintLn("Message received : " + message); int omsiblink = FlowSerialReadStringUntil(';').toInt(); int leftindicator = FlowSerialReadStringUntil(';').toInt(); int omsileft = FlowSerialReadStringUntil(';').toInt(); int rightindicator = FlowSerialReadStringUntil(';').toInt(); int omsiright = FlowSerialReadStringUntil(';').toInt(); int batterylight = FlowSerialReadStringUntil(';').toInt(); int fullbeamlight = FlowSerialReadStringUntil(';').toInt(); int fullbeamlight1 = FlowSerialReadStringUntil(';').toInt(); int omsibeamlight = FlowSerialReadStringUntil(';').toInt(); int handbrakelight = FlowSerialReadStringUntil(';').toInt(); int handbrakelight1 = FlowSerialReadStringUntil(';').toInt(); int abslight1 = FlowSerialReadStringUntil('\n').toInt();

if(leftindicator == 1){ DDRB=0B00000001 | DDRB; PORTB=0B00000001 | PORTB; } else { DDRB=0B11111110 & DDRB; } //left signal = pin 53 +vcc if(rightindicator == 1){ DDRB=0B00000010 | DDRB; PORTB=0B00000010 | PORTB; } else { DDRB=0B11111101 & DDRB; } //right signal = pin 52 +vcc if(batterylight == 1){ DDRB=0B00001000 | DDRB; PORTB=0B11110111 & PORTB; } else { DDRB=0B00001000 | DDRB; PORTB=0B00001000 | PORTB; } //batterylight+enginelight = pin50 gnd down if(abslight1 == 1){ DDRB=0B00000100 | DDRB; PORTB=0B11111011 & PORTB; } else { DDRB=0B00000100 | DDRB; PORTB=0B00000100 | PORTB; } //abslight = pin 51 gnd down if(handbrakelight1 == 1 || handbrakelight == 1){ DDRL=0B00000001 | DDRL; PORTL=0B11111110 & PORTL; } else { DDRL=0B00000001 | DDRL; PORTL=0B00000001 | PORTL; } if(fullbeamlight == 1 || fullbeamlight1 == 1 || omsibeamlight == 1){ DDRL=0B00100000 | DDRL; PORTL=0B00100000 | PORTL; } else { DDRL=0B11011111 & DDRL; } //pin 44

} // Called once per arduino loop, timing can't be predicted, // but it's called between each command sent to the arduino void loop() { }

// Called once between each byte read on arduino, // THIS IS A CRITICAL PATH : // AVOID ANY TIME CONSUMING ROUTINES !!! // PREFER READ OR LOOP METHOS AS MUCH AS POSSIBLE // AVOID ANY INTERRUPTS DISABLE (serial data would be lost!!!) void idle() { } };

#endif

 

xuezhe8973 avatar Jul 22 '22 09:07 xuezhe8973

Hi ! Unfortunately OMSI2 has a really bad telemetry which is not documented correctly (and mostly in deutch which makes it even harder :D) , there are lot of lacks in it. I tried to expand it without success : https://github.com/SHWotever/SimHub/issues/601 . The documentations are really old and incomplete.

Currently there are a little more than 150 properties which are normalised accross all games and which are obviously targeting mostly race games. Properties with different names are GameRawData (data which are not normalized and specific to a game telemetry. If you see telemetry values which would deserve to be normalized (because available in a similar way in many games) do not hesitate to notify me so I can add them as "cross game" data. I mostly add them on demand now as with more than 65 games its really hard to spot those "cross games" data which appears when I add a new game.

Nicolas

SHWotever avatar Jul 22 '22 10:07 SHWotever

The data in OMSI2 has been got. You just add lights_blinker_l and lights_blinker_r into the varlist in SimhubOmsi.opl. My friends are the authors of some ChineseVehicle, so they help me add these varlist to use the signal but when i add them in front of some other valists, the valists are input the old order (i add it into the ai_light, ai_light acted as the varlist i add,of course i change the varlist amount. Can you help me add these two varlists, it may help a lot of players, THX 捕获

xuezhe8973 avatar Jul 22 '22 11:07 xuezhe8973

The bemng data $prop('GameRawData.ShowLights') & DL_FULLBEAM and ETS2 DATA $prop('GameRawData.TruckValues.CurrentValues.LightsValues.BeamHigh') can be binded as highbeam

The bemng data $prop('GameRawData.ShowLights') & DL_HANDBRAKE and ETS2 DATA $prop('GameRawData.TruckValues.CurrentValues.MotorValues.BrakeValues.ParkingBrake') and omsi2 data $prop('GameRawData.cockpit_light_feststellbremse') can be binded as handbrake

the 'lights_blinker_l' in OMSI2 can be binded as TurnIndicatorLeft so as the 'lights_blinker_r'

i will keep send these similar data to help you bind them

xuezhe8973 avatar Jul 22 '22 11:07 xuezhe8973

Hi ! Unfortunately OMSI2 has a really bad telemetry which is not documented correctly (and mostly in deutch which makes it even harder :D) , there are lot of lacks in it. I tried to expand it without success : #601 . The documentations are really old and incomplete.

Currently there are a little more than 150 properties which are normalised accross all games and which are obviously targeting mostly race games. Properties with different names are GameRawData (data which are not normalized and specific to a game telemetry. If you see telemetry values which would deserve to be normalized (because available in a similar way in many games) do not hesitate to notify me so I can add them as "cross game" data. I mostly add them on demand now as with more than 65 games its really hard to spot those "cross games" data which appears when I add a new game.

Nicolas

Hope you can notice the reply above this reply,thx

xuezhe8973 avatar Jul 30 '22 08:07 xuezhe8973