-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsyscalls.cpp
More file actions
55 lines (46 loc) · 1.17 KB
/
Copy pathsyscalls.cpp
File metadata and controls
55 lines (46 loc) · 1.17 KB
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
#include <Arduino.h>
// #define __cplusplus test
#include <USB/USBAPI.h>
// #undef __cplusplus
#include "syscalls.h"
extern "C" {
int _close(int _) {
SerialUSB.println("_close() called with " + String(_));
return -1;
}
int _getpid() {
SerialUSB.println("_getpid() called");
return 1;
}
int _isatty() {
SerialUSB.println("_isatty() called");
return -1;
}
int _fstat(int _) { return 0; }
int _kill(int _, int __) {
SerialUSB.println("_kill() called with " + String(_) + ";" + String(__));
return -1;
}
int _lseek(int _) {
SerialUSB.println("_lseek() called with " + String(_));
return -1;
}
int _write(int fd, const char *buf, int len) {
if (fd == 1 || fd == 2) {
SerialUSB.println(String(len) + " " +
String(SerialUSB.availableForWrite()));
SerialUSB.flush();
SerialUSB.write(buf, len);
SerialUSB.flush();
// return 0;
} else
return -1;
}
int _read(int fd, char *buf, size_t count) {
SerialUSB.println("_read() called with fd " + String(fd));
if (fd == 0 && SerialUSB.available()) {
return SerialUSB.readBytes(buf, count);
} else
return 0;
}
}