summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomek CEDRO <cederom@tlen.pl>2011-06-21 00:37:00 +0200
committerTomek CEDRO <cederom@tlen.pl>2011-06-21 00:37:00 +0200
commite16521d3a16778fdacb62f97611a3b03baa65edc (patch)
treef37413292947690d99797405ead8cad20e872112
parent7f2221958dbc6bda0e51df87e80aa5a9c5140914 (diff)
downloadopenocd+libswd-e16521d3a16778fdacb62f97611a3b03baa65edc.tar.gz
openocd+libswd-e16521d3a16778fdacb62f97611a3b03baa65edc.tar.bz2
openocd+libswd-e16521d3a16778fdacb62f97611a3b03baa65edc.tar.xz
openocd+libswd-e16521d3a16778fdacb62f97611a3b03baa65edc.zip
INTERFACE/BITBANG: Fixed strnstr issue, command is now available only after 'init' as it should be, replaced hardcode with define.
-rw-r--r--src/interface/bitbang.c12
-rw-r--r--src/interface/bitbang.h1
2 files changed, 7 insertions, 6 deletions
diff --git a/src/interface/bitbang.c b/src/interface/bitbang.c
index 443e9aea..63c9ca1e 100644
--- a/src/interface/bitbang.c
+++ b/src/interface/bitbang.c
@@ -55,7 +55,7 @@ COMMAND_HANDLER(handle_bitbang_command)
LOG_DEBUG("%s", __func__);
if (!jtag_interface){
- LOG_ERROR("You need to setup interface first!");
+ LOG_ERROR("You need to select interface first!");
return ERROR_FAIL;
}
@@ -77,17 +77,17 @@ COMMAND_HANDLER(handle_bitbang_command)
static oocd_interface_signal_t *sig;
static unsigned int pn;
static int retval;
- static char *mark, *signame, *sigval, pcmd[45];
+ static char *mark, *signame, *sigval, pcmd[OOCD_BITBANG_PARAM_CMD_MAX_LEN];
// Iterate through list of command parameters
for (pn=0;pn<CMD_ARGC;pn++){
// Make a local copy of parameter command to work on
- if (!strncpy(pcmd, CMD_ARGV[pn], 45)){
+ if (!strncpy(pcmd, CMD_ARGV[pn], OOCD_BITBANG_PARAM_CMD_MAX_LEN)){
LOG_ERROR("Cannot copy parameter: %s", CMD_ARGV[pn]);
return ERROR_FAIL;
}
// Look for '=' mark to see if read or write will happen
- mark=strnstr(pcmd, "=", 45);
+ mark=strstr(pcmd, "=");
if (!mark){
// If no '=' was found then we read the signal value
// Check if specified signal exists
@@ -138,8 +138,8 @@ static const struct command_registration bitbang_commands[] = {
{
.name = "bitbang",
.handler = handle_bitbang_command,
- .mode = COMMAND_ANY,
- .help = "Perform bit-bang operations on interface signals (mask!).",
+ .mode = COMMAND_EXEC,
+ .help = "Perform bit-bang operations on interface signal (mask!).",
.usage = "'signal_name' to read, 'signal_name'='port_hex_value' to write.",
},
COMMAND_REGISTRATION_DONE
diff --git a/src/interface/bitbang.h b/src/interface/bitbang.h
index 8d15d49c..fa7d6d60 100644
--- a/src/interface/bitbang.h
+++ b/src/interface/bitbang.h
@@ -22,6 +22,7 @@
/** @file Simple framework to work with interface signals.
*/
+#define OOCD_BITBANG_PARAM_CMD_MAX_LEN 45
int bitbang_register_commands(struct command_context *ctx);
#endif