Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
ring
Commits
6cda8e02
Commit
6cda8e02
authored
3 years ago
by
Neil Gershenfeld (test)
Browse files
Options
Downloads
Patches
Plain Diff
add termios
parent
f6c24066
No related branches found
No related tags found
No related merge requests found
Pipeline
#11116
passed
3 years ago
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
comm/termios/ring.termios.c
+60
-0
60 additions, 0 deletions
comm/termios/ring.termios.c
index.html
+8
-0
8 additions, 0 deletions
index.html
with
68 additions
and
0 deletions
comm/termios/ring.termios.c
0 → 100644
+
60
−
0
View file @
6cda8e02
//
// ring.termios.c
//
// termios communication ring test
//
// Neil Gershenfeld 4/4/21
//
// This work may be reproduced, modified, distributed,
// performed, and displayed for any purpose, but must
// acknowledge this project. Copyright is retained and
// must be preserved. The work is provided as is; no
// warranty is provided, and users accept all liability.
//
#include
<stdio.h>
#include
<fcntl.h>
#include
<termios.h>
#include
<unistd.h>
#include
<stdlib.h>
#include
<sys/time.h>
//
#define nloop 100
//
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
printf
(
"command line: ring.termios serial_port port_speed
\n
"
);
return
-
1
;
}
int
speed
=
atoi
(
argv
[
2
]);
int
port
=
open
(
argv
[
1
],
O_RDWR
|
O_NOCTTY
|
O_NDELAY
);
fcntl
(
port
,
F_SETFL
,
0
);
struct
termios
term
;
tcgetattr
(
port
,
&
term
);
term
.
c_cflag
&=
~
(
PARENB
|
CSTOPB
|
CSIZE
|
CRTSCTS
);
term
.
c_cflag
|=
(
CS8
|
CREAD
|
CLOCAL
);
term
.
c_lflag
&=
~
(
ICANON
|
ECHO
|
ECHOE
|
ECHONL
|
ISIG
);
term
.
c_iflag
&=
~
(
IXON
|
IXOFF
|
IXANY
|
IGNBRK
|
BRKINT
|
PARMRK
|
ISTRIP
|
INLCR
|
IGNCR
|
ICRNL
);
term
.
c_oflag
&=
~
(
OPOST
|
ONLCR
);
term
.
c_cc
[
VTIME
]
=
0
;
term
.
c_cc
[
VMIN
]
=
1
;
cfsetispeed
(
&
term
,
speed
);
cfsetospeed
(
&
term
,
speed
);
tcsetattr
(
port
,
TCSANOW
,
&
term
);
unsigned
char
chr
=
0
;
struct
timeval
start
,
end
;
tcflush
(
port
,
TCIOFLUSH
);
gettimeofday
(
&
start
,
NULL
);
for
(
int
i
=
0
;
i
<
nloop
;
++
i
)
{
while
(
1
)
{
write
(
port
,
&
chr
,
1
);
read
(
port
,
&
chr
,
1
);
if
(
chr
==
0
)
break
;
}
}
gettimeofday
(
&
end
,
NULL
);
printf
(
"byte ring cycles per second: %6.3g
\n
"
,
nloop
*
256
/
((
end
.
tv_sec
+
end
.
tv_usec
/
1e6
)
-
(
start
.
tv_sec
+
start
.
tv_usec
/
1e6
)));
close
(
port
);
return
0
;
}
This diff is collapsed.
Click to expand it.
index.html
+
8
−
0
View file @
6cda8e02
...
@@ -189,6 +189,14 @@ The communication test measures how quickly two nodes can exchange messages; thi
...
@@ -189,6 +189,14 @@ The communication test measures how quickly two nodes can exchange messages; thi
<th>
date
</th>
<th>
date
</th>
</tr>
</tr>
<tr>
<td>
0.010
</td>
<td><a
href=
comm/termios/ring.termios.c
>
i7-8700T, C, termios
</a></td>
<td>
USB 2.1
</td>
<td><a
href=
comm/SerialUSB/ring.SerialUSB.ino
>
ATSAMD11C, Arduino, SerialUSB
</a></td>
<td>
April2021
</td>
</tr>
<tr>
<tr>
<td>
0.007
</td>
<td>
0.007
</td>
<td><a
href=
comm/pySerial/ring.pySerial.py
>
i7-8700T, Python, pySerial
</a></td>
<td><a
href=
comm/pySerial/ring.pySerial.py
>
i7-8700T, Python, pySerial
</a></td>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment