ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
host_services.cpp
Go to the documentation of this file.
1
/*
2
host_services.cpp - host services functions class
3
4
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#include "../../include/esp3d_config.h"
22
#include "
host_services.h
"
23
#include "../../core/settings_esp3d.h"
24
#include "../../core/esp3doutput.h"
25
#include "../serial/serial_service.h"
26
27
HostServices::HostServices
()
28
{
29
_started =
false
;
30
}
31
HostServices::~HostServices
()
32
{
33
end
();
34
}
35
36
bool
HostServices::begin
()
37
{
38
bool
res =
true
;
39
end
();
40
//Check autostart.g on SPIFFS
41
if
(!res) {
42
end
();
43
}
44
_started = res;
45
return
_started;
46
}
47
void
HostServices::end
()
48
{
49
if
(!_started) {
50
return
;
51
}
52
_started =
false
;
53
54
}
55
56
void
HostServices::handle
()
57
{
58
if
(_started) {
59
}
60
}
61
62
63
bool
HostServices::purge_serial()
64
{
65
uint32_t start = millis();
66
uint8_t buf [51];
67
serial_service
.
flush
();
68
log_esp3d
(
"Purge Serial"
);
69
while
(
serial_service
.
available
() > 0 ) {
70
if
((millis() - start ) > 2000) {
71
log_esp3d
(
"Purge timeout"
);
72
return
false
;
73
}
74
size_t
len =
serial_service
.
readBytes
(buf, 50);
75
buf[len] =
'\0'
;
76
log_esp3d
(
"Purge: %s"
,(
const
char
*)buf);
77
if
( (
Settings_ESP3D::GetFirmwareTarget
() ==
REPETIER4DV
) || (
Settings_ESP3D::GetFirmwareTarget
() ==
REPETIER
) ) {
78
String s = (
const
char
*)buf;
79
//repetier never stop sending data so no need to wait if have 'wait' or 'busy'
80
if
((s.indexOf (
"wait"
) > -1) || (s.indexOf (
"busy"
) > -1)) {
81
return
true
;
82
}
83
log_esp3d
(
"Purge interrupted"
);
84
}
85
Hal::wait
(5);
86
}
87
Hal::wait
(0);
88
log_esp3d
(
"Purge done"
);
89
return
true
;
90
}
REPETIER4DV
#define REPETIER4DV
Definition:
settings_esp3d.h:29
Hal::wait
static void wait(uint32_t milliseconds)
Definition:
hal.cpp:226
HostServices::~HostServices
~HostServices()
Definition:
host_services.cpp:31
host_services.h
Settings_ESP3D::GetFirmwareTarget
static uint8_t GetFirmwareTarget(bool fromsettings=false)
Definition:
settings_esp3d.cpp:183
REPETIER
#define REPETIER
Definition:
settings_esp3d.h:33
HostServices::handle
void handle()
Definition:
host_services.cpp:56
serial_service
SerialService serial_service
Definition:
serial_service.cpp:42
HostServices::HostServices
HostServices()
Definition:
host_services.cpp:27
log_esp3d
#define log_esp3d(format,...)
Definition:
debug_esp3d.h:29
SerialService::readBytes
size_t readBytes(uint8_t *sbuf, size_t len)
Definition:
serial_service.cpp:258
SerialService::available
int available()
Definition:
serial_service.cpp:248
SerialService::flush
void flush()
Definition:
serial_service.cpp:263
HostServices::end
void end()
Definition:
host_services.cpp:47
HostServices::begin
bool begin()
Definition:
host_services.cpp:36
esp3d
src
modules
host
host_services.cpp
Generated by
1.8.17