aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-06-20 12:09:55 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-06-29 13:33:59 -0400
commitc1bd628ce524f52851cf2bbcb4bc8bbc373dcd6b (patch)
tree4b3705dbf34c7f8ec0f52a7fadae17f43031d31b
parent849096d5f35185b082571665ca590fed9c35a073 (diff)
downloadkutter-c1bd628ce524f52851cf2bbcb4bc8bbc373dcd6b.tar.gz
kutter-c1bd628ce524f52851cf2bbcb4bc8bbc373dcd6b.tar.xz
kutter-c1bd628ce524f52851cf2bbcb4bc8bbc373dcd6b.zip
command: Directly call command_sendf() for ack/nak messages
Don't use the sendf() macro for ack and nak messages - directly call the command_sendf() code instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--scripts/buildcommands.py10
-rw-r--r--src/command.c9
2 files changed, 8 insertions, 11 deletions
diff --git a/scripts/buildcommands.py b/scripts/buildcommands.py
index a26801ee..0c147191 100644
--- a/scripts/buildcommands.py
+++ b/scripts/buildcommands.py
@@ -29,9 +29,6 @@ def error(msg):
######################################################################
def build_parser(parser, iscmd, all_param_types):
- if parser.name == "#empty":
- return "\n // Empty message\n .max_size=%d," % (
- msgproto.MESSAGE_MIN,)
if parser.name == "#output":
comment = "Output: " + parser.msgformat
else:
@@ -71,8 +68,6 @@ def build_encoders(encoders, msg_to_id, all_param_types):
if msgid in did_output:
continue
s = msg
- if s == '#empty':
- s = ''
did_output[msgid] = True
code = (' if (__builtin_strcmp(str, "%s") == 0)\n'
' return &command_encoder_%s;\n' % (s, msgid))
@@ -308,10 +303,7 @@ def main():
error("Conflicting definition for command '%s'" % msgname)
messages_by_name[msgname] = msg
elif cmd == '_DECL_ENCODER':
- if len(parts) == 1:
- msgname = msg = "#empty"
- else:
- msgname = parts[1]
+ msgname = parts[1]
m = messages_by_name.get(msgname)
if m is not None and m != msg:
error("Conflicting definition for message '%s'" % msgname)
diff --git a/src/command.c b/src/command.c
index 62db0bfd..af84539f 100644
--- a/src/command.c
+++ b/src/command.c
@@ -222,6 +222,11 @@ command_lookup_parser(uint8_t cmdid)
return &command_index[cmdid];
}
+// Empty message (for ack/nak transmission)
+const struct command_encoder encode_acknak PROGMEM = {
+ .max_size = MESSAGE_MIN,
+};
+
enum { CF_NEED_SYNC=1<<0, CF_NEED_VALID=1<<1 };
// Find the next complete message.
@@ -256,7 +261,7 @@ command_find_block(char *buf, uint8_t buf_len, uint8_t *pop_count)
goto nak;
}
next_sequence = ((msgseq + 1) & MESSAGE_SEQ_MASK) | MESSAGE_DEST;
- sendf(""); // An empty message with a new sequence number is an ack
+ command_sendf(&encode_acknak);
return 1;
need_more_data:
@@ -282,7 +287,7 @@ need_sync: ;
return -1;
sync_state |= CF_NEED_VALID;
nak:
- sendf(""); // An empty message with a duplicate sequence number is a nak
+ command_sendf(&encode_acknak);
return -1;
}