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
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
417046ca
Commit
417046ca
authored
Nov 17, 2023
by
Adam Wujek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/wrpc: add read only vuart (without stdin)
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
d77aca48
Pipeline
#4974
failed with stage
in 3 minutes and 44 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
3 deletions
+43
-3
wrpc.c
tools/wrpc.c
+43
-3
No files found.
tools/wrpc.c
View file @
417046ca
...
...
@@ -1099,8 +1099,12 @@ static int do_load(int argc, char *argv[])
static
void
help_vuart
(
void
)
{
fprintf
(
stderr
,
"%s BOARD-OPTIONS [-k]
\n
"
,
progname
);
fprintf
(
stderr
,
"%s BOARD-OPTIONS [-k]
[-c <cmd>] [-r] [-t <timeout>]
\n
"
,
progname
);
fprintf
(
stderr
,
" -k keep terminal
\n
"
);
fprintf
(
stderr
,
" -c <cmd> execute command
\n
"
);
fprintf
(
stderr
,
" -t <timeout> set a timeout to execute a command
\n
"
);
fprintf
(
stderr
,
" -r do not expect stdin (may be useful for scripts),"
" conflicts with -c
\n
"
);
}
static
uint32_t
vuart_readl
(
struct
board
*
board
,
int
reg
)
...
...
@@ -1281,6 +1285,31 @@ static void wrpc_vuart_term(struct board *board,
wrpc_vuart_restore_tty
(
&
oldkey
);
}
static
void
wrpc_vuart_only_read
(
struct
board
*
board
,
unsigned
timeout
)
{
int
need_exit
=
0
;
int
rx
;
time_t
start_time
;
fprintf
(
stderr
,
"[press C-a to exit]
\n
"
);
if
(
timeout
)
start_time
=
get_running_secs
();
while
(
!
need_exit
)
{
/* Print all the incoming characters */
while
((
rx
=
wr_vuart_rx
(
board
))
>
0
)
{
putchar
(
rx
);
}
fflush
(
stdout
);
usleep
(
10
);
if
(
timeout
&&
get_running_secs
()
>=
start_time
+
timeout
)
break
;
}
}
static
void
wrpc_vuart_command
(
struct
board
*
board
,
char
*
command
)
{
//above is place for old and new port settings for keyboard teletype
...
...
@@ -1342,12 +1371,13 @@ static int do_vuart(int argc, char *argv[])
int
keep_term
=
0
;
char
*
cmd
=
NULL
;
unsigned
timeout
=
0
;
int
read_only
=
0
;
if
(
board_open
(
&
argc
,
argv
)
<
0
)
return
1
;
/* Parse specific args */
while
((
c
=
getopt
(
argc
,
argv
,
"c:kt:"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"c:kt:
r
"
))
!=
-
1
)
{
switch
(
c
)
{
case
'c'
:
/* Enable command mode */
...
...
@@ -1359,12 +1389,22 @@ static int do_vuart(int argc, char *argv[])
case
't'
:
timeout
=
atoi
(
optarg
);
break
;
case
'r'
:
read_only
=
1
;
break
;
case
'?'
:
break
;
}
}
if
(
cmd
)
if
(
cmd
&&
read_only
)
{
perror
(
"-r conficts with -c
\n
"
);
return
1
;
}
if
(
read_only
)
wrpc_vuart_only_read
(
board
,
timeout
);
else
if
(
cmd
)
wrpc_vuart_command
(
board
,
cmd
);
else
wrpc_vuart_term
(
board
,
keep_term
,
timeout
);
...
...
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