projects
/
elmcan.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dcb1fe3
)
Rename TODO_* to ELM327_TX_DO_*
author
norly
<ny-git@enpas.org>
Sat, 12 Mar 2022 18:08:48 +0000
(19:08 +0100)
committer
norly
<ny-git@enpas.org>
Sat, 12 Mar 2022 18:08:48 +0000
(19:08 +0100)
Also rename elm->can_frame to elm->can_frame_to_send
module/elmcan.c
patch
|
blob
|
history
diff --git
a/module/elmcan.c
b/module/elmcan.c
index 1fc57895b0eaec0e0ff02ef0388f388ce2bff2f8..69ca8df78ae3fddf54cb396706898f36e273f52e 100644
(file)
--- a/
module/elmcan.c
+++ b/
module/elmcan.c
@@
-65,16
+65,16
@@
MODULE_AUTHOR("Max Staudt <max-linux@enpas.org>");
#define ELM327_READY_CHAR '>'
/* Bits in elm->cmds_todo */
#define ELM327_READY_CHAR '>'
/* Bits in elm->cmds_todo */
-enum ELM
_TODO
{
-
TO
DO_CAN_DATA = 0,
-
TO
DO_CANID_11BIT,
-
TO
DO_CANID_29BIT_LOW,
-
TO
DO_CANID_29BIT_HIGH,
-
TO
DO_CAN_CONFIG_PART2,
-
TO
DO_CAN_CONFIG,
-
TO
DO_RESPONSES,
-
TO
DO_SILENT_MONITOR,
-
TO
DO_INIT
+enum ELM
327_TX_DO_BITS
{
+
ELM327_TX_
DO_CAN_DATA = 0,
+
ELM327_TX_
DO_CANID_11BIT,
+
ELM327_TX_
DO_CANID_29BIT_LOW,
+
ELM327_TX_
DO_CANID_29BIT_HIGH,
+
ELM327_TX_
DO_CAN_CONFIG_PART2,
+
ELM327_TX_
DO_CAN_CONFIG,
+
ELM327_TX_
DO_RESPONSES,
+
ELM327_TX_
DO_SILENT_MONITOR,
+
ELM327_TX_
DO_INIT
};
struct elmcan {
};
struct elmcan {
@@
-127,7
+127,7
@@
struct elmcan {
/* The CAN frame and config the ELM327 is sending/using,
* or will send/use after finishing all cmds_todo
*/
/* The CAN frame and config the ELM327 is sending/using,
* or will send/use after finishing all cmds_todo
*/
- struct can_frame can_frame;
+ struct can_frame can_frame
_to_send
;
unsigned short can_config;
unsigned long can_bitrate;
unsigned char can_bitrate_divisor;
unsigned short can_config;
unsigned long can_bitrate;
unsigned char can_bitrate_divisor;
@@
-202,10
+202,10
@@
static void elm327_kick_into_cmd_mode(struct elmcan *elm)
static void elm327_send_frame(struct elmcan *elm, struct can_frame *frame)
{
/* Schedule any necessary changes in ELM327's CAN configuration */
static void elm327_send_frame(struct elmcan *elm, struct can_frame *frame)
{
/* Schedule any necessary changes in ELM327's CAN configuration */
- if (elm->can_frame.can_id != frame->can_id) {
+ if (elm->can_frame
_to_send
.can_id != frame->can_id) {
/* Set the new CAN ID for transmission. */
if ((frame->can_id & CAN_EFF_FLAG)
/* Set the new CAN ID for transmission. */
if ((frame->can_id & CAN_EFF_FLAG)
- ^ (elm->can_frame.can_id & CAN_EFF_FLAG)) {
+ ^ (elm->can_frame
_to_send
.can_id & CAN_EFF_FLAG)) {
elm->can_config = (frame->can_id & CAN_EFF_FLAG
? 0
: ELM327_CAN_CONFIG_SEND_SFF)
elm->can_config = (frame->can_id & CAN_EFF_FLAG
? 0
: ELM327_CAN_CONFIG_SEND_SFF)
@@
-213,23
+213,23
@@
static void elm327_send_frame(struct elmcan *elm, struct can_frame *frame)
| ELM327_CAN_CONFIG_RECV_BOTH_SFF_EFF
| elm->can_bitrate_divisor;
| ELM327_CAN_CONFIG_RECV_BOTH_SFF_EFF
| elm->can_bitrate_divisor;
- set_bit(
TO
DO_CAN_CONFIG, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_CAN_CONFIG, &elm->cmds_todo);
}
if (frame->can_id & CAN_EFF_FLAG) {
}
if (frame->can_id & CAN_EFF_FLAG) {
- clear_bit(
TO
DO_CANID_11BIT, &elm->cmds_todo);
- set_bit(
TO
DO_CANID_29BIT_LOW, &elm->cmds_todo);
- set_bit(
TO
DO_CANID_29BIT_HIGH, &elm->cmds_todo);
+ clear_bit(
ELM327_TX_
DO_CANID_11BIT, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_CANID_29BIT_LOW, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_CANID_29BIT_HIGH, &elm->cmds_todo);
} else {
} else {
- set_bit(
TO
DO_CANID_11BIT, &elm->cmds_todo);
- clear_bit(
TO
DO_CANID_29BIT_LOW, &elm->cmds_todo);
- clear_bit(
TO
DO_CANID_29BIT_HIGH, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_CANID_11BIT, &elm->cmds_todo);
+ clear_bit(
ELM327_TX_
DO_CANID_29BIT_LOW, &elm->cmds_todo);
+ clear_bit(
ELM327_TX_
DO_CANID_29BIT_HIGH, &elm->cmds_todo);
}
}
/* Schedule the CAN frame itself. */
}
}
/* Schedule the CAN frame itself. */
- elm->can_frame = *frame;
- set_bit(
TO
DO_CAN_DATA, &elm->cmds_todo);
+ elm->can_frame
_to_send
= *frame;
+ set_bit(
ELM327_TX_
DO_CAN_DATA, &elm->cmds_todo);
elm327_kick_into_cmd_mode(elm);
}
elm327_kick_into_cmd_mode(elm);
}
@@
-263,7
+263,7
@@
static char *elm327_init_script[] = {
static void elm327_init(struct elmcan *elm)
{
elm->state = ELM_NOTINIT;
static void elm327_init(struct elmcan *elm)
{
elm->state = ELM_NOTINIT;
- elm->can_frame
.can_id = 0x7df;
+ elm->can_frame
_to_send.can_id = 0x7df; /* ELM327 HW default */
elm->rxfill = 0;
elm->drop_next_line = 0;
elm->rxfill = 0;
elm->drop_next_line = 0;
@@
-279,10
+279,10
@@
static void elm327_init(struct elmcan *elm)
/* Configure ELM327 and then start monitoring */
elm->next_init_cmd = &elm327_init_script[0];
/* Configure ELM327 and then start monitoring */
elm->next_init_cmd = &elm327_init_script[0];
- set_bit(
TO
DO_INIT, &elm->cmds_todo);
- set_bit(
TO
DO_SILENT_MONITOR, &elm->cmds_todo);
- set_bit(
TO
DO_RESPONSES, &elm->cmds_todo);
- set_bit(
TO
DO_CAN_CONFIG, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_INIT, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_SILENT_MONITOR, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_RESPONSES, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_CAN_CONFIG, &elm->cmds_todo);
elm327_kick_into_cmd_mode(elm);
}
elm327_kick_into_cmd_mode(elm);
}
@@
-576,7
+576,7
@@
static void elm327_parse_line(struct elmcan *elm, size_t len)
/* Assumes elm->lock taken. */
static void elm327_handle_prompt(struct elmcan *elm)
{
/* Assumes elm->lock taken. */
static void elm327_handle_prompt(struct elmcan *elm)
{
- struct can_frame *frame = &elm->can_frame;
+ struct can_frame *frame = &elm->can_frame
_to_send
;
char local_txbuf[20];
if (!elm->cmds_todo) {
char local_txbuf[20];
if (!elm->cmds_todo) {
@@
-588,44
+588,44
@@
static void elm327_handle_prompt(struct elmcan *elm)
}
/* Reconfigure ELM327 step by step as indicated by elm->cmds_todo */
}
/* Reconfigure ELM327 step by step as indicated by elm->cmds_todo */
- if (test_bit(
TO
DO_INIT, &elm->cmds_todo)) {
+ if (test_bit(
ELM327_TX_
DO_INIT, &elm->cmds_todo)) {
strcpy(local_txbuf, *elm->next_init_cmd);
elm->next_init_cmd++;
if (!(*elm->next_init_cmd)) {
strcpy(local_txbuf, *elm->next_init_cmd);
elm->next_init_cmd++;
if (!(*elm->next_init_cmd)) {
- clear_bit(
TO
DO_INIT, &elm->cmds_todo);
+ clear_bit(
ELM327_TX_
DO_INIT, &elm->cmds_todo);
/* Init finished. */
}
/* Init finished. */
}
- } else if (test_and_clear_bit(
TO
DO_SILENT_MONITOR, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_SILENT_MONITOR, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATCSM%i\r",
!(!(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)));
sprintf(local_txbuf, "ATCSM%i\r",
!(!(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)));
- } else if (test_and_clear_bit(
TO
DO_RESPONSES, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_RESPONSES, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATR%i\r",
!(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY));
sprintf(local_txbuf, "ATR%i\r",
!(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY));
- } else if (test_and_clear_bit(
TO
DO_CAN_CONFIG, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_CAN_CONFIG, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATPC\r");
sprintf(local_txbuf, "ATPC\r");
- set_bit(
TO
DO_CAN_CONFIG_PART2, &elm->cmds_todo);
+ set_bit(
ELM327_TX_
DO_CAN_CONFIG_PART2, &elm->cmds_todo);
- } else if (test_and_clear_bit(
TO
DO_CAN_CONFIG_PART2, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_CAN_CONFIG_PART2, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATPB%04X\r",
elm->can_config);
sprintf(local_txbuf, "ATPB%04X\r",
elm->can_config);
- } else if (test_and_clear_bit(
TO
DO_CANID_29BIT_HIGH, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_CANID_29BIT_HIGH, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATCP%02X\r",
(frame->can_id & CAN_EFF_MASK) >> 24);
sprintf(local_txbuf, "ATCP%02X\r",
(frame->can_id & CAN_EFF_MASK) >> 24);
- } else if (test_and_clear_bit(
TO
DO_CANID_29BIT_LOW, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_CANID_29BIT_LOW, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATSH%06X\r",
frame->can_id & CAN_EFF_MASK & ((1 << 24) - 1));
sprintf(local_txbuf, "ATSH%06X\r",
frame->can_id & CAN_EFF_MASK & ((1 << 24) - 1));
- } else if (test_and_clear_bit(
TO
DO_CANID_11BIT, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_CANID_11BIT, &elm->cmds_todo)) {
sprintf(local_txbuf, "ATSH%03X\r",
frame->can_id & CAN_SFF_MASK);
sprintf(local_txbuf, "ATSH%03X\r",
frame->can_id & CAN_SFF_MASK);
- } else if (test_and_clear_bit(
TO
DO_CAN_DATA, &elm->cmds_todo)) {
+ } else if (test_and_clear_bit(
ELM327_TX_
DO_CAN_DATA, &elm->cmds_todo)) {
if (frame->can_id & CAN_RTR_FLAG) {
/* Send an RTR frame. Their DLC is fixed.
* Some chips don't send them at all.
if (frame->can_id & CAN_RTR_FLAG) {
/* Send an RTR frame. Their DLC is fixed.
* Some chips don't send them at all.