I'm currently adding firmware updater to ADI ICE-100B USB JTAG cable
in UrJTAG. This patch is needed to avoid confusing user when using the
firmware updater.
The firmware updating will be done in src/tap/cable/ice100.c:ice_init
(). When the updating is done, ice_init should return URJ_STATUS_FAIL
to cancel the current connection to the cable. URJ_STATUS_FAIL will be
passed up to urj_parse_line and cause an error message to be printed
out:
jtag> cable ICE-100B firmware=/home/jie/Desktop/firmware_1_6.hex
ICE-100B firmware version is 1.0.6
Error: The firmware on the ICE-100B needs to be updated. Please go to:
http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:ice100b
to learn how to update the firmware.
Updating to firmware /home/jie/Desktop/firmware_1_6.hex ............
The firmware has been updated successfully.
Please unplug the ICE-100B cable and reconnect it to finish the update process.
Error: parse.c:272 urj_parse_file() no error: Cannot open file
'/home/jie/.jtag/rc' to parse
jtag>
You can see that a strange "no error" error message following a
successful message. It's rather confusing: firmware updating is
successful or not?
This patch tries to remove this last error message. It first moves
printing "Error: " into urj_error_describe (). So it can be disabled
with the remaining error message. Second it makes urj_error_describe
not generate an error message when there is no error set in
urj_error_state. This patch also makes the format of a warning message
as same as an error message, i.e. starting with "Warning: ".
Any comments? If no one objects, I will commit it at the beginning of
the next week.
Regards,
Jie
* src/global/log-error.c (urj_error_describe): Add an argument
to indicate if it's a warning or an error.
* include/urjtag/error.h (urj_error_describe): Update declaration.
* include/urjtag/log.h (urj_warning): Make the message start with
"Warning".
* src/tap/detect.c (urj_tap_detect_parts): Update calling of
urj_error_describe.
* src/global/parse.c (urj_parse_stream): Likewise.
* src/apps/jtag/jtag.c (jtag_readline_multiple_commands_support):
Likewise.
(main): Likewise.
* src/apps/bsdl2jtag/bsdl2jtag.c (main): Likewise.
Index: include/urjtag/error.h
===================================================================
--- include/urjtag/error.h (revision 1907)
+++ include/urjtag/error.h (working copy)
@@ -149,6 +149,6 @@
*
* @return a pointer to a static area.
*/
-const char *urj_error_describe (void);
+const char *urj_error_describe (urj_log_level_t);
#endif /* URJ_ERROR_H */
Index: include/urjtag/log.h
===================================================================
--- include/urjtag/log.h (revision 1907)
+++ include/urjtag/log.h (working copy)
@@ -61,7 +61,7 @@
*/
#define urj_warning(...) \
do { \
- urj_log (URJ_LOG_LEVEL_WARNING, "%s:%d %s() Warning: ", \
+ urj_log (URJ_LOG_LEVEL_WARNING, "Warning: %s:%d %s(): ", \
__FILE__, __LINE__, __func__); \
urj_log (URJ_LOG_LEVEL_WARNING, __VA_ARGS__); \
} while (0)
Index: src/tap/detect.c
===================================================================
--- src/tap/detect.c (revision 1907)
+++ src/tap/detect.c (working copy)
@@ -427,8 +427,8 @@
strcpy (part->stepping, stepping);
if (urj_parse_include (chain, data_path, 0) == URJ_STATUS_FAIL)
{
- urj_log (URJ_LOG_LEVEL_NORMAL, "Error: %s\n",
- urj_error_describe());
+ urj_log (URJ_LOG_LEVEL_ERROR, "%s\n",
+ urj_error_describe(URJ_LOG_LEVEL_ERROR));
urj_error_reset();
}
#ifdef ENABLE_BSDL
Index: src/global/log-error.c
===================================================================
--- src/global/log-error.c (revision 1907)
+++ src/global/log-error.c (working copy)
@@ -141,13 +141,26 @@
}
const char *
-urj_error_describe (void)
+urj_error_describe (urj_log_level_t level)
{
static char msg[URJ_ERROR_MSG_LEN + 1024 + 256 + 20];
+ char *msg_header;
- if (urj_error_state.errnum == URJ_ERROR_IO)
+ if (level == URJ_LOG_LEVEL_WARNING)
+ msg_header = "Warning";
+ else if (level == URJ_LOG_LEVEL_ERROR)
+ msg_header = "Error";
+ else
+ msg_header = "";
+
+ if (urj_error_state.errnum == URJ_ERROR_OK)
+ {
+ msg[0] = '\0';
+ }
+ else if (urj_error_state.errnum == URJ_ERROR_IO)
{
- snprintf (msg, sizeof msg, "%s:%d %s() %s: %s %s",
+ snprintf (msg, sizeof msg, "%s: %s:%d %s() %s: %s %s",
+ msg_header,
urj_error_state.file, urj_error_state.line,
urj_error_state.function,
"System error", strerror(urj_error_state.sys_errno),
@@ -155,8 +168,9 @@
}
else
{
- snprintf (msg, sizeof msg, "%s:%d %s() %s: %s",
- urj_error_state.file, urj_error_state.line,
+ snprintf (msg, sizeof msg, "%s: %s:%d %s() %s: %s",
+ msg_header,
+ urj_error_state.file, urj_error_state.line,
urj_error_state.function,
urj_error_string (urj_error_state.errnum),
urj_error_state.msg);
Index: src/global/parse.c
===================================================================
--- src/global/parse.c (revision 1907)
+++ src/global/parse.c (working copy)
@@ -248,7 +248,7 @@
go = urj_parse_line (chain, inputline);
if (go == URJ_STATUS_FAIL)
{
- urj_log (ll, "Error: %s; command '%s'\n", urj_error_describe(), inputline);
+ urj_log (ll, "%s; command '%s'\n", urj_error_describe(URJ_LOG_LEVEL_ERROR), inputline);
urj_error_reset ();
}
urj_tap_chain_flush (chain);
Index: src/apps/jtag/jtag.c
===================================================================
--- src/apps/jtag/jtag.c (revision 1907)
+++ src/apps/jtag/jtag.c (working copy)
@@ -248,7 +248,8 @@
r = urj_parse_line (chain, line);
if (r == URJ_STATUS_FAIL)
{
- urj_log (URJ_LOG_LEVEL_NORMAL, "Error: %s\n", urj_error_describe());
+ urj_log (URJ_LOG_LEVEL_ERROR, "%s\n",
+ urj_error_describe(URJ_LOG_LEVEL_ERROR));
urj_error_reset ();
}
@@ -541,7 +542,8 @@
/* Create ~/.jtag */
if (jtag_create_jtagdir () != URJ_STATUS_OK)
{
- urj_warning ("%s\n", urj_error_describe());
+ urj_log (URJ_LOG_LEVEL_WARNING, "%s\n",
+ urj_error_describe(URJ_LOG_LEVEL_WARNING));
urj_error_reset();
}
@@ -553,8 +555,8 @@
if (urj_error_get() != URJ_ERROR_IO)
{
/* Only warn about RC problems; don't prevent running */
- urj_log (URJ_LOG_LEVEL_NORMAL, "Error: %s\n",
- urj_error_describe());
+ urj_log (URJ_LOG_LEVEL_WARNING, "%s\n",
+ urj_error_describe(URJ_LOG_LEVEL_WARNING));
}
urj_error_reset();
}
Index: src/apps/bsdl2jtag/bsdl2jtag.c
===================================================================
--- src/apps/bsdl2jtag/bsdl2jtag.c (revision 1907)
+++ src/apps/bsdl2jtag/bsdl2jtag.c (working copy)
@@ -68,8 +68,8 @@
chain = urj_tap_chain_alloc ();
if (chain == NULL)
{
- urj_log (URJ_LOG_LEVEL_NORMAL, "Error: %s\n",
- urj_error_describe());
+ urj_log (URJ_LOG_LEVEL_ERROR, "%s\n",
+ urj_error_describe(URJ_LOG_LEVEL_ERROR));
return 1;
}
@@ -93,7 +93,8 @@
result = urj_bsdl_read_file (chain, argv[1], URJ_BSDL_MODE_DUMP, NULL);
if (result < 0)
{
- urj_log (URJ_LOG_LEVEL_ERROR, "Error: %s\n", urj_error_describe());
+ urj_log (URJ_LOG_LEVEL_ERROR, "%s\n",
+ urj_error_describe(URJ_LOG_LEVEL_ERROR));
urj_error_reset ();
}
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development