Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino4D_Robot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
CLEAR
Arduino4D_Robot
Commits
099ff4bb
Commit
099ff4bb
authored
1 year ago
by
Kyrre Ness Sjobaek
Browse files
Options
Downloads
Patches
Plain Diff
Add DEFINE flagg NO_ETHERNET
parent
47ecf73e
No related branches found
No related tags found
1 merge request
!21
Allow to work without ethernet
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
4DrobotServer/4DrobotServer_config.h
+1
-1
1 addition, 1 deletion
4DrobotServer/4DrobotServer_config.h
4DrobotServer/NetworkIO.ino
+22
-0
22 additions, 0 deletions
4DrobotServer/NetworkIO.ino
with
23 additions
and
1 deletion
4DrobotServer/4DrobotServer_config.h
+
1
−
1
View file @
099ff4bb
...
...
@@ -187,6 +187,6 @@ const unsigned int stepper_zeroseek_confirmHitDelay = 1000; //[us]
//#define DUMMY_TEMP
//#define DUMMY_SERVO
//#define DUMMY_STEPPER
//#define NO_ETHERNET
#endif
This diff is collapsed.
Click to expand it.
4DrobotServer/NetworkIO.ino
+
22
−
0
View file @
099ff4bb
...
...
@@ -8,6 +8,13 @@
void
setup_networkIO
()
{
//Network setup
Serial
.
print
(
"Starting networking...
\n
"
);
#ifdef NO_ETHERNET
Serial
.
print
(
"NO_ETHERNET is enabled! Entering serial-only mode.
\n
"
);
#else
#ifdef USE_DHCP
Ethernet
.
begin
(
mac
);
#else
...
...
@@ -50,6 +57,8 @@ void setup_networkIO() {
//Server setup
telnet_socket
.
begin
();
#endif
for
(
uint8_t
i
=
0
;
i
<
telnet_numConnections
;
i
++
)
{
memset
(
telnet_buff
[
i
],
'\0'
,
sizeof
(
telnet_buff
[
i
]));
telnet_buffCount
[
i
]
=
0
;
...
...
@@ -70,6 +79,7 @@ void telnet_server() {
// Program for running the telnet- and serial communication
//1. Check for new connections
#ifndef NO_ETHERNET
while
(
true
)
{
//Loop in case there are multiple new connections
EthernetClient
newConnection
=
telnet_socket
.
accept
();
...
...
@@ -99,8 +109,10 @@ void telnet_server() {
break
;
}
}
#endif
//2. Check for incoming data (telnet & serial) and buffer it
#ifndef NO_ETHERNET
for
(
size_t
i
=
0
;
i
<
telnet_numConnections
;
i
++
)
{
while
(
telnet_connection
[
i
]
&&
telnet_connection
[
i
].
connected
()
&&
...
...
@@ -119,6 +131,7 @@ void telnet_server() {
#endif
}
}
#endif
while
(
Serial
.
available
()
>
0
)
{
bufferWrite
(
serial_buff
,
sizeof
(
serial_buff
),
serial_buffCount
,
Serial
.
read
());
...
...
@@ -141,6 +154,7 @@ void telnet_server() {
bool
keepParsing
=
true
;
bool
telnet_printReady
[
telnet_numConnections
];
bool
serial_printReady
=
false
;
#ifndef NO_ETHERNET
for
(
size_t
i
=
0
;
(
i
<
telnet_numConnections
);
i
++
)
{
if
(
not
(
telnet_connection
[
i
]
&&
telnet_connection
[
i
].
connected
()
...
...
@@ -157,6 +171,7 @@ void telnet_server() {
keepParsing
=
input_parser
(
telnet_buff
[
i
],
sizeof
(
telnet_buff
[
i
]),
telnet_buffCount
[
i
],
&
(
telnet_connection
[
i
]));
}
}
#endif
if
(
keepParsing
)
{
if
(
serial_buffCount
==
0
and
serial_buffCount_prev
>
0
)
{
serial_printReady
=
true
;
...
...
@@ -170,6 +185,7 @@ void telnet_server() {
output_buff_flush
();
//5b. Notify client that TTY is ready for more
#ifndef NO_ETHERNET
for
(
size_t
i
=
0
;
i
<
telnet_numConnections
;
i
++
)
{
if
(
not
(
telnet_connection
[
i
]
&&
telnet_connection
[
i
].
connected
()
...
...
@@ -180,11 +196,13 @@ void telnet_server() {
telnet_connection
[
i
].
print
(
"$
\n
"
);
}
}
#endif
if
(
serial_printReady
)
{
Serial
.
print
(
"$
\n
"
);
}
//6. Check for telnet disconnects & handle
#ifndef NO_ETHERNET
for
(
size_t
i
=
0
;
i
<
telnet_numConnections
;
i
++
)
{
if
(
telnet_connection
[
i
]
&&
!
telnet_connection
[
i
].
connected
()
)
{
...
...
@@ -206,6 +224,7 @@ void telnet_server() {
telnet_buffCount_prev
[
i
]
=
1
;
}
}
#endif
//7. Feed the clients & serial with disconnect messages
output_buff_flush
();
}
...
...
@@ -215,12 +234,15 @@ void output_buff_flush() {
// to all clients (TCP/IP and Serial)
if
(
output_buffCount
)
{
#ifndef NO_ETHERNET
for
(
size_t
i
=
0
;
i
<
telnet_numConnections
;
i
++
)
{
if
(
telnet_connection
[
i
]
&&
telnet_connection
[
i
].
connected
()
)
{
telnet_connection
[
i
].
print
(
output_buff
);
}
}
#endif
Serial
.
print
(
output_buff
);
Serial
.
flush
();
...
...
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