Skip to content

Commit

Permalink
Redirect stdout to serial
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Mar 11, 2016
1 parent 253f302 commit a83f793
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
35 changes: 21 additions & 14 deletions cores/esp8266/libc_replacements.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,49 @@ int ICACHE_RAM_ATTR _fstat_r(struct _reent* unused, int file, struct stat *st) {
return 0;
}

int _lseek_r(struct _reent* unused, int file, int ptr, int dir) {
int ICACHE_RAM_ATTR _lseek_r(struct _reent* unused, int file, int ptr, int dir) {
(void)unused;
(void)file;
(void)ptr;
(void)dir;
return 0;
}

int _read_r(struct _reent* unused, int file, char *ptr, int len) {
int ICACHE_RAM_ATTR _read_r(struct _reent* unused, int file, char *ptr, int len) {
(void)unused;
(void)file;
(void)ptr;
(void)len;
return 0;
}

int _write_r(struct _reent* unused, int file, char *ptr, int len) {
(void)unused;
(void)file;
(void)ptr;
int ICACHE_RAM_ATTR _write_r(struct _reent* r, int file, char *ptr, int len) {
if (file == STDOUT_FILENO) {
while(len--) {
ets_putc(*ptr);
++ptr;
}
}
return len;
}

// newlib has 'putchar' defined to a big scary construct
#undef putchar
int ICACHE_RAM_ATTR puts(const char * str) {
char c;
while((c = *str) != 0) {
ets_putc(c);
++str;
}
ets_putc('\n');
return true;
}

#undef putchar
int ICACHE_RAM_ATTR putchar(int c) {
return ets_putc(c);
ets_putc(c);
return c;
}


#if 0
int ICACHE_RAM_ATTR puts(const char * str) {
return ets_printf("%s", str);
}


int ICACHE_RAM_ATTR printf(const char* format, ...) {
int ret;
Expand Down
2 changes: 1 addition & 1 deletion tools/sdk/lib/make_libcmin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ lib_a-psignal.o
# lib_a-putchar_u.o
lib_a-putenv.o
lib_a-putenv_r.o
lib_a-puts.o
# lib_a-puts.o
lib_a-putw.o
lib_a-putwc.o
lib_a-putwchar.o
Expand Down

0 comments on commit a83f793

Please sign in to comment.