Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
[ALL] Cleaning, V0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoussin committed May 2, 2017
1 parent 0467b07 commit 01ed642
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 40 deletions.
2 changes: 1 addition & 1 deletion GUI/MotoLink.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TARGET = MotoLink
TEMPLATE = app
#win32:CONFIG += console

VERSION = 0.8.1
VERSION = 0.9.0
message(Version $$VERSION)

DEFINES *= QT_USE_QSTRINGBUILDER
Expand Down
6 changes: 3 additions & 3 deletions GUI/inc/motolink.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Motolink : public QObject
inline bool getFunctionAFR_OBD(void) { return mSettings.afrInput == AFR_INPUT_OBD ;}
inline bool getFunctionAFR_Test(void) { return mSettings.afrInput == AFR_INPUT_TEST ;}
inline bool getFunctionRecording(void) { return mSettings.functions & FUNC_RECORD ;}
inline bool getFunctionOBDEmulator(void) {return mSettings.functions & FUNC_OBD; }
inline bool getFunctionOBDEmulator(void) {return mSettings.functions & FUNC_OBD_SERVER; }
inline bool getFunctionInput_Direct(void) { return mSettings.sensorsInput == SENSORS_INPUT_DIRECT ;}
inline bool getFunctionInput_OBD(void) { return mSettings.sensorsInput == SENSORS_INPUT_OBD_CAN ;}
inline bool getFunctionInput_Yamaha(void) { return mSettings.sensorsInput == SENSORS_INPUT_YAMAHA_CAN ;}
Expand All @@ -113,8 +113,8 @@ class Motolink : public QObject
inline void setFunctionAFR_Test(void) { mSettings.afrInput = AFR_INPUT_TEST ;}
inline void setFunctionRecord(bool on) { if (on) mSettings.functions |= FUNC_RECORD;
else mSettings.functions &= ~FUNC_RECORD ;}
inline void setFunctionOBDEmulator(bool on) {if (on) mSettings.functions |= FUNC_OBD;
else mSettings.functions &= ~FUNC_OBD ;}
inline void setFunctionOBDEmulator(bool on) {if (on) mSettings.functions |= FUNC_OBD_SERVER;
else mSettings.functions &= ~FUNC_OBD_SERVER ;}

inline void setFunctionInput_Direct(void) { mSettings.sensorsInput = 0 ;}
inline void setFunctionInput_OBD(void) { mSettings.sensorsInput = SENSORS_INPUT_OBD_CAN ;}
Expand Down
2 changes: 2 additions & 0 deletions code/Motolink.files
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ ChibiOS-RT/os/rt/templates/chcore.h
ChibiOS-RT/os/rt/templates/chtypes.h
ChibiOS-RT/os/rt/templates/meta/module.c
ChibiOS-RT/os/rt/templates/meta/module.h
ChibiOS-RT/os/various/shell.c
ChibiOS-RT/os/various/shell.h
app/Makefile
app/canbus.c
app/canbus.h
Expand Down
2 changes: 1 addition & 1 deletion code/app/chconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define _CHCONF_H_

#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_MINOR 9
#define VERSION_PATCH 0

#include "vectors.h"
Expand Down
29 changes: 16 additions & 13 deletions code/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ CCM_FUNC static THD_FUNCTION(ThreadCAN, arg)
while(TRUE) {

// Are we using coms for sensor data? If not just sleep.
if (settings.sensorsInput != SENSORS_INPUT_COM && (settings.functions & FUNC_OBD) == 0) {
if (settings.sensorsInput != SENSORS_INPUT_COM && (settings.functions & FUNC_OBD_SERVER) == 0) {

chThdSleepMilliseconds(100);
continue;
Expand All @@ -167,39 +167,42 @@ CCM_FUNC static THD_FUNCTION(ThreadCAN, arg)
/* Process message.*/

if (dbg_can) {
chprintf((BaseSequentialStream *)&SDU1, "->[%08x][%02x]", rxmsg.SID, rxmsg.RTR);
chprintf((BaseSequentialStream *)&SDU1, "->[SID:%08x][RTR:%01x]", rxmsg.SID, rxmsg.RTR);
for(i = 0; i < 8; i++) {
chprintf((BaseSequentialStream *)&SDU1, ":%02x", rxmsg.data8[i]);
}
chprintf((BaseSequentialStream *)&SDU1, "\n");
chprintf((BaseSequentialStream *)&SDU1, "\r\n");
}

if (settings.functions & FUNC_OBD) {
if (settings.functions & FUNC_OBD_SERVER) {

serveCanOBDPidRequest(&CAND1, &txmsg, &rxmsg);

if (dbg_can) {
chprintf((BaseSequentialStream *)&SDU1, "<-[%08x][%02x]", txmsg.SID, txmsg.RTR);
chprintf((BaseSequentialStream *)&SDU1, "<-[%08x][%01x]", txmsg.SID, txmsg.RTR);
for(i = 0; i < 8; i++) {
chprintf((BaseSequentialStream *)&SDU1, ":%02x", txmsg.data8[i]);
}
chprintf((BaseSequentialStream *)&SDU1, "\n");
chprintf((BaseSequentialStream *)&SDU1, "\r\n");
}
}

if (settings.sensorsInput == SENSORS_INPUT_OBD_CAN && 0) {
if ((settings.functions & FUNC_OBD_SERVER) == 0) {
if (settings.sensorsInput == SENSORS_INPUT_OBD_CAN) {

readCanOBDPidResponse(&rxmsg);
}
else if (settings.sensorsInput == SENSORS_INPUT_YAMAHA_CAN && 0) {
readCanOBDPidResponse(&rxmsg);
}
else if (settings.sensorsInput == SENSORS_INPUT_YAMAHA_CAN) {

readCanYamahaPid(&rxmsg);
readCanYamahaPid(&rxmsg);
}
}
}

if (settings.sensorsInput == SENSORS_INPUT_OBD_CAN && 0) {
if (settings.sensorsInput == SENSORS_INPUT_OBD_CAN
&& (settings.functions & FUNC_OBD_SERVER) == 0) {

// Request PIDs
// Request OBD PIDs
sendCanOBDFrames(&CAND1, &txmsg);
chThdSleepMilliseconds(100); // ~10Hz
}
Expand Down
29 changes: 9 additions & 20 deletions code/app/shell_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "chprintf.h"

bool dbg_can = false;
extern uint16_t irq_pct;

static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
static const char *states[] = {CH_STATE_NAMES};
Expand All @@ -14,30 +15,17 @@ static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
chprintf(chp, "Usage: threads\r\n");
return;
}
#if CH_CFG_USE_DYNAMIC
chprintf(chp, " addr stack prio refs state\r\n");
chprintf(chp, "PRIO STATE PCT NAME\r\n");
tp = chRegFirstThread();
do {
chprintf(chp, "%08lx %08lx %4lu %4lu %9s %lu\r\n",
(uint32_t)tp,
(uint32_t)tp->p_ctx.r13,
chprintf(chp, "%4u %8s %05u %12s\r\n",
(uint32_t)tp->p_prio,
(uint32_t)(tp->p_refs - 1),
states[tp->p_state]);
states[tp->p_state],
tp->pct & 0x3FFF,
tp->p_name);
tp = chRegNextThread(tp);
} while (tp != NULL);
#else
chprintf(chp, " addr stack prio state\r\n");
tp = chRegFirstThread();
do {
chprintf(chp, "%08lx %08lx %4lu %4lu %lu\r\n",
(uint32_t)tp,
(uint32_t)tp->p_ctx.r13,
(uint32_t)tp->p_prio,
states[tp->p_state]);
tp = chRegNextThread(tp);
} while (tp != NULL);
#endif
chprintf(chp, "IRQ Pct: %05u\r\n", irq_pct);
}

static void cmd_candbg(BaseSequentialStream *chp, int argc, char *argv[]) {
Expand All @@ -46,14 +34,15 @@ static void cmd_candbg(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv;
uint8_t in, buf;

chprintf(chp, "Press any key to quit\n");
chprintf(chp, "CanBus debug active. Press any key to quit.\r\n");
chThdSleepMilliseconds(1000);
dbg_can = true;
in = chSequentialStreamRead(chp, &buf, 1);
while (in == 0) {
chThdSleepMilliseconds(10);
}
dbg_can = false;
chprintf(chp, "Closed CanBus debug.\r\n");
}

const ShellCommand sh_commands[] = {
Expand Down
4 changes: 2 additions & 2 deletions code/common/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
#define KNOCK_RATIO 4.66f
#define KNOCK_MAX (3.3*KNOCK_RATIO)

#define FUNC_RECORD (uint16_t)0x0001
#define FUNC_OBD (uint16_t)0x0002
#define FUNC_RECORD (uint16_t)0x0001
#define FUNC_OBD_SERVER (uint16_t)0x0002

#define AFR_INPUT_DISABLED (uint16_t)0x0000
#define AFR_INPUT_MTS (uint8_t)0x01
Expand Down

0 comments on commit 01ed642

Please sign in to comment.