Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ARDUINO-PositionGaugeServer
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
ARDUINO-PositionGaugeServer
Commits
07b36e9d
Commit
07b36e9d
authored
4 years ago
by
Kyrre Ness Sjobaek
Browse files
Options
Downloads
Patches
Plain Diff
WEB server timeout + fix SPC timeout
parent
b908c34a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PositionGaugeServer.ino
+13
-3
13 additions, 3 deletions
PositionGaugeServer.ino
with
13 additions
and
3 deletions
PositionGaugeServer.ino
+
13
−
3
View file @
07b36e9d
...
...
@@ -54,6 +54,7 @@ IPAddress subnet(255, 255, 0, 0);
// ***** OTHER CONFIG ***************************
const
unsigned
long
update_interval
=
1000
;
//[ms]
const
unsigned
long
SPC_timeout
=
5
;
//[ms] 260 us per 4-bit word, 13 words, plus some buffer
const
unsigned
long
WEB_timeout
=
600
;
//[ms] Max time allowed waiting for web client
// ***** GLOBAL VARIABLES ***********************
...
...
@@ -261,7 +262,7 @@ void loop() {
void
readSPCinstrument
(
uint8_t
ch
)
{
unsigned
long
SPC_timeout_time
=
millis
();
unsigned
long
SPC_timeout_time
=
millis
()
+
SPC_timeout
;
digitalWrite
(
pinREQ
[
ch
],
HIGH
);
...
...
@@ -378,10 +379,13 @@ void readSPCinstrument(uint8_t ch) {
void
HTTPserver
()
{
unsigned
long
WEB_timeout_time
=
millis
()
+
WEB_timeout
;
EthernetClient
client
=
srvWEB
.
available
();
if
(
client
)
{
Serial
.
println
();
Serial
.
println
(
"New web client"
);
Serial
.
print
(
"New web client "
);
Serial
.
println
(
client
.
remoteIP
());
}
else
{
return
;
...
...
@@ -393,7 +397,7 @@ void HTTPserver () {
// We should also echo what the client sends
boolean
currentLineIsBlank
=
true
;
while
(
client
.
connected
())
{
while
(
client
.
connected
()
and
millis
()
<
WEB_timeout_time
)
{
if
(
client
.
available
())
{
//WARNING: If client does not "do it's thing",
// the Arduino may become unresponsive.
...
...
@@ -473,6 +477,12 @@ void HTTPserver () {
}
}
if
(
millis
()
>=
WEB_timeout_time
)
{
Serial
.
println
();
Serial
.
println
(
"WEB timed out."
);
}
// give the web browser time to receive the data
delay
(
10
);
//[ms]
// close the connection:
...
...
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