forked from ttlappalainen/NMEA2000_esp32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNMEA2000_esp32_stream.cpp
56 lines (43 loc) · 1015 Bytes
/
NMEA2000_esp32_stream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//@formatter:off
#include "NMEA2000_esp32_stream.h"
#include "stdio.h"
#include "stdarg.h"
const char* TAG = "n2k";
EspN2kStream Serial;
int EspN2kStream::read() {
return 0;
}
int EspN2kStream::peek() {
return 0;
}
size_t EspN2kStream::write( const uint8_t *data, size_t size ) {
return fwrite(data, size, 1, stdout);
}
void EspN2kStream::print( const char *format, ... ) {
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}
void EspN2kStream::print( int value, int radix ) {
if ( radix == 10) {
printf("%d", value);
} else if ( radix == 16) {
printf("%02x", value);
} else {
// throw std::invalid_argument("unsupported radix ");
}
}
void EspN2kStream::println( const char *format, ... ) {
va_list ap;
va_start(ap, format);
vprintf(format, ap);
println();
va_end(ap);
}
void EspN2kStream::println( int value ) {
printf( "%d\n", value );
}
void EspN2kStream::println() {
putchar( '\n' );
}