Skip to content

Commit 2e8e407

Browse files
authored
Merge pull request #4 from designer2k2/signed_int_bugfix
Signed int bugfix
2 parents 113c9ac + 9546952 commit 2e8e407

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "git",
1212
"url": "https://github.com/designer2k2/EMUcan"
1313
},
14-
"version": "1.0.5",
14+
"version": "1.0.6",
1515
"license": "GPL-3.0-only",
1616
"frameworks": "arduino",
1717
"platforms": "*",

library.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name=EMUcan
2-
version=1.0.5
2+
version=1.0.6
33
author=Stephan M. <designer2k2@gmail.com>
44
maintainer=Stephan M. <designer2k2@gmail.com>
55
sentence=ECUMaster EMU CAN Stream Reader Arduino Library
66
paragraph=Library to read and decode the ECUMaster default CAN Stream with a MCP2515. It can also send data to the EMU.
77
category=Communication
88
url=https://github.com/designer2k2/EMUcan
99
architectures=*
10-
includes=EMUcan.h
10+
includes=EMUcan.h
11+
depends=autowp-mcp2515

src/EMUcan.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ bool EMUcan::decodeEmuFrame(struct can_frame *msg) {
9292
//0-1 RPM in 16Bit unsigned
9393
emu_data.RPM = (msg->data[1] << 8) + msg->data[0];
9494
//2 TPS in /2 %
95-
emu_data.TPS = msg->data[2] / 2;
95+
emu_data.TPS = msg->data[2] * 0.5;
9696
//3 IAT 8bit signed -40-127°C
97-
emu_data.IAT = msg->data[3];
97+
emu_data.IAT = int8_t(msg->data[3]);
9898
//4-5 MAP 16Bit 0-600kpa
9999
emu_data.MAP = (msg->data[5] << 8) + msg->data[4];
100100
//6-7 INJPW 0-50 0.016129ms
@@ -110,29 +110,29 @@ bool EMUcan::decodeEmuFrame(struct can_frame *msg) {
110110
}
111111
//Base +2:
112112
if (msg->can_id == _EMUbase + 2) {
113-
//0-1 VSPD in 16Bit unsigned
113+
//0-1 VSPD in 16Bit unsigned 1 kmh/h / bit
114114
emu_data.vssSpeed = (msg->data[1] << 8) + msg->data[0];
115-
//2 BARO kPa
115+
//2 BARO 50-130 kPa
116116
emu_data.Baro = msg->data[2];
117117
//3 OILT 0-160°C
118118
emu_data.oilTemperature = msg->data[3];
119-
//4 OILP BAR 0.0625
119+
//4 OILP BAR 0.0625 bar/bit
120120
emu_data.oilPressure = msg->data[4] * 0.0625;
121-
//5 FUELP BAR 0.0625
121+
//5 FUELP BAR 0.0625 bar/bit
122122
emu_data.fuelPressure = msg->data[5] * 0.0625;
123-
//6-7 CLT 16bit Signed 0.016129ms
124-
emu_data.CLT = ((msg->data[7] << 8) + msg->data[6]);
123+
//6-7 CLT 16bit Signed -40-250 1 C/bit
124+
emu_data.CLT = int16_t(((msg->data[7] << 8) + msg->data[6]));
125125
}
126126
//Base +3:
127127
if (msg->can_id == _EMUbase + 3) {
128128
//0 IGNANG in 8Bit signed -60 60 0.5deg/bit
129-
emu_data.IgnAngle = msg->data[0] / 2;
129+
emu_data.IgnAngle = int8_t(msg->data[0]) * 0.5;
130130
//1 DWELL 0-10ms 0.05ms/bit
131131
emu_data.dwellTime = msg->data[1] * 0.05;
132132
//2 LAMBDA 8bit 0-2 0.0078125 L/bit
133133
emu_data.wboLambda = msg->data[2] * 0.0078125;
134134
//3 LAMBDACORR 75-125 0.5%
135-
emu_data.LambdaCorrection = msg->data[3] / 2;
135+
emu_data.LambdaCorrection = msg->data[3] * 0.5;
136136
//4-5 EGT1 16bit °C
137137
emu_data.Egt1 = ((msg->data[5] << 8) + msg->data[4]);
138138
//6-7 EGT2 16bit °C
@@ -169,14 +169,14 @@ bool EMUcan::decodeEmuFrame(struct can_frame *msg) {
169169
emu_data.boostTarget = ((msg->data[1] << 8) + msg->data[0]);
170170
//2 PWM#1 DC 1%/bit
171171
emu_data.pwm1 = msg->data[2];
172-
if (msg->can_dlc == 8) {
173-
//4 Lambda target 8bit 0.01%/bit
174-
emu_data.lambdaTarget = msg->buf[4] / 100.0;
175-
//5 PWM#2 DC 1%/bit
176-
emu_data.pwm2 = msg->buf[5];
177-
//6-7 Fuel used 16bit 0.01L/bit
178-
emu_data.fuel_used = ((msg->buf[7] << 8) + msg->buf[6]) / 100.0;
179-
}
172+
if (msg->can_dlc == 8) {
173+
//4 Lambda target 8bit 0.01%/bit
174+
emu_data.lambdaTarget = msg->data[4] * 0.01;
175+
//5 PWM#2 DC 1%/bit
176+
emu_data.pwm2 = msg->data[5];
177+
//6-7 Fuel used 16bit 0.01L/bit
178+
emu_data.fuel_used = ((msg->data[7] << 8) + msg->data[6]) * 0.01;
179+
}
180180
}
181181
return true;
182182
}

src/EMUcan.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <mcp2515.h>
2828

29-
#define EMUCAN_LIB_VERSION (F("1.0.5"))
29+
#define EMUCAN_LIB_VERSION (F("1.0.6"))
3030

3131
// Available data
3232
struct emu_data_t {
@@ -100,7 +100,7 @@ class EMUcan {
100100
bool sendFrame(const struct can_frame *);
101101
bool CanCheckError();
102102
uint8_t CanErrorCounter(bool RXorTX);
103-
103+
104104
// Data
105105
struct emu_data_t emu_data;
106106

@@ -185,7 +185,7 @@ class EMUcan {
185185
enum EMUcan_STATUS EMUcan_Status = EMUcan_FRESH;
186186
MCP2515 *getMcp2515();
187187

188-
void ReturnAllFrames (ReturnAllFramesFunction response);
188+
void ReturnAllFrames (ReturnAllFramesFunction response);
189189
void ReturnAllFramesStop();
190190

191191
// Privates
@@ -206,4 +206,4 @@ class EMUcan {
206206
unsigned long _previousMillis = 0;
207207

208208
};
209-
#endif
209+
#endif

0 commit comments

Comments
 (0)