Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
4cd129da
Commit
4cd129da
authored
Apr 06, 2017
by
Alessandro Rubini
Committed by
Adam Wujek
Jun 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
general: allow puts to go to syslog
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
d91fec21
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
5 deletions
+62
-5
Kconfig
Kconfig
+12
-0
dev.mk
dev/dev.mk
+1
-0
puts-syslog.c
dev/puts-syslog.c
+34
-0
uart.c
dev/uart.c
+1
-1
shell.h
include/shell.h
+1
-0
shell.c
shell/shell.c
+13
-4
No files found.
Kconfig
View file @
4cd129da
...
...
@@ -151,6 +151,18 @@ config SYSLOG
The user (or init script) must use "syslog <ipaddr> <macaddr>"
to enable it. The special "off" ipaddr disables syslog.
config PUTS_SYSLOG
depends on SYSLOG
boolean "Sent puts (i.e. printf) to syslog too"
help
This allows logging the various warning and error messages
that normally go to the console alone, where nobody is looking
in a deployed system. Output from interactive commands is
not sent to syslog, but self-timed diagnostic (stat, gui, verbose)
will reach syslog anyways, if an interactive user enables them.
Unfortunately, "stat" will reach syslog as several short strings,
and "gui" is full of escape sequences.
config SNMP
depends on IP && !HOST_PROCESS
default y
...
...
dev/dev.mk
View file @
4cd129da
...
...
@@ -19,6 +19,7 @@ obj-$(CONFIG_WR_NODE) += \
dev/pps_gen.o
obj-$(CONFIG_WR_SWITCH) += dev/timer-wrs.o dev/ad9516.o
obj-$(CONFIG_PUTS_SYSLOG) += dev/puts-syslog.o
obj-$(CONFIG_LEGACY_EEPROM) += dev/eeprom.o
obj-$(CONFIG_SDB_STORAGE) += dev/sdb-storage.o
...
...
dev/puts-syslog.c
0 → 100644
View file @
4cd129da
#include <wrc.h>
#include <string.h>
#include <uart.h>
#include <shell.h>
#include <lib/ipv4.h>
int
puts
(
const
char
*
s
)
{
char
new_s
[
CONFIG_PRINT_BUFSIZE
+
4
];
int
l
,
ret
;
ret
=
uart_write_string
(
s
);
l
=
strlen
(
s
);
/* avoid shell-interation stuff */
if
(
shell_is_interacting
)
return
ret
;
if
(
l
<
2
||
s
[
0
]
==
'\e'
)
return
ret
;
if
(
!
strncmp
(
s
,
"wrc#"
,
4
))
return
ret
;
/* if not terminating with newline, add a trailing "...\n" */
strcpy
(
new_s
,
s
);
if
(
s
[
l
-
1
]
!=
'\n'
)
{
new_s
[
l
++
]
=
'.'
;
new_s
[
l
++
]
=
'.'
;
new_s
[
l
++
]
=
'.'
;
new_s
[
l
++
]
=
'\n'
;
new_s
[
l
++
]
=
'\0'
;
}
syslog_report
(
new_s
);
return
ret
;
}
dev/uart.c
View file @
4cd129da
...
...
@@ -56,4 +56,4 @@ int uart_read_byte(void)
}
int
puts
(
const
char
*
s
)
__attribute__
((
alias
(
"uart_write_string"
)));
__attribute__
((
weak
,
alias
(
"uart_write_string"
)));
include/shell.h
View file @
4cd129da
...
...
@@ -36,6 +36,7 @@ void env_init(void);
int
shell_exec
(
const
char
*
buf
);
int
shell_interactive
(
void
);
extern
int
shell_is_interacting
;
void
shell_boot_script
(
void
);
...
...
shell/shell.c
View file @
4cd129da
...
...
@@ -42,6 +42,8 @@ static int cmd_pos = 0, cmd_len = 0;
static
int
state
=
SH_PROMPT
;
static
int
current_key
=
0
;
int
shell_is_interacting
;
static
int
insert
(
char
c
)
{
if
(
cmd_len
>=
SH_MAX_LINE_LEN
)
...
...
@@ -116,9 +118,15 @@ static int _shell_exec(void)
int
shell_exec
(
const
char
*
cmd
)
{
strncpy
(
cmd_buf
,
cmd
,
SH_MAX_LINE_LEN
);
int
i
;
if
(
cmd
!=
cmd_buf
)
strncpy
(
cmd_buf
,
cmd
,
SH_MAX_LINE_LEN
);
cmd_len
=
strlen
(
cmd_buf
);
return
_shell_exec
();
shell_is_interacting
=
1
;
i
=
_shell_exec
();
shell_is_interacting
=
0
;
return
i
;
}
void
shell_init
()
...
...
@@ -130,6 +138,7 @@ void shell_init()
int
shell_interactive
()
{
int
c
;
switch
(
state
)
{
case
SH_PROMPT
:
pp_printf
(
"wrc# "
);
...
...
@@ -285,7 +294,7 @@ void shell_boot_script(void)
if
(
!
cmd_len
)
break
;
pp_printf
(
"executing: %s
\n
"
,
cmd_buf
);
_shell_exec
(
);
shell_exec
(
cmd_buf
);
}
while
(
CONFIG_HAS_FLASH_INIT
)
{
...
...
@@ -299,7 +308,7 @@ void shell_boot_script(void)
cmd_buf
[
cmd_len
-
1
]
=
0
;
pp_printf
(
"executing: %s
\n
"
,
cmd_buf
);
_shell_exec
(
);
shell_exec
(
cmd_buf
);
next
=
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment