ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
serial_service.h
Go to the documentation of this file.
1
/*
2
serial_service.h - serial 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
#ifndef _SERIAL_SERVICES_H
22
#define _SERIAL_SERVICES_H
23
24
#include "Print.h"
25
26
#define ESP3D_SERIAL_BUFFER_SIZE 1024
27
28
class
SerialService
:
public
Print
29
{
30
public
:
31
SerialService
();
32
~SerialService
();
33
bool
begin
();
34
bool
end
();
35
void
handle
();
36
bool
reset
();
37
long
baudRate
();
38
const
long
*
get_baudratelist
(uint8_t * count);
39
void
flush
();
40
void
swap
();
41
uint
availableForWrite
();
42
int
available
();
43
bool
is_valid_baudrate
(
long
br);
44
size_t
write
(uint8_t c);
45
size_t
write
(
const
uint8_t *buffer,
size_t
size);
46
inline
size_t
write
(
const
char
* s)
47
{
48
return
write
((uint8_t*) s, strlen(s));
49
}
50
inline
size_t
write
(
unsigned
long
n)
51
{
52
return
write
((uint8_t) n);
53
}
54
inline
size_t
write
(
long
n)
55
{
56
return
write
((uint8_t) n);
57
}
58
inline
size_t
write
(
unsigned
int
n)
59
{
60
return
write
((uint8_t) n);
61
}
62
inline
size_t
write
(
int
n)
63
{
64
return
write
((uint8_t) n);
65
}
66
int
read
();
67
size_t
readBytes
(uint8_t * sbuf,
size_t
len);
68
inline
bool
started
()
69
{
70
return
_started;
71
}
72
private
:
73
bool
_started;
74
uint32_t _lastflush;
75
uint8_t _buffer[
ESP3D_SERIAL_BUFFER_SIZE
+ 1];
//keep space of 0x0 terminal
76
size_t
_buffer_size;
77
void
push2buffer(uint8_t * sbuf,
size_t
len);
78
void
flushbuffer();
79
};
80
81
extern
SerialService
serial_service
;
82
83
#endif //_SERIAL_SERVICES_H
84
SerialService::availableForWrite
uint availableForWrite()
Definition:
serial_service.cpp:243
SerialService::write
size_t write(uint8_t c)
Definition:
serial_service.cpp:212
SerialService::~SerialService
~SerialService()
Definition:
serial_service.cpp:55
ESP3D_SERIAL_BUFFER_SIZE
#define ESP3D_SERIAL_BUFFER_SIZE
Definition:
serial_service.h:26
SerialService
Definition:
serial_service.h:28
SerialService::write
size_t write(const char *s)
Definition:
serial_service.h:46
SerialService::begin
bool begin()
Definition:
serial_service.cpp:61
SerialService::get_baudratelist
const long * get_baudratelist(uint8_t *count)
Definition:
serial_service.cpp:99
SerialService::end
bool end()
Definition:
serial_service.cpp:87
serial_service
SerialService serial_service
Definition:
serial_service.cpp:42
SerialService::reset
bool reset()
Definition:
serial_service.cpp:189
SerialService::handle
void handle()
Definition:
serial_service.cpp:120
SerialService::SerialService
SerialService()
Definition:
serial_service.cpp:48
SerialService::started
bool started()
Definition:
serial_service.h:68
SerialService::baudRate
long baudRate()
Definition:
serial_service.cpp:196
SerialService::swap
void swap()
Definition:
serial_service.cpp:268
SerialService::write
size_t write(int n)
Definition:
serial_service.h:62
SerialService::is_valid_baudrate
bool is_valid_baudrate(long br)
Definition:
serial_service.cpp:108
SerialService::readBytes
size_t readBytes(uint8_t *sbuf, size_t len)
Definition:
serial_service.cpp:258
SerialService::write
size_t write(unsigned long n)
Definition:
serial_service.h:50
SerialService::write
size_t write(unsigned int n)
Definition:
serial_service.h:58
SerialService::available
int available()
Definition:
serial_service.cpp:248
SerialService::write
size_t write(long n)
Definition:
serial_service.h:54
SerialService::flush
void flush()
Definition:
serial_service.cpp:263
SerialService::read
int read()
Definition:
serial_service.cpp:253
esp3d
src
modules
serial
serial_service.h
Generated by
1.8.17