Notifications
Clear all

OMSI 2

3 Posts
3 Users
0 Reactions
7,478 Views
Gary Swallow
(@gary_swallow)
Estimable Member
Joined: 6 years ago
Posts: 48
Topic starter  

Replays for OMSI 2


   
Quote
(@xuezhe8973)
New Member
Joined: 2 years ago
Posts: 1
 

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

 


   
ReplyQuote
(@allone)
New Member
Joined: 1 year ago
Posts: 1
 

Thank you so much.

basket random

 

This post was modified 1 year ago by Allone

   
ReplyQuote
Share: